-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.sv
More file actions
39 lines (32 loc) · 668 Bytes
/
array.sv
File metadata and controls
39 lines (32 loc) · 668 Bytes
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
37
38
39
module array #(
parameter s_index = 3,
parameter width = 1,
parameter num_sets = 2**s_index
)
(
clk,
read,
load,
rindex,
windex,
datain,
dataout
);
input clk;
input read;
input load;
input [s_index-1:0] rindex;
input [s_index-1:0] windex;
input [width-1:0] datain;
output logic [width-1:0] dataout;
logic [width-1:0] data [num_sets-1:0] /* synthesis ramstyle = "logic" */= '{default: '0};
logic [width-1:0] _dataout;
assign dataout = _dataout;
always_ff @(posedge clk)
begin
if (read)
_dataout <= (load & (rindex == windex)) ? datain : data[rindex];
if(load)
data[windex] <= datain;
end
endmodule : array