Skip to content

Commit ae9d2e9

Browse files
committed
Add KR260 fpga_10g_ddr reference design
Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
1 parent 271f5a0 commit ae9d2e9

20 files changed

+2680
-0
lines changed
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
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
Run `make` to build. Ensure that the Xilinx Vivado toolchain components are
16+
in PATH.
17+
18+
## How to test
19+
20+
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:
21+
22+
netcat -u 192.168.1.128 1234
23+
24+
to open a UDP connection to port 1234. Any text entered into netcat will be
25+
echoed back after pressing enter.
26+
27+
It is also possible to use hping to test the design by running
28+
29+
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
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
#
9+
# use the 25 MHz clock outputs to the PL from U91
10+
# and feed that into a PLL to convert it to 125 MHz
11+
set_property -dict {LOC C3 IOSTANDARD LVCMOS18} [get_ports clk_25mhz_ref] ;# HPA_CLK0P_CLK, HPA_CLK0_P, via U91, SOM240_1 A6
12+
create_clock -period 40.000 -name clk_25mhz [get_ports clk_25mhz_ref]
13+
14+
# LEDs
15+
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
16+
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
17+
18+
set_false_path -to [get_ports {led[*]}]
19+
set_output_delay 0 [get_ports {led[*]}]
20+
21+
# SFP+ Interface
22+
set_property -dict {LOC T2 } [get_ports sfp0_rx_p] ;# GTH_DP2_C2M_P, som240_2_b1
23+
set_property -dict {LOC T1 } [get_ports sfp0_rx_n] ;# GTH_DP2_C2M_N, som240_2_b2
24+
set_property -dict {LOC R4 } [get_ports sfp0_tx_p] ;# GTH_DP2_M2C_P, som240_2_b5
25+
set_property -dict {LOC R3 } [get_ports sfp0_tx_n] ;# GTH_DP2_M2C_N, som240_2_b6
26+
27+
set_property -dict {LOC Y6 } [get_ports sfp_mgt_refclk_0_p] ;# GTH_REFCLK0_C2M_P via U90, SOM240_2 C3
28+
set_property -dict {LOC Y5 } [get_ports sfp_mgt_refclk_0_n] ;# GTH_REFCLK0_C2M_N via U90, SOM240_2 C4
29+
set_property -dict {LOC Y10 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 8 } [get_ports sfp0_tx_disable_b] ;# HDB19, SOM240_2_A47
30+
31+
# 156.25 MHz MGT reference clock
32+
create_clock -period 6.400 -name sfp_mgt_refclk_0 [get_ports sfp_mgt_refclk_0_p]
33+
34+
set_false_path -to [get_ports {sfp0_tx_disable_b}]
35+
set_output_delay 0 [get_ports {sfp0_tx_disable_b}]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*
2+
!.gitignore
3+
!.Makefile
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright (c) 2021 Alex Forencich
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
set base_name {eth_xcvr_gt}
22+
23+
set preset {GTH-10GBASE-R}
24+
25+
set freerun_freq {125}
26+
set line_rate {10.3125}
27+
set refclk_freq {156.25}
28+
set qpll_fracn [expr {int(fmod($line_rate*1000/2 / $refclk_freq, 1)*pow(2, 24))}]
29+
set user_data_width {64}
30+
set int_data_width {32}
31+
set extra_ports [list]
32+
set extra_pll_ports [list {qpll0lock_out}]
33+
34+
set config [dict create]
35+
36+
dict set config TX_LINE_RATE $line_rate
37+
dict set config TX_REFCLK_FREQUENCY $refclk_freq
38+
dict set config TX_QPLL_FRACN_NUMERATOR $qpll_fracn
39+
dict set config TX_USER_DATA_WIDTH $user_data_width
40+
dict set config TX_INT_DATA_WIDTH $int_data_width
41+
dict set config RX_LINE_RATE $line_rate
42+
dict set config RX_REFCLK_FREQUENCY $refclk_freq
43+
dict set config RX_QPLL_FRACN_NUMERATOR $qpll_fracn
44+
dict set config RX_USER_DATA_WIDTH $user_data_width
45+
dict set config RX_INT_DATA_WIDTH $int_data_width
46+
dict set config ENABLE_OPTIONAL_PORTS $extra_ports
47+
dict set config LOCATE_COMMON {CORE}
48+
dict set config LOCATE_RESET_CONTROLLER {CORE}
49+
dict set config LOCATE_TX_USER_CLOCKING {CORE}
50+
dict set config LOCATE_RX_USER_CLOCKING {CORE}
51+
dict set config LOCATE_USER_DATA_WIDTH_SIZING {CORE}
52+
dict set config FREERUN_FREQUENCY $freerun_freq
53+
dict set config DISABLE_LOC_XDC {1}
54+
55+
proc create_gtwizard_ip {name preset config} {
56+
create_ip -name gtwizard_ultrascale -vendor xilinx.com -library ip -module_name $name
57+
set ip [get_ips $name]
58+
set_property CONFIG.preset $preset $ip
59+
set config_list {}
60+
dict for {name value} $config {
61+
lappend config_list "CONFIG.${name}" $value
62+
}
63+
set_property -dict $config_list $ip
64+
}
65+
66+
# variant with channel and common
67+
dict set config ENABLE_OPTIONAL_PORTS [concat $extra_pll_ports $extra_ports]
68+
dict set config LOCATE_COMMON {CORE}
69+
70+
create_gtwizard_ip "${base_name}_full" $preset $config
71+
72+
# variant with channel only
73+
dict set config ENABLE_OPTIONAL_PORTS $extra_ports
74+
dict set config LOCATE_COMMON {EXAMPLE_DESIGN}
75+
76+
create_gtwizard_ip "${base_name}_channel" $preset $config

0 commit comments

Comments
 (0)