Skip to content

Commit 8dcb5c8

Browse files
committed
Add KR260 reference design example
Signed-off-by: Víctor Mayoral Vilches <[email protected]>
1 parent 77adf30 commit 8dcb5c8

File tree

16 files changed

+2251
-0
lines changed

16 files changed

+2251
-0
lines changed

example/KR260/fpga/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Targets
2+
TARGETS:=
3+
4+
# Subdirectories
5+
SUBDIRS = fpga
6+
SUBDIRS_CLEAN = $(patsubst %,%.clean,$(SUBDIRS))
7+
8+
# Rules
9+
.PHONY: all
10+
all: $(SUBDIRS) $(TARGETS)
11+
12+
.PHONY: $(SUBDIRS)
13+
$(SUBDIRS):
14+
cd $@ && $(MAKE)
15+
16+
.PHONY: $(SUBDIRS_CLEAN)
17+
$(SUBDIRS_CLEAN):
18+
cd $(@:.clean=) && $(MAKE) clean
19+
20+
.PHONY: clean
21+
clean: $(SUBDIRS_CLEAN)
22+
-rm -rf $(TARGETS)
23+
24+
program:
25+
#djtgcfg prog -d Atlys --index 0 --file fpga/fpga.bit

example/KR260/fpga/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Verilog Ethernet KR260 Example Design
2+
3+
## Introduction
4+
5+
This example design targets the AMD KR260 FPGA SoC board.
6+
7+
The design by default listens to UDP port 1234 at IP address 192.168.1.128 and
8+
will echo back any packets received. The design will also respond correctly
9+
to ARP requests.
10+
11+
* FPGA: `XCK26-SFVC784-2LV-C` (or `-I`, if industrial-grade)
12+
* PHY: 10G BASE-R PHY IP core and internal GTY transceiver
13+
14+
## How to build
15+
16+
:warning: *<ins>To generate the bitstream for the reference design example here
17+
you need a Vivado license</ins>*. In case you don't have it, you can either
18+
fetch it from [here](https://www.xilinx.com/support/licensing_solution_center.html)
19+
or use the the default "30 day evaluation license" that comes with Vivado default
20+
installation.
21+
22+
Run `make` to build. Ensure that the Xilinx Vivado toolchain components are
23+
in PATH.
24+
25+
## How to test
26+
27+
Program the KR260 board with Vivado's Hardware Device Manager (via JTAG). Connect the KR260 SFP+ port to a 10G Ethernet NIC in your host. Then run in your host machine:
28+
29+
netcat -u 192.168.1.128 1234
30+
31+
to open a UDP connection to port 1234. Any text entered into netcat will be
32+
echoed back after pressing enter.
33+
34+
It is also possible to use hping to test the design by running
35+
36+
hping 192.168.1.128 -2 -p 1234 -d 1024
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
###################################################################
2+
#
3+
# Xilinx Vivado FPGA Makefile
4+
#
5+
# Copyright (c) 2016 Alex Forencich
6+
#
7+
###################################################################
8+
#
9+
# Parameters:
10+
# FPGA_TOP - Top module name
11+
# FPGA_FAMILY - FPGA family (e.g. VirtexUltrascale)
12+
# FPGA_DEVICE - FPGA device (e.g. xcvu095-ffva2104-2-e)
13+
# SYN_FILES - space-separated list of source files
14+
# INC_FILES - space-separated list of include files
15+
# XDC_FILES - space-separated list of timing constraint files
16+
# XCI_FILES - space-separated list of IP XCI files
17+
#
18+
# Example:
19+
#
20+
# FPGA_TOP = fpga
21+
# FPGA_FAMILY = VirtexUltrascale
22+
# FPGA_DEVICE = xcvu095-ffva2104-2-e
23+
# SYN_FILES = rtl/fpga.v
24+
# XDC_FILES = fpga.xdc
25+
# XCI_FILES = ip/pcspma.xci
26+
# include ../common/vivado.mk
27+
#
28+
###################################################################
29+
30+
# phony targets
31+
.PHONY: clean fpga
32+
33+
# prevent make from deleting intermediate files and reports
34+
.PRECIOUS: %.xpr %.bit %.mcs %.prm
35+
.SECONDARY:
36+
37+
CONFIG ?= config.mk
38+
-include ../$(CONFIG)
39+
40+
FPGA_TOP ?= fpga
41+
PROJECT ?= $(FPGA_TOP)
42+
43+
SYN_FILES_REL = $(patsubst %, ../%, $(SYN_FILES))
44+
INC_FILES_REL = $(patsubst %, ../%, $(INC_FILES))
45+
XCI_FILES_REL = $(patsubst %, ../%, $(XCI_FILES))
46+
IP_TCL_FILES_REL = $(patsubst %, ../%, $(IP_TCL_FILES))
47+
48+
ifdef XDC_FILES
49+
XDC_FILES_REL = $(patsubst %, ../%, $(XDC_FILES))
50+
else
51+
XDC_FILES_REL = $(FPGA_TOP).xdc
52+
endif
53+
54+
###################################################################
55+
# Main Targets
56+
#
57+
# all: build everything
58+
# clean: remove output files and project files
59+
###################################################################
60+
61+
all: fpga
62+
63+
fpga: $(FPGA_TOP).bit
64+
65+
vivado: $(FPGA_TOP).xpr
66+
vivado $(FPGA_TOP).xpr
67+
68+
tmpclean:
69+
-rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
70+
-rm -rf create_project.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
71+
72+
clean: tmpclean
73+
-rm -rf *.bit *.ltx program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
74+
-rm -rf *_utilization.rpt *_utilization_hierarchical.rpt
75+
76+
distclean: clean
77+
-rm -rf rev
78+
79+
###################################################################
80+
# Target implementations
81+
###################################################################
82+
83+
# Vivado project file
84+
create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
85+
rm -rf defines.v
86+
touch defines.v
87+
for x in $(DEFS); do echo '`define' $$x >> defines.v; done
88+
echo "create_project -force -part $(FPGA_PART) $(PROJECT)" > $@
89+
echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
90+
echo "set_property top $(FPGA_TOP) [current_fileset]" >> $@
91+
echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
92+
for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
93+
for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
94+
95+
$(PROJECT).xpr: create_project.tcl
96+
vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
97+
98+
# synthesis run
99+
$(PROJECT).runs/synth_1/$(PROJECT).dcp: $(PROJECT).xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL)
100+
echo "open_project $(PROJECT).xpr" > run_synth.tcl
101+
echo "reset_run synth_1" >> run_synth.tcl
102+
echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
103+
echo "wait_on_run synth_1" >> run_synth.tcl
104+
vivado -nojournal -nolog -mode batch -source run_synth.tcl
105+
106+
# implementation run
107+
$(PROJECT).runs/impl_1/$(PROJECT)_routed.dcp: $(PROJECT).runs/synth_1/$(PROJECT).dcp
108+
echo "open_project $(PROJECT).xpr" > run_impl.tcl
109+
echo "reset_run impl_1" >> run_impl.tcl
110+
echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
111+
echo "wait_on_run impl_1" >> run_impl.tcl
112+
echo "open_run impl_1" >> run_impl.tcl
113+
echo "report_utilization -file $(PROJECT)_utilization.rpt" >> run_impl.tcl
114+
echo "report_utilization -hierarchical -file $(PROJECT)_utilization_hierarchical.rpt" >> run_impl.tcl
115+
vivado -nojournal -nolog -mode batch -source run_impl.tcl
116+
117+
# bit file
118+
$(PROJECT).bit $(PROJECT).ltx: $(PROJECT).runs/impl_1/$(PROJECT)_routed.dcp
119+
echo "open_project $(PROJECT).xpr" > generate_bit.tcl
120+
echo "open_run impl_1" >> generate_bit.tcl
121+
echo "write_bitstream -force $(PROJECT).runs/impl_1/$(PROJECT).bit" >> generate_bit.tcl
122+
echo "write_debug_probes -force $(PROJECT).runs/impl_1/$(PROJECT).ltx" >> generate_bit.tcl
123+
vivado -nojournal -nolog -mode batch -source generate_bit.tcl
124+
ln -f -s $(PROJECT).runs/impl_1/$(PROJECT).bit .
125+
if [ -e $(PROJECT).runs/impl_1/$(PROJECT).ltx ]; then ln -f -s $(PROJECT).runs/impl_1/$(PROJECT).ltx .; fi
126+
mkdir -p rev
127+
COUNT=100; \
128+
while [ -e rev/$(PROJECT)_rev$$COUNT.bit ]; \
129+
do COUNT=$$((COUNT+1)); done; \
130+
cp -pv $(PROJECT).runs/impl_1/$(PROJECT).bit rev/$(PROJECT)_rev$$COUNT.bit; \
131+
if [ -e $(PROJECT).runs/impl_1/$(PROJECT).ltx ]; then cp -pv $(PROJECT).runs/impl_1/$(PROJECT).ltx rev/$(PROJECT)_rev$$COUNT.ltx; fi

