Altera_Forum
Honored Contributor
14 years agoproblem with initialising rom and reading data
Hi,
I would like to read binary data from a text file. Perform FIR filtering on the data and store the simulated result values in another text/mif file for further processing in Matlab. I used $readmemb function with verilog code in Quartus II. The following code seems to work. module test(addr_a,addr_b,clk,q_a,q_b,c); input [3:0] addr_a,addr_b; input clk; output [3:0] q_a,q_b; output [7:0] c; reg [7:0] c; reg [3:0] q_a,q_b; parameter data_width=4; parameter addr_width=4; reg[data_width-1:0] rom[2*addr_width-1:0]; initial begin $readmemb("script.txt",rom); end always@(posedge clk) begin q_a<=rom[addr_a]; q_b<=rom[addr_b]; c<=q_a+q_b; end endmodule But instead if I use the following, my code does not work. always@(posedge clk) begin x[0]<=rom[n]; n<=n+1; temp<=x[0]; end I don't want to use the address as input signal. I would like to use a counter to fetch the subsequent addresses. Could someone suggest me how to do that.