Verilog readmemh
Submitted by abettino on Wed, 04/14/2010 - 12:43
The $readmemh system task in Verilog allows a program to read data from a text file with hexadecimal formatted data. For example, if a file test_data.dat contains the data.
00000001 ffffffff abcd1234 55558888 00000001 ffffffff abcd1234 55558888
Then this snippet can read in this data and display it.
module verilog_readmemh; reg [31:0] data_ram [0:7]; // array to store the data in. integer ii; // loop variable. initial begin $readmemh("test_data.dat",data_ram); // read hex data from file into data_ram for (ii=0;ii<8;ii=ii+1) $display("%x",data_ram[ii]); // display it. $stop; end endmodule
