Skip to content

Commit 549b92a

Browse files
committed
HyperRAM in simulation
- Simulation model of HyperRAM device, based on W956D8MBYA. - Uses a dual-port RAM for the memory itself, with one port being used for data reads and the other for data writes. - Implement simple models of FPGA primitives for use in simulation.
1 parent 728a66f commit 549b92a

File tree

12 files changed

+568
-9
lines changed

12 files changed

+568
-9
lines changed

dv/models/fpga/rtl/IOBUF.v

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright lowRISC contributors.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
// This is a crude model of the Xilinx IOBUF primitive; enough to make the
6+
// OpenHBMC implementation simulate correctly.
7+
module IOBUF #(
8+
parameter DRIVE = 0,
9+
parameter SLEW = "SLOW"
10+
) (
11+
output O,
12+
inout IO,
13+
input I,
14+
input T
15+
);
16+
17+
assign O = IO;
18+
assign IO = T ? 1'bZ : I;
19+
20+
endmodule
21+

dv/models/fpga/rtl/ISERDESE2.v

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright lowRISC contributors.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
// This is a crude model of the Xilinx ISERDESE2 primitive; enough to make the
6+
// OpenHBMC implementation simulate correctly.
7+
module ISERDESE2 #(
8+
parameter SERDES_MODE = "MASTER",
9+
parameter INTERFACE_TYPE = "NETWORKING",
10+
parameter DATA_RATE = "DDR",
11+
parameter DATA_WIDTH = 6,
12+
parameter DYN_CLKDIV_INV_EN = "FALSE",
13+
parameter DYN_CLK_INV_EN = "FALSE",
14+
parameter OFB_USED = "NONE",
15+
parameter IOBDELAY = 0,
16+
parameter NUM_CE = 1,
17+
parameter INIT_Q1 = 1'b0,
18+
parameter INIT_Q2 = 1'b0,
19+
parameter INIT_Q3 = 1'b0,
20+
parameter INIT_Q4 = 1'b0,
21+
parameter SRVAL_Q1 = 1'b0,
22+
parameter SRVAL_Q2 = 1'b0,
23+
parameter SRVAL_Q3 = 1'b0,
24+
parameter SRVAL_Q4 = 1'b0
25+
) (
26+
output O,
27+
28+
output Q1,
29+
output Q2,
30+
output Q3,
31+
output Q4,
32+
output Q5,
33+
output Q6,
34+
output Q7,
35+
output Q8,
36+
37+
input BITSLIP,
38+
39+
input CE1,
40+
input CE2,
41+
42+
input CLK,
43+
input CLKB,
44+
45+
input CLKDIV,
46+
input CLKDIVP,
47+
input OCLK,
48+
input OCLKB,
49+
50+
input D,
51+
input DDLY,
52+
53+
input OFB,
54+
input RST,
55+
56+
input DYNCLKDIVSEL,
57+
input DYNCLKSEL,
58+
59+
output SHIFTOUT1,
60+
output SHIFTOUT2,
61+
62+
input SHIFTIN1,
63+
input SHIFTIN2
64+
);
65+
66+
reg [8:1] iserdes_int;
67+
always @(edge CLK or posedge RST) begin
68+
if (RST) begin
69+
iserdes_int <= {2{SRVAL_Q4, SRVAL_Q3, SRVAL_Q2, SRVAL_Q1}};
70+
end else begin
71+
iserdes_int <= {iserdes_int[7:1], D};
72+
end
73+
end
74+
75+
// In the ISERDESE2 module, Q8 is the oldest bit received.
76+
assign {Q8,Q7,Q6,Q5,Q4,Q3,Q2,Q1} = iserdes_int;
77+
assign O = D;
78+
79+
// These outputs are unused.
80+
assign {SHIFTOUT2, SHIFTOUT1} = 2'b0;
81+
82+
endmodule
83+

dv/models/fpga/rtl/OBUF.v

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright lowRISC contributors.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
// This is a crude model of the Xilinx OBUF primitive; enough to make the
6+
// OpenHBMC implementation simulate correctly.
7+
module OBUF #(
8+
parameter DRIVE = 0,
9+
parameter SLEW = "SLOW"
10+
) (
11+
input I,
12+
output O
13+
);
14+
15+
assign O = I;
16+
17+
endmodule
18+

dv/models/fpga/rtl/ODDR.v

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright lowRISC contributors.
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
// This is a crude model of the Xilinx ODDR primitive; enough to make the
6+
// OpenHBMC implementation simulate correctly.
7+
module ODDR #(
8+
parameter DDR_CLK_EDGE = "SAME_EDGE",
9+
parameter INIT = 1'b0,
10+
parameter SRTYPE = "ASYNC"
11+
) (
12+
output Q, // DDR output.
13+
input C, // Clock input.
14+
input CE, // Clock Enable.
15+
input D1, // Two data inputs.
16+
input D2,
17+
input R, // ReSet inputs.
18+
input S
19+
);
20+
21+
// Phase detection; PH is asserted during the second (negative edge)
22+
// phase of the clock 'C.'
23+
// ___ ___
24+
// C ___/ \___/ \___
25+
// PH 1 0 1 0 1
26+
27+
reg PH, PC, NC;
28+
always @(posedge C) PC <= !PC;
29+
always @(negedge C) NC <= !NC;
30+
assign PH = !(PC ^ NC);
31+
32+
reg S2;
33+
if (DDR_CLK_EDGE == "SAME_EDGE") begin : gen_same_edge
34+
// Both data inputs are presented together on posedge.
35+
always @(posedge C) begin
36+
if (CE) S2 <= D2;
37+
end
38+
end else begin : gen_opposite_edge
39+
// Inputs are presented on opposite edges.
40+
assign S2 = D2;
41+
end
42+
43+
// Output is clocked on both edges of clock input 'C'.
44+
reg OUT;
45+
always @(edge C, posedge R, posedge S) begin
46+
if (R || S) OUT <= S & ~R;
47+
else if (CE) OUT <= PH ? D1 : S2;
48+
end
49+
assign Q = OUT;
50+
51+
endmodule
52+

0 commit comments

Comments
 (0)