Skip to content

Commit

Permalink
Added INIT_FILE parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
rherveille committed Oct 15, 2021
1 parent fee5c5d commit 552bd78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions rtl/verilog/rl_ram_1rw.sv
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
module rl_ram_1rw #(
parameter ABITS = 10,
parameter DBITS = 32,
parameter TECHNOLOGY = "GENERIC"
parameter TECHNOLOGY = "GENERIC",
parameter INIT_FILE = ""
)
(
input rst_ni,
Expand Down Expand Up @@ -115,8 +116,9 @@ generate
initial $display ("INFO : No memory technology specified. Using generic inferred memory (%m)");

rl_ram_1rw_generic #(
.ABITS ( ABITS ),
.DBITS ( DBITS ) )
.ABITS ( ABITS ),
.DBITS ( DBITS ),
.INIT_FILE ( INIT_FILE) )
ram_inst (
.rst_ni ( rst_ni ),
.clk_i ( clk_i ),
Expand Down
13 changes: 12 additions & 1 deletion rtl/verilog/rl_ram_1rw_generic.sv
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@

module rl_ram_1rw_generic #(
parameter ABITS = 10,
parameter DBITS = 32
parameter DBITS = 32,
parameter INIT_FILE = ""
)
(
input rst_ni,
Expand Down Expand Up @@ -94,6 +95,16 @@ module rl_ram_1rw_generic #(
// Module Body
//

//preload memory
//This seems to be synthesizable in FPGAs
initial
if (INIT_FILE != "")
begin
$display ("INFO : Loading %s (%m)", INIT_FILE);
$readmemh(INIT_FILE, mem_array);
end


//write side
generate
for (i=0; i<(DBITS+7)/8; i++)
Expand Down

0 comments on commit 552bd78

Please sign in to comment.