mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-23 00:55:32 +00:00
Merge pull request #1670 from rodrigomelo9/master
$readmem[hb] file inclusion is now relative to the Verilog file
This commit is contained in:
commit
d4ff5b2d00
7 changed files with 152 additions and 3 deletions
1
tests/memfile/.gitignore
vendored
Normal file
1
tests/memfile/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
temp*
|
64
tests/memfile/content1.dat
Normal file
64
tests/memfile/content1.dat
Normal file
|
@ -0,0 +1,64 @@
|
|||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
||||
00001111000000001111111100000000
|
23
tests/memfile/memory.v
Normal file
23
tests/memfile/memory.v
Normal file
|
@ -0,0 +1,23 @@
|
|||
// A memory initialized with an external file
|
||||
|
||||
module memory (
|
||||
input clk_i,
|
||||
input we_i,
|
||||
input [5:0] addr_i,
|
||||
input [31:0] data_i,
|
||||
output reg [31:0] data_o
|
||||
);
|
||||
|
||||
parameter MEMFILE = "";
|
||||
|
||||
reg [31:0] mem [0:63];
|
||||
|
||||
initial $readmemb(MEMFILE,mem);
|
||||
|
||||
always @(posedge clk_i) begin
|
||||
if (we_i)
|
||||
mem[addr_i] <= data_i;
|
||||
data_o <= mem[addr_i];
|
||||
end
|
||||
|
||||
endmodule
|
49
tests/memfile/run-test.sh
Executable file
49
tests/memfile/run-test.sh
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
mkdir -p temp
|
||||
cp content1.dat temp/content2.dat
|
||||
|
||||
cd ..
|
||||
|
||||
echo "Running from the parent directory with content1.dat"
|
||||
../yosys -qp "read_verilog -defer memfile/memory.v; chparam -set MEMFILE \"content1.dat\" memory"
|
||||
echo "Running from the parent directory with temp/content2.dat"
|
||||
../yosys -qp "read_verilog -defer memfile/memory.v; chparam -set MEMFILE \"temp/content2.dat\" memory"
|
||||
echo "Running from the parent directory with memfile/temp/content2.dat"
|
||||
../yosys -qp "read_verilog -defer memfile/memory.v; chparam -set MEMFILE \"memfile/temp/content2.dat\" memory"
|
||||
|
||||
cd memfile
|
||||
|
||||
echo "Running from the same directory with content1.dat"
|
||||
../../yosys -qp "read_verilog -defer memory.v; chparam -set MEMFILE \"content1.dat\" memory"
|
||||
echo "Running from the same directory with temp/content2.dat"
|
||||
../../yosys -qp "read_verilog -defer memory.v; chparam -set MEMFILE \"temp/content2.dat\" memory"
|
||||
|
||||
cd temp
|
||||
|
||||
echo "Running from a child directory with content1.dat"
|
||||
../../../yosys -qp "read_verilog -defer ../memory.v; chparam -set MEMFILE \"content1.dat\" memory"
|
||||
echo "Running from a child directory with temp/content2.dat"
|
||||
../../../yosys -qp "read_verilog -defer ../memory.v; chparam -set MEMFILE \"temp/content2.dat\" memory"
|
||||
echo "Running from a child directory with content2.dat"
|
||||
../../../yosys -qp "read_verilog -defer ../memory.v; chparam -set MEMFILE \"temp/content2.dat\" memory"
|
||||
|
||||
cd ..
|
||||
|
||||
echo "Checking a failure when zero length filename is provided"
|
||||
if ../../yosys -qp "read_verilog memory.v"; then
|
||||
echo "The execution should fail but it didn't happen, which is WRONG."
|
||||
exit 1
|
||||
else
|
||||
echo "Execution failed, which is OK."
|
||||
fi
|
||||
|
||||
echo "Checking a failure when not existing filename is provided"
|
||||
if ../../yosys -qp "read_verilog -defer memory.v; chparam -set MEMFILE \"content3.dat\" memory"; then
|
||||
echo "The execution should fail but it didn't happen, which is WRONG."
|
||||
exit 1
|
||||
else
|
||||
echo "Execution failed, which is OK."
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue