PS: I searched on Google without success. (I am very very new to Verilog)
http://fullchipdesign.com/index_files/readmemh.htm
< p>In any case, these functions are not too many, the syntax is:
$readmem[hb]("File",ArrayName,StartAddr,EndAddr)
$ writemem[hb]("File",ArrayName,StartAddr,EndAddr)
Verilog is very picky about the file format. The number of digits in the text file must match the number of digits in the array.
< p>I suggest you fill in the data by defining an array, then write out the data with writememh/writememb, and then print it out.
Something like this should get you started (not tried!).
integer i;
reg [7:0] memory [0:15]; // 8 bit memory with 16 entries
initial begin< br /> for (i=0; i<16; i++) begin
memory = i;
end
$writememb("memory_binary.txt", memory);
$ writememh("memory_hex.txt", memory);
end
Cheers!
Suddenly, I saw some use of $readmemh And the verilog testbench code of $writememh . I understand it basically reads into memory and writes to memory. If you can point out some resources related to these routines, I will be very happy.
PS: I searched on Google without success. (I’m very very new to Verilog )
I agree that it is not too easy to find things about readmem/writemem. You can find a little bit here:
http://fullchipdesign.com/index_files/readmemh .htm
Anyway, these functions are not too many, the syntax is:
$readmem[hb]("File",ArrayName ,StartAddr,EndAddr)
$writemem[hb]("File",ArrayName,StartAddr,EndAddr)
Verilog is very picky about the file format. The number of bits in the text file must be the same as that in the array. The number of digits matches.
I suggest you fill in the data by defining an array, then write out the data with writememh/writememb, and then print it out.
Something like this should get you started (untested! ).
integer i;
reg [7:0] memory [0:15]; // 8 bit memory with 16 entries
initial begin
for (i=0; i<16; i++) begin
memory = i;
end
$writememb("memory_binary.txt", memory);
$writememh("memory_hex.txt", memory);
end
Cheers!