-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathINS_RAM.sv
More file actions
36 lines (30 loc) · 1.04 KB
/
INS_RAM.sv
File metadata and controls
36 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module INS_RAM import details::*;
#(
parameter mem_init_t mem_init = no,
parameter WIDTH = 8,
parameter DEPTH = 256,
parameter ADDR_WIDTH = $clog2(DEPTH)
)
(
input logic clk, wrEn,
input logic [WIDTH-1:0]dataIn,
input logic [ADDR_WIDTH-1:0]addr,
output logic [WIDTH-1:0]dataOut
);
logic [ADDR_WIDTH-1:0]addr_reg;
logic [WIDTH-1:0]memory[0:DEPTH-1] ;
/// initialize memory for simulation /////////
initial begin
if (mem_init == yes) begin
$readmemb("D:/ACA/SEM5_TRONIC_ACA/1_EN3030 _Circuits_and_Systems_Design/2020/learnFPGA/learn_processor_design/matrix_multiply/system_verilog_design_3_1_github/Multicore_processor_matrix_multiply/matrix_generation_for_tb/9_ins_mem_tb.txt", memory);
end
end
///////////////////////////////////////////////
always_ff @(posedge clk) begin
addr_reg <= addr;
if (wrEn) begin
memory[addr] <= dataIn; // write requires only 1 clk cyle.
end
end
assign dataOut = memory[addr_reg]; // address is registered. Need 2 clk cycles to read.
endmodule : INS_RAM