Skip to content

Commit c0d4ce9

Browse files
Merge pull request #59 from muhammadhamza15/main
Simulation Models Updates
2 parents 71b9b04 + 3b8efcc commit c0d4ce9

30 files changed

+1016
-0
lines changed

models_internal/verilog/LATCH.v

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCH simulation model
5+
// Positive level-sensitive latch
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCH (
11+
input D, // Data Input
12+
input G,
13+
output Q // Data Output
14+
);
15+
16+
endmodule
17+
`endcelldefine

models_internal/verilog/LATCHN.v

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCHN simulation model
5+
// Negative level-sensitive latch
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCHN (
11+
input D, // Data Input
12+
input G,
13+
output Q // Data Output
14+
);
15+
16+
endmodule
17+
`endcelldefine

models_internal/verilog/LATCHNR.v

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCHNR simulation model
5+
// Negative level-sensitive latch with active-high asyncronous reset
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCHNR (
11+
input D, // Data Input
12+
input G,
13+
input R, // Active-high asyncronous reset
14+
output Q // Data Output
15+
);
16+
17+
endmodule
18+
`endcelldefine

models_internal/verilog/LATCHNS.v

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCHNS simulation model
5+
// Negative level-sensitive latch with active-high asyncronous set
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCHNS (
11+
input D, // Data Input
12+
input G, // Active-high asyncronous set
13+
input R, // Active-high asyncronous reset
14+
output Q // Data Output
15+
);
16+
17+
endmodule
18+
`endcelldefine

models_internal/verilog/LATCHR.v

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCHR simulation model
5+
// Positive level-sensitive latch with active-high asyncronous reset
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCHR (
11+
input D, // Data Input
12+
input G,
13+
input R, // Active-high asyncronous reset
14+
output Q // Data Output
15+
);
16+
17+
endmodule
18+
`endcelldefine

models_internal/verilog/LATCHS.v

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// LATCHS simulation model
5+
// Positive level-sensitive latch with active-high asyncronous set
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module LATCHS (
11+
input D, // Data Input
12+
input G, // Active-high asyncronous set
13+
input R, // Active-high asyncronous reset
14+
output Q // Data Output
15+
);
16+
17+
endmodule
18+
`endcelldefine

