Verilog readmemb
Submitted by abettino on Wed, 04/14/2010 - 12:44
The $readmemb system task in Verilog allows a program to read data from a text file with binary formatted data. For example, if a file test_data_bin.dat contains the data.
00000001000000010000000100000001 11111111111111111111111111111111 01010101010101010101010101010101 00000000000000000000000000000000 10101010101010101010101010101010 01010111110101111110101111101111 11111111111111111111111111111111 10101010101010101010101010101010
Then this snippet can read in this data and display it.
module verilog_readmemb; reg [31:0] data_ram [0:7]; integer ii; initial begin $readmemb("test_data_bin.dat",data_ram); for (ii=0;ii<8;ii=ii+1) $display("%x",data_ram[ii]); $stop; end endmodule
