-
Notifications
You must be signed in to change notification settings - Fork 2
/
BRAM6k9bit.v
83 lines (67 loc) · 1.38 KB
/
BRAM6k9bit.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module BRAM6k9bit(CLK, ADDR, WE, EN, DIN, DINP, DOUT, DOUTP);
input CLK;
input WE;
input EN;
input [12:0] ADDR;
input [7:0] DIN;
input DINP;
output [7:0] DOUT;
output DOUTP;
wire [7:0] ram0_DOUT, ram1_DOUT, ram2_DOUT;
wire ram0_DOUTP, ram1_DOUTP, ram2_DOUTP;
reg [3:0] ram_EN;
always @*
begin
#1;
ram_EN = 0;
ram_EN[ADDR[12:11]] = EN;
end
//
// Output mux...
//
reg [1:0] dly_ADDR, next_dly_ADDR;
always @(posedge CLK)
begin
dly_ADDR = next_dly_ADDR;
end
always @*
begin
#1;
next_dly_ADDR = ADDR[12:11];
end
reg [7:0] DOUT;
reg DOUTP;
always @*
begin
#1;
DOUT = 8'h0;
DOUTP = 1'b0;
case (dly_ADDR)
2'h0 : begin DOUT = ram0_DOUT; DOUTP = ram0_DOUTP; end
2'h1 : begin DOUT = ram1_DOUT; DOUTP = ram1_DOUTP; end
2'h2 : begin DOUT = ram2_DOUT; DOUTP = ram2_DOUTP; end
endcase
end
//
// Instantiate the 2Kx8 RAM's...
//
RAMB16_S9 ram0 (
.CLK(CLK), .ADDR(ADDR[10:0]),
.DI(DIN), .DIP(DINP),
.DO(ram0_DOUT), .DOP(ram0_DOUTP),
.EN(ram_EN[0]), .SSR(1'b0), .WE(WE));
RAMB16_S9 ram1 (
.CLK(CLK), .ADDR(ADDR[10:0]),
.DI(DIN), .DIP(DINP),
.DO(ram1_DOUT), .DOP(ram1_DOUTP),
.EN(ram_EN[1]),
.SSR(1'b0),
.WE(WE));
RAMB16_S9 ram2 (
.CLK(CLK), .ADDR(ADDR[10:0]),
.DI(DIN), .DIP(DINP),
.DO(ram2_DOUT), .DOP(ram2_DOUTP),
.EN(ram_EN[2]),
.SSR(1'b0),
.WE(WE));
endmodule