Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Initializing memory array in Verilog with test data from file

Status
Not open for further replies.

ajanders

Newbie level 1
Joined
Apr 10, 2012
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
I am a grad student trying to learn while writing a Tx design in verilog and want to use approx 64k - 128k of my own test data. I know how to use $readmemh(fileID,mem) when in simulation and it works great. However, I want to implement into FPGA (Stratix IV) and want to know how to do that syntactically.

I just need to know the syntax to fill the memory with all the data.
Code:
reg [15:0] mem[0:2^N-1];  // N is arbitrary
Do I need to actually go element by element?:
Code:
(some looping struct.) begin
mem[0] <= 10AF;
.
.
mem[2^N-1] <= 039D;
end // would like to avoid since there are over 64k elements
or is there a way to:
Code:
mem[all] <= contents of file (with some certain syntax);

I have been using Matlab to generate the bit sequence and I was thinking I could just have it write to a dummy module that only has the memory elements I create and `include dummy.v into the design file. I still need to know how I can put all this data into memory.
 
Last edited by a moderator:

yes. I suggest making an invalid mem file if possible -- one that has an incorrect length of 0's for the last all 0 element or such. Quartus has had issues in the past with readmem and can fail silently. If there is a minor problem in the file, quartus will fix it and give a warning. Or it won't fix it and won't report the warning. Either way, its easier than opening the chip editor to confirm the ram was loaded. They may have fixed that and the other readmem issue (readmem also can't handle parameters for the file name, it must be a hard-coded file name. there is a workaround for that, but it is ugly)
 

Write the data into a file,such as .hex, .mic.
example:
`ifdef NO_PLI
altsyncram_component.init_file = "fir_zero.rif"
`else
altsyncram_component.init_file = "fir_zero.hex"
`endif
,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top