- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello forum Members,
I have been experimenting with file-based initialization of Verilog multidimensional arrays. Until now i succeeded initializing with the help of flat temp. array ------------------------------------------------------------------------
reg charMem;
reg colMem;
reg charMemTmp;
reg colMemTmp;
initial
begin
$readmemh("DE0_CV_SCREENCHAR.txt",charMemTmp);
$readmemh("DE0_CV_SCREENCOL.txt" ,colMemTmp);
$readmemh("DE0_CV_SCREENPAL.txt" ,palMem);
end
and always @(posedge CLOCK_50)
begin
if (~RESET_N)
begin
integer row;
integer kol;
for (row=0;row<25;row++)
begin
for (kol=0;kol<80;kol++)
begin
charMem=charMemTmp;
colMem=colMemTmp;
end
end
end
end
=> This works fine, i use a flat helper array read in the data and copy everything to a 2-d array. However if i try to read it directly: ------------------------------------- reg charMem;
reg colMem;
initial
begin
$readmemh("DE0_CV_SCREENCHAR.txt",charMem);
$readmemh("DE0_CV_SCREENCOL.txt" ,colMem);
$readmemh("DE0_CV_SCREENPAL.txt" ,palMem);
end
=> I get: "10853 verilog HDL error ... : argument 1 to $readmemh must be a memory identifier ??? I also tried reading from a .mif file (1d file 2000 x 1 byte Width=8 depth=2000): ------------------------------------- (* ram_init_file = "DE0_CV_SCREENCHARMEM.mif" *) reg charMem;
(* ram_init_file = "DE0_CV_SCREENCOLORMEM.mif" *) reg colorMem
; => this works fine Does anybody know how to initialize the 2-d array from a file using ram_init_file or $readmemh ? I a using Quartus 15.1 on Win7. Thanks in advance, Johi. Update: I have a hunch (from debgging the .mif files generated by quartus from the .txt initialization files that depth needs to be 25 and widt 640 = 8*80 I will try this and come with an update. Johi.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Conclusion:
initializing a 2 d array using a .mif file works for a 2d array:Example:
// char mem
/*(* ram_init_file = "DE0_CV_SCREENCHAR.mif" *)*/ reg charMem;
// color mem
(* ram_init_file = "DE0_CV_SCREENCOL.mif" *) reg colMem;
// color mem
(* ram_init_file = "DE0_CV_SCREENPAL.mif" *) reg palMem
I added the .mif files for these initializations. initializing a 1 d array also works. // helper variabeles to read .txt file: reg [7:0] charMemTmp[2000]; reg [7:0] colMemTmp[2000]; reg [3:0] palMemTmp[48];
//--------------------------------------------------------
// initialize char memory (this statement will be synthetisised):
initial
begin
$readmemh("DE0_CV_SCREENCHAR.txt",charMemTmp);
$readmemh("DE0_CV_SCREENCOL.txt" ,colMemTmp);
$readmemh("DE0_CV_SCREENPAL.txt" ,palMemTmp);
end
In the zip file, all .mif and .txt are included. And also a .XLS with macro's to generate these files. Best Regards, Johi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for sharing!

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