-
Notifications
You must be signed in to change notification settings - Fork 3
/
RAM32X1S.v
68 lines (61 loc) · 1.55 KB
/
RAM32X1S.v
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
`ifdef verilator3
`else
`timescale 1 ps / 1 ps
`endif
//
// RAM32X1S primitive for Xilinx FPGAs
// Compatible with Verilator tool (www.veripool.org)
// Copyright (c) 2019-2022 Frédéric REQUIN
// License : BSD
//
/* verilator coverage_off */
module RAM32X1S
#(
parameter [31:0] INIT = 32'h0,
parameter [0:0] IS_WCLK_INVERTED = 1'b0
)
(
// Write clock
input wire WCLK,
// Write enable
input wire WE,
// Read / Write address
input wire A0,
input wire A1,
input wire A2,
input wire A3,
input wire A4,
// Data in
input wire D,
// Data out
output wire O
);
// Read / Write address
wire [4:0] _w_A = { A4, A3, A2, A1, A0 };
// 32 x 1-bit Select RAM
reg [31:0] _r_mem;
// Power-up value
initial begin : INIT_STATE
_r_mem = INIT;
end
// Synchronous memory write
generate
if (IS_WCLK_INVERTED) begin : GEN_WCLK_NEG
always @(negedge WCLK) begin : MEM_WRITE
if (WE) begin
_r_mem[_w_A] <= D;
end
end
end
else begin : GEN_WCLK_POS
always @(posedge WCLK) begin : MEM_WRITE
if (WE) begin
_r_mem[_w_A] <= D;
end
end
end
endgenerate
// Asynchronous memory read
assign O = _r_mem[_w_A];
endmodule
/* verilator coverage_on */