mirror of https://github.com/openXC7/prjxray.git
IDELAY minitest with variable (preloaded) delay value.
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
This commit is contained in:
parent
1f41082937
commit
d3891f41d3
|
|
@ -0,0 +1,43 @@
|
|||
SYNTH ?= vivado
|
||||
YOSYS = $(XRAY_DIR)/third_party/yosys/yosys
|
||||
PART = xc7a35tcsg324-1
|
||||
|
||||
VERILOG_FILES = $(wildcard *.v)
|
||||
BIT_FILES = $(VERILOG_FILES:.v=.bit)
|
||||
|
||||
all: $(BIT_FILES)
|
||||
|
||||
clean:
|
||||
@find . -name "build-par.*" | xargs rm -rf
|
||||
@find . -name "build-syn.*" | xargs rm -rf
|
||||
@rm -f *.edif
|
||||
@rm -f *.bit
|
||||
@rm -f *.bin
|
||||
@rm -f *.log
|
||||
@rm -f *.dcp
|
||||
|
||||
help:
|
||||
@echo "Usage: make all [SYNTH=<vivado/yosys>]"
|
||||
|
||||
.PHONY: all clean help
|
||||
|
||||
$(YOSYS):
|
||||
cd $(XRAY_DIR)/third_party/yosys && make config-gcc && make -j$(shell nproc)
|
||||
|
||||
ifeq ($(SYNTH), yosys)
|
||||
%.edif: %.v $(YOSYS)
|
||||
$(YOSYS) -p "read_verilog $< ; synth_xilinx -flatten -nosrl; write_edif -pvector bra -attrprop $@" -l $@.log
|
||||
|
||||
else ifeq ($(SYNTH), vivado)
|
||||
%.edif: %.v tcl/syn.tcl basys3.xdc
|
||||
mkdir -p build-syn.$(basename $@)
|
||||
cd build-syn.$(basename $@) && env PROJECT_NAME=$(basename $@) $(XRAY_VIVADO) -mode batch -source ../tcl/syn.tcl -nojournal -log ../$@.log
|
||||
rm -rf *.backup.log
|
||||
|
||||
endif
|
||||
|
||||
%.bit: %.edif tcl/par.tcl basys3.xdc
|
||||
mkdir -p build-par.$(basename $@)
|
||||
cd build-par.$(basename $@) && env PROJECT_NAME=$(basename $@) $(XRAY_VIVADO) -mode batch -source ../tcl/par.tcl -nojournal -log ../$@.log
|
||||
rm -rf *.backup.log
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Minitests for IDELAY
|
||||
|
||||
## 1. basys3_idelay_ext
|
||||
|
||||
A design for Basys3 board.
|
||||
|
||||
### Description
|
||||
|
||||
This test generates a 50MHz square wave on an output pin which is then fed back to the FPGA IDELAY bel through another input pin. The delayed signal is then routed to yet another output pin which allows it to be compared with the input signal using an oscilloscope. The IDELAY is calibrated using 100MHz clock hence delays from 0 to 5ns can be achieved.
|
||||
|
||||
The switch `SW0` acts as reset. The switch `SW1` allows to change the delay value. One toggle of that switch increases the delay counter by one.
|
||||
|
||||
The `LED0` blinks continuously. The `LED1` indicates that the calibration of IDELAY has been completed (the `RDY` signal from IDELAYCTRL bel). Leds `LED11` through `LED15` indicate current delay setting (the `CNTVALUEOUT` of IDELAY bel).
|
||||
|
||||
### Physical loopback
|
||||
|
||||
Consider the `JXADC` connector on the Basys3 board as seen when looking at the board edge:
|
||||
```
|
||||
-- -- -- -- -- --
|
||||
| 6| 5| 4| 3| 2| 1|
|
||||
-- -- -- -- -- --
|
||||
|12|11|10| 9| 8| 7|
|
||||
-- -- -- -- -- --
|
||||
```
|
||||
|
||||
- Pin1 - Signal output. Connect to CH1 of the oscilloscope.
|
||||
- Pin2 - Delayed signal output. Connect to CH2 of the oscilloscope.
|
||||
- Pin7 - Delay signal input, connect to Pin8.
|
||||
- Pin8 - Signal output. Connect to Pin7.
|
||||
|
||||
**The oscilloscope must have bandwidth of at least 100MHz.**
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
create_clock -period 10.000 -name clk [get_ports clk]
|
||||
|
||||
set_property PACKAGE_PIN W5 [get_ports clk]
|
||||
|
||||
set_property PACKAGE_PIN B18 [get_ports rx]
|
||||
set_property PACKAGE_PIN A18 [get_ports tx]
|
||||
|
||||
set_property PACKAGE_PIN V17 [get_ports sw[ 0]]
|
||||
set_property PACKAGE_PIN V16 [get_ports sw[ 1]]
|
||||
set_property PACKAGE_PIN W16 [get_ports sw[ 2]]
|
||||
set_property PACKAGE_PIN W17 [get_ports sw[ 3]]
|
||||
set_property PACKAGE_PIN W15 [get_ports sw[ 4]]
|
||||
set_property PACKAGE_PIN V15 [get_ports sw[ 5]]
|
||||
set_property PACKAGE_PIN W14 [get_ports sw[ 6]]
|
||||
set_property PACKAGE_PIN W13 [get_ports sw[ 7]]
|
||||
set_property PACKAGE_PIN V2 [get_ports sw[ 8]]
|
||||
set_property PACKAGE_PIN T3 [get_ports sw[ 9]]
|
||||
set_property PACKAGE_PIN T2 [get_ports sw[10]]
|
||||
set_property PACKAGE_PIN R3 [get_ports sw[11]]
|
||||
set_property PACKAGE_PIN W2 [get_ports sw[12]]
|
||||
set_property PACKAGE_PIN U1 [get_ports sw[13]]
|
||||
set_property PACKAGE_PIN T1 [get_ports sw[14]]
|
||||
set_property PACKAGE_PIN R2 [get_ports sw[15]]
|
||||
|
||||
set_property PACKAGE_PIN U16 [get_ports led[ 0]]
|
||||
set_property PACKAGE_PIN E19 [get_ports led[ 1]]
|
||||
set_property PACKAGE_PIN U19 [get_ports led[ 2]]
|
||||
set_property PACKAGE_PIN V19 [get_ports led[ 3]]
|
||||
set_property PACKAGE_PIN W18 [get_ports led[ 4]]
|
||||
set_property PACKAGE_PIN U15 [get_ports led[ 5]]
|
||||
set_property PACKAGE_PIN U14 [get_ports led[ 6]]
|
||||
set_property PACKAGE_PIN V14 [get_ports led[ 7]]
|
||||
set_property PACKAGE_PIN V13 [get_ports led[ 8]]
|
||||
set_property PACKAGE_PIN V3 [get_ports led[ 9]]
|
||||
set_property PACKAGE_PIN W3 [get_ports led[10]]
|
||||
set_property PACKAGE_PIN U3 [get_ports led[11]]
|
||||
set_property PACKAGE_PIN P3 [get_ports led[12]]
|
||||
set_property PACKAGE_PIN N3 [get_ports led[13]]
|
||||
set_property PACKAGE_PIN P1 [get_ports led[14]]
|
||||
set_property PACKAGE_PIN L1 [get_ports led[15]]
|
||||
|
||||
set_property PACKAGE_PIN J1 [get_ports ja1]
|
||||
set_property PACKAGE_PIN L2 [get_ports ja2]
|
||||
set_property PACKAGE_PIN J2 [get_ports ja3]
|
||||
set_property PACKAGE_PIN G2 [get_ports ja4]
|
||||
set_property PACKAGE_PIN H1 [get_ports ja7]
|
||||
set_property PACKAGE_PIN K2 [get_ports ja8]
|
||||
set_property PACKAGE_PIN H2 [get_ports ja9]
|
||||
set_property PACKAGE_PIN G3 [get_ports ja10]
|
||||
|
||||
set_property PACKAGE_PIN A14 [get_ports jb1]
|
||||
set_property PACKAGE_PIN A16 [get_ports jb2]
|
||||
set_property PACKAGE_PIN B15 [get_ports jb3]
|
||||
set_property PACKAGE_PIN B16 [get_ports jb4]
|
||||
set_property PACKAGE_PIN A15 [get_ports jb7]
|
||||
set_property PACKAGE_PIN A17 [get_ports jb8]
|
||||
set_property PACKAGE_PIN C15 [get_ports jb9]
|
||||
set_property PACKAGE_PIN C16 [get_ports jb10]
|
||||
|
||||
set_property PACKAGE_PIN K17 [get_ports jc1]
|
||||
set_property PACKAGE_PIN M18 [get_ports jc2]
|
||||
set_property PACKAGE_PIN N17 [get_ports jc3]
|
||||
set_property PACKAGE_PIN P18 [get_ports jc4]
|
||||
set_property PACKAGE_PIN L17 [get_ports jc7]
|
||||
set_property PACKAGE_PIN M19 [get_ports jc8]
|
||||
set_property PACKAGE_PIN P17 [get_ports jc9]
|
||||
set_property PACKAGE_PIN R18 [get_ports jc10]
|
||||
|
||||
set_property PACKAGE_PIN J3 [get_ports xadc1_p]
|
||||
set_property PACKAGE_PIN L3 [get_ports xadc2_p]
|
||||
#set_property PACKAGE_PIN M2 [get_ports xadc3_p]
|
||||
#set_property PACKAGE_PIN N2 [get_ports xadc4_p]
|
||||
set_property PACKAGE_PIN K3 [get_ports xadc1_n]
|
||||
set_property PACKAGE_PIN M3 [get_ports xadc2_n]
|
||||
#set_property PACKAGE_PIN M1 [get_ports xadc3_n]
|
||||
#set_property PACKAGE_PIN N1 [get_ports xadc4_n]
|
||||
|
||||
foreach port [get_ports] {
|
||||
set_property IOSTANDARD LVTTL $port
|
||||
set_property SLEW FAST $port
|
||||
set_property DRIVE 24 $port
|
||||
}
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
`include "src/idelay_calibrator.v"
|
||||
|
||||
`default_nettype none
|
||||
|
||||
// ============================================================================
|
||||
|
||||
module top
|
||||
(
|
||||
input wire clk,
|
||||
|
||||
input wire rx,
|
||||
output wire tx,
|
||||
|
||||
input wire [15:0] sw,
|
||||
output wire [15:0] led,
|
||||
|
||||
output wire ja1,
|
||||
output wire ja2,
|
||||
output wire ja3,
|
||||
output wire ja4,
|
||||
input wire ja7,
|
||||
input wire ja8,
|
||||
input wire ja9,
|
||||
input wire ja10,
|
||||
|
||||
output wire jb1,
|
||||
output wire jb2,
|
||||
output wire jb3,
|
||||
output wire jb4,
|
||||
input wire jb7,
|
||||
input wire jb8,
|
||||
input wire jb9,
|
||||
input wire jb10,
|
||||
|
||||
output wire jc1,
|
||||
output wire jc2,
|
||||
output wire jc3,
|
||||
output wire jc4,
|
||||
input wire jc7,
|
||||
input wire jc8,
|
||||
input wire jc9,
|
||||
input wire jc10,
|
||||
|
||||
output wire xadc1_p,
|
||||
input wire xadc1_n,
|
||||
output wire xadc2_p,
|
||||
output wire xadc2_n
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// Clock & reset
|
||||
reg [3:0] rst_sr;
|
||||
|
||||
initial rst_sr <= 4'hF;
|
||||
|
||||
always @(posedge clk)
|
||||
if (sw[0])
|
||||
rst_sr <= 4'hF;
|
||||
else
|
||||
rst_sr <= rst_sr >> 1;
|
||||
|
||||
wire CLK = clk;
|
||||
wire RST = rst_sr[0];
|
||||
|
||||
// ============================================================================
|
||||
// IDELAY calibrator
|
||||
wire cal_rdy;
|
||||
|
||||
idelay_calibrator cal
|
||||
(
|
||||
.refclk (CLK),
|
||||
.rst (RST),
|
||||
.rdy (cal_rdy)
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// Delay selector
|
||||
wire btn_in = sw[1];
|
||||
reg [3:0] btn_sr;
|
||||
wire btn_edge;
|
||||
reg [16:0] btn_cnt;
|
||||
|
||||
always @(posedge CLK)
|
||||
if (RST)
|
||||
btn_sr <= (btn_in) ? 4'hF : 4'h0;
|
||||
else
|
||||
btn_sr <= (btn_sr >> 1) | (btn_in << 3);
|
||||
|
||||
assign btn_edge = btn_sr[1] ^ btn_sr[0];
|
||||
|
||||
always @(posedge CLK)
|
||||
if (RST)
|
||||
btn_cnt <= -1;
|
||||
else if (btn_edge)
|
||||
btn_cnt <= 1000000 - 1;
|
||||
else if (!btn_cnt[15])
|
||||
btn_cnt <= btn_cnt - 1;
|
||||
|
||||
wire dly_ld_req = btn_edge && btn_cnt[15];
|
||||
|
||||
// ============================================================================
|
||||
// IDELAY path
|
||||
reg dly_ld;
|
||||
wire dly_out;
|
||||
reg [4:0] dly_delay_in;
|
||||
wire [4:0] dly_delay_out;
|
||||
|
||||
always @(posedge CLK)
|
||||
if (RST || !cal_rdy)
|
||||
dly_ld <= 0;
|
||||
else if ( dly_ld)
|
||||
dly_ld <= 0;
|
||||
else if (!dly_ld && dly_ld_req)
|
||||
dly_ld <= 1;
|
||||
|
||||
always @(posedge CLK)
|
||||
if (RST || !cal_rdy)
|
||||
dly_delay_in <= 0;
|
||||
else if (!dly_ld && dly_ld_req)
|
||||
dly_delay_in <= dly_delay_in + 1;
|
||||
|
||||
(* KEEP, DONT_TOUCH *)
|
||||
IDELAYE2 #
|
||||
(
|
||||
.IDELAY_TYPE ("VAR_LOAD"),
|
||||
.DELAY_SRC ("IDATAIN")
|
||||
)
|
||||
idelay
|
||||
(
|
||||
.IDATAIN (xadc1_n),
|
||||
.DATAOUT (dly_out),
|
||||
|
||||
.REGRST (RST),
|
||||
.C (CLK),
|
||||
.LD (dly_ld),
|
||||
.CNTVALUEIN (dly_delay_in),
|
||||
.CNTVALUEOUT (dly_delay_out)
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// I/O connections
|
||||
reg O;
|
||||
always @(posedge CLK)
|
||||
if (RST) O <= 0;
|
||||
else O <= ~O;
|
||||
|
||||
reg [23:0] heartbeat_cnt;
|
||||
|
||||
always @(posedge CLK)
|
||||
heartbeat_cnt <= heartbeat_cnt + 1;
|
||||
|
||||
assign led[ 0] = heartbeat_cnt[23];
|
||||
assign led[ 1] = cal_rdy;
|
||||
assign led[ 2] = 1'b0;
|
||||
assign led[ 3] = 1'b0;
|
||||
assign led[ 4] = 1'b0;
|
||||
assign led[ 5] = 1'b0;
|
||||
assign led[ 6] = 1'b0;
|
||||
assign led[ 7] = 1'b0;
|
||||
assign led[ 8] = 1'b0;
|
||||
assign led[ 9] = 1'b0;
|
||||
assign led[10] = 1'b0;
|
||||
assign led[11] = dly_delay_out[0];
|
||||
assign led[12] = dly_delay_out[1];
|
||||
assign led[13] = dly_delay_out[2];
|
||||
assign led[14] = dly_delay_out[3];
|
||||
assign led[15] = dly_delay_out[4];
|
||||
|
||||
assign ja1 = 1'b0;
|
||||
assign ja2 = 1'b0;
|
||||
assign ja3 = 1'b0;
|
||||
assign ja4 = 1'b0;
|
||||
|
||||
assign jb1 = 1'b0;
|
||||
assign jb2 = 1'b0;
|
||||
assign jb3 = 1'b0;
|
||||
assign jb4 = 1'b0;
|
||||
|
||||
assign jc1 = 1'b0;
|
||||
assign jc2 = 1'b0;
|
||||
assign jc3 = 1'b0;
|
||||
assign jc4 = 1'b0;
|
||||
|
||||
assign xadc2_p = O;
|
||||
assign xadc2_n = O;
|
||||
assign xadc1_p = dly_out;
|
||||
|
||||
endmodule
|
||||
Binary file not shown.
|
|
@ -0,0 +1,43 @@
|
|||
`default_nettype none
|
||||
|
||||
// ============================================================================
|
||||
|
||||
module idelay_calibrator #
|
||||
(
|
||||
parameter SITE_LOC = ""
|
||||
)
|
||||
(
|
||||
input wire refclk, // REFCLK for IDELAYCTRL
|
||||
input wire rst, // External reset
|
||||
|
||||
output wire rdy // Output ready signal
|
||||
);
|
||||
|
||||
// ============================================================================
|
||||
// Long reset generator (~60ns for Artix 7 according to the datasheet)
|
||||
|
||||
reg [6:0] r_cnt;
|
||||
wire r_rst;
|
||||
|
||||
initial r_cnt <= 0;
|
||||
|
||||
always @(posedge refclk)
|
||||
if (rst)
|
||||
r_cnt <= 0;
|
||||
else if (r_rst)
|
||||
r_cnt <= r_cnt + 1;
|
||||
|
||||
assign r_rst = !r_cnt[6];
|
||||
|
||||
// ============================================================================
|
||||
// IDELAYCTRL
|
||||
|
||||
(* KEEP, DONT_TOUCH, LOC = SITE_LOC *)
|
||||
IDELAYCTRL idelayctlr
|
||||
(
|
||||
.REFCLK (refclk),
|
||||
.RST (r_rst),
|
||||
.RDY (rdy)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
create_project -force -name $env(PROJECT_NAME) -part xc7a35tcpg236-1
|
||||
|
||||
read_edif ../$env(PROJECT_NAME).edif
|
||||
|
||||
link_design -part xc7a35tcpg236-1
|
||||
source ../basys3.xdc
|
||||
|
||||
report_timing_summary -file top_timing_synth.rpt
|
||||
report_utilization -hierarchical -file top_utilization_hierarchical_synth.rpt
|
||||
report_utilization -file top_utilization_synth.rpt
|
||||
|
||||
opt_design
|
||||
place_design
|
||||
|
||||
report_utilization -hierarchical -file top_utilization_hierarchical_place.rpt
|
||||
report_utilization -file top_utilization_place.rpt
|
||||
report_io -file top_io.rpt
|
||||
report_control_sets -verbose -file top_control_sets.rpt
|
||||
report_clock_utilization -file top_clock_utilization.rpt
|
||||
|
||||
route_design
|
||||
#phys_opt_design
|
||||
|
||||
report_timing_summary -no_header -no_detailed_paths
|
||||
|
||||
write_checkpoint -force ../$env(PROJECT_NAME).dcp
|
||||
|
||||
set_property SEVERITY {Warning} [get_drc_checks UCIO-1]
|
||||
set_property SEVERITY {Warning} [get_drc_checks NSTD-1]
|
||||
|
||||
report_route_status -file top_route_status.rpt
|
||||
report_drc -file top_drc.rpt
|
||||
report_timing_summary -datasheet -max_paths 10 -file top_timing.rpt
|
||||
report_power -file top_power.rpt
|
||||
|
||||
write_bitstream -force ../$env(PROJECT_NAME).bit
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
create_project -force -name $env(PROJECT_NAME) -part xc7a35tcpg236-1
|
||||
|
||||
read_verilog ../$env(PROJECT_NAME).v
|
||||
|
||||
synth_design -top top
|
||||
|
||||
report_timing_summary -file top_timing_synth.rpt
|
||||
report_utilization -hierarchical -file top_utilization_hierarchical_synth.rpt
|
||||
report_utilization -file top_utilization_synth.rpt
|
||||
|
||||
write_edif -force ../$env(PROJECT_NAME).edif
|
||||
Loading…
Reference in New Issue