example/KR260/fpga/fpga.xdc

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# XDC constraints for the AMD KR260 board
2+
# part: XCK26-SFVC784-2LV-C/I
3+
4+
# General configuration
5+
set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
6+
7+
# System clocks
8+
# 125 MHz
9+
#
10+
# The 125 MHz clock signal is a standard reference clock frequency used
11+
# in many Ethernet PHYs. This clock signal is used as a timing reference
12+
# for the PHY's internal circuitry, including the serializer/deserializer
13+
# (SERDES) components that convert digital data to analog signals for
14+
# transmission over the physical medium and vice versa. The SERDES components
15+
# require a precise clock signal to ensure accurate timing of the transmitted
16+
# and received data.
17+
#
18+
# NOTE: the GTH transceivers need a free-running clock.
19+
#
20+
21+
# # Option 1: use the 125 MHz clock from the U87 chip
22+
# # GTR pins, connected to the PS, cannot use directly
23+
# set_property -dict {LOC C47 IOSTANDARD LVDS_25} [get_ports clk_125mhz_p]
24+
# set_property -dict {LOC C48 IOSTANDARD LVDS_25} [get_ports clk_125mhz_n]
25+
# create_clock -period 8.000 -name clk_125mhz [get_ports clk_125mhz_p]
26+
27+
# # Option 2: use the 156.25 MHz MGT reference clock
28+
# # GTH pins, connected to the PL, however:
29+
# #
30+
# # The MGT (Multi-Gigabit Transceiver) reference clock inputs and GTH (Gigabit Transceiver)
31+
# # pins are designed for different types of clock signals, and connecting them together can
32+
# # result in damage to the circuitry or a non-functioning design.
33+
# #
34+
# # Connecting the MGT reference clock inputs to GTH pins can result in damage to the
35+
# # circuitry or a non-functioning design because the MGT reference clock signal has different
36+
# # voltage and timing requirements than the GTH system clock. The MGT reference clock signal
37+
# # requires a dedicated input buffer, such as the IBUFDS_GTE2 or IBUFDS_GTH, to properly
38+
# # receive the clock signal and perform the necessary signal conditioning before it can be
39+
# # used by the MGT transceiver. The GTH pins, on the other hand, require a specific input
40+
# # buffer, such as the IBUFDS_GTE2 or IBUFDS_GTH, to properly receive the system clock signal
41+
# # and perform the necessary signal conditioning before it can be used for data transfer.
42+
# #
43+
# set_property -dict {LOC Y6 IOSTANDARD LVDS_25} [get_ports clk_125mhz_p] ;# GTH_REFCLK0_C2M_P via U90, SOM240_2 C3
44+
# set_property -dict {LOC Y5 IOSTANDARD LVDS_25} [get_ports clk_125mhz_n] ;# GTH_REFCLK0_C2M_N via U90, SOM240_2 C4
45+
# create_clock -period 6.400 -name clk_125mhz [get_ports clk_125mhz_p]
46+
47+
# Option 3: use the 25 MHz clock outputs to the PL from U91
48+
# and feed that into a PLL to convert it to 125 MHz
49+
set_property -dict {LOC C3 IOSTANDARD LVCMOS18} [get_ports clk_25mhz_ref] ;# HPA_CLK0P_CLK, HPA_CLK0_P, via U91, SOM240_1 A6
50+
create_clock -period 40.000 -name clk_25mhz [get_ports clk_25mhz_ref]
51+
52+
# LEDs
53+
set_property -dict {LOC F8 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 8} [get_ports {led[0]}] ;# HPA14P, HPA14_P, som240_1_d13, VCCO - som240_1_d1
54+
set_property -dict {LOC E8 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 8} [get_ports {led[1]}] ;# HPA14N, HPA14_N, som240_1_d14, VCCO - som240_1_d1
55+
56+
set_false_path -to [get_ports {led[*]}]
57+
set_output_delay 0 [get_ports {led[*]}]
58+
59+
# # Reset button
60+
# # PS_POR_L, note schematics hints C15 is PS_POR_B (Power-on Reset) signal
61+
# # whereas the "Kria SOM Carrier Card Design Guide" says C15 is PS_POR_L.
62+
# #
63+
# # Signal is pulled up to 1.8V through a 4.70 KΩ resistor on the SOM, LVCMOS18
64+
# #
65+
# # NOTE: Connected to the PS, not accessible to the PL
66+
# #
67+
# # see https://docs.xilinx.com/r/en-US/ug1091-carrier-card-design/Sideband-Signals
68+
# set_property -dict {LOC P16 IOSTANDARD LVCMOS18} [get_ports reset] ;# som240_1_c15, PS_POR_B, PS_POR_L
69+
#
70+
# set_false_path -from [get_ports {reset}]
71+
# set_input_delay 0 [get_ports {reset}]
72+
73+
# No push buttons in KR260
74+
# FWEN is used for other features
75+
#
76+
# set_property -dict {LOC AG15 IOSTANDARD LVCMOS33} [get_ports btnu]
77+
# set_property -dict {LOC AF15 IOSTANDARD LVCMOS33} [get_ports btnl]
78+
# set_property -dict {LOC AE15 IOSTANDARD LVCMOS33} [get_ports btnd]
79+
# set_property -dict {LOC AE14 IOSTANDARD LVCMOS33} [get_ports btnr]
80+
# set_property -dict {LOC AG13 IOSTANDARD LVCMOS33} [get_ports btnc]
81+
#
82+
# set_false_path -from [get_ports {btnu btnl btnd btnr btnc}]
83+
# set_input_delay 0 [get_ports {btnu btnl btnd btnr btnc}]
84+
85+
# No DIP switches in KR260
86+
#
87+
# set_property -dict {LOC AN14 IOSTANDARD LVCMOS33} [get_ports {sw[0]}]
88+
#
89+
# set_false_path -from [get_ports {sw[*]}]
90+
# set_input_delay 0 [get_ports {sw[*]}]
91+
92+
# No PL-Side UART available from default banks
93+
#
94+
# set_property -dict {LOC F13 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports uart_txd]
95+
# set_property -dict {LOC E13 IOSTANDARD LVCMOS33} [get_ports uart_rxd]
96+
# set_property -dict {LOC D12 IOSTANDARD LVCMOS33} [get_ports uart_rts]
97+
# set_property -dict {LOC E12 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports uart_cts]
98+
#
99+
# set_false_path -to [get_ports {uart_txd uart_cts}]
100+
# set_output_delay 0 [get_ports {uart_txd uart_cts}]
101+
# set_false_path -from [get_ports {uart_rxd uart_rts}]
102+
# set_input_delay 0 [get_ports {uart_rxd uart_rts}]
103+
104+
# No PL-I2C interfaces
105+
#set_property -dict {LOC J10 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports i2c0_scl]
106+
#set_property -dict {LOC J11 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports i2c0_sda]
107+
#set_property -dict {LOC K20 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports i2c1_scl]
108+
#set_property -dict {LOC L20 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 8} [get_ports i2c1_sda]
109+
110+
#set_false_path -to [get_ports {i2c1_sda i2c1_scl}]
111+
#set_output_delay 0 [get_ports {i2c1_sda i2c1_scl}]
112+
#set_false_path -from [get_ports {i2c1_sda i2c1_scl}]
113+
#set_input_delay 0 [get_ports {i2c1_sda i2c1_scl}]
114+
115+
# SFP+ Interface
116+
set_property -dict {LOC T2 } [get_ports sfp0_rx_p] ;# GTH_DP2_C2M_P, som240_2_b1
117+
set_property -dict {LOC T1 } [get_ports sfp0_rx_n] ;# GTH_DP2_C2M_N, som240_2_b2
118+
set_property -dict {LOC R4 } [get_ports sfp0_tx_p] ;# GTH_DP2_M2C_P, som240_2_b5
119+
set_property -dict {LOC R3 } [get_ports sfp0_tx_n] ;# GTH_DP2_M2C_N, som240_2_b6
120+
121+
set_property -dict {LOC Y6 } [get_ports sfp_mgt_refclk_0_p] ;# GTH_REFCLK0_C2M_P via U90, SOM240_2 C3
122+
set_property -dict {LOC Y5 } [get_ports sfp_mgt_refclk_0_n] ;# GTH_REFCLK0_C2M_N via U90, SOM240_2 C4
123+
set_property -dict {LOC Y10 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 8 } [get_ports sfp0_tx_disable_b] ;# HDB19, SOM240_2_A47
124+
125+
# 156.25 MHz MGT reference clock
126+
create_clock -period 6.400 -name sfp_mgt_refclk_0 [get_ports sfp_mgt_refclk_0_p]
127+
128+
set_false_path -to [get_ports {sfp0_tx_disable_b}]
129+
set_output_delay 0 [get_ports {sfp0_tx_disable_b}]

example/KR260/fpga/fpga/Makefile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
# FPGA settings
3+
FPGA_PART = XCK26-SFVC784-2LV-C
4+
FPGA_TOP = fpga
5+
FPGA_ARCH = zynquplus
6+
7+
# Files for synthesis
8+
SYN_FILES = rtl/fpga.v
9+
SYN_FILES += rtl/fpga_core.v
10+
SYN_FILES += rtl/eth_xcvr_phy_wrapper.v
11+
SYN_FILES += rtl/debounce_switch.v
12+
SYN_FILES += rtl/sync_signal.v
13+
SYN_FILES += lib/eth/rtl/eth_mac_10g_fifo.v
14+
SYN_FILES += lib/eth/rtl/eth_mac_10g.v
15+
SYN_FILES += lib/eth/rtl/axis_xgmii_rx_64.v
16+
SYN_FILES += lib/eth/rtl/axis_xgmii_tx_64.v
17+
SYN_FILES += lib/eth/rtl/eth_phy_10g.v
18+
SYN_FILES += lib/eth/rtl/eth_phy_10g_rx.v
19+
SYN_FILES += lib/eth/rtl/eth_phy_10g_rx_if.v
20+
SYN_FILES += lib/eth/rtl/eth_phy_10g_rx_frame_sync.v
21+
SYN_FILES += lib/eth/rtl/eth_phy_10g_rx_ber_mon.v
22+
SYN_FILES += lib/eth/rtl/eth_phy_10g_rx_watchdog.v
23+
SYN_FILES += lib/eth/rtl/eth_phy_10g_tx.v
24+
SYN_FILES += lib/eth/rtl/eth_phy_10g_tx_if.v
25+
SYN_FILES += lib/eth/rtl/xgmii_baser_dec_64.v
26+
SYN_FILES += lib/eth/rtl/xgmii_baser_enc_64.v
27+
SYN_FILES += lib/eth/rtl/lfsr.v
28+
SYN_FILES += lib/eth/rtl/eth_axis_rx.v
29+
SYN_FILES += lib/eth/rtl/eth_axis_tx.v
30+
SYN_FILES += lib/eth/rtl/udp_complete_64.v
31+
SYN_FILES += lib/eth/rtl/udp_checksum_gen_64.v
32+
SYN_FILES += lib/eth/rtl/udp_64.v
33+
SYN_FILES += lib/eth/rtl/udp_ip_rx_64.v
34+
SYN_FILES += lib/eth/rtl/udp_ip_tx_64.v
35+
SYN_FILES += lib/eth/rtl/ip_complete_64.v
36+
SYN_FILES += lib/eth/rtl/ip_64.v
37+
SYN_FILES += lib/eth/rtl/ip_eth_rx_64.v
38+
SYN_FILES += lib/eth/rtl/ip_eth_tx_64.v
39+
SYN_FILES += lib/eth/rtl/ip_arb_mux.v
40+
SYN_FILES += lib/eth/rtl/arp.v
41+
SYN_FILES += lib/eth/rtl/arp_cache.v
42+
SYN_FILES += lib/eth/rtl/arp_eth_rx.v
43+
SYN_FILES += lib/eth/rtl/arp_eth_tx.v
44+
SYN_FILES += lib/eth/rtl/eth_arb_mux.v
45+
SYN_FILES += lib/eth/lib/axis/rtl/arbiter.v
46+
SYN_FILES += lib/eth/lib/axis/rtl/priority_encoder.v
47+
SYN_FILES += lib/eth/lib/axis/rtl/axis_fifo.v
48+
SYN_FILES += lib/eth/lib/axis/rtl/axis_async_fifo.v
49+
SYN_FILES += lib/eth/lib/axis/rtl/axis_async_fifo_adapter.v
50+
SYN_FILES += lib/eth/lib/axis/rtl/sync_reset.v
51+
52+
# XDC files
53+
XDC_FILES = fpga.xdc
54+
XDC_FILES += lib/eth/syn/vivado/eth_mac_fifo.tcl
55+
XDC_FILES += lib/eth/lib/axis/syn/vivado/axis_async_fifo.tcl
56+
XDC_FILES += lib/eth/lib/axis/syn/vivado/sync_reset.tcl
57+
58+
# IP
59+
IP_TCL_FILES += ip/eth_xcvr_gt.tcl
60+
61+
include ../common/vivado.mk
62+
63+
program: $(FPGA_TOP).bit
64+
echo "open_hw" > program.tcl
65+
echo "connect_hw_server" >> program.tcl
66+
echo "open_hw_target" >> program.tcl
67+
echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
68+
echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
69+
echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
70+
echo "program_hw_devices [current_hw_device]" >> program.tcl
71+
echo "exit" >> program.tcl
72+
vivado -nojournal -nolog -mode batch -source program.tcl
73+

0 commit comments

Comments
 (0)