models_internal/verilog/MIPI_TX.v

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
`timescale 1ns/1ps
2+
`celldefine
3+
//
4+
// MIPI_TX simulation model
5+
// MIPI Transmitter
6+
//
7+
// Copyright (c) 2023 Rapid Silicon, Inc. All rights reserved.
8+
//
9+
10+
module MIPI_TX #(
11+
parameter WIDTH = 4, // Width of input data to serializer (3-10)
12+
parameter EN_ODLY = "FALSE", // True or False
13+
parameter LANE_MODE = "Master", // Master or Slave
14+
parameter DELAY = 0 // Fixed TAP delay value (0-63)
15+
) (
16+
input RST, // Active-low, asynchronous reset
17+
input RX_CLK, // MIPI RX_IO clock input, PLL_CLK
18+
input PLL_LOCK, // PLL lock input
19+
input CLK_IN, // Fabric core clock input
20+
input [WIDTH-1:0] HS_TX_DATA, // Parallel Data input bus from fabric
21+
input HS_TXD_VALID, // Load word input from Fabric
22+
input HS_EN, // EN HS Data Transmission (From Fabric)
23+
input TX_LP_DP, // LP TX Data positive from the Fabric
24+
input TX_LP_DN, // LP TX Data negative from the Fabric
25+
input LP_EN, // EN LP Data Transmission (From Fabric). Active high signal. This is a common signal between MIPI RX/TX interface.
26+
input TX_ODT_EN, // EN Termination
27+
input DLY_LOAD, // Delay load input, from Fabric
28+
input DLY_ADJ, // Delay adjust input, from Fabric
29+
input DLY_INCDEC, // Delay increment / decrement input, from Fabric
30+
output TX_OE, // IBUF OE signal for MIPI O_BUF
31+
output TX_DP, // Serial Data output to O_BUF
32+
output TX_DN, // Serial Data output to O_BUF
33+
input CHANNEL_BOND_SYNC_IN, // Channel bond sync input
34+
output CHANNEL_BOND_SYNC_OUT // Channel bond sync output
35+
);
36+
37+
38+
wire o_serdes_dout;
39+
wire o_delay_dout;
40+
41+
O_SERDES # (
42+
.DATA_RATE("DDR"),
43+
.WIDTH(WIDTH)
44+
)
45+
O_SERDES_inst (
46+
.D(HS_TX_DATA),
47+
.RST(RST),
48+
.DATA_VALID(HS_TXD_VALID),
49+
.CLK_IN(CLK_IN),
50+
.OE_IN(),
51+
.OE_OUT(),
52+
.Q(o_serdes_dout),
53+
.CHANNEL_BOND_SYNC_IN(CHANNEL_BOND_SYNC_IN),
54+
.CHANNEL_BOND_SYNC_OUT(CHANNEL_BOND_SYNC_OUT),
55+
.PLL_LOCK(PLL_LOCK),
56+
.PLL_CLK(RX_CLK)
57+
);
58+
59+
O_DELAY # (
60+
.DELAY(DELAY)
61+
)
62+
O_DELAY_inst (
63+
.I(tx_dp),
64+
.DLY_LOAD(DLY_LOAD),
65+
.DLY_ADJ(DLY_ADJ),
66+
.DLY_INCDEC(DLY_INCDEC),
67+
.DLY_TAP_VALUE(),
68+
.CLK_IN(CLK_IN),
69+
.O(o_delay_dout)
70+
);
71+
reg tx_dp;
72+
reg tx_dn;
73+
assign TX_OE = LP_EN | HS_EN;
74+
75+
always @(*)
76+
begin
77+
if(HS_EN && TX_OE)
78+
begin
79+
tx_dp = o_serdes_dout;
80+
tx_dn = ~tx_dp;
81+
end
82+
else if (LP_EN && TX_OE)
83+
begin
84+
tx_dp = TX_LP_DP;
85+
tx_dn = TX_LP_DN;
86+
end
87+
end
88+
89+
assign TX_DP = (EN_ODLY=="FALSE")? tx_dp:o_delay_dout;
90+
assign TX_DN = (EN_ODLY=="FALSE")? tx_dn:~o_delay_dout;
91+
92+
// assign TX_DP = tx_dp;
93+
// assign TX_DN = tx_dn;
94+
95+
always@(*)
96+
begin
97+
if(LP_EN && HS_EN)
98+
$fatal(1,"\nERROR: MIPI TX instance %m LP_EN and HS_EN can't be hight at same time");
99+
end initial begin
100+
101+
if ((WIDTH < 3) || (WIDTH > 10)) begin
102+
$fatal(1,"MIPI_TX instance %m WIDTH set to incorrect value, %d. Values must be between 3 and 10.", WIDTH);
103+
end
104+
case(EN_ODLY)
105+
"TRUE" ,
106+
"FALSE": begin end
107+
default: begin
108+
$fatal(1,"\nError: MIPI_TX instance %m has parameter EN_ODLY set to %s. Valid values are TRUE, FALSE\n", EN_ODLY);
109+
end
110+
endcase
111+
case(LANE_MODE)
112+
"Master" ,
113+
"Slave": begin end
114+
default: begin
115+
$fatal(1,"\nError: MIPI_TX instance %m has parameter LANE_MODE set to %s. Valid values are Master, Slave\n", LANE_MODE);
116+
end
117+
endcase
118+
119+
if ((DELAY < 0) || (DELAY > 63)) begin
120+
$fatal(1,"MIPI_TX instance %m DELAY set to incorrect value, %d. Values must be between 0 and 63.", DELAY);
121+
end
122+
123+
end
124+
125+
endmodule
126+
`endcelldefine

models_internal/verilog/inc/LATCH.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCH.pro.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHN.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHN.pro.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHNR.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHNR.pro.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHNS.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHNS.pro.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHR.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHR.pro.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHS.inc.v

Whitespace-only changes.

models_internal/verilog/inc/LATCHS.pro.v

Whitespace-only changes.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
3+
wire o_serdes_dout;
4+
wire o_delay_dout;
5+
6+
O_SERDES # (
7+
.DATA_RATE("DDR"),
8+
.WIDTH(WIDTH)
9+
)
10+
O_SERDES_inst (
11+
.D(HS_TX_DATA),
12+
.RST(RST),
13+
.DATA_VALID(HS_TXD_VALID),
14+
.CLK_IN(CLK_IN),
15+
.OE_IN(),
16+
.OE_OUT(),
17+
.Q(o_serdes_dout),
18+
.CHANNEL_BOND_SYNC_IN(CHANNEL_BOND_SYNC_IN),
19+
.CHANNEL_BOND_SYNC_OUT(CHANNEL_BOND_SYNC_OUT),
20+
.PLL_LOCK(PLL_LOCK),
21+
.PLL_CLK(RX_CLK)
22+
);
23+
24+
O_DELAY # (
25+
.DELAY(DELAY)
26+
)
27+
O_DELAY_inst (
28+
.I(tx_dp),
29+
.DLY_LOAD(DLY_LOAD),
30+
.DLY_ADJ(DLY_ADJ),
31+
.DLY_INCDEC(DLY_INCDEC),
32+
.DLY_TAP_VALUE(),
33+
.CLK_IN(CLK_IN),
34+
.O(o_delay_dout)
35+
);
36+
reg tx_dp;
37+
reg tx_dn;
38+
assign TX_OE = LP_EN | HS_EN;
39+
40+
always @(*)
41+
begin
42+
if(HS_EN && TX_OE)
43+
begin
44+
tx_dp = o_serdes_dout;
45+
tx_dn = ~tx_dp;
46+
end
47+
else if (LP_EN && TX_OE)
48+
begin
49+
tx_dp = TX_LP_DP;
50+
tx_dn = TX_LP_DN;
51+
end
52+
end
53+
54+
assign TX_DP = (EN_ODLY=="FALSE")? tx_dp:o_delay_dout;
55+
assign TX_DN = (EN_ODLY=="FALSE")? tx_dn:~o_delay_dout;
56+
57+
// assign TX_DP = tx_dp;
58+
// assign TX_DN = tx_dn;
59+
60+
always@(*)
61+
begin
62+
if(LP_EN && HS_EN)
63+
$fatal(1,"\nERROR: MIPI TX instance %m LP_EN and HS_EN can't be hight at same time");
64+
end

models_internal/verilog/inc/MIPI_TX.pro.v

Whitespace-only changes.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
`timescale 1ns/1ps
2+
module MIPI_TX_tb;
3+
4+
// Parameters
5+
localparam WIDTH = 4;
6+
localparam EN_ODLY = "FALSE";
7+
localparam LANE_MODE = "Master";
8+
localparam DELAY = 0;
9+
10+
//Ports
11+
reg RST;
12+
reg RX_CLK;
13+
reg PLL_LOCK;
14+
reg CLK_IN;
15+
reg [WIDTH-1:0] HS_TX_DATA;
16+
reg HS_TXD_VALID;
17+
reg HS_EN;
18+
reg TX_LP_DP;
19+
reg TX_LP_DN;
20+
reg LP_EN;
21+
reg TX_ODT_EN;
22+
reg DLY_LOAD;
23+
reg DLY_ADJ;
24+
reg DLY_INCDEC;
25+
wire TX_OE;
26+
wire TX_DP;
27+
wire TX_DN;
28+
reg CHANNEL_BOND_SYNC_IN;
29+
wire CHANNEL_BOND_SYNC_OUT;
30+
31+
MIPI_TX # (
32+
.WIDTH(WIDTH),
33+
.EN_ODLY(EN_ODLY),
34+
.LANE_MODE(LANE_MODE),
35+
.DELAY(DELAY)
36+
)
37+
MIPI_TX_inst (
38+
.RST(RST),
39+
.RX_CLK(RX_CLK),
40+
.PLL_LOCK(PLL_LOCK),
41+
.CLK_IN(CLK_IN),
42+
.HS_TX_DATA(HS_TX_DATA),
43+
.HS_TXD_VALID(HS_TXD_VALID),
44+
.HS_EN(HS_EN),
45+
.TX_LP_DP(TX_LP_DP),
46+
.TX_LP_DN(TX_LP_DN),
47+
.LP_EN(LP_EN),
48+
.TX_ODT_EN(TX_ODT_EN),
49+
.DLY_LOAD(DLY_LOAD),
50+
.DLY_ADJ(DLY_ADJ),
51+
.DLY_INCDEC(DLY_INCDEC),
52+
.TX_OE(TX_OE),
53+
.TX_DP(TX_DP),
54+
.TX_DN(TX_DN),
55+
.CHANNEL_BOND_SYNC_IN(CHANNEL_BOND_SYNC_IN),
56+
.CHANNEL_BOND_SYNC_OUT(CHANNEL_BOND_SYNC_OUT)
57+
);
58+
59+
always #0.2 RX_CLK = ! RX_CLK ; // 2.5 GHz
60+
always #0.8 CLK_IN = ! CLK_IN ;
61+
62+
initial
63+
begin
64+
CLK_IN=0;
65+
RX_CLK=1;
66+
PLL_LOCK=0;
67+
RST=0;
68+
HS_EN=1;
69+
LP_EN=0;
70+
CHANNEL_BOND_SYNC_IN=0;
71+
HS_TXD_VALID=1;
72+
HS_TX_DATA=0;
73+
@(negedge CLK_IN);
74+
RST=1;
75+
CHANNEL_BOND_SYNC_IN=1;
76+
PLL_LOCK=1;
77+
repeat(260)@(posedge RX_CLK);
78+
HS_TX_DATA=4'b0101;
79+
@(negedge CLK_IN);
80+
HS_TX_DATA=$urandom();
81+
@(negedge CLK_IN);
82+
HS_TX_DATA=$urandom();
83+
#1000;
84+
$finish;
85+
86+
end
87+
88+
initial
89+
begin
90+
$dumpfile("waves.vcd");
91+
$dumpvars;
92+
end
93+
endmodule

0 commit comments

Comments
 (0)