Skip to content
Snippets Groups Projects
Commit 27b865f3 authored by auphelia's avatar auphelia
Browse files

[finn-rtllib] Change readmemh function to allow ID >= 10 for .dat files

parent dc3286e6
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ module ramb18_wf_dualport ...@@ -37,7 +37,7 @@ module ramb18_wf_dualport
) )
( (
input clk, input clk,
input wea, input wea,
input [AWIDTH-1:0] addra, input [AWIDTH-1:0] addra,
input [DWIDTH-1:0] wdataa, input [DWIDTH-1:0] wdataa,
...@@ -53,7 +53,7 @@ module ramb18_wf_dualport ...@@ -53,7 +53,7 @@ module ramb18_wf_dualport
reg [DWIDTH-1:0] rdataa; reg [DWIDTH-1:0] rdataa;
reg [DWIDTH-1:0] rdatab; reg [DWIDTH-1:0] rdatab;
reg [7:0] idx = ID; reg [15:0] idx;
//initialize memory //initialize memory
initial begin initial begin
//note the hacky way of adding a filename memblock_ID.dat to the path provided in MEM_INIT //note the hacky way of adding a filename memblock_ID.dat to the path provided in MEM_INIT
...@@ -63,10 +63,11 @@ initial begin ...@@ -63,10 +63,11 @@ initial begin
$finish(); $finish();
end end
//MEM_INIT path must be terminated by / //MEM_INIT path must be terminated by /
if (ID < 10) $sformat(idx,"%0d",ID);
$readmemh({MEM_INIT,"memblock_",idx+8'd48,".dat"}, mem, 0, 1023); if (ID < 10)
$readmemh({MEM_INIT,"memblock_",idx[7:0],".dat"}, mem, 0, 1023);
else else
$readmemh({MEM_INIT,"memblock_",(idx/10)+8'd48,(idx%10)+8'd48,".dat"}, mem, 0, 1023); $readmemh({MEM_INIT,"memblock_",idx,".dat"}, mem, 0, 1023);
end end
//memory ports, with output pipeline register //memory ports, with output pipeline register
...@@ -83,4 +84,4 @@ always @(posedge clk) begin ...@@ -83,4 +84,4 @@ always @(posedge clk) begin
rdqb <= rdatab; rdqb <= rdatab;
end end
endmodule endmodule
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment