How can I read a file into verilog?
The system task $readmemb (and also $readmemh) will read in a file. It takes 2 arguments, the file name and the memory structure name. It reads the file into the memory structure. Words are white space separated (space, tab, return, etc). The difference between $readmemb and $readmemh is that, memb reads in binary, and memh reads in hex. Here’s a sample code fragment: reg [13:0] Prog[4095:0]; // program to execute initial begin // Here, it would be a good idea to initialize the Prog array with // all zeros or something, just incase the read in file is // shorter than the array.