- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's not clear to me what you intend with the code that does not work.
However, the code that does work will have to be the basis of what you want. Instead of having the address as a input to your module, you can simply generate the address(es) inside it. Something like: reg addr_a = 4'h0; allways @ (posedge clk) addr_a <= addr_a + 4'd1; reg addr_a = 4'h2; allways @ (posedge clk) addr_b <= addr_b + 4'd1;- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. Yes, I wanted to know how to access address values without assigning addr as input.
I appreciate your help. Ambrin
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page