Skip to content

Commit

Permalink
Add support for OCLK and OCLKB inputs of ISERDESE2. Add matching test…
Browse files Browse the repository at this point in the history
… bench.
  • Loading branch information
bl0x committed Jan 24, 2022
1 parent 5fa5e71 commit a607049
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xc/xc7/techmap/cells_map.v
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,8 @@ module ISERDESE2 (
input CE2,
input CLK,
input CLKB,
input OCLK,
input OCLKB,
input CLKDIV,
input RST,
input D,
Expand Down Expand Up @@ -2909,6 +2911,8 @@ module ISERDESE2 (
.CE2 (CE2),
.CLK (CLK),
.CLKB (CLKB),
.OCLK (OCLK),
.OCLKB (OCLKB),
.CLKDIV (CLKDIV),
.RST (RST),
.DDLY (DDLY),
Expand Down Expand Up @@ -2969,6 +2973,8 @@ module ISERDESE2 (
.CE2 (CE2),
.CLK (CLK),
.CLKB (CLKB),
.OCLK (OCLK),
.OCLKB (OCLKB),
.CLKDIV (CLKDIV),
.RST (RST),
.D (D),
Expand Down
4 changes: 4 additions & 0 deletions xc/xc7/techmap/cells_sim.v
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ module ISERDESE2_IDELAY_VPR (
input CE2,
input CLK,
input CLKB,
input OCLK,
input OCLKB,
input CLKDIV,
input RST,
input DDLY,
Expand Down Expand Up @@ -1137,6 +1139,8 @@ module ISERDESE2_NO_IDELAY_VPR (
input CE2,
input CLK,
input CLKB,
input OCLK,
input OCLKB,
input CLKDIV,
input RST,
input D,
Expand Down
21 changes: 21 additions & 0 deletions xc/xc7/tests/serdes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_file_target(FILE serdes_test.v SCANNER_TYPE verilog)
add_file_target(FILE serdes_test_idelay.v SCANNER_TYPE verilog)
add_file_target(FILE serdes_test_oversample.v SCANNER_TYPE verilog)
add_file_target(FILE basys3.pcf)

add_custom_target(all_serdes_test)
Expand Down Expand Up @@ -81,3 +82,23 @@ serdes_test(8 SDR)
serdes_test(4 DDR)
serdes_test(6 DDR)
serdes_test(8 DDR)

# Oversample
add_fpga_target(
NAME serdes_basys3_oversample
BOARD basys3-bottom
SOURCES
serdes_basys3_oversample.v
serdes_test_oversample.v
INPUT_IO_FILE basys3.pcf
EXPLICIT_ADD_FILE_TARGET
)

add_vivado_target(
NAME serdes_basys3_oversample_vivado
PARENT_NAME serdes_basys3_oversample
)

add_dependencies(all_serdes_test
serdes_basys3_oversample_bit
)
116 changes: 116 additions & 0 deletions xc/xc7/tests/serdes/serdes_basys3_oversample.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
`default_nettype none

`define CLKFBOUT_MULT 2

// ============================================================================

module top
(
input wire clk,

input wire rst,

input wire [7:0] sw,
output wire [9:0] led,

inout wire io
);

// ============================================================================
// Clock & reset
reg [3:0] rst_sr;

initial rst_sr <= 4'hF;

wire CLK;

BUFG bufg(.I(clk), .O(CLK));

always @(posedge CLK)
if (rst)
rst_sr <= 4'hF;
else
rst_sr <= rst_sr >> 1;

wire RST = rst_sr[0];

// ============================================================================
// Clocks for ISERDES

wire PRE_BUFG_SYSCLK;
wire PRE_BUFG_SYSCLK_90;

wire SYSCLK;
wire SYSCLK_90;

wire O_LOCKED;

wire clk_fb_i;
wire clk_fb_o;

localparam DIVIDE_RATE = DATA_RATE == "SDR" ? DATA_WIDTH : DATA_WIDTH / 2;

PLLE2_ADV #(
.BANDWIDTH ("HIGH"),
.COMPENSATION ("ZHOLD"),

.CLKIN1_PERIOD (10.0), // 100MHz

.CLKFBOUT_MULT (`CLKFBOUT_MULT),
.CLKOUT0_DIVIDE (`CLKFBOUT_MULT * 4), // SYSCLK, 25MHz
.CLKOUT1_DIVIDE (`CLKFBOUT_MULT * 4), // SYSCLK, 25MHz, shifted 90 degrees
.CLKOUT1_PHASE (90.0), // SYSCLK, 25MHz, shifted 90 degrees

.STARTUP_WAIT ("FALSE"),

.DIVCLK_DIVIDE (1'd1)
)
pll
(
.CLKIN1 (CLK),
.CLKINSEL (1),

.RST (RST),
.PWRDWN (0),
.LOCKED (O_LOCKED),

.CLKFBIN (clk_fb_i),
.CLKFBOUT (clk_fb_o),

.CLKOUT0 (PRE_BUFG_SYSCLK),
.CLKOUT1 (PRE_BUFG_SYSCLK_90)
);

BUFG bufg_clk(.I(PRE_BUFG_SYSCLK), .O(SYSCLK));
BUFG bufg_clk90(.I(PRE_BUFG_SYSCLK_90), .O(SYSCLK_90));

// ============================================================================
// Test uints
wire INPUT = sw[0];
wire [3:0] SAMPLES;

serdes_test_oversample
(
.SYSCLK (SYSCLK),
.SYSCLK_90 (SYSCLK_90),
.RST (RST),

.OUTPUTS (SAMPLES),

.I_DAT (INPUT)
);

wire [7:0] MASKED_OUTPUTS = OUTPUTS & MASK;

// ============================================================================
// I/O connections

reg [23:0] heartbeat_cnt;

always @(posedge SYSCLK)
heartbeat_cnt <= heartbeat_cnt + 1;

assign led[0] = heartbeat_cnt[22];
assign led[4:1] = SAMPLES;

endmodule
55 changes: 55 additions & 0 deletions xc/xc7/tests/serdes/serdes_test_oversample.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
`default_nettype none

// ============================================================================

module serdes_test_oversample
(
input wire SYSCLK,
input wire SYSCLK_90,
input wire RST,

input wire I_DAT,

output wire [3:0] OUTPUTS
);

// ============================================================================
wire i_rstdiv;

// ISERDES reset generator
reg [3:0] rst_sr;
initial rst_sr <= 4'hF;

always @(posedge SYSCLK)
if (RST) rst_sr <= 4'hF;
else rst_sr <= rst_sr >> 1;

assign i_rstdiv = rst_sr[0];

// ============================================================================
// ISERDES
ISERDESE2 #
(
.DATA_RATE ("DDR"),
.DATA_WIDTH (4),
.INTERFACE_TYPE ("OVERSAMPLE"),
.NUM_CE (2)
)
iserdes
(
.CLK (SYSCLK),
.CLKB (SYSCLK),
.OCLK (SYSCLK_90),
.OCLKB (SYSCLK_90),
.CLKDIV (1'b0),
.CE1 (1'b1),
.CE2 (1'b1),
.RST (i_rstdiv),
.D (I_DAT),
.Q1 (OUTPUTS[1]),
.Q2 (OUTPUTS[2]),
.Q3 (OUTPUTS[3]),
.Q4 (OUTPUTS[4])
);

endmodule

0 comments on commit a607049

Please sign in to comment.