Zanehpn commited on
Commit
2eb90ff
·
verified ·
1 Parent(s): 4ffe429

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/README.md +19 -0
  2. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/common/vivado.mk +126 -0
  3. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/fpga.xdc +259 -0
  4. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/fpga/Makefile +94 -0
  5. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/ip/pcie4_uscale_plus_0.tcl +28 -0
  6. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/debounce_switch.v +93 -0
  7. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/fpga.v +463 -0
  8. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/fpga_core.v +271 -0
  9. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/sync_reset.v +56 -0
  10. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/sync_signal.v +62 -0
  11. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/Makefile +25 -0
  12. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/README.md +26 -0
  13. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/common/vivado.mk +126 -0
  14. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/fpga.xdc +259 -0
  15. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/fpga/Makefile +85 -0
  16. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/ip/pcie4_uscale_plus_0.tcl +28 -0
  17. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/axi_ram.v +369 -0
  18. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/axis_register.v +268 -0
  19. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/debounce_switch.v +93 -0
  20. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/fpga.v +428 -0
  21. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/fpga_core.v +1123 -0
  22. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/sync_reset.v +56 -0
  23. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/sync_signal.v +62 -0
  24. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/tb/fpga_core/Makefile +102 -0
  25. snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/tb/fpga_core/test_fpga_core.py +376 -0
  26. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/README.md +19 -0
  27. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/common/vivado.mk +126 -0
  28. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/fpga/Makefile +93 -0
  29. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/ip/pcie4c_uscale_plus_0.tcl +28 -0
  30. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/fpga.v +454 -0
  31. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/fpga_core.v +274 -0
  32. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/sync_reset.v +56 -0
  33. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/sync_signal.v +62 -0
  34. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/tb/fpga_core/Makefile +123 -0
  35. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/tb/fpga_core/test_fpga_core.py +472 -0
  36. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/common/vivado.mk +126 -0
  37. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/fpga/Makefile +84 -0
  38. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/ip/pcie4c_uscale_plus_0.tcl +28 -0
  39. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/axi_ram.v +369 -0
  40. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/axis_register.v +268 -0
  41. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/fpga.v +416 -0
  42. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/fpga_core.v +1126 -0
  43. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/sync_reset.v +56 -0
  44. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/sync_signal.v +62 -0
  45. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/tb/fpga_core/Makefile +102 -0
  46. snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/tb/fpga_core/test_fpga_core.py +374 -0
  47. snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/README.md +19 -0
  48. snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/common/vivado.mk +126 -0
  49. snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/fpga.xdc +187 -0
  50. snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/fpga/Makefile +95 -0
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilog PCIe Alveo U250 Example Design
2
+
3
+ ## Introduction
4
+
5
+ This example design targets the Xilinx Alveo U250 FPGA board.
6
+
7
+ The design implements the PCIe AXI lite master module, the PCIe AXI master module, and the PCIe DMA module. A very simple Linux driver is included to test the FPGA design.
8
+
9
+ * FPGA: xcu250-figd2104-2-e
10
+
11
+ ## How to build
12
+
13
+ Run `make` to build. Ensure that the Xilinx Vivado components are in PATH.
14
+
15
+ Run `make` to build the driver. Ensure the headers for the running kernel are installed, otherwise the driver cannot be compiled.
16
+
17
+ ## How to test
18
+
19
+ Run `make program` to program the Alveo U250 board with Vivado. Then load the driver with `insmod example.ko`. Check dmesg for the output.
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/common/vivado.mk ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: fpga vivado tmpclean clean distclean
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
+ SYN_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(SYN_FILES))) $(filter /% ./%,$(SYN_FILES))
41
+ INC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(INC_FILES))) $(filter /% ./%,$(INC_FILES))
42
+ XCI_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XCI_FILES))) $(filter /% ./%,$(XCI_FILES))
43
+ IP_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(IP_TCL_FILES))) $(filter /% ./%,$(IP_TCL_FILES))
44
+ CONFIG_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(CONFIG_TCL_FILES))) $(filter /% ./%,$(CONFIG_TCL_FILES))
45
+
46
+ ifdef XDC_FILES
47
+ XDC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XDC_FILES))) $(filter /% ./%,$(XDC_FILES))
48
+ else
49
+ XDC_FILES_REL = $(FPGA_TOP).xdc
50
+ endif
51
+
52
+ ###################################################################
53
+ # Main Targets
54
+ #
55
+ # all: build everything
56
+ # clean: remove output files and project files
57
+ ###################################################################
58
+
59
+ all: fpga
60
+
61
+ fpga: $(FPGA_TOP).bit
62
+
63
+ vivado: $(FPGA_TOP).xpr
64
+ vivado $(FPGA_TOP).xpr
65
+
66
+ tmpclean::
67
+ -rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
68
+ -rm -rf create_project.tcl update_config.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
69
+
70
+ clean:: tmpclean
71
+ -rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
72
+
73
+ distclean:: clean
74
+ -rm -rf rev
75
+
76
+ ###################################################################
77
+ # Target implementations
78
+ ###################################################################
79
+
80
+ # Vivado project file
81
+ create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
82
+ rm -rf defines.v
83
+ touch defines.v
84
+ for x in $(DEFS); do echo '`define' $$x >> defines.v; done
85
+ echo "create_project -force -part $(FPGA_PART) $(FPGA_TOP)" > $@
86
+ echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
87
+ echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
88
+ for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
89
+ for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
90
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
91
+
92
+ update_config.tcl: $(CONFIG_TCL_FILES_REL)
93
+ echo "open_project -quiet $(FPGA_TOP).xpr" > $@
94
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
95
+
96
+ $(FPGA_TOP).xpr: create_project.tcl update_config.tcl
97
+ vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
98
+
99
+ # synthesis run
100
+ %.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL) $(CONFIG_TCL_FILES_REL)
101
+ echo "open_project $*.xpr" > run_synth.tcl
102
+ echo "reset_run synth_1" >> run_synth.tcl
103
+ echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
104
+ echo "wait_on_run synth_1" >> run_synth.tcl
105
+ vivado -nojournal -nolog -mode batch -source run_synth.tcl
106
+
107
+ # implementation run
108
+ %.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
109
+ echo "open_project $*.xpr" > run_impl.tcl
110
+ echo "reset_run impl_1" >> run_impl.tcl
111
+ echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
112
+ echo "wait_on_run impl_1" >> run_impl.tcl
113
+ vivado -nojournal -nolog -mode batch -source run_impl.tcl
114
+
115
+ # bit file
116
+ %.bit: %.runs/impl_1/%_routed.dcp
117
+ echo "open_project $*.xpr" > generate_bit.tcl
118
+ echo "open_run impl_1" >> generate_bit.tcl
119
+ echo "write_bitstream -force $*.bit" >> generate_bit.tcl
120
+ vivado -nojournal -nolog -mode batch -source generate_bit.tcl
121
+ mkdir -p rev
122
+ EXT=bit; COUNT=100; \
123
+ while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
124
+ do COUNT=$$((COUNT+1)); done; \
125
+ cp $@ rev/$*_rev$$COUNT.$$EXT; \
126
+ echo "Output: rev/$*_rev$$COUNT.$$EXT";
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/fpga.xdc ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XDC constraints for the Xilinx Alveo U250 board
2
+ # part: xcu250-figd2104-2-e
3
+
4
+ # General configuration
5
+ set_property CFGBVS GND [current_design]
6
+ set_property CONFIG_VOLTAGE 1.8 [current_design]
7
+ set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
8
+ set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
9
+ set_property BITSTREAM.CONFIG.EXTMASTERCCLK_EN DISABLE [current_design]
10
+ set_property BITSTREAM.CONFIG.CONFIGRATE 63.8 [current_design]
11
+ set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR YES [current_design]
12
+ set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
13
+ set_property BITSTREAM.CONFIG.SPI_FALL_EDGE YES [current_design]
14
+ set_property BITSTREAM.CONFIG.UNUSEDPIN PULLUP [current_design]
15
+
16
+ set_operating_conditions -design_power_budget 160
17
+
18
+ # System clocks
19
+ # 300 MHz (DDR 0)
20
+ #set_property -dict {LOC AY37 IOSTANDARD LVDS} [get_ports clk_300mhz_0_p]
21
+ #set_property -dict {LOC AY38 IOSTANDARD LVDS} [get_ports clk_300mhz_0_n]
22
+ #create_clock -period 3.333 -name clk_300mhz_0 [get_ports clk_300mhz_0_p]
23
+
24
+ # 300 MHz (DDR 1)
25
+ #set_property -dict {LOC AW20 IOSTANDARD LVDS} [get_ports clk_300mhz_1_p]
26
+ #set_property -dict {LOC AW19 IOSTANDARD LVDS} [get_ports clk_300mhz_1_n]
27
+ #create_clock -period 3.333 -name clk_300mhz_1 [get_ports clk_300mhz_1_p]
28
+
29
+ # 300 MHz (DDR 2)
30
+ #set_property -dict {LOC F32 IOSTANDARD LVDS} [get_ports clk_300mhz_2_p]
31
+ #set_property -dict {LOC E32 IOSTANDARD LVDS} [get_ports clk_300mhz_2_n]
32
+ #create_clock -period 3.333 -name clk_300mhz_2 [get_ports clk_300mhz_2_p]
33
+
34
+ # 300 MHz (DDR 3)
35
+ #set_property -dict {LOC J16 IOSTANDARD LVDS} [get_ports clk_300mhz_3_p]
36
+ #set_property -dict {LOC H16 IOSTANDARD LVDS} [get_ports clk_300mhz_3_n]
37
+ #create_clock -period 3.333 -name clk_300mhz_3 [get_ports clk_300mhz_3_p]
38
+
39
+ # SI570 user clock
40
+ #set_property -dict {LOC AU19 IOSTANDARD LVDS} [get_ports clk_user_p]
41
+ #set_property -dict {LOC AV19 IOSTANDARD LVDS} [get_ports clk_user_n]
42
+ #create_clock -period 6.400 -name clk_user [get_ports clk_user_p]
43
+
44
+ # LEDs
45
+ set_property -dict {LOC BC21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[0]}]
46
+ set_property -dict {LOC BB21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[1]}]
47
+ set_property -dict {LOC BA20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[2]}]
48
+
49
+ set_false_path -to [get_ports {led[*]}]
50
+ set_output_delay 0 [get_ports {led[*]}]
51
+
52
+ # Reset button
53
+ #set_property -dict {LOC AL20 IOSTANDARD LVCMOS12} [get_ports reset]
54
+
55
+ #set_false_path -from [get_ports {reset}]
56
+ #set_input_delay 0 [get_ports {reset}]
57
+
58
+ # DIP switches
59
+ set_property -dict {LOC AN22 IOSTANDARD LVCMOS12} [get_ports {sw[0]}]
60
+ set_property -dict {LOC AM19 IOSTANDARD LVCMOS12} [get_ports {sw[1]}]
61
+ set_property -dict {LOC AL19 IOSTANDARD LVCMOS12} [get_ports {sw[2]}]
62
+ set_property -dict {LOC AP20 IOSTANDARD LVCMOS12} [get_ports {sw[3]}]
63
+
64
+ set_false_path -from [get_ports {sw[*]}]
65
+ set_input_delay 0 [get_ports {sw[*]}]
66
+
67
+ # UART
68
+ #set_property -dict {LOC BF18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports uart_txd]
69
+ #set_property -dict {LOC BB20 IOSTANDARD LVCMOS12} [get_ports uart_rxd]
70
+
71
+ #set_false_path -to [get_ports {uart_txd}]
72
+ #set_output_delay 0 [get_ports {uart_txd}]
73
+ #set_false_path -from [get_ports {uart_rxd}]
74
+ #set_input_delay 0 [get_ports {uart_rxd}]
75
+
76
+ # BMC
77
+ #set_property -dict {LOC AR20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[0]}]
78
+ #set_property -dict {LOC AM20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[1]}]
79
+ #set_property -dict {LOC AM21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[2]}]
80
+ #set_property -dict {LOC AN21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[3]}]
81
+ #set_property -dict {LOC BB19 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_uart_txd}]
82
+ #set_property -dict {LOC BA19 IOSTANDARD LVCMOS12} [get_ports {msp_uart_rxd}]
83
+
84
+ #set_false_path -to [get_ports {msp_uart_txd}]
85
+ #set_output_delay 0 [get_ports {msp_uart_txd}]
86
+ #set_false_path -from [get_ports {msp_gpio[*] msp_uart_rxd}]
87
+ #set_input_delay 0 [get_ports {msp_gpio[*] msp_uart_rxd}]
88
+
89
+ # QSFP28 Interfaces
90
+ #set_property -dict {LOC N4 } [get_ports qsfp0_rx1_p] ;# MGTYRXP0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
91
+ #set_property -dict {LOC N3 } [get_ports qsfp0_rx1_n] ;# MGTYRXN0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
92
+ #set_property -dict {LOC N9 } [get_ports qsfp0_tx1_p] ;# MGTYTXP0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
93
+ #set_property -dict {LOC N8 } [get_ports qsfp0_tx1_n] ;# MGTYTXN0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
94
+ #set_property -dict {LOC M2 } [get_ports qsfp0_rx2_p] ;# MGTYRXP1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
95
+ #set_property -dict {LOC M1 } [get_ports qsfp0_rx2_n] ;# MGTYRXN1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
96
+ #set_property -dict {LOC M7 } [get_ports qsfp0_tx2_p] ;# MGTYTXP1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
97
+ #set_property -dict {LOC M6 } [get_ports qsfp0_tx2_n] ;# MGTYTXN1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
98
+ #set_property -dict {LOC L4 } [get_ports qsfp0_rx3_p] ;# MGTYRXP2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
99
+ #set_property -dict {LOC L3 } [get_ports qsfp0_rx3_n] ;# MGTYRXN2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
100
+ #set_property -dict {LOC L9 } [get_ports qsfp0_tx3_p] ;# MGTYTXP2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
101
+ #set_property -dict {LOC L8 } [get_ports qsfp0_tx3_n] ;# MGTYTXN2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
102
+ #set_property -dict {LOC K2 } [get_ports qsfp0_rx4_p] ;# MGTYRXP3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
103
+ #set_property -dict {LOC K1 } [get_ports qsfp0_rx4_n] ;# MGTYRXN3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
104
+ #set_property -dict {LOC K7 } [get_ports qsfp0_tx4_p] ;# MGTYTXP3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
105
+ #set_property -dict {LOC K6 } [get_ports qsfp0_tx4_n] ;# MGTYTXN3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
106
+ #set_property -dict {LOC M11 } [get_ports qsfp0_mgt_refclk_0_p] ;# MGTREFCLK0P_231 from U14.4 via U43.13
107
+ #set_property -dict {LOC M10 } [get_ports qsfp0_mgt_refclk_0_n] ;# MGTREFCLK0N_231 from U14.5 via U43.14
108
+ #set_property -dict {LOC K11 } [get_ports qsfp0_mgt_refclk_1_p] ;# MGTREFCLK1P_231 from U9.18
109
+ #set_property -dict {LOC K10 } [get_ports qsfp0_mgt_refclk_1_n] ;# MGTREFCLK1N_231 from U9.17
110
+ #set_property -dict {LOC BE16 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_modsell]
111
+ #set_property -dict {LOC BE17 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_resetl]
112
+ #set_property -dict {LOC BE20 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp0_modprsl]
113
+ #set_property -dict {LOC BE21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp0_intl]
114
+ #set_property -dict {LOC BD18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_lpmode]
115
+ #set_property -dict {LOC AT22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_refclk_reset]
116
+ #set_property -dict {LOC AT20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp0_fs[0]}]
117
+ #set_property -dict {LOC AU22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp0_fs[1]}]
118
+
119
+ # 156.25 MHz MGT reference clock (from SI570)
120
+ #create_clock -period 6.400 -name qsfp0_mgt_refclk_0 [get_ports qsfp0_mgt_refclk_0_p]
121
+
122
+ # 156.25 MHz MGT reference clock (from SI5335, FS = 0b01)
123
+ #create_clock -period 6.400 -name qsfp0_mgt_refclk_1 [get_ports qsfp0_mgt_refclk_1_p]
124
+
125
+ # 161.1328125 MHz MGT reference clock (from SI5335, FS = 0b10)
126
+ #create_clock -period 6.206 -name qsfp0_mgt_refclk_1 [get_ports qsfp0_mgt_refclk_1_p]
127
+
128
+ #set_false_path -to [get_ports {qsfp0_modsell qsfp0_resetl qsfp0_lpmode qsfp0_refclk_reset qsfp0_fs[*]}]
129
+ #set_output_delay 0 [get_ports {qsfp0_modsell qsfp0_resetl qsfp0_lpmode qsfp0_refclk_reset qsfp0_fs[*]}]
130
+ #set_false_path -from [get_ports {qsfp0_modprsl qsfp0_intl}]
131
+ #set_input_delay 0 [get_ports {qsfp0_modprsl qsfp0_intl}]
132
+
133
+ #set_property -dict {LOC U4 } [get_ports qsfp1_rx1_p] ;# MGTYRXP0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
134
+ #set_property -dict {LOC U3 } [get_ports qsfp1_rx1_n] ;# MGTYRXN0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
135
+ #set_property -dict {LOC U9 } [get_ports qsfp1_tx1_p] ;# MGTYTXP0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
136
+ #set_property -dict {LOC U8 } [get_ports qsfp1_tx1_n] ;# MGTYTXN0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
137
+ #set_property -dict {LOC T2 } [get_ports qsfp1_rx2_p] ;# MGTYRXP1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
138
+ #set_property -dict {LOC T1 } [get_ports qsfp1_rx2_n] ;# MGTYRXN1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
139
+ #set_property -dict {LOC T7 } [get_ports qsfp1_tx2_p] ;# MGTYTXP1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
140
+ #set_property -dict {LOC T6 } [get_ports qsfp1_tx2_n] ;# MGTYTXN1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
141
+ #set_property -dict {LOC R4 } [get_ports qsfp1_rx3_p] ;# MGTYRXP2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
142
+ #set_property -dict {LOC R3 } [get_ports qsfp1_rx3_n] ;# MGTYRXN2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
143
+ #set_property -dict {LOC R9 } [get_ports qsfp1_tx3_p] ;# MGTYTXP2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
144
+ #set_property -dict {LOC R8 } [get_ports qsfp1_tx3_n] ;# MGTYTXN2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
145
+ #set_property -dict {LOC P2 } [get_ports qsfp1_rx4_p] ;# MGTYRXP3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
146
+ #set_property -dict {LOC P1 } [get_ports qsfp1_rx4_n] ;# MGTYRXN3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
147
+ #set_property -dict {LOC P7 } [get_ports qsfp1_tx4_p] ;# MGTYTXP3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
148
+ #set_property -dict {LOC P6 } [get_ports qsfp1_tx4_n] ;# MGTYTXN3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
149
+ #set_property -dict {LOC T11 } [get_ports qsfp1_mgt_refclk_0_p] ;# MGTREFCLK0P_230 from U14.4 via U43.15
150
+ #set_property -dict {LOC T10 } [get_ports qsfp1_mgt_refclk_0_n] ;# MGTREFCLK0N_230 from U14.5 via U43.16
151
+ #set_property -dict {LOC P11 } [get_ports qsfp1_mgt_refclk_1_p] ;# MGTREFCLK1P_230 from U12.18
152
+ #set_property -dict {LOC P10 } [get_ports qsfp1_mgt_refclk_1_n] ;# MGTREFCLK1N_230 from U12.17
153
+ #set_property -dict {LOC AY20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_modsell]
154
+ #set_property -dict {LOC BC18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_resetl]
155
+ #set_property -dict {LOC BC19 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp1_modprsl]
156
+ #set_property -dict {LOC AV21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp1_intl]
157
+ #set_property -dict {LOC AV22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_lpmode]
158
+ #set_property -dict {LOC AR21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_refclk_reset]
159
+ #set_property -dict {LOC AR22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp1_fs[0]}]
160
+ #set_property -dict {LOC AU20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp1_fs[1]}]
161
+
162
+ # 156.25 MHz MGT reference clock (from SI570)
163
+ #create_clock -period 6.400 -name qsfp1_mgt_refclk_0 [get_ports qsfp1_mgt_refclk_0_p]
164
+
165
+ # 156.25 MHz MGT reference clock (from SI5335, FS = 0b01)
166
+ #create_clock -period 6.400 -name qsfp1_mgt_refclk_1 [get_ports qsfp1_mgt_refclk_1_p]
167
+
168
+ # 161.1328125 MHz MGT reference clock (from SI5335, FS = 0b10)
169
+ #create_clock -period 6.206 -name qsfp1_mgt_refclk_1 [get_ports qsfp1_mgt_refclk_1_p]
170
+
171
+ #set_false_path -to [get_ports {qsfp1_modsell qsfp1_resetl qsfp1_lpmode qsfp1_refclk_reset qsfp1_fs[*]}]
172
+ #set_output_delay 0 [get_ports {qsfp1_modsell qsfp1_resetl qsfp1_lpmode qsfp1_refclk_reset qsfp1_fs[*]}]
173
+ #set_false_path -from [get_ports {qsfp1_modprsl qsfp1_intl}]
174
+ #set_input_delay 0 [get_ports {qsfp1_modprsl qsfp1_intl}]
175
+
176
+ # I2C interface
177
+ #set_property -dict {LOC BF19 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_mux_reset]
178
+ #set_property -dict {LOC BF20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_scl]
179
+ #set_property -dict {LOC BF17 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_sda]
180
+
181
+ #set_false_path -to [get_ports {i2c_sda i2c_scl}]
182
+ #set_output_delay 0 [get_ports {i2c_sda i2c_scl}]
183
+ #set_false_path -from [get_ports {i2c_sda i2c_scl}]
184
+ #set_input_delay 0 [get_ports {i2c_sda i2c_scl}]
185
+
186
+ # PCIe Interface
187
+ set_property -dict {LOC AF2 } [get_ports {pcie_rx_p[0]}] ;# MGTYRXP3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
188
+ set_property -dict {LOC AF1 } [get_ports {pcie_rx_n[0]}] ;# MGTYRXN3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
189
+ set_property -dict {LOC AF7 } [get_ports {pcie_tx_p[0]}] ;# MGTYTXP3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
190
+ set_property -dict {LOC AF6 } [get_ports {pcie_tx_n[0]}] ;# MGTYTXN3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
191
+ set_property -dict {LOC AG4 } [get_ports {pcie_rx_p[1]}] ;# MGTYRXP2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
192
+ set_property -dict {LOC AG3 } [get_ports {pcie_rx_n[1]}] ;# MGTYRXN2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
193
+ set_property -dict {LOC AG9 } [get_ports {pcie_tx_p[1]}] ;# MGTYTXP2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
194
+ set_property -dict {LOC AG8 } [get_ports {pcie_tx_n[1]}] ;# MGTYTXN2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
195
+ set_property -dict {LOC AH2 } [get_ports {pcie_rx_p[2]}] ;# MGTYRXP1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
196
+ set_property -dict {LOC AH1 } [get_ports {pcie_rx_n[2]}] ;# MGTYRXN1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
197
+ set_property -dict {LOC AH7 } [get_ports {pcie_tx_p[2]}] ;# MGTYTXP1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
198
+ set_property -dict {LOC AH6 } [get_ports {pcie_tx_n[2]}] ;# MGTYTXN1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
199
+ set_property -dict {LOC AJ4 } [get_ports {pcie_rx_p[3]}] ;# MGTYRXP0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
200
+ set_property -dict {LOC AJ3 } [get_ports {pcie_rx_n[3]}] ;# MGTYRXN0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
201
+ set_property -dict {LOC AJ9 } [get_ports {pcie_tx_p[3]}] ;# MGTYTXP0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
202
+ set_property -dict {LOC AJ8 } [get_ports {pcie_tx_n[3]}] ;# MGTYTXN0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
203
+ set_property -dict {LOC AK2 } [get_ports {pcie_rx_p[4]}] ;# MGTYRXP3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
204
+ set_property -dict {LOC AK1 } [get_ports {pcie_rx_n[4]}] ;# MGTYRXN3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
205
+ set_property -dict {LOC AK7 } [get_ports {pcie_tx_p[4]}] ;# MGTYTXP3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
206
+ set_property -dict {LOC AK6 } [get_ports {pcie_tx_n[4]}] ;# MGTYTXN3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
207
+ set_property -dict {LOC AL4 } [get_ports {pcie_rx_p[5]}] ;# MGTYRXP2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
208
+ set_property -dict {LOC AL3 } [get_ports {pcie_rx_n[5]}] ;# MGTYRXN2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
209
+ set_property -dict {LOC AL9 } [get_ports {pcie_tx_p[5]}] ;# MGTYTXP2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
210
+ set_property -dict {LOC AL8 } [get_ports {pcie_tx_n[5]}] ;# MGTYTXN2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
211
+ set_property -dict {LOC AM2 } [get_ports {pcie_rx_p[6]}] ;# MGTYRXP1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
212
+ set_property -dict {LOC AM1 } [get_ports {pcie_rx_n[6]}] ;# MGTYRXN1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
213
+ set_property -dict {LOC AM7 } [get_ports {pcie_tx_p[6]}] ;# MGTYTXP1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
214
+ set_property -dict {LOC AM6 } [get_ports {pcie_tx_n[6]}] ;# MGTYTXN1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
215
+ set_property -dict {LOC AN4 } [get_ports {pcie_rx_p[7]}] ;# MGTYRXP0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
216
+ set_property -dict {LOC AN3 } [get_ports {pcie_rx_n[7]}] ;# MGTYRXN0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
217
+ set_property -dict {LOC AN9 } [get_ports {pcie_tx_p[7]}] ;# MGTYTXP0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
218
+ set_property -dict {LOC AN8 } [get_ports {pcie_tx_n[7]}] ;# MGTYTXN0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
219
+ set_property -dict {LOC AP2 } [get_ports {pcie_rx_p[8]}] ;# MGTYRXP3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
220
+ set_property -dict {LOC AP1 } [get_ports {pcie_rx_n[8]}] ;# MGTYRXN3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
221
+ set_property -dict {LOC AP7 } [get_ports {pcie_tx_p[8]}] ;# MGTYTXP3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
222
+ set_property -dict {LOC AP6 } [get_ports {pcie_tx_n[8]}] ;# MGTYTXN3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
223
+ set_property -dict {LOC AR4 } [get_ports {pcie_rx_p[9]}] ;# MGTYRXP2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
224
+ set_property -dict {LOC AR3 } [get_ports {pcie_rx_n[9]}] ;# MGTYRXN2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
225
+ set_property -dict {LOC AR9 } [get_ports {pcie_tx_p[9]}] ;# MGTYTXP2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
226
+ set_property -dict {LOC AR8 } [get_ports {pcie_tx_n[9]}] ;# MGTYTXN2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
227
+ set_property -dict {LOC AT2 } [get_ports {pcie_rx_p[10]}] ;# MGTYRXP1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
228
+ set_property -dict {LOC AT1 } [get_ports {pcie_rx_n[10]}] ;# MGTYRXN1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
229
+ set_property -dict {LOC AT7 } [get_ports {pcie_tx_p[10]}] ;# MGTYTXP1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
230
+ set_property -dict {LOC AT6 } [get_ports {pcie_tx_n[10]}] ;# MGTYTXN1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
231
+ set_property -dict {LOC AU4 } [get_ports {pcie_rx_p[11]}] ;# MGTYRXP0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
232
+ set_property -dict {LOC AU3 } [get_ports {pcie_rx_n[11]}] ;# MGTYRXN0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
233
+ set_property -dict {LOC AU9 } [get_ports {pcie_tx_p[11]}] ;# MGTYTXP0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
234
+ set_property -dict {LOC AU8 } [get_ports {pcie_tx_n[11]}] ;# MGTYTXN0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
235
+ set_property -dict {LOC AV2 } [get_ports {pcie_rx_p[12]}] ;# MGTYRXP3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
236
+ set_property -dict {LOC AV1 } [get_ports {pcie_rx_n[12]}] ;# MGTYRXN3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
237
+ set_property -dict {LOC AV7 } [get_ports {pcie_tx_p[12]}] ;# MGTYTXP3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
238
+ set_property -dict {LOC AV6 } [get_ports {pcie_tx_n[12]}] ;# MGTYTXN3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
239
+ set_property -dict {LOC AW4 } [get_ports {pcie_rx_p[13]}] ;# MGTYRXP2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
240
+ set_property -dict {LOC AW3 } [get_ports {pcie_rx_n[13]}] ;# MGTYRXN2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
241
+ set_property -dict {LOC BB5 } [get_ports {pcie_tx_p[13]}] ;# MGTYTXP2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
242
+ set_property -dict {LOC BB4 } [get_ports {pcie_tx_n[13]}] ;# MGTYTXN2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
243
+ set_property -dict {LOC BA2 } [get_ports {pcie_rx_p[14]}] ;# MGTYRXP1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
244
+ set_property -dict {LOC BA1 } [get_ports {pcie_rx_n[14]}] ;# MGTYRXN1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
245
+ set_property -dict {LOC BD5 } [get_ports {pcie_tx_p[14]}] ;# MGTYTXP1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
246
+ set_property -dict {LOC BD4 } [get_ports {pcie_tx_n[14]}] ;# MGTYTXN1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
247
+ set_property -dict {LOC BC2 } [get_ports {pcie_rx_p[15]}] ;# MGTYRXP0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
248
+ set_property -dict {LOC BC1 } [get_ports {pcie_rx_n[15]}] ;# MGTYRXN0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
249
+ set_property -dict {LOC BF5 } [get_ports {pcie_tx_p[15]}] ;# MGTYTXP0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
250
+ set_property -dict {LOC BF4 } [get_ports {pcie_tx_n[15]}] ;# MGTYTXN0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
251
+ set_property -dict {LOC AM11 } [get_ports pcie_refclk_p] ;# MGTREFCLK0P_226
252
+ set_property -dict {LOC AM10 } [get_ports pcie_refclk_n] ;# MGTREFCLK0N_226
253
+ set_property -dict {LOC BD21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports pcie_reset_n]
254
+
255
+ # 100 MHz MGT reference clock
256
+ create_clock -period 10 -name pcie_mgt_refclk_1 [get_ports pcie_refclk_p]
257
+
258
+ set_false_path -from [get_ports {pcie_reset_n}]
259
+ set_input_delay 0 [get_ports {pcie_reset_n}]
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/fpga/Makefile ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # FPGA settings
3
+ FPGA_PART = xcu250-figd2104-2-e
4
+ FPGA_TOP = fpga
5
+ FPGA_ARCH = virtexuplus
6
+
7
+ # Files for synthesis
8
+ SYN_FILES = rtl/fpga.v
9
+ SYN_FILES += rtl/fpga_core.v
10
+ SYN_FILES += rtl/debounce_switch.v
11
+ SYN_FILES += rtl/sync_reset.v
12
+ SYN_FILES += rtl/sync_signal.v
13
+ SYN_FILES += rtl/common/example_core_pcie_us.v
14
+ SYN_FILES += rtl/common/example_core_pcie.v
15
+ SYN_FILES += rtl/common/example_core.v
16
+ SYN_FILES += rtl/common/axi_ram.v
17
+ SYN_FILES += lib/pcie/rtl/pcie_us_if.v
18
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rc.v
19
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rq.v
20
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cq.v
21
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cc.v
22
+ SYN_FILES += lib/pcie/rtl/pcie_us_cfg.v
23
+ SYN_FILES += lib/pcie/rtl/pcie_us_msi.v
24
+ SYN_FILES += lib/pcie/rtl/pcie_axil_master.v
25
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master.v
26
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_rd.v
27
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_wr.v
28
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux_bar.v
29
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux.v
30
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_mux.v
31
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie.v
32
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_rd.v
33
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_wr.v
34
+ SYN_FILES += lib/pcie/rtl/dma_psdpram.v
35
+ SYN_FILES += lib/pcie/rtl/arbiter.v
36
+ SYN_FILES += lib/pcie/rtl/priority_encoder.v
37
+ SYN_FILES += lib/pcie/rtl/pulse_merge.v
38
+
39
+ # XDC files
40
+ XDC_FILES = fpga.xdc
41
+
42
+ # IP
43
+ IP_TCL_FILES = ip/pcie4_uscale_plus_0.tcl
44
+
45
+ include ../common/vivado.mk
46
+
47
+ program: $(FPGA_TOP).bit
48
+ echo "open_hw" > program.tcl
49
+ echo "connect_hw_server" >> program.tcl
50
+ echo "open_hw_target" >> program.tcl
51
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
52
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
53
+ echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
54
+ echo "program_hw_devices [current_hw_device]" >> program.tcl
55
+ echo "exit" >> program.tcl
56
+ vivado -nojournal -nolog -mode batch -source program.tcl
57
+
58
+ %.mcs %.prm: %.bit
59
+ echo "write_cfgmem -force -format mcs -size 128 -interface SPIx4 -loadbit {up 0x01002000 $*.bit} -checksum -file $*.mcs" > generate_mcs.tcl
60
+ echo "exit" >> generate_mcs.tcl
61
+ vivado -nojournal -nolog -mode batch -source generate_mcs.tcl
62
+ mkdir -p rev
63
+ COUNT=100; \
64
+ while [ -e rev/$*_rev$$COUNT.bit ]; \
65
+ do COUNT=$$((COUNT+1)); done; \
66
+ COUNT=$$((COUNT-1)); \
67
+ for x in .mcs .prm; \
68
+ do cp $*$$x rev/$*_rev$$COUNT$$x; \
69
+ echo "Output: rev/$*_rev$$COUNT$$x"; done;
70
+
71
+ flash: $(FPGA_TOP).mcs $(FPGA_TOP).prm
72
+ echo "open_hw" > flash.tcl
73
+ echo "connect_hw_server" >> flash.tcl
74
+ echo "open_hw_target" >> flash.tcl
75
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> flash.tcl
76
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> flash.tcl
77
+ echo "create_hw_cfgmem -hw_device [current_hw_device] [lindex [get_cfgmem_parts {mt25qu01g-spi-x1_x2_x4}] 0]" >> flash.tcl
78
+ echo "current_hw_cfgmem -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM [current_hw_device]]" >> flash.tcl
79
+ echo "set_property PROGRAM.FILES [list \"$(FPGA_TOP).mcs\"] [current_hw_cfgmem]" >> flash.tcl
80
+ echo "set_property PROGRAM.PRM_FILES [list \"$(FPGA_TOP).prm\"] [current_hw_cfgmem]" >> flash.tcl
81
+ echo "set_property PROGRAM.ERASE 1 [current_hw_cfgmem]" >> flash.tcl
82
+ echo "set_property PROGRAM.CFG_PROGRAM 1 [current_hw_cfgmem]" >> flash.tcl
83
+ echo "set_property PROGRAM.VERIFY 1 [current_hw_cfgmem]" >> flash.tcl
84
+ echo "set_property PROGRAM.CHECKSUM 0 [current_hw_cfgmem]" >> flash.tcl
85
+ echo "set_property PROGRAM.ADDRESS_RANGE {use_file} [current_hw_cfgmem]" >> flash.tcl
86
+ echo "set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [current_hw_cfgmem]" >> flash.tcl
87
+ echo "create_hw_bitstream -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM_BITFILE [current_hw_device]]" >> flash.tcl
88
+ echo "program_hw_devices [current_hw_device]" >> flash.tcl
89
+ echo "refresh_hw_device [current_hw_device]" >> flash.tcl
90
+ echo "program_hw_cfgmem -hw_cfgmem [current_hw_cfgmem]" >> flash.tcl
91
+ echo "boot_hw_device [current_hw_device]" >> flash.tcl
92
+ echo "exit" >> flash.tcl
93
+ vivado -nojournal -nolog -mode batch -source flash.tcl
94
+
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/ip/pcie4_uscale_plus_0.tcl ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ create_ip -name pcie4_uscale_plus -vendor xilinx.com -library ip -module_name pcie4_uscale_plus_0
3
+
4
+ set_property -dict [list \
5
+ CONFIG.PL_LINK_CAP_MAX_LINK_SPEED {8.0_GT/s} \
6
+ CONFIG.PL_LINK_CAP_MAX_LINK_WIDTH {X16} \
7
+ CONFIG.AXISTEN_IF_EXT_512_RQ_STRADDLE {false} \
8
+ CONFIG.axisten_if_enable_client_tag {true} \
9
+ CONFIG.axisten_if_width {512_bit} \
10
+ CONFIG.axisten_freq {250} \
11
+ CONFIG.PF0_CLASS_CODE {058000} \
12
+ CONFIG.PF0_DEVICE_ID {0001} \
13
+ CONFIG.PF0_MSI_CAP_MULTIMSGCAP {32_vectors} \
14
+ CONFIG.PF0_SUBSYSTEM_ID {90fa} \
15
+ CONFIG.PF0_SUBSYSTEM_VENDOR_ID {10ee} \
16
+ CONFIG.pf0_bar0_64bit {true} \
17
+ CONFIG.pf0_bar0_prefetchable {true} \
18
+ CONFIG.pf0_bar0_scale {Megabytes} \
19
+ CONFIG.pf0_bar0_size {16} \
20
+ CONFIG.pf0_bar2_64bit {true} \
21
+ CONFIG.pf0_bar2_prefetchable {true} \
22
+ CONFIG.pf0_bar2_enabled {true} \
23
+ CONFIG.pf0_bar2_type {Memory} \
24
+ CONFIG.pf0_bar2_scale {Megabytes} \
25
+ CONFIG.pf0_bar2_size {16} \
26
+ CONFIG.vendor_id {1234} \
27
+ CONFIG.en_msi_per_vec_masking {true} \
28
+ ] [get_ips pcie4_uscale_plus_0]
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/debounce_switch.v ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes switch and button inputs with a slow sampled shift register
33
+ */
34
+ module debounce_switch #(
35
+ parameter WIDTH=1, // width of the input and output signals
36
+ parameter N=3, // length of shift register
37
+ parameter RATE=125000 // clock division factor
38
+ )(
39
+ input wire clk,
40
+ input wire rst,
41
+ input wire [WIDTH-1:0] in,
42
+ output wire [WIDTH-1:0] out
43
+ );
44
+
45
+ reg [23:0] cnt_reg = 24'd0;
46
+
47
+ reg [N-1:0] debounce_reg[WIDTH-1:0];
48
+
49
+ reg [WIDTH-1:0] state;
50
+
51
+ /*
52
+ * The synchronized output is the state register
53
+ */
54
+ assign out = state;
55
+
56
+ integer k;
57
+
58
+ always @(posedge clk or posedge rst) begin
59
+ if (rst) begin
60
+ cnt_reg <= 0;
61
+ state <= 0;
62
+
63
+ for (k = 0; k < WIDTH; k = k + 1) begin
64
+ debounce_reg[k] <= 0;
65
+ end
66
+ end else begin
67
+ if (cnt_reg < RATE) begin
68
+ cnt_reg <= cnt_reg + 24'd1;
69
+ end else begin
70
+ cnt_reg <= 24'd0;
71
+ end
72
+
73
+ if (cnt_reg == 24'd0) begin
74
+ for (k = 0; k < WIDTH; k = k + 1) begin
75
+ debounce_reg[k] <= {debounce_reg[k][N-2:0], in[k]};
76
+ end
77
+ end
78
+
79
+ for (k = 0; k < WIDTH; k = k + 1) begin
80
+ if (|debounce_reg[k] == 0) begin
81
+ state[k] <= 0;
82
+ end else if (&debounce_reg[k] == 1) begin
83
+ state[k] <= 1;
84
+ end else begin
85
+ state[k] <= state[k];
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ endmodule
92
+
93
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/fpga.v ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA top-level module
33
+ */
34
+ module fpga (
35
+ /*
36
+ * GPIO
37
+ */
38
+ input wire [3:0] sw,
39
+ output wire [2:0] led,
40
+
41
+ /*
42
+ * PCI express
43
+ */
44
+ input wire [15:0] pcie_rx_p,
45
+ input wire [15:0] pcie_rx_n,
46
+ output wire [15:0] pcie_tx_p,
47
+ output wire [15:0] pcie_tx_n,
48
+ input wire pcie_refclk_p,
49
+ input wire pcie_refclk_n,
50
+ input wire pcie_reset_n
51
+ );
52
+
53
+ parameter AXIS_PCIE_DATA_WIDTH = 512;
54
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32);
55
+ parameter AXIS_PCIE_RC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 75 : 161;
56
+ parameter AXIS_PCIE_RQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 60 : 137;
57
+ parameter AXIS_PCIE_CQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 85 : 183;
58
+ parameter AXIS_PCIE_CC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 33 : 81;
59
+
60
+ parameter RQ_SEQ_NUM_WIDTH = AXIS_PCIE_RQ_USER_WIDTH == 60 ? 4 : 6;
61
+ parameter RQ_SEQ_NUM_ENABLE = 1;
62
+
63
+ parameter PCIE_TAG_COUNT = 64;
64
+ parameter BAR0_APERTURE = 24;
65
+ parameter BAR2_APERTURE = 24;
66
+
67
+ // Clock and reset
68
+ wire pcie_user_clk;
69
+ wire pcie_user_reset;
70
+
71
+ // GPIO
72
+ wire [3:0] sw_int;
73
+
74
+ debounce_switch #(
75
+ .WIDTH(4),
76
+ .N(4),
77
+ .RATE(250000)
78
+ )
79
+ debounce_switch_inst (
80
+ .clk(pcie_user_clk),
81
+ .rst(pcie_user_reset),
82
+ .in({sw}),
83
+ .out({sw_int})
84
+ );
85
+
86
+ // PCIe
87
+ wire pcie_sys_clk;
88
+ wire pcie_sys_clk_gt;
89
+
90
+ IBUFDS_GTE4 #(
91
+ .REFCLK_HROW_CK_SEL(2'b00)
92
+ )
93
+ ibufds_gte4_pcie_mgt_refclk_inst (
94
+ .I (pcie_refclk_p),
95
+ .IB (pcie_refclk_n),
96
+ .CEB (1'b0),
97
+ .O (pcie_sys_clk_gt),
98
+ .ODIV2 (pcie_sys_clk)
99
+ );
100
+
101
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rq_tdata;
102
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rq_tkeep;
103
+ wire axis_rq_tlast;
104
+ wire axis_rq_tready;
105
+ wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] axis_rq_tuser;
106
+ wire axis_rq_tvalid;
107
+
108
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata;
109
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep;
110
+ wire axis_rc_tlast;
111
+ wire axis_rc_tready;
112
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser;
113
+ wire axis_rc_tvalid;
114
+
115
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata;
116
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep;
117
+ wire axis_cq_tlast;
118
+ wire axis_cq_tready;
119
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser;
120
+ wire axis_cq_tvalid;
121
+
122
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata;
123
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep;
124
+ wire axis_cc_tlast;
125
+ wire axis_cc_tready;
126
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser;
127
+ wire axis_cc_tvalid;
128
+
129
+ wire [RQ_SEQ_NUM_WIDTH-1:0] pcie_rq_seq_num0;
130
+ wire pcie_rq_seq_num_vld0;
131
+ wire [RQ_SEQ_NUM_WIDTH-1:0] pcie_rq_seq_num1;
132
+ wire pcie_rq_seq_num_vld1;
133
+
134
+ // ila_0 rq_ila (
135
+ // .clk(pcie_user_clk),
136
+ // .probe0(axis_rq_tdata),
137
+ // .probe1(axis_rq_tkeep),
138
+ // .probe2(axis_rq_tlast),
139
+ // .probe3(axis_rq_tready),
140
+ // .probe4(axis_rq_tuser),
141
+ // .probe5(axis_rq_tvalid)
142
+ // );
143
+
144
+ // ila_0 rc_ila (
145
+ // .clk(pcie_user_clk),
146
+ // .probe0(axis_rc_tdata),
147
+ // .probe1(axis_rc_tkeep),
148
+ // .probe2(axis_rc_tlast),
149
+ // .probe3(axis_rc_tready),
150
+ // .probe4(axis_rc_tuser),
151
+ // .probe5(axis_rc_tvalid)
152
+ // );
153
+
154
+ wire [2:0] cfg_max_payload;
155
+ wire [2:0] cfg_max_read_req;
156
+
157
+ wire [9:0] cfg_mgmt_addr;
158
+ wire [7:0] cfg_mgmt_function_number;
159
+ wire cfg_mgmt_write;
160
+ wire [31:0] cfg_mgmt_write_data;
161
+ wire [3:0] cfg_mgmt_byte_enable;
162
+ wire cfg_mgmt_read;
163
+ wire [31:0] cfg_mgmt_read_data;
164
+ wire cfg_mgmt_read_write_done;
165
+
166
+ wire [7:0] cfg_fc_ph;
167
+ wire [11:0] cfg_fc_pd;
168
+ wire [7:0] cfg_fc_nph;
169
+ wire [11:0] cfg_fc_npd;
170
+ wire [7:0] cfg_fc_cplh;
171
+ wire [11:0] cfg_fc_cpld;
172
+ wire [2:0] cfg_fc_sel;
173
+
174
+ wire [3:0] cfg_interrupt_msi_enable;
175
+ wire [11:0] cfg_interrupt_msi_mmenable;
176
+ wire cfg_interrupt_msi_mask_update;
177
+ wire [31:0] cfg_interrupt_msi_data;
178
+ wire [3:0] cfg_interrupt_msi_select;
179
+ wire [31:0] cfg_interrupt_msi_int;
180
+ wire [31:0] cfg_interrupt_msi_pending_status;
181
+ wire cfg_interrupt_msi_pending_status_data_enable;
182
+ wire [3:0] cfg_interrupt_msi_pending_status_function_num;
183
+ wire cfg_interrupt_msi_sent;
184
+ wire cfg_interrupt_msi_fail;
185
+ wire [2:0] cfg_interrupt_msi_attr;
186
+ wire cfg_interrupt_msi_tph_present;
187
+ wire [1:0] cfg_interrupt_msi_tph_type;
188
+ wire [8:0] cfg_interrupt_msi_tph_st_tag;
189
+ wire [3:0] cfg_interrupt_msi_function_number;
190
+
191
+ wire status_error_cor;
192
+ wire status_error_uncor;
193
+
194
+ pcie4_uscale_plus_0
195
+ pcie4_uscale_plus_inst (
196
+ .pci_exp_txn(pcie_tx_n),
197
+ .pci_exp_txp(pcie_tx_p),
198
+ .pci_exp_rxn(pcie_rx_n),
199
+ .pci_exp_rxp(pcie_rx_p),
200
+ .user_clk(pcie_user_clk),
201
+ .user_reset(pcie_user_reset),
202
+ .user_lnk_up(),
203
+
204
+ .s_axis_rq_tdata(axis_rq_tdata),
205
+ .s_axis_rq_tkeep(axis_rq_tkeep),
206
+ .s_axis_rq_tlast(axis_rq_tlast),
207
+ .s_axis_rq_tready(axis_rq_tready),
208
+ .s_axis_rq_tuser(axis_rq_tuser),
209
+ .s_axis_rq_tvalid(axis_rq_tvalid),
210
+
211
+ .m_axis_rc_tdata(axis_rc_tdata),
212
+ .m_axis_rc_tkeep(axis_rc_tkeep),
213
+ .m_axis_rc_tlast(axis_rc_tlast),
214
+ .m_axis_rc_tready(axis_rc_tready),
215
+ .m_axis_rc_tuser(axis_rc_tuser),
216
+ .m_axis_rc_tvalid(axis_rc_tvalid),
217
+
218
+ .m_axis_cq_tdata(axis_cq_tdata),
219
+ .m_axis_cq_tkeep(axis_cq_tkeep),
220
+ .m_axis_cq_tlast(axis_cq_tlast),
221
+ .m_axis_cq_tready(axis_cq_tready),
222
+ .m_axis_cq_tuser(axis_cq_tuser),
223
+ .m_axis_cq_tvalid(axis_cq_tvalid),
224
+
225
+ .s_axis_cc_tdata(axis_cc_tdata),
226
+ .s_axis_cc_tkeep(axis_cc_tkeep),
227
+ .s_axis_cc_tlast(axis_cc_tlast),
228
+ .s_axis_cc_tready(axis_cc_tready),
229
+ .s_axis_cc_tuser(axis_cc_tuser),
230
+ .s_axis_cc_tvalid(axis_cc_tvalid),
231
+
232
+ .pcie_rq_seq_num0(pcie_rq_seq_num0),
233
+ .pcie_rq_seq_num_vld0(pcie_rq_seq_num_vld0),
234
+ .pcie_rq_seq_num1(pcie_rq_seq_num1),
235
+ .pcie_rq_seq_num_vld1(pcie_rq_seq_num_vld1),
236
+ .pcie_rq_tag0(),
237
+ .pcie_rq_tag1(),
238
+ .pcie_rq_tag_av(),
239
+ .pcie_rq_tag_vld0(),
240
+ .pcie_rq_tag_vld1(),
241
+
242
+ .pcie_tfc_nph_av(),
243
+ .pcie_tfc_npd_av(),
244
+
245
+ .pcie_cq_np_req(1'b1),
246
+ .pcie_cq_np_req_count(),
247
+
248
+ .cfg_phy_link_down(),
249
+ .cfg_phy_link_status(),
250
+ .cfg_negotiated_width(),
251
+ .cfg_current_speed(),
252
+ .cfg_max_payload(cfg_max_payload),
253
+ .cfg_max_read_req(cfg_max_read_req),
254
+ .cfg_function_status(),
255
+ .cfg_function_power_state(),
256
+ .cfg_vf_status(),
257
+ .cfg_vf_power_state(),
258
+ .cfg_link_power_state(),
259
+
260
+ .cfg_mgmt_addr(cfg_mgmt_addr),
261
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
262
+ .cfg_mgmt_write(cfg_mgmt_write),
263
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
264
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
265
+ .cfg_mgmt_read(cfg_mgmt_read),
266
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
267
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
268
+ .cfg_mgmt_debug_access(1'b0),
269
+
270
+ .cfg_err_cor_out(),
271
+ .cfg_err_nonfatal_out(),
272
+ .cfg_err_fatal_out(),
273
+ .cfg_local_error_valid(),
274
+ .cfg_local_error_out(),
275
+ .cfg_ltssm_state(),
276
+ .cfg_rx_pm_state(),
277
+ .cfg_tx_pm_state(),
278
+ .cfg_rcb_status(),
279
+ .cfg_obff_enable(),
280
+ .cfg_pl_status_change(),
281
+ .cfg_tph_requester_enable(),
282
+ .cfg_tph_st_mode(),
283
+ .cfg_vf_tph_requester_enable(),
284
+ .cfg_vf_tph_st_mode(),
285
+
286
+ .cfg_msg_received(),
287
+ .cfg_msg_received_data(),
288
+ .cfg_msg_received_type(),
289
+ .cfg_msg_transmit(1'b0),
290
+ .cfg_msg_transmit_type(3'd0),
291
+ .cfg_msg_transmit_data(32'd0),
292
+ .cfg_msg_transmit_done(),
293
+
294
+ .cfg_fc_ph(cfg_fc_ph),
295
+ .cfg_fc_pd(cfg_fc_pd),
296
+ .cfg_fc_nph(cfg_fc_nph),
297
+ .cfg_fc_npd(cfg_fc_npd),
298
+ .cfg_fc_cplh(cfg_fc_cplh),
299
+ .cfg_fc_cpld(cfg_fc_cpld),
300
+ .cfg_fc_sel(cfg_fc_sel),
301
+
302
+ .cfg_dsn(64'd0),
303
+
304
+ .cfg_bus_number(),
305
+
306
+ .cfg_power_state_change_ack(1'b1),
307
+ .cfg_power_state_change_interrupt(),
308
+
309
+ .cfg_err_cor_in(status_error_cor),
310
+ .cfg_err_uncor_in(status_error_uncor),
311
+ .cfg_flr_in_process(),
312
+ .cfg_flr_done(4'd0),
313
+ .cfg_vf_flr_in_process(),
314
+ .cfg_vf_flr_func_num(8'd0),
315
+ .cfg_vf_flr_done(8'd0),
316
+
317
+ .cfg_link_training_enable(1'b1),
318
+
319
+ .cfg_interrupt_int(4'd0),
320
+ .cfg_interrupt_pending(4'd0),
321
+ .cfg_interrupt_sent(),
322
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
323
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
324
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
325
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
326
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
327
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
328
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
329
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
330
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
331
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
332
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
333
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
334
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
335
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
336
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
337
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
338
+
339
+ .cfg_pm_aspm_l1_entry_reject(1'b0),
340
+ .cfg_pm_aspm_tx_l0s_entry_disable(1'b0),
341
+
342
+ .cfg_hot_reset_out(),
343
+
344
+ .cfg_config_space_enable(1'b1),
345
+ .cfg_req_pm_transition_l23_ready(1'b0),
346
+ .cfg_hot_reset_in(1'b0),
347
+
348
+ .cfg_ds_port_number(8'd0),
349
+ .cfg_ds_bus_number(8'd0),
350
+ .cfg_ds_device_number(5'd0),
351
+
352
+ .sys_clk(pcie_sys_clk),
353
+ .sys_clk_gt(pcie_sys_clk_gt),
354
+ .sys_reset(pcie_reset_n),
355
+
356
+ .phy_rdy_out()
357
+ );
358
+
359
+ fpga_core #(
360
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
361
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
362
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
363
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
364
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
365
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
366
+ .RQ_SEQ_NUM_WIDTH(RQ_SEQ_NUM_WIDTH),
367
+ .RQ_SEQ_NUM_ENABLE(RQ_SEQ_NUM_ENABLE),
368
+ .PCIE_TAG_COUNT(PCIE_TAG_COUNT),
369
+ .BAR0_APERTURE(BAR0_APERTURE),
370
+ .BAR2_APERTURE(BAR2_APERTURE)
371
+ )
372
+ core_inst (
373
+ /*
374
+ * Clock: 250 MHz
375
+ * Synchronous reset
376
+ */
377
+ .clk(pcie_user_clk),
378
+ .rst(pcie_user_reset),
379
+ /*
380
+ * GPIO
381
+ */
382
+ .sw(sw_int),
383
+ .led(led),
384
+ /*
385
+ * PCIe
386
+ */
387
+ .m_axis_rq_tdata(axis_rq_tdata),
388
+ .m_axis_rq_tkeep(axis_rq_tkeep),
389
+ .m_axis_rq_tlast(axis_rq_tlast),
390
+ .m_axis_rq_tready(axis_rq_tready),
391
+ .m_axis_rq_tuser(axis_rq_tuser),
392
+ .m_axis_rq_tvalid(axis_rq_tvalid),
393
+
394
+ .s_axis_rc_tdata(axis_rc_tdata),
395
+ .s_axis_rc_tkeep(axis_rc_tkeep),
396
+ .s_axis_rc_tlast(axis_rc_tlast),
397
+ .s_axis_rc_tready(axis_rc_tready),
398
+ .s_axis_rc_tuser(axis_rc_tuser),
399
+ .s_axis_rc_tvalid(axis_rc_tvalid),
400
+
401
+ .s_axis_cq_tdata(axis_cq_tdata),
402
+ .s_axis_cq_tkeep(axis_cq_tkeep),
403
+ .s_axis_cq_tlast(axis_cq_tlast),
404
+ .s_axis_cq_tready(axis_cq_tready),
405
+ .s_axis_cq_tuser(axis_cq_tuser),
406
+ .s_axis_cq_tvalid(axis_cq_tvalid),
407
+
408
+ .m_axis_cc_tdata(axis_cc_tdata),
409
+ .m_axis_cc_tkeep(axis_cc_tkeep),
410
+ .m_axis_cc_tlast(axis_cc_tlast),
411
+ .m_axis_cc_tready(axis_cc_tready),
412
+ .m_axis_cc_tuser(axis_cc_tuser),
413
+ .m_axis_cc_tvalid(axis_cc_tvalid),
414
+
415
+ .s_axis_rq_seq_num_0(pcie_rq_seq_num0),
416
+ .s_axis_rq_seq_num_valid_0(pcie_rq_seq_num_vld0),
417
+ .s_axis_rq_seq_num_1(pcie_rq_seq_num1),
418
+ .s_axis_rq_seq_num_valid_1(pcie_rq_seq_num_vld1),
419
+
420
+ .cfg_max_payload(cfg_max_payload),
421
+ .cfg_max_read_req(cfg_max_read_req),
422
+
423
+ .cfg_mgmt_addr(cfg_mgmt_addr),
424
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
425
+ .cfg_mgmt_write(cfg_mgmt_write),
426
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
427
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
428
+ .cfg_mgmt_read(cfg_mgmt_read),
429
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
430
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
431
+
432
+ .cfg_fc_ph(cfg_fc_ph),
433
+ .cfg_fc_pd(cfg_fc_pd),
434
+ .cfg_fc_nph(cfg_fc_nph),
435
+ .cfg_fc_npd(cfg_fc_npd),
436
+ .cfg_fc_cplh(cfg_fc_cplh),
437
+ .cfg_fc_cpld(cfg_fc_cpld),
438
+ .cfg_fc_sel(cfg_fc_sel),
439
+
440
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
441
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
442
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
443
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
444
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
445
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
446
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
447
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
448
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
449
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
450
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
451
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
452
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
453
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
454
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
455
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
456
+
457
+ .status_error_cor(status_error_cor),
458
+ .status_error_uncor(status_error_uncor)
459
+ );
460
+
461
+ endmodule
462
+
463
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/fpga_core.v ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA core logic
33
+ */
34
+ module fpga_core #
35
+ (
36
+ parameter AXIS_PCIE_DATA_WIDTH = 512,
37
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32),
38
+ parameter AXIS_PCIE_RC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 75 : 161,
39
+ parameter AXIS_PCIE_RQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 60 : 137,
40
+ parameter AXIS_PCIE_CQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 85 : 183,
41
+ parameter AXIS_PCIE_CC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 33 : 81,
42
+ parameter RQ_SEQ_NUM_WIDTH = AXIS_PCIE_RQ_USER_WIDTH == 60 ? 4 : 6,
43
+ parameter RQ_SEQ_NUM_ENABLE = 1,
44
+ parameter PCIE_TAG_COUNT = 64,
45
+ parameter BAR0_APERTURE = 24,
46
+ parameter BAR2_APERTURE = 24
47
+ )
48
+ (
49
+ /*
50
+ * Clock: 250 MHz
51
+ * Synchronous reset
52
+ */
53
+ input wire clk,
54
+ input wire rst,
55
+
56
+ /*
57
+ * GPIO
58
+ */
59
+ input wire [3:0] sw,
60
+ output wire [2:0] led,
61
+
62
+ /*
63
+ * PCIe
64
+ */
65
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_rq_tdata,
66
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_rq_tkeep,
67
+ output wire m_axis_rq_tlast,
68
+ input wire m_axis_rq_tready,
69
+ output wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] m_axis_rq_tuser,
70
+ output wire m_axis_rq_tvalid,
71
+
72
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_rc_tdata,
73
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_rc_tkeep,
74
+ input wire s_axis_rc_tlast,
75
+ output wire s_axis_rc_tready,
76
+ input wire [AXIS_PCIE_RC_USER_WIDTH-1:0] s_axis_rc_tuser,
77
+ input wire s_axis_rc_tvalid,
78
+
79
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_cq_tdata,
80
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_cq_tkeep,
81
+ input wire s_axis_cq_tlast,
82
+ output wire s_axis_cq_tready,
83
+ input wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] s_axis_cq_tuser,
84
+ input wire s_axis_cq_tvalid,
85
+
86
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_cc_tdata,
87
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_cc_tkeep,
88
+ output wire m_axis_cc_tlast,
89
+ input wire m_axis_cc_tready,
90
+ output wire [AXIS_PCIE_CC_USER_WIDTH-1:0] m_axis_cc_tuser,
91
+ output wire m_axis_cc_tvalid,
92
+
93
+ input wire [RQ_SEQ_NUM_WIDTH-1:0] s_axis_rq_seq_num_0,
94
+ input wire s_axis_rq_seq_num_valid_0,
95
+ input wire [RQ_SEQ_NUM_WIDTH-1:0] s_axis_rq_seq_num_1,
96
+ input wire s_axis_rq_seq_num_valid_1,
97
+
98
+ input wire [2:0] cfg_max_payload,
99
+ input wire [2:0] cfg_max_read_req,
100
+
101
+ output wire [9:0] cfg_mgmt_addr,
102
+ output wire [7:0] cfg_mgmt_function_number,
103
+ output wire cfg_mgmt_write,
104
+ output wire [31:0] cfg_mgmt_write_data,
105
+ output wire [3:0] cfg_mgmt_byte_enable,
106
+ output wire cfg_mgmt_read,
107
+ input wire [31:0] cfg_mgmt_read_data,
108
+ input wire cfg_mgmt_read_write_done,
109
+
110
+ input wire [7:0] cfg_fc_ph,
111
+ input wire [11:0] cfg_fc_pd,
112
+ input wire [7:0] cfg_fc_nph,
113
+ input wire [11:0] cfg_fc_npd,
114
+ input wire [7:0] cfg_fc_cplh,
115
+ input wire [11:0] cfg_fc_cpld,
116
+ output wire [2:0] cfg_fc_sel,
117
+
118
+ input wire [3:0] cfg_interrupt_msi_enable,
119
+ input wire [11:0] cfg_interrupt_msi_mmenable,
120
+ input wire cfg_interrupt_msi_mask_update,
121
+ input wire [31:0] cfg_interrupt_msi_data,
122
+ output wire [3:0] cfg_interrupt_msi_select,
123
+ output wire [31:0] cfg_interrupt_msi_int,
124
+ output wire [31:0] cfg_interrupt_msi_pending_status,
125
+ output wire cfg_interrupt_msi_pending_status_data_enable,
126
+ output wire [3:0] cfg_interrupt_msi_pending_status_function_num,
127
+ input wire cfg_interrupt_msi_sent,
128
+ input wire cfg_interrupt_msi_fail,
129
+ output wire [2:0] cfg_interrupt_msi_attr,
130
+ output wire cfg_interrupt_msi_tph_present,
131
+ output wire [1:0] cfg_interrupt_msi_tph_type,
132
+ output wire [8:0] cfg_interrupt_msi_tph_st_tag,
133
+ output wire [3:0] cfg_interrupt_msi_function_number,
134
+
135
+ output wire status_error_cor,
136
+ output wire status_error_uncor
137
+ );
138
+
139
+ assign led = 3'd0;
140
+
141
+ example_core_pcie_us #(
142
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
143
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
144
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
145
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
146
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
147
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
148
+ .RQ_SEQ_NUM_WIDTH(RQ_SEQ_NUM_WIDTH),
149
+ .RQ_SEQ_NUM_ENABLE(RQ_SEQ_NUM_ENABLE),
150
+ .PCIE_TAG_COUNT(PCIE_TAG_COUNT),
151
+ .READ_OP_TABLE_SIZE(PCIE_TAG_COUNT),
152
+ .READ_TX_LIMIT(2**(RQ_SEQ_NUM_WIDTH-1)),
153
+ .READ_TX_FC_ENABLE(1),
154
+ .WRITE_OP_TABLE_SIZE(2**(RQ_SEQ_NUM_WIDTH-1)),
155
+ .WRITE_TX_LIMIT(2**(RQ_SEQ_NUM_WIDTH-1)),
156
+ .WRITE_TX_FC_ENABLE(1),
157
+ .BAR0_APERTURE(BAR0_APERTURE),
158
+ .BAR2_APERTURE(BAR2_APERTURE)
159
+ )
160
+ example_core_pcie_us_inst (
161
+ .clk(clk),
162
+ .rst(rst),
163
+
164
+ /*
165
+ * AXI input (RC)
166
+ */
167
+ .s_axis_rc_tdata(s_axis_rc_tdata),
168
+ .s_axis_rc_tkeep(s_axis_rc_tkeep),
169
+ .s_axis_rc_tvalid(s_axis_rc_tvalid),
170
+ .s_axis_rc_tready(s_axis_rc_tready),
171
+ .s_axis_rc_tlast(s_axis_rc_tlast),
172
+ .s_axis_rc_tuser(s_axis_rc_tuser),
173
+
174
+ /*
175
+ * AXI output (RQ)
176
+ */
177
+ .m_axis_rq_tdata(m_axis_rq_tdata),
178
+ .m_axis_rq_tkeep(m_axis_rq_tkeep),
179
+ .m_axis_rq_tvalid(m_axis_rq_tvalid),
180
+ .m_axis_rq_tready(m_axis_rq_tready),
181
+ .m_axis_rq_tlast(m_axis_rq_tlast),
182
+ .m_axis_rq_tuser(m_axis_rq_tuser),
183
+
184
+ /*
185
+ * AXI input (CQ)
186
+ */
187
+ .s_axis_cq_tdata(s_axis_cq_tdata),
188
+ .s_axis_cq_tkeep(s_axis_cq_tkeep),
189
+ .s_axis_cq_tvalid(s_axis_cq_tvalid),
190
+ .s_axis_cq_tready(s_axis_cq_tready),
191
+ .s_axis_cq_tlast(s_axis_cq_tlast),
192
+ .s_axis_cq_tuser(s_axis_cq_tuser),
193
+
194
+ /*
195
+ * AXI output (CC)
196
+ */
197
+ .m_axis_cc_tdata(m_axis_cc_tdata),
198
+ .m_axis_cc_tkeep(m_axis_cc_tkeep),
199
+ .m_axis_cc_tvalid(m_axis_cc_tvalid),
200
+ .m_axis_cc_tready(m_axis_cc_tready),
201
+ .m_axis_cc_tlast(m_axis_cc_tlast),
202
+ .m_axis_cc_tuser(m_axis_cc_tuser),
203
+
204
+ /*
205
+ * Transmit sequence number input
206
+ */
207
+ .s_axis_rq_seq_num_0(s_axis_rq_seq_num_0),
208
+ .s_axis_rq_seq_num_valid_0(s_axis_rq_seq_num_valid_0),
209
+ .s_axis_rq_seq_num_1(s_axis_rq_seq_num_1),
210
+ .s_axis_rq_seq_num_valid_1(s_axis_rq_seq_num_valid_1),
211
+
212
+ /*
213
+ * Flow control
214
+ */
215
+ .cfg_fc_ph(cfg_fc_ph),
216
+ .cfg_fc_pd(cfg_fc_pd),
217
+ .cfg_fc_nph(cfg_fc_nph),
218
+ .cfg_fc_npd(cfg_fc_npd),
219
+ .cfg_fc_cplh(cfg_fc_cplh),
220
+ .cfg_fc_cpld(cfg_fc_cpld),
221
+ .cfg_fc_sel(cfg_fc_sel),
222
+
223
+ /*
224
+ * Configuration interface
225
+ */
226
+ .cfg_mgmt_addr(cfg_mgmt_addr),
227
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
228
+ .cfg_mgmt_write(cfg_mgmt_write),
229
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
230
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
231
+ .cfg_mgmt_read(cfg_mgmt_read),
232
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
233
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
234
+
235
+ /*
236
+ * Interrupt interface
237
+ */
238
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
239
+ .cfg_interrupt_msi_vf_enable(8'd0),
240
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
241
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
242
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
243
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
244
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
245
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
246
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
247
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
248
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
249
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
250
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
251
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
252
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
253
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
254
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
255
+
256
+ /*
257
+ * Configuration
258
+ */
259
+ .cfg_max_read_req(cfg_max_read_req),
260
+ .cfg_max_payload(cfg_max_payload),
261
+
262
+ /*
263
+ * Status
264
+ */
265
+ .status_error_cor(status_error_cor),
266
+ .status_error_uncor(status_error_uncor)
267
+ );
268
+
269
+ endmodule
270
+
271
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/sync_reset.v ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an active-high asynchronous reset signal to a given clock by
33
+ * using a pipeline of N registers.
34
+ */
35
+ module sync_reset #(
36
+ parameter N=2 // depth of synchronizer
37
+ )(
38
+ input wire clk,
39
+ input wire rst,
40
+ output wire sync_reset_out
41
+ );
42
+
43
+ reg [N-1:0] sync_reg = {N{1'b1}};
44
+
45
+ assign sync_reset_out = sync_reg[N-1];
46
+
47
+ always @(posedge clk or posedge rst) begin
48
+ if (rst)
49
+ sync_reg <= {N{1'b1}};
50
+ else
51
+ sync_reg <= {sync_reg[N-2:0], 1'b0};
52
+ end
53
+
54
+ endmodule
55
+
56
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga/rtl/sync_signal.v ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an asyncronous signal to a given clock by using a pipeline of
33
+ * two registers.
34
+ */
35
+ module sync_signal #(
36
+ parameter WIDTH=1, // width of the input and output signals
37
+ parameter N=2 // depth of synchronizer
38
+ )(
39
+ input wire clk,
40
+ input wire [WIDTH-1:0] in,
41
+ output wire [WIDTH-1:0] out
42
+ );
43
+
44
+ reg [WIDTH-1:0] sync_reg[N-1:0];
45
+
46
+ /*
47
+ * The synchronized output is the last register in the pipeline.
48
+ */
49
+ assign out = sync_reg[N-1];
50
+
51
+ integer k;
52
+
53
+ always @(posedge clk) begin
54
+ sync_reg[0] <= in;
55
+ for (k = 1; k < N; k = k + 1) begin
56
+ sync_reg[k] <= sync_reg[k-1];
57
+ end
58
+ end
59
+
60
+ endmodule
61
+
62
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/Makefile ADDED
@@ -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
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilog PCIe Alveo U250 Example Design
2
+
3
+ ## Introduction
4
+
5
+ This example design targets the Xilinx Alveo U250 FPGA board.
6
+
7
+ The design implements the PCIe AXI lite master module, the PCIe AXI master
8
+ module, and the PCIe AXI DMA module. A very simple Linux driver is included
9
+ to test the FPGA design.
10
+
11
+ FPGA: xcu250-figd2104-2-e
12
+
13
+ ## How to build
14
+
15
+ Run make to build. Ensure that the Xilinx Vivado toolchain components are
16
+ in PATH.
17
+
18
+ Run make to build the driver. Ensure the headers for the running kernel are
19
+ installed, otherwise the driver cannot be compiled.
20
+
21
+ ## How to test
22
+
23
+ Run make program to program the Alveo U250 board with Vivado. Then load the
24
+ driver with insmod example.ko. Check dmesg for the output.
25
+
26
+
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/common/vivado.mk ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: fpga vivado tmpclean clean distclean
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
+ SYN_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(SYN_FILES))) $(filter /% ./%,$(SYN_FILES))
41
+ INC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(INC_FILES))) $(filter /% ./%,$(INC_FILES))
42
+ XCI_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XCI_FILES))) $(filter /% ./%,$(XCI_FILES))
43
+ IP_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(IP_TCL_FILES))) $(filter /% ./%,$(IP_TCL_FILES))
44
+ CONFIG_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(CONFIG_TCL_FILES))) $(filter /% ./%,$(CONFIG_TCL_FILES))
45
+
46
+ ifdef XDC_FILES
47
+ XDC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XDC_FILES))) $(filter /% ./%,$(XDC_FILES))
48
+ else
49
+ XDC_FILES_REL = $(FPGA_TOP).xdc
50
+ endif
51
+
52
+ ###################################################################
53
+ # Main Targets
54
+ #
55
+ # all: build everything
56
+ # clean: remove output files and project files
57
+ ###################################################################
58
+
59
+ all: fpga
60
+
61
+ fpga: $(FPGA_TOP).bit
62
+
63
+ vivado: $(FPGA_TOP).xpr
64
+ vivado $(FPGA_TOP).xpr
65
+
66
+ tmpclean::
67
+ -rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
68
+ -rm -rf create_project.tcl update_config.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
69
+
70
+ clean:: tmpclean
71
+ -rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
72
+
73
+ distclean:: clean
74
+ -rm -rf rev
75
+
76
+ ###################################################################
77
+ # Target implementations
78
+ ###################################################################
79
+
80
+ # Vivado project file
81
+ create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
82
+ rm -rf defines.v
83
+ touch defines.v
84
+ for x in $(DEFS); do echo '`define' $$x >> defines.v; done
85
+ echo "create_project -force -part $(FPGA_PART) $(FPGA_TOP)" > $@
86
+ echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
87
+ echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
88
+ for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
89
+ for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
90
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
91
+
92
+ update_config.tcl: $(CONFIG_TCL_FILES_REL)
93
+ echo "open_project -quiet $(FPGA_TOP).xpr" > $@
94
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
95
+
96
+ $(FPGA_TOP).xpr: create_project.tcl update_config.tcl
97
+ vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
98
+
99
+ # synthesis run
100
+ %.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL) $(CONFIG_TCL_FILES_REL)
101
+ echo "open_project $*.xpr" > run_synth.tcl
102
+ echo "reset_run synth_1" >> run_synth.tcl
103
+ echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
104
+ echo "wait_on_run synth_1" >> run_synth.tcl
105
+ vivado -nojournal -nolog -mode batch -source run_synth.tcl
106
+
107
+ # implementation run
108
+ %.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
109
+ echo "open_project $*.xpr" > run_impl.tcl
110
+ echo "reset_run impl_1" >> run_impl.tcl
111
+ echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
112
+ echo "wait_on_run impl_1" >> run_impl.tcl
113
+ vivado -nojournal -nolog -mode batch -source run_impl.tcl
114
+
115
+ # bit file
116
+ %.bit: %.runs/impl_1/%_routed.dcp
117
+ echo "open_project $*.xpr" > generate_bit.tcl
118
+ echo "open_run impl_1" >> generate_bit.tcl
119
+ echo "write_bitstream -force $*.bit" >> generate_bit.tcl
120
+ vivado -nojournal -nolog -mode batch -source generate_bit.tcl
121
+ mkdir -p rev
122
+ EXT=bit; COUNT=100; \
123
+ while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
124
+ do COUNT=$$((COUNT+1)); done; \
125
+ cp $@ rev/$*_rev$$COUNT.$$EXT; \
126
+ echo "Output: rev/$*_rev$$COUNT.$$EXT";
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/fpga.xdc ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XDC constraints for the Xilinx Alveo U250 board
2
+ # part: xcu250-figd2104-2-e
3
+
4
+ # General configuration
5
+ set_property CFGBVS GND [current_design]
6
+ set_property CONFIG_VOLTAGE 1.8 [current_design]
7
+ set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
8
+ set_property BITSTREAM.CONFIG.CONFIGFALLBACK ENABLE [current_design]
9
+ set_property BITSTREAM.CONFIG.EXTMASTERCCLK_EN DISABLE [current_design]
10
+ set_property BITSTREAM.CONFIG.CONFIGRATE 63.8 [current_design]
11
+ set_property BITSTREAM.CONFIG.SPI_32BIT_ADDR YES [current_design]
12
+ set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]
13
+ set_property BITSTREAM.CONFIG.SPI_FALL_EDGE YES [current_design]
14
+ set_property BITSTREAM.CONFIG.UNUSEDPIN PULLUP [current_design]
15
+
16
+ set_operating_conditions -design_power_budget 160
17
+
18
+ # System clocks
19
+ # 300 MHz (DDR 0)
20
+ #set_property -dict {LOC AY37 IOSTANDARD LVDS} [get_ports clk_300mhz_0_p]
21
+ #set_property -dict {LOC AY38 IOSTANDARD LVDS} [get_ports clk_300mhz_0_n]
22
+ #create_clock -period 3.333 -name clk_300mhz_0 [get_ports clk_300mhz_0_p]
23
+
24
+ # 300 MHz (DDR 1)
25
+ #set_property -dict {LOC AW20 IOSTANDARD LVDS} [get_ports clk_300mhz_1_p]
26
+ #set_property -dict {LOC AW19 IOSTANDARD LVDS} [get_ports clk_300mhz_1_n]
27
+ #create_clock -period 3.333 -name clk_300mhz_1 [get_ports clk_300mhz_1_p]
28
+
29
+ # 300 MHz (DDR 2)
30
+ #set_property -dict {LOC F32 IOSTANDARD LVDS} [get_ports clk_300mhz_2_p]
31
+ #set_property -dict {LOC E32 IOSTANDARD LVDS} [get_ports clk_300mhz_2_n]
32
+ #create_clock -period 3.333 -name clk_300mhz_2 [get_ports clk_300mhz_2_p]
33
+
34
+ # 300 MHz (DDR 3)
35
+ #set_property -dict {LOC J16 IOSTANDARD LVDS} [get_ports clk_300mhz_3_p]
36
+ #set_property -dict {LOC H16 IOSTANDARD LVDS} [get_ports clk_300mhz_3_n]
37
+ #create_clock -period 3.333 -name clk_300mhz_3 [get_ports clk_300mhz_3_p]
38
+
39
+ # SI570 user clock
40
+ #set_property -dict {LOC AU19 IOSTANDARD LVDS} [get_ports clk_user_p]
41
+ #set_property -dict {LOC AV19 IOSTANDARD LVDS} [get_ports clk_user_n]
42
+ #create_clock -period 6.400 -name clk_user [get_ports clk_user_p]
43
+
44
+ # LEDs
45
+ set_property -dict {LOC BC21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[0]}]
46
+ set_property -dict {LOC BB21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[1]}]
47
+ set_property -dict {LOC BA20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {led[2]}]
48
+
49
+ set_false_path -to [get_ports {led[*]}]
50
+ set_output_delay 0 [get_ports {led[*]}]
51
+
52
+ # Reset button
53
+ #set_property -dict {LOC AL20 IOSTANDARD LVCMOS12} [get_ports reset]
54
+
55
+ #set_false_path -from [get_ports {reset}]
56
+ #set_input_delay 0 [get_ports {reset}]
57
+
58
+ # DIP switches
59
+ set_property -dict {LOC AN22 IOSTANDARD LVCMOS12} [get_ports {sw[0]}]
60
+ set_property -dict {LOC AM19 IOSTANDARD LVCMOS12} [get_ports {sw[1]}]
61
+ set_property -dict {LOC AL19 IOSTANDARD LVCMOS12} [get_ports {sw[2]}]
62
+ set_property -dict {LOC AP20 IOSTANDARD LVCMOS12} [get_ports {sw[3]}]
63
+
64
+ set_false_path -from [get_ports {sw[*]}]
65
+ set_input_delay 0 [get_ports {sw[*]}]
66
+
67
+ # UART
68
+ #set_property -dict {LOC BF18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports uart_txd]
69
+ #set_property -dict {LOC BB20 IOSTANDARD LVCMOS12} [get_ports uart_rxd]
70
+
71
+ #set_false_path -to [get_ports {uart_txd}]
72
+ #set_output_delay 0 [get_ports {uart_txd}]
73
+ #set_false_path -from [get_ports {uart_rxd}]
74
+ #set_input_delay 0 [get_ports {uart_rxd}]
75
+
76
+ # BMC
77
+ #set_property -dict {LOC AR20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[0]}]
78
+ #set_property -dict {LOC AM20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[1]}]
79
+ #set_property -dict {LOC AM21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[2]}]
80
+ #set_property -dict {LOC AN21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_gpio[3]}]
81
+ #set_property -dict {LOC BB19 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 4} [get_ports {msp_uart_txd}]
82
+ #set_property -dict {LOC BA19 IOSTANDARD LVCMOS12} [get_ports {msp_uart_rxd}]
83
+
84
+ #set_false_path -to [get_ports {msp_uart_txd}]
85
+ #set_output_delay 0 [get_ports {msp_uart_txd}]
86
+ #set_false_path -from [get_ports {msp_gpio[*] msp_uart_rxd}]
87
+ #set_input_delay 0 [get_ports {msp_gpio[*] msp_uart_rxd}]
88
+
89
+ # QSFP28 Interfaces
90
+ #set_property -dict {LOC N4 } [get_ports qsfp0_rx1_p] ;# MGTYRXP0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
91
+ #set_property -dict {LOC N3 } [get_ports qsfp0_rx1_n] ;# MGTYRXN0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
92
+ #set_property -dict {LOC N9 } [get_ports qsfp0_tx1_p] ;# MGTYTXP0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
93
+ #set_property -dict {LOC N8 } [get_ports qsfp0_tx1_n] ;# MGTYTXN0_231 GTYE4_CHANNEL_X1Y44 / GTYE4_COMMON_X1Y11
94
+ #set_property -dict {LOC M2 } [get_ports qsfp0_rx2_p] ;# MGTYRXP1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
95
+ #set_property -dict {LOC M1 } [get_ports qsfp0_rx2_n] ;# MGTYRXN1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
96
+ #set_property -dict {LOC M7 } [get_ports qsfp0_tx2_p] ;# MGTYTXP1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
97
+ #set_property -dict {LOC M6 } [get_ports qsfp0_tx2_n] ;# MGTYTXN1_231 GTYE4_CHANNEL_X1Y45 / GTYE4_COMMON_X1Y11
98
+ #set_property -dict {LOC L4 } [get_ports qsfp0_rx3_p] ;# MGTYRXP2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
99
+ #set_property -dict {LOC L3 } [get_ports qsfp0_rx3_n] ;# MGTYRXN2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
100
+ #set_property -dict {LOC L9 } [get_ports qsfp0_tx3_p] ;# MGTYTXP2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
101
+ #set_property -dict {LOC L8 } [get_ports qsfp0_tx3_n] ;# MGTYTXN2_231 GTYE4_CHANNEL_X1Y46 / GTYE4_COMMON_X1Y11
102
+ #set_property -dict {LOC K2 } [get_ports qsfp0_rx4_p] ;# MGTYRXP3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
103
+ #set_property -dict {LOC K1 } [get_ports qsfp0_rx4_n] ;# MGTYRXN3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
104
+ #set_property -dict {LOC K7 } [get_ports qsfp0_tx4_p] ;# MGTYTXP3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
105
+ #set_property -dict {LOC K6 } [get_ports qsfp0_tx4_n] ;# MGTYTXN3_231 GTYE4_CHANNEL_X1Y47 / GTYE4_COMMON_X1Y11
106
+ #set_property -dict {LOC M11 } [get_ports qsfp0_mgt_refclk_0_p] ;# MGTREFCLK0P_231 from U14.4 via U43.13
107
+ #set_property -dict {LOC M10 } [get_ports qsfp0_mgt_refclk_0_n] ;# MGTREFCLK0N_231 from U14.5 via U43.14
108
+ #set_property -dict {LOC K11 } [get_ports qsfp0_mgt_refclk_1_p] ;# MGTREFCLK1P_231 from U9.18
109
+ #set_property -dict {LOC K10 } [get_ports qsfp0_mgt_refclk_1_n] ;# MGTREFCLK1N_231 from U9.17
110
+ #set_property -dict {LOC BE16 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_modsell]
111
+ #set_property -dict {LOC BE17 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_resetl]
112
+ #set_property -dict {LOC BE20 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp0_modprsl]
113
+ #set_property -dict {LOC BE21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp0_intl]
114
+ #set_property -dict {LOC BD18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_lpmode]
115
+ #set_property -dict {LOC AT22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp0_refclk_reset]
116
+ #set_property -dict {LOC AT20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp0_fs[0]}]
117
+ #set_property -dict {LOC AU22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp0_fs[1]}]
118
+
119
+ # 156.25 MHz MGT reference clock (from SI570)
120
+ #create_clock -period 6.400 -name qsfp0_mgt_refclk_0 [get_ports qsfp0_mgt_refclk_0_p]
121
+
122
+ # 156.25 MHz MGT reference clock (from SI5335, FS = 0b01)
123
+ #create_clock -period 6.400 -name qsfp0_mgt_refclk_1 [get_ports qsfp0_mgt_refclk_1_p]
124
+
125
+ # 161.1328125 MHz MGT reference clock (from SI5335, FS = 0b10)
126
+ #create_clock -period 6.206 -name qsfp0_mgt_refclk_1 [get_ports qsfp0_mgt_refclk_1_p]
127
+
128
+ #set_false_path -to [get_ports {qsfp0_modsell qsfp0_resetl qsfp0_lpmode qsfp0_refclk_reset qsfp0_fs[*]}]
129
+ #set_output_delay 0 [get_ports {qsfp0_modsell qsfp0_resetl qsfp0_lpmode qsfp0_refclk_reset qsfp0_fs[*]}]
130
+ #set_false_path -from [get_ports {qsfp0_modprsl qsfp0_intl}]
131
+ #set_input_delay 0 [get_ports {qsfp0_modprsl qsfp0_intl}]
132
+
133
+ #set_property -dict {LOC U4 } [get_ports qsfp1_rx1_p] ;# MGTYRXP0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
134
+ #set_property -dict {LOC U3 } [get_ports qsfp1_rx1_n] ;# MGTYRXN0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
135
+ #set_property -dict {LOC U9 } [get_ports qsfp1_tx1_p] ;# MGTYTXP0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
136
+ #set_property -dict {LOC U8 } [get_ports qsfp1_tx1_n] ;# MGTYTXN0_230 GTYE4_CHANNEL_X1Y40 / GTYE4_COMMON_X1Y10
137
+ #set_property -dict {LOC T2 } [get_ports qsfp1_rx2_p] ;# MGTYRXP1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
138
+ #set_property -dict {LOC T1 } [get_ports qsfp1_rx2_n] ;# MGTYRXN1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
139
+ #set_property -dict {LOC T7 } [get_ports qsfp1_tx2_p] ;# MGTYTXP1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
140
+ #set_property -dict {LOC T6 } [get_ports qsfp1_tx2_n] ;# MGTYTXN1_230 GTYE4_CHANNEL_X1Y41 / GTYE4_COMMON_X1Y10
141
+ #set_property -dict {LOC R4 } [get_ports qsfp1_rx3_p] ;# MGTYRXP2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
142
+ #set_property -dict {LOC R3 } [get_ports qsfp1_rx3_n] ;# MGTYRXN2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
143
+ #set_property -dict {LOC R9 } [get_ports qsfp1_tx3_p] ;# MGTYTXP2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
144
+ #set_property -dict {LOC R8 } [get_ports qsfp1_tx3_n] ;# MGTYTXN2_230 GTYE4_CHANNEL_X1Y42 / GTYE4_COMMON_X1Y10
145
+ #set_property -dict {LOC P2 } [get_ports qsfp1_rx4_p] ;# MGTYRXP3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
146
+ #set_property -dict {LOC P1 } [get_ports qsfp1_rx4_n] ;# MGTYRXN3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
147
+ #set_property -dict {LOC P7 } [get_ports qsfp1_tx4_p] ;# MGTYTXP3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
148
+ #set_property -dict {LOC P6 } [get_ports qsfp1_tx4_n] ;# MGTYTXN3_230 GTYE4_CHANNEL_X1Y43 / GTYE4_COMMON_X1Y10
149
+ #set_property -dict {LOC T11 } [get_ports qsfp1_mgt_refclk_0_p] ;# MGTREFCLK0P_230 from U14.4 via U43.15
150
+ #set_property -dict {LOC T10 } [get_ports qsfp1_mgt_refclk_0_n] ;# MGTREFCLK0N_230 from U14.5 via U43.16
151
+ #set_property -dict {LOC P11 } [get_ports qsfp1_mgt_refclk_1_p] ;# MGTREFCLK1P_230 from U12.18
152
+ #set_property -dict {LOC P10 } [get_ports qsfp1_mgt_refclk_1_n] ;# MGTREFCLK1N_230 from U12.17
153
+ #set_property -dict {LOC AY20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_modsell]
154
+ #set_property -dict {LOC BC18 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_resetl]
155
+ #set_property -dict {LOC BC19 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp1_modprsl]
156
+ #set_property -dict {LOC AV21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports qsfp1_intl]
157
+ #set_property -dict {LOC AV22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_lpmode]
158
+ #set_property -dict {LOC AR21 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports qsfp1_refclk_reset]
159
+ #set_property -dict {LOC AR22 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp1_fs[0]}]
160
+ #set_property -dict {LOC AU20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports {qsfp1_fs[1]}]
161
+
162
+ # 156.25 MHz MGT reference clock (from SI570)
163
+ #create_clock -period 6.400 -name qsfp1_mgt_refclk_0 [get_ports qsfp1_mgt_refclk_0_p]
164
+
165
+ # 156.25 MHz MGT reference clock (from SI5335, FS = 0b01)
166
+ #create_clock -period 6.400 -name qsfp1_mgt_refclk_1 [get_ports qsfp1_mgt_refclk_1_p]
167
+
168
+ # 161.1328125 MHz MGT reference clock (from SI5335, FS = 0b10)
169
+ #create_clock -period 6.206 -name qsfp1_mgt_refclk_1 [get_ports qsfp1_mgt_refclk_1_p]
170
+
171
+ #set_false_path -to [get_ports {qsfp1_modsell qsfp1_resetl qsfp1_lpmode qsfp1_refclk_reset qsfp1_fs[*]}]
172
+ #set_output_delay 0 [get_ports {qsfp1_modsell qsfp1_resetl qsfp1_lpmode qsfp1_refclk_reset qsfp1_fs[*]}]
173
+ #set_false_path -from [get_ports {qsfp1_modprsl qsfp1_intl}]
174
+ #set_input_delay 0 [get_ports {qsfp1_modprsl qsfp1_intl}]
175
+
176
+ # I2C interface
177
+ #set_property -dict {LOC BF19 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_mux_reset]
178
+ #set_property -dict {LOC BF20 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_scl]
179
+ #set_property -dict {LOC BF17 IOSTANDARD LVCMOS12 SLEW SLOW DRIVE 8} [get_ports i2c_sda]
180
+
181
+ #set_false_path -to [get_ports {i2c_sda i2c_scl}]
182
+ #set_output_delay 0 [get_ports {i2c_sda i2c_scl}]
183
+ #set_false_path -from [get_ports {i2c_sda i2c_scl}]
184
+ #set_input_delay 0 [get_ports {i2c_sda i2c_scl}]
185
+
186
+ # PCIe Interface
187
+ set_property -dict {LOC AF2 } [get_ports {pcie_rx_p[0]}] ;# MGTYRXP3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
188
+ set_property -dict {LOC AF1 } [get_ports {pcie_rx_n[0]}] ;# MGTYRXN3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
189
+ set_property -dict {LOC AF7 } [get_ports {pcie_tx_p[0]}] ;# MGTYTXP3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
190
+ set_property -dict {LOC AF6 } [get_ports {pcie_tx_n[0]}] ;# MGTYTXN3_227 GTYE4_CHANNEL_X1Y31 / GTYE4_COMMON_X1Y7
191
+ set_property -dict {LOC AG4 } [get_ports {pcie_rx_p[1]}] ;# MGTYRXP2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
192
+ set_property -dict {LOC AG3 } [get_ports {pcie_rx_n[1]}] ;# MGTYRXN2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
193
+ set_property -dict {LOC AG9 } [get_ports {pcie_tx_p[1]}] ;# MGTYTXP2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
194
+ set_property -dict {LOC AG8 } [get_ports {pcie_tx_n[1]}] ;# MGTYTXN2_227 GTYE4_CHANNEL_X1Y30 / GTYE4_COMMON_X1Y7
195
+ set_property -dict {LOC AH2 } [get_ports {pcie_rx_p[2]}] ;# MGTYRXP1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
196
+ set_property -dict {LOC AH1 } [get_ports {pcie_rx_n[2]}] ;# MGTYRXN1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
197
+ set_property -dict {LOC AH7 } [get_ports {pcie_tx_p[2]}] ;# MGTYTXP1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
198
+ set_property -dict {LOC AH6 } [get_ports {pcie_tx_n[2]}] ;# MGTYTXN1_227 GTYE4_CHANNEL_X1Y29 / GTYE4_COMMON_X1Y7
199
+ set_property -dict {LOC AJ4 } [get_ports {pcie_rx_p[3]}] ;# MGTYRXP0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
200
+ set_property -dict {LOC AJ3 } [get_ports {pcie_rx_n[3]}] ;# MGTYRXN0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
201
+ set_property -dict {LOC AJ9 } [get_ports {pcie_tx_p[3]}] ;# MGTYTXP0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
202
+ set_property -dict {LOC AJ8 } [get_ports {pcie_tx_n[3]}] ;# MGTYTXN0_227 GTYE4_CHANNEL_X1Y28 / GTYE4_COMMON_X1Y7
203
+ set_property -dict {LOC AK2 } [get_ports {pcie_rx_p[4]}] ;# MGTYRXP3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
204
+ set_property -dict {LOC AK1 } [get_ports {pcie_rx_n[4]}] ;# MGTYRXN3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
205
+ set_property -dict {LOC AK7 } [get_ports {pcie_tx_p[4]}] ;# MGTYTXP3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
206
+ set_property -dict {LOC AK6 } [get_ports {pcie_tx_n[4]}] ;# MGTYTXN3_226 GTYE4_CHANNEL_X1Y27 / GTYE4_COMMON_X1Y6
207
+ set_property -dict {LOC AL4 } [get_ports {pcie_rx_p[5]}] ;# MGTYRXP2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
208
+ set_property -dict {LOC AL3 } [get_ports {pcie_rx_n[5]}] ;# MGTYRXN2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
209
+ set_property -dict {LOC AL9 } [get_ports {pcie_tx_p[5]}] ;# MGTYTXP2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
210
+ set_property -dict {LOC AL8 } [get_ports {pcie_tx_n[5]}] ;# MGTYTXN2_226 GTYE4_CHANNEL_X1Y26 / GTYE4_COMMON_X1Y6
211
+ set_property -dict {LOC AM2 } [get_ports {pcie_rx_p[6]}] ;# MGTYRXP1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
212
+ set_property -dict {LOC AM1 } [get_ports {pcie_rx_n[6]}] ;# MGTYRXN1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
213
+ set_property -dict {LOC AM7 } [get_ports {pcie_tx_p[6]}] ;# MGTYTXP1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
214
+ set_property -dict {LOC AM6 } [get_ports {pcie_tx_n[6]}] ;# MGTYTXN1_226 GTYE4_CHANNEL_X1Y25 / GTYE4_COMMON_X1Y6
215
+ set_property -dict {LOC AN4 } [get_ports {pcie_rx_p[7]}] ;# MGTYRXP0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
216
+ set_property -dict {LOC AN3 } [get_ports {pcie_rx_n[7]}] ;# MGTYRXN0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
217
+ set_property -dict {LOC AN9 } [get_ports {pcie_tx_p[7]}] ;# MGTYTXP0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
218
+ set_property -dict {LOC AN8 } [get_ports {pcie_tx_n[7]}] ;# MGTYTXN0_226 GTYE4_CHANNEL_X1Y24 / GTYE4_COMMON_X1Y6
219
+ set_property -dict {LOC AP2 } [get_ports {pcie_rx_p[8]}] ;# MGTYRXP3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
220
+ set_property -dict {LOC AP1 } [get_ports {pcie_rx_n[8]}] ;# MGTYRXN3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
221
+ set_property -dict {LOC AP7 } [get_ports {pcie_tx_p[8]}] ;# MGTYTXP3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
222
+ set_property -dict {LOC AP6 } [get_ports {pcie_tx_n[8]}] ;# MGTYTXN3_225 GTYE4_CHANNEL_X1Y23 / GTYE4_COMMON_X1Y5
223
+ set_property -dict {LOC AR4 } [get_ports {pcie_rx_p[9]}] ;# MGTYRXP2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
224
+ set_property -dict {LOC AR3 } [get_ports {pcie_rx_n[9]}] ;# MGTYRXN2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
225
+ set_property -dict {LOC AR9 } [get_ports {pcie_tx_p[9]}] ;# MGTYTXP2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
226
+ set_property -dict {LOC AR8 } [get_ports {pcie_tx_n[9]}] ;# MGTYTXN2_225 GTYE4_CHANNEL_X1Y22 / GTYE4_COMMON_X1Y5
227
+ set_property -dict {LOC AT2 } [get_ports {pcie_rx_p[10]}] ;# MGTYRXP1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
228
+ set_property -dict {LOC AT1 } [get_ports {pcie_rx_n[10]}] ;# MGTYRXN1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
229
+ set_property -dict {LOC AT7 } [get_ports {pcie_tx_p[10]}] ;# MGTYTXP1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
230
+ set_property -dict {LOC AT6 } [get_ports {pcie_tx_n[10]}] ;# MGTYTXN1_225 GTYE4_CHANNEL_X1Y21 / GTYE4_COMMON_X1Y5
231
+ set_property -dict {LOC AU4 } [get_ports {pcie_rx_p[11]}] ;# MGTYRXP0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
232
+ set_property -dict {LOC AU3 } [get_ports {pcie_rx_n[11]}] ;# MGTYRXN0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
233
+ set_property -dict {LOC AU9 } [get_ports {pcie_tx_p[11]}] ;# MGTYTXP0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
234
+ set_property -dict {LOC AU8 } [get_ports {pcie_tx_n[11]}] ;# MGTYTXN0_225 GTYE4_CHANNEL_X1Y20 / GTYE4_COMMON_X1Y5
235
+ set_property -dict {LOC AV2 } [get_ports {pcie_rx_p[12]}] ;# MGTYRXP3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
236
+ set_property -dict {LOC AV1 } [get_ports {pcie_rx_n[12]}] ;# MGTYRXN3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
237
+ set_property -dict {LOC AV7 } [get_ports {pcie_tx_p[12]}] ;# MGTYTXP3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
238
+ set_property -dict {LOC AV6 } [get_ports {pcie_tx_n[12]}] ;# MGTYTXN3_224 GTYE4_CHANNEL_X1Y19 / GTYE4_COMMON_X1Y4
239
+ set_property -dict {LOC AW4 } [get_ports {pcie_rx_p[13]}] ;# MGTYRXP2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
240
+ set_property -dict {LOC AW3 } [get_ports {pcie_rx_n[13]}] ;# MGTYRXN2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
241
+ set_property -dict {LOC BB5 } [get_ports {pcie_tx_p[13]}] ;# MGTYTXP2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
242
+ set_property -dict {LOC BB4 } [get_ports {pcie_tx_n[13]}] ;# MGTYTXN2_224 GTYE4_CHANNEL_X1Y18 / GTYE4_COMMON_X1Y4
243
+ set_property -dict {LOC BA2 } [get_ports {pcie_rx_p[14]}] ;# MGTYRXP1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
244
+ set_property -dict {LOC BA1 } [get_ports {pcie_rx_n[14]}] ;# MGTYRXN1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
245
+ set_property -dict {LOC BD5 } [get_ports {pcie_tx_p[14]}] ;# MGTYTXP1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
246
+ set_property -dict {LOC BD4 } [get_ports {pcie_tx_n[14]}] ;# MGTYTXN1_224 GTYE4_CHANNEL_X1Y17 / GTYE4_COMMON_X1Y4
247
+ set_property -dict {LOC BC2 } [get_ports {pcie_rx_p[15]}] ;# MGTYRXP0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
248
+ set_property -dict {LOC BC1 } [get_ports {pcie_rx_n[15]}] ;# MGTYRXN0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
249
+ set_property -dict {LOC BF5 } [get_ports {pcie_tx_p[15]}] ;# MGTYTXP0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
250
+ set_property -dict {LOC BF4 } [get_ports {pcie_tx_n[15]}] ;# MGTYTXN0_224 GTYE4_CHANNEL_X1Y16 / GTYE4_COMMON_X1Y4
251
+ set_property -dict {LOC AM11 } [get_ports pcie_refclk_p] ;# MGTREFCLK0P_226
252
+ set_property -dict {LOC AM10 } [get_ports pcie_refclk_n] ;# MGTREFCLK0N_226
253
+ set_property -dict {LOC BD21 IOSTANDARD LVCMOS12 PULLUP true} [get_ports pcie_reset_n]
254
+
255
+ # 100 MHz MGT reference clock
256
+ create_clock -period 10 -name pcie_mgt_refclk_1 [get_ports pcie_refclk_p]
257
+
258
+ set_false_path -from [get_ports {pcie_reset_n}]
259
+ set_input_delay 0 [get_ports {pcie_reset_n}]
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/fpga/Makefile ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # FPGA settings
3
+ FPGA_PART = xcu250-figd2104-2-e
4
+ FPGA_TOP = fpga
5
+ FPGA_ARCH = virtexuplus
6
+
7
+ # Files for synthesis
8
+ SYN_FILES = rtl/fpga.v
9
+ SYN_FILES += rtl/fpga_core.v
10
+ SYN_FILES += rtl/debounce_switch.v
11
+ SYN_FILES += rtl/sync_reset.v
12
+ SYN_FILES += rtl/sync_signal.v
13
+ SYN_FILES += rtl/axi_ram.v
14
+ SYN_FILES += rtl/axis_register.v
15
+ SYN_FILES += lib/pcie/rtl/axis_arb_mux.v
16
+ SYN_FILES += lib/pcie/rtl/pcie_us_axil_master.v
17
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma.v
18
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma_rd.v
19
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma_wr.v
20
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master.v
21
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master_rd.v
22
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master_wr.v
23
+ SYN_FILES += lib/pcie/rtl/pcie_us_axis_cq_demux.v
24
+ SYN_FILES += lib/pcie/rtl/pcie_us_cfg.v
25
+ SYN_FILES += lib/pcie/rtl/pcie_us_msi.v
26
+ SYN_FILES += lib/pcie/rtl/arbiter.v
27
+ SYN_FILES += lib/pcie/rtl/priority_encoder.v
28
+ SYN_FILES += lib/pcie/rtl/pulse_merge.v
29
+
30
+ # XDC files
31
+ XDC_FILES = fpga.xdc
32
+
33
+ # IP
34
+ IP_TCL_FILES = ip/pcie4_uscale_plus_0.tcl
35
+
36
+ include ../common/vivado.mk
37
+
38
+ program: $(FPGA_TOP).bit
39
+ echo "open_hw" > program.tcl
40
+ echo "connect_hw_server" >> program.tcl
41
+ echo "open_hw_target" >> program.tcl
42
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
43
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
44
+ echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
45
+ echo "program_hw_devices [current_hw_device]" >> program.tcl
46
+ echo "exit" >> program.tcl
47
+ vivado -nojournal -nolog -mode batch -source program.tcl
48
+
49
+ %.mcs %.prm: %.bit
50
+ echo "write_cfgmem -force -format mcs -size 128 -interface SPIx4 -loadbit {up 0x01002000 $*.bit} -checksum -file $*.mcs" > generate_mcs.tcl
51
+ echo "exit" >> generate_mcs.tcl
52
+ vivado -nojournal -nolog -mode batch -source generate_mcs.tcl
53
+ mkdir -p rev
54
+ COUNT=100; \
55
+ while [ -e rev/$*_rev$$COUNT.bit ]; \
56
+ do COUNT=$$((COUNT+1)); done; \
57
+ COUNT=$$((COUNT-1)); \
58
+ for x in .mcs .prm; \
59
+ do cp $*$$x rev/$*_rev$$COUNT$$x; \
60
+ echo "Output: rev/$*_rev$$COUNT$$x"; done;
61
+
62
+ flash: $(FPGA_TOP).mcs $(FPGA_TOP).prm
63
+ echo "open_hw" > flash.tcl
64
+ echo "connect_hw_server" >> flash.tcl
65
+ echo "open_hw_target" >> flash.tcl
66
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> flash.tcl
67
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> flash.tcl
68
+ echo "create_hw_cfgmem -hw_device [current_hw_device] [lindex [get_cfgmem_parts {mt25qu01g-spi-x1_x2_x4}] 0]" >> flash.tcl
69
+ echo "current_hw_cfgmem -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM [current_hw_device]]" >> flash.tcl
70
+ echo "set_property PROGRAM.FILES [list \"$(FPGA_TOP).mcs\"] [current_hw_cfgmem]" >> flash.tcl
71
+ echo "set_property PROGRAM.PRM_FILES [list \"$(FPGA_TOP).prm\"] [current_hw_cfgmem]" >> flash.tcl
72
+ echo "set_property PROGRAM.ERASE 1 [current_hw_cfgmem]" >> flash.tcl
73
+ echo "set_property PROGRAM.CFG_PROGRAM 1 [current_hw_cfgmem]" >> flash.tcl
74
+ echo "set_property PROGRAM.VERIFY 1 [current_hw_cfgmem]" >> flash.tcl
75
+ echo "set_property PROGRAM.CHECKSUM 0 [current_hw_cfgmem]" >> flash.tcl
76
+ echo "set_property PROGRAM.ADDRESS_RANGE {use_file} [current_hw_cfgmem]" >> flash.tcl
77
+ echo "set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [current_hw_cfgmem]" >> flash.tcl
78
+ echo "create_hw_bitstream -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM_BITFILE [current_hw_device]]" >> flash.tcl
79
+ echo "program_hw_devices [current_hw_device]" >> flash.tcl
80
+ echo "refresh_hw_device [current_hw_device]" >> flash.tcl
81
+ echo "program_hw_cfgmem -hw_cfgmem [current_hw_cfgmem]" >> flash.tcl
82
+ echo "boot_hw_device [current_hw_device]" >> flash.tcl
83
+ echo "exit" >> flash.tcl
84
+ vivado -nojournal -nolog -mode batch -source flash.tcl
85
+
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/ip/pcie4_uscale_plus_0.tcl ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ create_ip -name pcie4_uscale_plus -vendor xilinx.com -library ip -module_name pcie4_uscale_plus_0
3
+
4
+ set_property -dict [list \
5
+ CONFIG.PL_LINK_CAP_MAX_LINK_SPEED {8.0_GT/s} \
6
+ CONFIG.PL_LINK_CAP_MAX_LINK_WIDTH {X16} \
7
+ CONFIG.AXISTEN_IF_EXT_512_RQ_STRADDLE {false} \
8
+ CONFIG.axisten_if_enable_client_tag {true} \
9
+ CONFIG.axisten_if_width {512_bit} \
10
+ CONFIG.axisten_freq {250} \
11
+ CONFIG.PF0_CLASS_CODE {058000} \
12
+ CONFIG.PF0_DEVICE_ID {0001} \
13
+ CONFIG.PF0_MSI_CAP_MULTIMSGCAP {32_vectors} \
14
+ CONFIG.PF0_SUBSYSTEM_ID {90fa} \
15
+ CONFIG.PF0_SUBSYSTEM_VENDOR_ID {10ee} \
16
+ CONFIG.pf0_bar0_64bit {true} \
17
+ CONFIG.pf0_bar0_prefetchable {true} \
18
+ CONFIG.pf0_bar0_scale {Megabytes} \
19
+ CONFIG.pf0_bar0_size {16} \
20
+ CONFIG.pf0_bar2_64bit {true} \
21
+ CONFIG.pf0_bar2_prefetchable {true} \
22
+ CONFIG.pf0_bar2_enabled {true} \
23
+ CONFIG.pf0_bar2_type {Memory} \
24
+ CONFIG.pf0_bar2_scale {Megabytes} \
25
+ CONFIG.pf0_bar2_size {16} \
26
+ CONFIG.vendor_id {1234} \
27
+ CONFIG.en_msi_per_vec_masking {true} \
28
+ ] [get_ips pcie4_uscale_plus_0]
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/axi_ram.v ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * AXI4 RAM
33
+ */
34
+ module axi_ram #
35
+ (
36
+ parameter DATA_WIDTH = 32, // width of data bus in bits
37
+ parameter ADDR_WIDTH = 16, // width of address bus in bits
38
+ parameter STRB_WIDTH = (DATA_WIDTH/8),
39
+ parameter ID_WIDTH = 8,
40
+ parameter PIPELINE_OUTPUT = 0
41
+ )
42
+ (
43
+ input wire clk,
44
+ input wire rst,
45
+
46
+ input wire [ID_WIDTH-1:0] s_axi_awid,
47
+ input wire [ADDR_WIDTH-1:0] s_axi_awaddr,
48
+ input wire [7:0] s_axi_awlen,
49
+ input wire [2:0] s_axi_awsize,
50
+ input wire [1:0] s_axi_awburst,
51
+ input wire s_axi_awlock,
52
+ input wire [3:0] s_axi_awcache,
53
+ input wire [2:0] s_axi_awprot,
54
+ input wire s_axi_awvalid,
55
+ output wire s_axi_awready,
56
+ input wire [DATA_WIDTH-1:0] s_axi_wdata,
57
+ input wire [STRB_WIDTH-1:0] s_axi_wstrb,
58
+ input wire s_axi_wlast,
59
+ input wire s_axi_wvalid,
60
+ output wire s_axi_wready,
61
+ output wire [ID_WIDTH-1:0] s_axi_bid,
62
+ output wire [1:0] s_axi_bresp,
63
+ output wire s_axi_bvalid,
64
+ input wire s_axi_bready,
65
+ input wire [ID_WIDTH-1:0] s_axi_arid,
66
+ input wire [ADDR_WIDTH-1:0] s_axi_araddr,
67
+ input wire [7:0] s_axi_arlen,
68
+ input wire [2:0] s_axi_arsize,
69
+ input wire [1:0] s_axi_arburst,
70
+ input wire s_axi_arlock,
71
+ input wire [3:0] s_axi_arcache,
72
+ input wire [2:0] s_axi_arprot,
73
+ input wire s_axi_arvalid,
74
+ output wire s_axi_arready,
75
+ output wire [ID_WIDTH-1:0] s_axi_rid,
76
+ output wire [DATA_WIDTH-1:0] s_axi_rdata,
77
+ output wire [1:0] s_axi_rresp,
78
+ output wire s_axi_rlast,
79
+ output wire s_axi_rvalid,
80
+ input wire s_axi_rready
81
+ );
82
+
83
+ parameter VALID_ADDR_WIDTH = ADDR_WIDTH - $clog2(STRB_WIDTH);
84
+ parameter WORD_WIDTH = STRB_WIDTH;
85
+ parameter WORD_SIZE = DATA_WIDTH/WORD_WIDTH;
86
+
87
+ // bus width assertions
88
+ initial begin
89
+ if (WORD_SIZE * STRB_WIDTH != DATA_WIDTH) begin
90
+ $error("Error: AXI data width not evenly divisble");
91
+ $finish;
92
+ end
93
+
94
+ if (2**$clog2(WORD_WIDTH) != WORD_WIDTH) begin
95
+ $error("Error: AXI word width must be even power of two");
96
+ $finish;
97
+ end
98
+ end
99
+
100
+ localparam [0:0]
101
+ READ_STATE_IDLE = 1'd0,
102
+ READ_STATE_BURST = 1'd1;
103
+
104
+ reg [0:0] read_state_reg = READ_STATE_IDLE, read_state_next;
105
+
106
+ localparam [1:0]
107
+ WRITE_STATE_IDLE = 2'd0,
108
+ WRITE_STATE_BURST = 2'd1,
109
+ WRITE_STATE_RESP = 2'd2;
110
+
111
+ reg [1:0] write_state_reg = WRITE_STATE_IDLE, write_state_next;
112
+
113
+ reg mem_wr_en;
114
+ reg mem_rd_en;
115
+
116
+ reg [ID_WIDTH-1:0] read_id_reg = {ID_WIDTH{1'b0}}, read_id_next;
117
+ reg [ADDR_WIDTH-1:0] read_addr_reg = {ADDR_WIDTH{1'b0}}, read_addr_next;
118
+ reg [7:0] read_count_reg = 8'd0, read_count_next;
119
+ reg [2:0] read_size_reg = 3'd0, read_size_next;
120
+ reg [1:0] read_burst_reg = 2'd0, read_burst_next;
121
+ reg [ID_WIDTH-1:0] write_id_reg = {ID_WIDTH{1'b0}}, write_id_next;
122
+ reg [ADDR_WIDTH-1:0] write_addr_reg = {ADDR_WIDTH{1'b0}}, write_addr_next;
123
+ reg [7:0] write_count_reg = 8'd0, write_count_next;
124
+ reg [2:0] write_size_reg = 3'd0, write_size_next;
125
+ reg [1:0] write_burst_reg = 2'd0, write_burst_next;
126
+
127
+ reg s_axi_awready_reg = 1'b0, s_axi_awready_next;
128
+ reg s_axi_wready_reg = 1'b0, s_axi_wready_next;
129
+ reg [ID_WIDTH-1:0] s_axi_bid_reg = {ID_WIDTH{1'b0}}, s_axi_bid_next;
130
+ reg s_axi_bvalid_reg = 1'b0, s_axi_bvalid_next;
131
+ reg s_axi_arready_reg = 1'b0, s_axi_arready_next;
132
+ reg [ID_WIDTH-1:0] s_axi_rid_reg = {ID_WIDTH{1'b0}}, s_axi_rid_next;
133
+ reg [DATA_WIDTH-1:0] s_axi_rdata_reg = {DATA_WIDTH{1'b0}}, s_axi_rdata_next;
134
+ reg s_axi_rlast_reg = 1'b0, s_axi_rlast_next;
135
+ reg s_axi_rvalid_reg = 1'b0, s_axi_rvalid_next;
136
+ reg [ID_WIDTH-1:0] s_axi_rid_pipe_reg = {ID_WIDTH{1'b0}};
137
+ reg [DATA_WIDTH-1:0] s_axi_rdata_pipe_reg = {DATA_WIDTH{1'b0}};
138
+ reg s_axi_rlast_pipe_reg = 1'b0;
139
+ reg s_axi_rvalid_pipe_reg = 1'b0;
140
+
141
+ // (* RAM_STYLE="BLOCK" *)
142
+ reg [DATA_WIDTH-1:0] mem[(2**VALID_ADDR_WIDTH)-1:0];
143
+
144
+ wire [VALID_ADDR_WIDTH-1:0] s_axi_awaddr_valid = s_axi_awaddr >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
145
+ wire [VALID_ADDR_WIDTH-1:0] s_axi_araddr_valid = s_axi_araddr >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
146
+ wire [VALID_ADDR_WIDTH-1:0] read_addr_valid = read_addr_reg >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
147
+ wire [VALID_ADDR_WIDTH-1:0] write_addr_valid = write_addr_reg >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
148
+
149
+ assign s_axi_awready = s_axi_awready_reg;
150
+ assign s_axi_wready = s_axi_wready_reg;
151
+ assign s_axi_bid = s_axi_bid_reg;
152
+ assign s_axi_bresp = 2'b00;
153
+ assign s_axi_bvalid = s_axi_bvalid_reg;
154
+ assign s_axi_arready = s_axi_arready_reg;
155
+ assign s_axi_rid = PIPELINE_OUTPUT ? s_axi_rid_pipe_reg : s_axi_rid_reg;
156
+ assign s_axi_rdata = PIPELINE_OUTPUT ? s_axi_rdata_pipe_reg : s_axi_rdata_reg;
157
+ assign s_axi_rresp = 2'b00;
158
+ assign s_axi_rlast = PIPELINE_OUTPUT ? s_axi_rlast_pipe_reg : s_axi_rlast_reg;
159
+ assign s_axi_rvalid = PIPELINE_OUTPUT ? s_axi_rvalid_pipe_reg : s_axi_rvalid_reg;
160
+
161
+ integer i, j;
162
+
163
+ initial begin
164
+ // two nested loops for smaller number of iterations per loop
165
+ // workaround for synthesizer complaints about large loop counts
166
+ for (i = 0; i < 2**ADDR_WIDTH; i = i + 2**(ADDR_WIDTH/2)) begin
167
+ for (j = i; j < i + 2**(ADDR_WIDTH/2); j = j + 1) begin
168
+ mem[j] = 0;
169
+ end
170
+ end
171
+ end
172
+
173
+ always @* begin
174
+ write_state_next = WRITE_STATE_IDLE;
175
+
176
+ mem_wr_en = 1'b0;
177
+
178
+ write_id_next = write_id_reg;
179
+ write_addr_next = write_addr_reg;
180
+ write_count_next = write_count_reg;
181
+ write_size_next = write_size_reg;
182
+ write_burst_next = write_burst_reg;
183
+
184
+ s_axi_awready_next = 1'b0;
185
+ s_axi_wready_next = 1'b0;
186
+ s_axi_bid_next = s_axi_bid_reg;
187
+ s_axi_bvalid_next = s_axi_bvalid_reg && !s_axi_bready;
188
+
189
+ case (write_state_reg)
190
+ WRITE_STATE_IDLE: begin
191
+ s_axi_awready_next = 1'b1;
192
+
193
+ if (s_axi_awready && s_axi_awvalid) begin
194
+ write_id_next = s_axi_awid;
195
+ write_addr_next = s_axi_awaddr;
196
+ write_count_next = s_axi_awlen;
197
+ write_size_next = s_axi_awsize < $clog2(STRB_WIDTH) ? s_axi_awsize : $clog2(STRB_WIDTH);
198
+ write_burst_next = s_axi_awburst;
199
+
200
+ s_axi_awready_next = 1'b0;
201
+ s_axi_wready_next = 1'b1;
202
+ write_state_next = WRITE_STATE_BURST;
203
+ end else begin
204
+ write_state_next = WRITE_STATE_IDLE;
205
+ end
206
+ end
207
+ WRITE_STATE_BURST: begin
208
+ s_axi_wready_next = 1'b1;
209
+
210
+ if (s_axi_wready && s_axi_wvalid) begin
211
+ mem_wr_en = 1'b1;
212
+ if (write_burst_reg != 2'b00) begin
213
+ write_addr_next = write_addr_reg + (1 << write_size_reg);
214
+ end
215
+ write_count_next = write_count_reg - 1;
216
+ if (write_count_reg > 0) begin
217
+ write_state_next = WRITE_STATE_BURST;
218
+ end else begin
219
+ s_axi_wready_next = 1'b0;
220
+ if (s_axi_bready || !s_axi_bvalid) begin
221
+ s_axi_bid_next = write_id_reg;
222
+ s_axi_bvalid_next = 1'b1;
223
+ s_axi_awready_next = 1'b1;
224
+ write_state_next = WRITE_STATE_IDLE;
225
+ end else begin
226
+ write_state_next = WRITE_STATE_RESP;
227
+ end
228
+ end
229
+ end else begin
230
+ write_state_next = WRITE_STATE_BURST;
231
+ end
232
+ end
233
+ WRITE_STATE_RESP: begin
234
+ if (s_axi_bready || !s_axi_bvalid) begin
235
+ s_axi_bid_next = write_id_reg;
236
+ s_axi_bvalid_next = 1'b1;
237
+ s_axi_awready_next = 1'b1;
238
+ write_state_next = WRITE_STATE_IDLE;
239
+ end else begin
240
+ write_state_next = WRITE_STATE_RESP;
241
+ end
242
+ end
243
+ endcase
244
+ end
245
+
246
+ always @(posedge clk) begin
247
+ if (rst) begin
248
+ write_state_reg <= WRITE_STATE_IDLE;
249
+ s_axi_awready_reg <= 1'b0;
250
+ s_axi_wready_reg <= 1'b0;
251
+ s_axi_bvalid_reg <= 1'b0;
252
+ end else begin
253
+ write_state_reg <= write_state_next;
254
+ s_axi_awready_reg <= s_axi_awready_next;
255
+ s_axi_wready_reg <= s_axi_wready_next;
256
+ s_axi_bvalid_reg <= s_axi_bvalid_next;
257
+ end
258
+
259
+ write_id_reg <= write_id_next;
260
+ write_addr_reg <= write_addr_next;
261
+ write_count_reg <= write_count_next;
262
+ write_size_reg <= write_size_next;
263
+ write_burst_reg <= write_burst_next;
264
+
265
+ s_axi_bid_reg <= s_axi_bid_next;
266
+
267
+ for (i = 0; i < WORD_WIDTH; i = i + 1) begin
268
+ if (mem_wr_en & s_axi_wstrb[i]) begin
269
+ mem[write_addr_valid][WORD_SIZE*i +: WORD_SIZE] <= s_axi_wdata[WORD_SIZE*i +: WORD_SIZE];
270
+ end
271
+ end
272
+ end
273
+
274
+ always @* begin
275
+ read_state_next = READ_STATE_IDLE;
276
+
277
+ mem_rd_en = 1'b0;
278
+
279
+ s_axi_rid_next = s_axi_rid_reg;
280
+ s_axi_rlast_next = s_axi_rlast_reg;
281
+ s_axi_rvalid_next = s_axi_rvalid_reg && !(s_axi_rready || (PIPELINE_OUTPUT && !s_axi_rvalid_pipe_reg));
282
+
283
+ read_id_next = read_id_reg;
284
+ read_addr_next = read_addr_reg;
285
+ read_count_next = read_count_reg;
286
+ read_size_next = read_size_reg;
287
+ read_burst_next = read_burst_reg;
288
+
289
+ s_axi_arready_next = 1'b0;
290
+
291
+ case (read_state_reg)
292
+ READ_STATE_IDLE: begin
293
+ s_axi_arready_next = 1'b1;
294
+
295
+ if (s_axi_arready && s_axi_arvalid) begin
296
+ read_id_next = s_axi_arid;
297
+ read_addr_next = s_axi_araddr;
298
+ read_count_next = s_axi_arlen;
299
+ read_size_next = s_axi_arsize < $clog2(STRB_WIDTH) ? s_axi_arsize : $clog2(STRB_WIDTH);
300
+ read_burst_next = s_axi_arburst;
301
+
302
+ s_axi_arready_next = 1'b0;
303
+ read_state_next = READ_STATE_BURST;
304
+ end else begin
305
+ read_state_next = READ_STATE_IDLE;
306
+ end
307
+ end
308
+ READ_STATE_BURST: begin
309
+ if (s_axi_rready || (PIPELINE_OUTPUT && !s_axi_rvalid_pipe_reg) || !s_axi_rvalid_reg) begin
310
+ mem_rd_en = 1'b1;
311
+ s_axi_rvalid_next = 1'b1;
312
+ s_axi_rid_next = read_id_reg;
313
+ s_axi_rlast_next = read_count_reg == 0;
314
+ if (read_burst_reg != 2'b00) begin
315
+ read_addr_next = read_addr_reg + (1 << read_size_reg);
316
+ end
317
+ read_count_next = read_count_reg - 1;
318
+ if (read_count_reg > 0) begin
319
+ read_state_next = READ_STATE_BURST;
320
+ end else begin
321
+ s_axi_arready_next = 1'b1;
322
+ read_state_next = READ_STATE_IDLE;
323
+ end
324
+ end else begin
325
+ read_state_next = READ_STATE_BURST;
326
+ end
327
+ end
328
+ endcase
329
+ end
330
+
331
+ always @(posedge clk) begin
332
+ if (rst) begin
333
+ read_state_reg <= READ_STATE_IDLE;
334
+ s_axi_arready_reg <= 1'b0;
335
+ s_axi_rvalid_reg <= 1'b0;
336
+ s_axi_rvalid_pipe_reg <= 1'b0;
337
+ end else begin
338
+ read_state_reg <= read_state_next;
339
+ s_axi_arready_reg <= s_axi_arready_next;
340
+ s_axi_rvalid_reg <= s_axi_rvalid_next;
341
+
342
+ if (!s_axi_rvalid_pipe_reg || s_axi_rready) begin
343
+ s_axi_rvalid_pipe_reg <= s_axi_rvalid_reg;
344
+ end
345
+ end
346
+
347
+ read_id_reg <= read_id_next;
348
+ read_addr_reg <= read_addr_next;
349
+ read_count_reg <= read_count_next;
350
+ read_size_reg <= read_size_next;
351
+ read_burst_reg <= read_burst_next;
352
+
353
+ s_axi_rid_reg <= s_axi_rid_next;
354
+ s_axi_rlast_reg <= s_axi_rlast_next;
355
+
356
+ if (mem_rd_en) begin
357
+ s_axi_rdata_reg <= mem[read_addr_valid];
358
+ end
359
+
360
+ if (!s_axi_rvalid_pipe_reg || s_axi_rready) begin
361
+ s_axi_rid_pipe_reg <= s_axi_rid_reg;
362
+ s_axi_rdata_pipe_reg <= s_axi_rdata_reg;
363
+ s_axi_rlast_pipe_reg <= s_axi_rlast_reg;
364
+ end
365
+ end
366
+
367
+ endmodule
368
+
369
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/axis_register.v ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * AXI4-Stream register
33
+ */
34
+ module axis_register #
35
+ (
36
+ parameter DATA_WIDTH = 8,
37
+ parameter KEEP_ENABLE = (DATA_WIDTH>8),
38
+ parameter KEEP_WIDTH = (DATA_WIDTH/8),
39
+ parameter LAST_ENABLE = 1,
40
+ parameter ID_ENABLE = 0,
41
+ parameter ID_WIDTH = 8,
42
+ parameter DEST_ENABLE = 0,
43
+ parameter DEST_WIDTH = 8,
44
+ parameter USER_ENABLE = 1,
45
+ parameter USER_WIDTH = 1,
46
+ parameter REG_TYPE = 2
47
+ )
48
+ (
49
+ input wire clk,
50
+ input wire rst,
51
+
52
+ /*
53
+ * AXI Stream input
54
+ */
55
+ input wire [DATA_WIDTH-1:0] s_axis_tdata,
56
+ input wire [KEEP_WIDTH-1:0] s_axis_tkeep,
57
+ input wire s_axis_tvalid,
58
+ output wire s_axis_tready,
59
+ input wire s_axis_tlast,
60
+ input wire [ID_WIDTH-1:0] s_axis_tid,
61
+ input wire [DEST_WIDTH-1:0] s_axis_tdest,
62
+ input wire [USER_WIDTH-1:0] s_axis_tuser,
63
+
64
+ /*
65
+ * AXI Stream output
66
+ */
67
+ output wire [DATA_WIDTH-1:0] m_axis_tdata,
68
+ output wire [KEEP_WIDTH-1:0] m_axis_tkeep,
69
+ output wire m_axis_tvalid,
70
+ input wire m_axis_tready,
71
+ output wire m_axis_tlast,
72
+ output wire [ID_WIDTH-1:0] m_axis_tid,
73
+ output wire [DEST_WIDTH-1:0] m_axis_tdest,
74
+ output wire [USER_WIDTH-1:0] m_axis_tuser
75
+ );
76
+
77
+ generate
78
+
79
+ if (REG_TYPE > 1) begin
80
+ // skid buffer, no bubble cycles
81
+
82
+ // datapath registers
83
+ reg s_axis_tready_reg = 1'b0;
84
+
85
+ reg [DATA_WIDTH-1:0] m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
86
+ reg [KEEP_WIDTH-1:0] m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
87
+ reg m_axis_tvalid_reg = 1'b0, m_axis_tvalid_next;
88
+ reg m_axis_tlast_reg = 1'b0;
89
+ reg [ID_WIDTH-1:0] m_axis_tid_reg = {ID_WIDTH{1'b0}};
90
+ reg [DEST_WIDTH-1:0] m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
91
+ reg [USER_WIDTH-1:0] m_axis_tuser_reg = {USER_WIDTH{1'b0}};
92
+
93
+ reg [DATA_WIDTH-1:0] temp_m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
94
+ reg [KEEP_WIDTH-1:0] temp_m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
95
+ reg temp_m_axis_tvalid_reg = 1'b0, temp_m_axis_tvalid_next;
96
+ reg temp_m_axis_tlast_reg = 1'b0;
97
+ reg [ID_WIDTH-1:0] temp_m_axis_tid_reg = {ID_WIDTH{1'b0}};
98
+ reg [DEST_WIDTH-1:0] temp_m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
99
+ reg [USER_WIDTH-1:0] temp_m_axis_tuser_reg = {USER_WIDTH{1'b0}};
100
+
101
+ // datapath control
102
+ reg store_axis_input_to_output;
103
+ reg store_axis_input_to_temp;
104
+ reg store_axis_temp_to_output;
105
+
106
+ assign s_axis_tready = s_axis_tready_reg;
107
+
108
+ assign m_axis_tdata = m_axis_tdata_reg;
109
+ assign m_axis_tkeep = KEEP_ENABLE ? m_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
110
+ assign m_axis_tvalid = m_axis_tvalid_reg;
111
+ assign m_axis_tlast = LAST_ENABLE ? m_axis_tlast_reg : 1'b1;
112
+ assign m_axis_tid = ID_ENABLE ? m_axis_tid_reg : {ID_WIDTH{1'b0}};
113
+ assign m_axis_tdest = DEST_ENABLE ? m_axis_tdest_reg : {DEST_WIDTH{1'b0}};
114
+ assign m_axis_tuser = USER_ENABLE ? m_axis_tuser_reg : {USER_WIDTH{1'b0}};
115
+
116
+ // enable ready input next cycle if output is ready or the temp reg will not be filled on the next cycle (output reg empty or no input)
117
+ wire s_axis_tready_early = m_axis_tready || (!temp_m_axis_tvalid_reg && (!m_axis_tvalid_reg || !s_axis_tvalid));
118
+
119
+ always @* begin
120
+ // transfer sink ready state to source
121
+ m_axis_tvalid_next = m_axis_tvalid_reg;
122
+ temp_m_axis_tvalid_next = temp_m_axis_tvalid_reg;
123
+
124
+ store_axis_input_to_output = 1'b0;
125
+ store_axis_input_to_temp = 1'b0;
126
+ store_axis_temp_to_output = 1'b0;
127
+
128
+ if (s_axis_tready_reg) begin
129
+ // input is ready
130
+ if (m_axis_tready || !m_axis_tvalid_reg) begin
131
+ // output is ready or currently not valid, transfer data to output
132
+ m_axis_tvalid_next = s_axis_tvalid;
133
+ store_axis_input_to_output = 1'b1;
134
+ end else begin
135
+ // output is not ready, store input in temp
136
+ temp_m_axis_tvalid_next = s_axis_tvalid;
137
+ store_axis_input_to_temp = 1'b1;
138
+ end
139
+ end else if (m_axis_tready) begin
140
+ // input is not ready, but output is ready
141
+ m_axis_tvalid_next = temp_m_axis_tvalid_reg;
142
+ temp_m_axis_tvalid_next = 1'b0;
143
+ store_axis_temp_to_output = 1'b1;
144
+ end
145
+ end
146
+
147
+ always @(posedge clk) begin
148
+ if (rst) begin
149
+ s_axis_tready_reg <= 1'b0;
150
+ m_axis_tvalid_reg <= 1'b0;
151
+ temp_m_axis_tvalid_reg <= 1'b0;
152
+ end else begin
153
+ s_axis_tready_reg <= s_axis_tready_early;
154
+ m_axis_tvalid_reg <= m_axis_tvalid_next;
155
+ temp_m_axis_tvalid_reg <= temp_m_axis_tvalid_next;
156
+ end
157
+
158
+ // datapath
159
+ if (store_axis_input_to_output) begin
160
+ m_axis_tdata_reg <= s_axis_tdata;
161
+ m_axis_tkeep_reg <= s_axis_tkeep;
162
+ m_axis_tlast_reg <= s_axis_tlast;
163
+ m_axis_tid_reg <= s_axis_tid;
164
+ m_axis_tdest_reg <= s_axis_tdest;
165
+ m_axis_tuser_reg <= s_axis_tuser;
166
+ end else if (store_axis_temp_to_output) begin
167
+ m_axis_tdata_reg <= temp_m_axis_tdata_reg;
168
+ m_axis_tkeep_reg <= temp_m_axis_tkeep_reg;
169
+ m_axis_tlast_reg <= temp_m_axis_tlast_reg;
170
+ m_axis_tid_reg <= temp_m_axis_tid_reg;
171
+ m_axis_tdest_reg <= temp_m_axis_tdest_reg;
172
+ m_axis_tuser_reg <= temp_m_axis_tuser_reg;
173
+ end
174
+
175
+ if (store_axis_input_to_temp) begin
176
+ temp_m_axis_tdata_reg <= s_axis_tdata;
177
+ temp_m_axis_tkeep_reg <= s_axis_tkeep;
178
+ temp_m_axis_tlast_reg <= s_axis_tlast;
179
+ temp_m_axis_tid_reg <= s_axis_tid;
180
+ temp_m_axis_tdest_reg <= s_axis_tdest;
181
+ temp_m_axis_tuser_reg <= s_axis_tuser;
182
+ end
183
+ end
184
+
185
+ end else if (REG_TYPE == 1) begin
186
+ // simple register, inserts bubble cycles
187
+
188
+ // datapath registers
189
+ reg s_axis_tready_reg = 1'b0;
190
+
191
+ reg [DATA_WIDTH-1:0] m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
192
+ reg [KEEP_WIDTH-1:0] m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
193
+ reg m_axis_tvalid_reg = 1'b0, m_axis_tvalid_next;
194
+ reg m_axis_tlast_reg = 1'b0;
195
+ reg [ID_WIDTH-1:0] m_axis_tid_reg = {ID_WIDTH{1'b0}};
196
+ reg [DEST_WIDTH-1:0] m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
197
+ reg [USER_WIDTH-1:0] m_axis_tuser_reg = {USER_WIDTH{1'b0}};
198
+
199
+ // datapath control
200
+ reg store_axis_input_to_output;
201
+
202
+ assign s_axis_tready = s_axis_tready_reg;
203
+
204
+ assign m_axis_tdata = m_axis_tdata_reg;
205
+ assign m_axis_tkeep = KEEP_ENABLE ? m_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
206
+ assign m_axis_tvalid = m_axis_tvalid_reg;
207
+ assign m_axis_tlast = LAST_ENABLE ? m_axis_tlast_reg : 1'b1;
208
+ assign m_axis_tid = ID_ENABLE ? m_axis_tid_reg : {ID_WIDTH{1'b0}};
209
+ assign m_axis_tdest = DEST_ENABLE ? m_axis_tdest_reg : {DEST_WIDTH{1'b0}};
210
+ assign m_axis_tuser = USER_ENABLE ? m_axis_tuser_reg : {USER_WIDTH{1'b0}};
211
+
212
+ // enable ready input next cycle if output buffer will be empty
213
+ wire s_axis_tready_early = !m_axis_tvalid_next;
214
+
215
+ always @* begin
216
+ // transfer sink ready state to source
217
+ m_axis_tvalid_next = m_axis_tvalid_reg;
218
+
219
+ store_axis_input_to_output = 1'b0;
220
+
221
+ if (s_axis_tready_reg) begin
222
+ m_axis_tvalid_next = s_axis_tvalid;
223
+ store_axis_input_to_output = 1'b1;
224
+ end else if (m_axis_tready) begin
225
+ m_axis_tvalid_next = 1'b0;
226
+ end
227
+ end
228
+
229
+ always @(posedge clk) begin
230
+ if (rst) begin
231
+ s_axis_tready_reg <= 1'b0;
232
+ m_axis_tvalid_reg <= 1'b0;
233
+ end else begin
234
+ s_axis_tready_reg <= s_axis_tready_early;
235
+ m_axis_tvalid_reg <= m_axis_tvalid_next;
236
+ end
237
+
238
+ // datapath
239
+ if (store_axis_input_to_output) begin
240
+ m_axis_tdata_reg <= s_axis_tdata;
241
+ m_axis_tkeep_reg <= s_axis_tkeep;
242
+ m_axis_tlast_reg <= s_axis_tlast;
243
+ m_axis_tid_reg <= s_axis_tid;
244
+ m_axis_tdest_reg <= s_axis_tdest;
245
+ m_axis_tuser_reg <= s_axis_tuser;
246
+ end
247
+ end
248
+
249
+ end else begin
250
+ // bypass
251
+
252
+ assign m_axis_tdata = s_axis_tdata;
253
+ assign m_axis_tkeep = KEEP_ENABLE ? s_axis_tkeep : {KEEP_WIDTH{1'b1}};
254
+ assign m_axis_tvalid = s_axis_tvalid;
255
+ assign m_axis_tlast = LAST_ENABLE ? s_axis_tlast : 1'b1;
256
+ assign m_axis_tid = ID_ENABLE ? s_axis_tid : {ID_WIDTH{1'b0}};
257
+ assign m_axis_tdest = DEST_ENABLE ? s_axis_tdest : {DEST_WIDTH{1'b0}};
258
+ assign m_axis_tuser = USER_ENABLE ? s_axis_tuser : {USER_WIDTH{1'b0}};
259
+
260
+ assign s_axis_tready = m_axis_tready;
261
+
262
+ end
263
+
264
+ endgenerate
265
+
266
+ endmodule
267
+
268
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/debounce_switch.v ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes switch and button inputs with a slow sampled shift register
33
+ */
34
+ module debounce_switch #(
35
+ parameter WIDTH=1, // width of the input and output signals
36
+ parameter N=3, // length of shift register
37
+ parameter RATE=125000 // clock division factor
38
+ )(
39
+ input wire clk,
40
+ input wire rst,
41
+ input wire [WIDTH-1:0] in,
42
+ output wire [WIDTH-1:0] out
43
+ );
44
+
45
+ reg [23:0] cnt_reg = 24'd0;
46
+
47
+ reg [N-1:0] debounce_reg[WIDTH-1:0];
48
+
49
+ reg [WIDTH-1:0] state;
50
+
51
+ /*
52
+ * The synchronized output is the state register
53
+ */
54
+ assign out = state;
55
+
56
+ integer k;
57
+
58
+ always @(posedge clk or posedge rst) begin
59
+ if (rst) begin
60
+ cnt_reg <= 0;
61
+ state <= 0;
62
+
63
+ for (k = 0; k < WIDTH; k = k + 1) begin
64
+ debounce_reg[k] <= 0;
65
+ end
66
+ end else begin
67
+ if (cnt_reg < RATE) begin
68
+ cnt_reg <= cnt_reg + 24'd1;
69
+ end else begin
70
+ cnt_reg <= 24'd0;
71
+ end
72
+
73
+ if (cnt_reg == 24'd0) begin
74
+ for (k = 0; k < WIDTH; k = k + 1) begin
75
+ debounce_reg[k] <= {debounce_reg[k][N-2:0], in[k]};
76
+ end
77
+ end
78
+
79
+ for (k = 0; k < WIDTH; k = k + 1) begin
80
+ if (|debounce_reg[k] == 0) begin
81
+ state[k] <= 0;
82
+ end else if (&debounce_reg[k] == 1) begin
83
+ state[k] <= 1;
84
+ end else begin
85
+ state[k] <= state[k];
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ endmodule
92
+
93
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/fpga.v ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA top-level module
33
+ */
34
+ module fpga (
35
+ /*
36
+ * GPIO
37
+ */
38
+ input wire [3:0] sw,
39
+ output wire [2:0] led,
40
+
41
+ /*
42
+ * PCI express
43
+ */
44
+ input wire [15:0] pcie_rx_p,
45
+ input wire [15:0] pcie_rx_n,
46
+ output wire [15:0] pcie_tx_p,
47
+ output wire [15:0] pcie_tx_n,
48
+ input wire pcie_refclk_p,
49
+ input wire pcie_refclk_n,
50
+ input wire pcie_reset_n
51
+ );
52
+
53
+ parameter AXIS_PCIE_DATA_WIDTH = 512;
54
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32);
55
+ parameter AXIS_PCIE_RC_USER_WIDTH = 161;
56
+ parameter AXIS_PCIE_RQ_USER_WIDTH = 137;
57
+ parameter AXIS_PCIE_CQ_USER_WIDTH = 183;
58
+ parameter AXIS_PCIE_CC_USER_WIDTH = 81;
59
+
60
+ // Clock and reset
61
+ wire pcie_user_clk;
62
+ wire pcie_user_reset;
63
+
64
+ // GPIO
65
+ wire [3:0] sw_int;
66
+
67
+ debounce_switch #(
68
+ .WIDTH(4),
69
+ .N(4),
70
+ .RATE(250000)
71
+ )
72
+ debounce_switch_inst (
73
+ .clk(pcie_user_clk),
74
+ .rst(pcie_user_reset),
75
+ .in({sw}),
76
+ .out({sw_int})
77
+ );
78
+
79
+ // PCIe
80
+ wire pcie_sys_clk;
81
+ wire pcie_sys_clk_gt;
82
+
83
+ IBUFDS_GTE4 #(
84
+ .REFCLK_HROW_CK_SEL(2'b00)
85
+ )
86
+ ibufds_gte4_pcie_mgt_refclk_inst (
87
+ .I (pcie_refclk_p),
88
+ .IB (pcie_refclk_n),
89
+ .CEB (1'b0),
90
+ .O (pcie_sys_clk_gt),
91
+ .ODIV2 (pcie_sys_clk)
92
+ );
93
+
94
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rq_tdata;
95
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rq_tkeep;
96
+ wire axis_rq_tlast;
97
+ wire axis_rq_tready;
98
+ wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] axis_rq_tuser;
99
+ wire axis_rq_tvalid;
100
+
101
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata;
102
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep;
103
+ wire axis_rc_tlast;
104
+ wire axis_rc_tready;
105
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser;
106
+ wire axis_rc_tvalid;
107
+
108
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata;
109
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep;
110
+ wire axis_cq_tlast;
111
+ wire axis_cq_tready;
112
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser;
113
+ wire axis_cq_tvalid;
114
+
115
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata;
116
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep;
117
+ wire axis_cc_tlast;
118
+ wire axis_cc_tready;
119
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser;
120
+ wire axis_cc_tvalid;
121
+
122
+ // ila_0 rq_ila (
123
+ // .clk(pcie_user_clk),
124
+ // .probe0(axis_rq_tdata),
125
+ // .probe1(axis_rq_tkeep),
126
+ // .probe2(axis_rq_tlast),
127
+ // .probe3(axis_rq_tready),
128
+ // .probe4(axis_rq_tuser),
129
+ // .probe5(axis_rq_tvalid)
130
+ // );
131
+
132
+ // ila_0 rc_ila (
133
+ // .clk(pcie_user_clk),
134
+ // .probe0(axis_rc_tdata),
135
+ // .probe1(axis_rc_tkeep),
136
+ // .probe2(axis_rc_tlast),
137
+ // .probe3(axis_rc_tready),
138
+ // .probe4(axis_rc_tuser),
139
+ // .probe5(axis_rc_tvalid)
140
+ // );
141
+
142
+ wire [2:0] cfg_max_payload;
143
+ wire [2:0] cfg_max_read_req;
144
+
145
+ wire [9:0] cfg_mgmt_addr;
146
+ wire [7:0] cfg_mgmt_function_number;
147
+ wire cfg_mgmt_write;
148
+ wire [31:0] cfg_mgmt_write_data;
149
+ wire [3:0] cfg_mgmt_byte_enable;
150
+ wire cfg_mgmt_read;
151
+ wire [31:0] cfg_mgmt_read_data;
152
+ wire cfg_mgmt_read_write_done;
153
+
154
+ wire [3:0] cfg_interrupt_msi_enable;
155
+ wire [11:0] cfg_interrupt_msi_mmenable;
156
+ wire cfg_interrupt_msi_mask_update;
157
+ wire [31:0] cfg_interrupt_msi_data;
158
+ wire [3:0] cfg_interrupt_msi_select;
159
+ wire [31:0] cfg_interrupt_msi_int;
160
+ wire [31:0] cfg_interrupt_msi_pending_status;
161
+ wire cfg_interrupt_msi_pending_status_data_enable;
162
+ wire [3:0] cfg_interrupt_msi_pending_status_function_num;
163
+ wire cfg_interrupt_msi_sent;
164
+ wire cfg_interrupt_msi_fail;
165
+ wire [2:0] cfg_interrupt_msi_attr;
166
+ wire cfg_interrupt_msi_tph_present;
167
+ wire [1:0] cfg_interrupt_msi_tph_type;
168
+ wire [8:0] cfg_interrupt_msi_tph_st_tag;
169
+ wire [3:0] cfg_interrupt_msi_function_number;
170
+
171
+ wire status_error_cor;
172
+ wire status_error_uncor;
173
+
174
+ pcie4_uscale_plus_0
175
+ pcie4_uscale_plus_inst (
176
+ .pci_exp_txn(pcie_tx_n),
177
+ .pci_exp_txp(pcie_tx_p),
178
+ .pci_exp_rxn(pcie_rx_n),
179
+ .pci_exp_rxp(pcie_rx_p),
180
+ .user_clk(pcie_user_clk),
181
+ .user_reset(pcie_user_reset),
182
+ .user_lnk_up(),
183
+
184
+ .s_axis_rq_tdata(axis_rq_tdata),
185
+ .s_axis_rq_tkeep(axis_rq_tkeep),
186
+ .s_axis_rq_tlast(axis_rq_tlast),
187
+ .s_axis_rq_tready(axis_rq_tready),
188
+ .s_axis_rq_tuser(axis_rq_tuser),
189
+ .s_axis_rq_tvalid(axis_rq_tvalid),
190
+
191
+ .m_axis_rc_tdata(axis_rc_tdata),
192
+ .m_axis_rc_tkeep(axis_rc_tkeep),
193
+ .m_axis_rc_tlast(axis_rc_tlast),
194
+ .m_axis_rc_tready(axis_rc_tready),
195
+ .m_axis_rc_tuser(axis_rc_tuser),
196
+ .m_axis_rc_tvalid(axis_rc_tvalid),
197
+
198
+ .m_axis_cq_tdata(axis_cq_tdata),
199
+ .m_axis_cq_tkeep(axis_cq_tkeep),
200
+ .m_axis_cq_tlast(axis_cq_tlast),
201
+ .m_axis_cq_tready(axis_cq_tready),
202
+ .m_axis_cq_tuser(axis_cq_tuser),
203
+ .m_axis_cq_tvalid(axis_cq_tvalid),
204
+
205
+ .s_axis_cc_tdata(axis_cc_tdata),
206
+ .s_axis_cc_tkeep(axis_cc_tkeep),
207
+ .s_axis_cc_tlast(axis_cc_tlast),
208
+ .s_axis_cc_tready(axis_cc_tready),
209
+ .s_axis_cc_tuser(axis_cc_tuser),
210
+ .s_axis_cc_tvalid(axis_cc_tvalid),
211
+
212
+ .pcie_rq_seq_num0(),
213
+ .pcie_rq_seq_num_vld0(),
214
+ .pcie_rq_seq_num1(),
215
+ .pcie_rq_seq_num_vld1(),
216
+ .pcie_rq_tag0(),
217
+ .pcie_rq_tag1(),
218
+ .pcie_rq_tag_av(),
219
+ .pcie_rq_tag_vld0(),
220
+ .pcie_rq_tag_vld1(),
221
+
222
+ .pcie_tfc_nph_av(),
223
+ .pcie_tfc_npd_av(),
224
+
225
+ .pcie_cq_np_req(1'b1),
226
+ .pcie_cq_np_req_count(),
227
+
228
+ .cfg_phy_link_down(),
229
+ .cfg_phy_link_status(),
230
+ .cfg_negotiated_width(),
231
+ .cfg_current_speed(),
232
+ .cfg_max_payload(cfg_max_payload),
233
+ .cfg_max_read_req(cfg_max_read_req),
234
+ .cfg_function_status(),
235
+ .cfg_function_power_state(),
236
+ .cfg_vf_status(),
237
+ .cfg_vf_power_state(),
238
+ .cfg_link_power_state(),
239
+
240
+ .cfg_mgmt_addr(cfg_mgmt_addr),
241
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
242
+ .cfg_mgmt_write(cfg_mgmt_write),
243
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
244
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
245
+ .cfg_mgmt_read(cfg_mgmt_read),
246
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
247
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
248
+ .cfg_mgmt_debug_access(1'b0),
249
+
250
+ .cfg_err_cor_out(),
251
+ .cfg_err_nonfatal_out(),
252
+ .cfg_err_fatal_out(),
253
+ .cfg_local_error_valid(),
254
+ .cfg_local_error_out(),
255
+ .cfg_ltssm_state(),
256
+ .cfg_rx_pm_state(),
257
+ .cfg_tx_pm_state(),
258
+ .cfg_rcb_status(),
259
+ .cfg_obff_enable(),
260
+ .cfg_pl_status_change(),
261
+ .cfg_tph_requester_enable(),
262
+ .cfg_tph_st_mode(),
263
+ .cfg_vf_tph_requester_enable(),
264
+ .cfg_vf_tph_st_mode(),
265
+
266
+ .cfg_msg_received(),
267
+ .cfg_msg_received_data(),
268
+ .cfg_msg_received_type(),
269
+ .cfg_msg_transmit(1'b0),
270
+ .cfg_msg_transmit_type(3'd0),
271
+ .cfg_msg_transmit_data(32'd0),
272
+ .cfg_msg_transmit_done(),
273
+
274
+ .cfg_fc_ph(),
275
+ .cfg_fc_pd(),
276
+ .cfg_fc_nph(),
277
+ .cfg_fc_npd(),
278
+ .cfg_fc_cplh(),
279
+ .cfg_fc_cpld(),
280
+ .cfg_fc_sel(3'd0),
281
+
282
+ .cfg_dsn(64'd0),
283
+
284
+ .cfg_bus_number(),
285
+
286
+ .cfg_power_state_change_ack(1'b1),
287
+ .cfg_power_state_change_interrupt(),
288
+
289
+ .cfg_err_cor_in(status_error_cor),
290
+ .cfg_err_uncor_in(status_error_uncor),
291
+ .cfg_flr_in_process(),
292
+ .cfg_flr_done(4'd0),
293
+ .cfg_vf_flr_in_process(),
294
+ .cfg_vf_flr_func_num(8'd0),
295
+ .cfg_vf_flr_done(8'd0),
296
+
297
+ .cfg_link_training_enable(1'b1),
298
+
299
+ .cfg_interrupt_int(4'd0),
300
+ .cfg_interrupt_pending(4'd0),
301
+ .cfg_interrupt_sent(),
302
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
303
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
304
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
305
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
306
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
307
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
308
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
309
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
310
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
311
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
312
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
313
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
314
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
315
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
316
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
317
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
318
+
319
+ .cfg_pm_aspm_l1_entry_reject(1'b0),
320
+ .cfg_pm_aspm_tx_l0s_entry_disable(1'b0),
321
+
322
+ .cfg_hot_reset_out(),
323
+
324
+ .cfg_config_space_enable(1'b1),
325
+ .cfg_req_pm_transition_l23_ready(1'b0),
326
+ .cfg_hot_reset_in(1'b0),
327
+
328
+ .cfg_ds_port_number(8'd0),
329
+ .cfg_ds_bus_number(8'd0),
330
+ .cfg_ds_device_number(5'd0),
331
+ //.cfg_ds_function_number(3'd0),
332
+
333
+ //.cfg_subsys_vend_id(16'h1234),
334
+
335
+ .sys_clk(pcie_sys_clk),
336
+ .sys_clk_gt(pcie_sys_clk_gt),
337
+ .sys_reset(pcie_reset_n),
338
+
339
+ .phy_rdy_out()
340
+ );
341
+
342
+ fpga_core #(
343
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
344
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
345
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
346
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
347
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
348
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH)
349
+ )
350
+ core_inst (
351
+ /*
352
+ * Clock: 250 MHz
353
+ * Synchronous reset
354
+ */
355
+ .clk(pcie_user_clk),
356
+ .rst(pcie_user_reset),
357
+ /*
358
+ * GPIO
359
+ */
360
+ .sw(sw_int),
361
+ .led(led),
362
+ /*
363
+ * PCIe
364
+ */
365
+ .m_axis_rq_tdata(axis_rq_tdata),
366
+ .m_axis_rq_tkeep(axis_rq_tkeep),
367
+ .m_axis_rq_tlast(axis_rq_tlast),
368
+ .m_axis_rq_tready(axis_rq_tready),
369
+ .m_axis_rq_tuser(axis_rq_tuser),
370
+ .m_axis_rq_tvalid(axis_rq_tvalid),
371
+
372
+ .s_axis_rc_tdata(axis_rc_tdata),
373
+ .s_axis_rc_tkeep(axis_rc_tkeep),
374
+ .s_axis_rc_tlast(axis_rc_tlast),
375
+ .s_axis_rc_tready(axis_rc_tready),
376
+ .s_axis_rc_tuser(axis_rc_tuser),
377
+ .s_axis_rc_tvalid(axis_rc_tvalid),
378
+
379
+ .s_axis_cq_tdata(axis_cq_tdata),
380
+ .s_axis_cq_tkeep(axis_cq_tkeep),
381
+ .s_axis_cq_tlast(axis_cq_tlast),
382
+ .s_axis_cq_tready(axis_cq_tready),
383
+ .s_axis_cq_tuser(axis_cq_tuser),
384
+ .s_axis_cq_tvalid(axis_cq_tvalid),
385
+
386
+ .m_axis_cc_tdata(axis_cc_tdata),
387
+ .m_axis_cc_tkeep(axis_cc_tkeep),
388
+ .m_axis_cc_tlast(axis_cc_tlast),
389
+ .m_axis_cc_tready(axis_cc_tready),
390
+ .m_axis_cc_tuser(axis_cc_tuser),
391
+ .m_axis_cc_tvalid(axis_cc_tvalid),
392
+
393
+ .cfg_max_payload(cfg_max_payload),
394
+ .cfg_max_read_req(cfg_max_read_req),
395
+
396
+ .cfg_mgmt_addr(cfg_mgmt_addr),
397
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
398
+ .cfg_mgmt_write(cfg_mgmt_write),
399
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
400
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
401
+ .cfg_mgmt_read(cfg_mgmt_read),
402
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
403
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
404
+
405
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
406
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
407
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
408
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
409
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
410
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
411
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
412
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
413
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
414
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
415
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
416
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
417
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
418
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
419
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
420
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
421
+
422
+ .status_error_cor(status_error_cor),
423
+ .status_error_uncor(status_error_uncor)
424
+ );
425
+
426
+ endmodule
427
+
428
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/fpga_core.v ADDED
@@ -0,0 +1,1123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA core logic
33
+ */
34
+ module fpga_core #
35
+ (
36
+ parameter AXIS_PCIE_DATA_WIDTH = 512,
37
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32),
38
+ parameter AXIS_PCIE_RC_USER_WIDTH = 161,
39
+ parameter AXIS_PCIE_RQ_USER_WIDTH = 137,
40
+ parameter AXIS_PCIE_CQ_USER_WIDTH = 183,
41
+ parameter AXIS_PCIE_CC_USER_WIDTH = 81
42
+ )
43
+ (
44
+ /*
45
+ * Clock: 250 MHz
46
+ * Synchronous reset
47
+ */
48
+ input wire clk,
49
+ input wire rst,
50
+
51
+ /*
52
+ * GPIO
53
+ */
54
+ input wire [3:0] sw,
55
+ output wire [2:0] led,
56
+
57
+ /*
58
+ * PCIe
59
+ */
60
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_rq_tdata,
61
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_rq_tkeep,
62
+ output wire m_axis_rq_tlast,
63
+ input wire m_axis_rq_tready,
64
+ output wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] m_axis_rq_tuser,
65
+ output wire m_axis_rq_tvalid,
66
+
67
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_rc_tdata,
68
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_rc_tkeep,
69
+ input wire s_axis_rc_tlast,
70
+ output wire s_axis_rc_tready,
71
+ input wire [AXIS_PCIE_RC_USER_WIDTH-1:0] s_axis_rc_tuser,
72
+ input wire s_axis_rc_tvalid,
73
+
74
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_cq_tdata,
75
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_cq_tkeep,
76
+ input wire s_axis_cq_tlast,
77
+ output wire s_axis_cq_tready,
78
+ input wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] s_axis_cq_tuser,
79
+ input wire s_axis_cq_tvalid,
80
+
81
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_cc_tdata,
82
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_cc_tkeep,
83
+ output wire m_axis_cc_tlast,
84
+ input wire m_axis_cc_tready,
85
+ output wire [AXIS_PCIE_CC_USER_WIDTH-1:0] m_axis_cc_tuser,
86
+ output wire m_axis_cc_tvalid,
87
+
88
+ input wire [2:0] cfg_max_payload,
89
+ input wire [2:0] cfg_max_read_req,
90
+
91
+ output wire [9:0] cfg_mgmt_addr,
92
+ output wire [7:0] cfg_mgmt_function_number,
93
+ output wire cfg_mgmt_write,
94
+ output wire [31:0] cfg_mgmt_write_data,
95
+ output wire [3:0] cfg_mgmt_byte_enable,
96
+ output wire cfg_mgmt_read,
97
+ input wire [31:0] cfg_mgmt_read_data,
98
+ input wire cfg_mgmt_read_write_done,
99
+
100
+ input wire [3:0] cfg_interrupt_msi_enable,
101
+ input wire [11:0] cfg_interrupt_msi_mmenable,
102
+ input wire cfg_interrupt_msi_mask_update,
103
+ input wire [31:0] cfg_interrupt_msi_data,
104
+ output wire [3:0] cfg_interrupt_msi_select,
105
+ output wire [31:0] cfg_interrupt_msi_int,
106
+ output wire [31:0] cfg_interrupt_msi_pending_status,
107
+ output wire cfg_interrupt_msi_pending_status_data_enable,
108
+ output wire [3:0] cfg_interrupt_msi_pending_status_function_num,
109
+ input wire cfg_interrupt_msi_sent,
110
+ input wire cfg_interrupt_msi_fail,
111
+ output wire [2:0] cfg_interrupt_msi_attr,
112
+ output wire cfg_interrupt_msi_tph_present,
113
+ output wire [1:0] cfg_interrupt_msi_tph_type,
114
+ output wire [8:0] cfg_interrupt_msi_tph_st_tag,
115
+ output wire [3:0] cfg_interrupt_msi_function_number,
116
+
117
+ output wire status_error_cor,
118
+ output wire status_error_uncor
119
+ );
120
+
121
+ parameter PCIE_ADDR_WIDTH = 64;
122
+
123
+ parameter AXIL_DATA_WIDTH = 32;
124
+ parameter AXIL_STRB_WIDTH = (AXIL_DATA_WIDTH/8);
125
+ parameter AXIL_ADDR_WIDTH = 32;
126
+
127
+ parameter AXI_DATA_WIDTH = AXIS_PCIE_DATA_WIDTH;
128
+ parameter AXI_STRB_WIDTH = (AXI_DATA_WIDTH/8);
129
+ parameter AXI_ADDR_WIDTH = 32;
130
+ parameter AXI_ID_WIDTH = 8;
131
+
132
+ parameter DMA_TAG_WIDTH = 8;
133
+
134
+ // Completer mux/demux
135
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata_bar_0;
136
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep_bar_0;
137
+ wire axis_cq_tvalid_bar_0;
138
+ wire axis_cq_tready_bar_0;
139
+ wire axis_cq_tlast_bar_0;
140
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser_bar_0;
141
+
142
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata_bar_0;
143
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep_bar_0;
144
+ wire axis_cc_tvalid_bar_0;
145
+ wire axis_cc_tready_bar_0;
146
+ wire axis_cc_tlast_bar_0;
147
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser_bar_0;
148
+
149
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata_bar_2;
150
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep_bar_2;
151
+ wire axis_cq_tvalid_bar_2;
152
+ wire axis_cq_tready_bar_2;
153
+ wire axis_cq_tlast_bar_2;
154
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser_bar_2;
155
+
156
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata_bar_2;
157
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep_bar_2;
158
+ wire axis_cc_tvalid_bar_2;
159
+ wire axis_cc_tready_bar_2;
160
+ wire axis_cc_tlast_bar_2;
161
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser_bar_2;
162
+
163
+ wire [2:0] bar_id;
164
+ wire [1:0] select;
165
+
166
+ pcie_us_axis_cq_demux #(
167
+ .M_COUNT(2),
168
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
169
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
170
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH)
171
+ )
172
+ cq_demux_inst (
173
+ .clk(clk),
174
+ .rst(rst),
175
+
176
+ /*
177
+ * AXI input (CQ)
178
+ */
179
+ .s_axis_cq_tdata(s_axis_cq_tdata),
180
+ .s_axis_cq_tkeep(s_axis_cq_tkeep),
181
+ .s_axis_cq_tvalid(s_axis_cq_tvalid),
182
+ .s_axis_cq_tready(s_axis_cq_tready),
183
+ .s_axis_cq_tlast(s_axis_cq_tlast),
184
+ .s_axis_cq_tuser(s_axis_cq_tuser),
185
+
186
+ /*
187
+ * AXI output (CQ)
188
+ */
189
+ .m_axis_cq_tdata({axis_cq_tdata_bar_2, axis_cq_tdata_bar_0}),
190
+ .m_axis_cq_tkeep({axis_cq_tkeep_bar_2, axis_cq_tkeep_bar_0}),
191
+ .m_axis_cq_tvalid({axis_cq_tvalid_bar_2, axis_cq_tvalid_bar_0}),
192
+ .m_axis_cq_tready({axis_cq_tready_bar_2, axis_cq_tready_bar_0}),
193
+ .m_axis_cq_tlast({axis_cq_tlast_bar_2, axis_cq_tlast_bar_0}),
194
+ .m_axis_cq_tuser({axis_cq_tuser_bar_2, axis_cq_tuser_bar_0}),
195
+
196
+ /*
197
+ * Fields
198
+ */
199
+ .req_type(),
200
+ .target_function(),
201
+ .bar_id(bar_id),
202
+ .msg_code(),
203
+ .msg_routing(),
204
+
205
+ /*
206
+ * Control
207
+ */
208
+ .enable(1),
209
+ .drop(0),
210
+ .select(select)
211
+ );
212
+
213
+ assign select[1] = bar_id == 3'd2;
214
+ assign select[0] = bar_id == 3'd0;
215
+
216
+ axis_arb_mux #(
217
+ .S_COUNT(2),
218
+ .DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
219
+ .KEEP_ENABLE(1),
220
+ .KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
221
+ .ID_ENABLE(0),
222
+ .DEST_ENABLE(0),
223
+ .USER_ENABLE(1),
224
+ .USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH)
225
+ )
226
+ cc_mux_inst (
227
+ .clk(clk),
228
+ .rst(rst),
229
+
230
+ /*
231
+ * AXI inputs
232
+ */
233
+ .s_axis_tdata({axis_cc_tdata_bar_2, axis_cc_tdata_bar_0}),
234
+ .s_axis_tkeep({axis_cc_tkeep_bar_2, axis_cc_tkeep_bar_0}),
235
+ .s_axis_tvalid({axis_cc_tvalid_bar_2, axis_cc_tvalid_bar_0}),
236
+ .s_axis_tready({axis_cc_tready_bar_2, axis_cc_tready_bar_0}),
237
+ .s_axis_tlast({axis_cc_tlast_bar_2, axis_cc_tlast_bar_0}),
238
+ .s_axis_tid(0),
239
+ .s_axis_tdest(0),
240
+ .s_axis_tuser({axis_cc_tuser_bar_2, axis_cc_tuser_bar_0}),
241
+
242
+ /*
243
+ * AXI output
244
+ */
245
+ .m_axis_tdata(m_axis_cc_tdata),
246
+ .m_axis_tkeep(m_axis_cc_tkeep),
247
+ .m_axis_tvalid(m_axis_cc_tvalid),
248
+ .m_axis_tready(m_axis_cc_tready),
249
+ .m_axis_tlast(m_axis_cc_tlast),
250
+ .m_axis_tid(),
251
+ .m_axis_tdest(),
252
+ .m_axis_tuser(m_axis_cc_tuser)
253
+ );
254
+
255
+ wire [AXIL_ADDR_WIDTH-1:0] axil_ctrl_awaddr;
256
+ wire [2:0] axil_ctrl_awprot;
257
+ wire axil_ctrl_awvalid;
258
+ wire axil_ctrl_awready;
259
+ wire [AXIL_DATA_WIDTH-1:0] axil_ctrl_wdata;
260
+ wire [AXIL_STRB_WIDTH-1:0] axil_ctrl_wstrb;
261
+ wire axil_ctrl_wvalid;
262
+ wire axil_ctrl_wready;
263
+ wire [1:0] axil_ctrl_bresp;
264
+ wire axil_ctrl_bvalid;
265
+ wire axil_ctrl_bready;
266
+ wire [AXIL_ADDR_WIDTH-1:0] axil_ctrl_araddr;
267
+ wire [2:0] axil_ctrl_arprot;
268
+ wire axil_ctrl_arvalid;
269
+ wire axil_ctrl_arready;
270
+ wire [AXIL_DATA_WIDTH-1:0] axil_ctrl_rdata;
271
+ wire [1:0] axil_ctrl_rresp;
272
+ wire axil_ctrl_rvalid;
273
+ wire axil_ctrl_rready;
274
+
275
+ wire [AXI_ID_WIDTH-1:0] axi_awid;
276
+ wire [AXI_ADDR_WIDTH-1:0] axi_awaddr;
277
+ wire [7:0] axi_awlen;
278
+ wire [2:0] axi_awsize;
279
+ wire [1:0] axi_awburst;
280
+ wire axi_awlock;
281
+ wire [3:0] axi_awcache;
282
+ wire [2:0] axi_awprot;
283
+ wire axi_awvalid;
284
+ wire axi_awready;
285
+ wire [AXI_DATA_WIDTH-1:0] axi_wdata;
286
+ wire [AXI_STRB_WIDTH-1:0] axi_wstrb;
287
+ wire axi_wlast;
288
+ wire axi_wvalid;
289
+ wire axi_wready;
290
+ wire [AXI_ID_WIDTH-1:0] axi_bid;
291
+ wire [1:0] axi_bresp;
292
+ wire axi_bvalid;
293
+ wire axi_bready;
294
+ wire [AXI_ID_WIDTH-1:0] axi_arid;
295
+ wire [AXI_ADDR_WIDTH-1:0] axi_araddr;
296
+ wire [7:0] axi_arlen;
297
+ wire [2:0] axi_arsize;
298
+ wire [1:0] axi_arburst;
299
+ wire axi_arlock;
300
+ wire [3:0] axi_arcache;
301
+ wire [2:0] axi_arprot;
302
+ wire axi_arvalid;
303
+ wire axi_arready;
304
+ wire [AXI_ID_WIDTH-1:0] axi_rid;
305
+ wire [AXI_DATA_WIDTH-1:0] axi_rdata;
306
+ wire [1:0] axi_rresp;
307
+ wire axi_rlast;
308
+ wire axi_rvalid;
309
+ wire axi_rready;
310
+
311
+ wire [AXI_ID_WIDTH-1:0] axi_dma_awid;
312
+ wire [AXI_ADDR_WIDTH-1:0] axi_dma_awaddr;
313
+ wire [7:0] axi_dma_awlen;
314
+ wire [2:0] axi_dma_awsize;
315
+ wire [1:0] axi_dma_awburst;
316
+ wire axi_dma_awlock;
317
+ wire [3:0] axi_dma_awcache;
318
+ wire [2:0] axi_dma_awprot;
319
+ wire axi_dma_awvalid;
320
+ wire axi_dma_awready;
321
+ wire [AXI_DATA_WIDTH-1:0] axi_dma_wdata;
322
+ wire [AXI_STRB_WIDTH-1:0] axi_dma_wstrb;
323
+ wire axi_dma_wlast;
324
+ wire axi_dma_wvalid;
325
+ wire axi_dma_wready;
326
+ wire [AXI_ID_WIDTH-1:0] axi_dma_bid;
327
+ wire [1:0] axi_dma_bresp;
328
+ wire axi_dma_bvalid;
329
+ wire axi_dma_bready;
330
+ wire [AXI_ID_WIDTH-1:0] axi_dma_arid;
331
+ wire [AXI_ADDR_WIDTH-1:0] axi_dma_araddr;
332
+ wire [7:0] axi_dma_arlen;
333
+ wire [2:0] axi_dma_arsize;
334
+ wire [1:0] axi_dma_arburst;
335
+ wire axi_dma_arlock;
336
+ wire [3:0] axi_dma_arcache;
337
+ wire [2:0] axi_dma_arprot;
338
+ wire axi_dma_arvalid;
339
+ wire axi_dma_arready;
340
+ wire [AXI_ID_WIDTH-1:0] axi_dma_rid;
341
+ wire [AXI_DATA_WIDTH-1:0] axi_dma_rdata;
342
+ wire [1:0] axi_dma_rresp;
343
+ wire axi_dma_rlast;
344
+ wire axi_dma_rvalid;
345
+ wire axi_dma_rready;
346
+
347
+ // PCIe DMA control
348
+ wire [PCIE_ADDR_WIDTH-1:0] pcie_dma_read_desc_pcie_addr;
349
+ wire [AXI_ADDR_WIDTH-1:0] pcie_dma_read_desc_axi_addr;
350
+ wire [15:0] pcie_dma_read_desc_len;
351
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_tag;
352
+ wire pcie_dma_read_desc_valid;
353
+ wire pcie_dma_read_desc_ready;
354
+
355
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_status_tag;
356
+ wire [3:0] pcie_dma_read_desc_status_error;
357
+ wire pcie_dma_read_desc_status_valid;
358
+
359
+ wire [PCIE_ADDR_WIDTH-1:0] pcie_dma_write_desc_pcie_addr;
360
+ wire [AXI_ADDR_WIDTH-1:0] pcie_dma_write_desc_axi_addr;
361
+ wire [15:0] pcie_dma_write_desc_len;
362
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_tag;
363
+ wire pcie_dma_write_desc_valid;
364
+ wire pcie_dma_write_desc_ready;
365
+
366
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_status_tag;
367
+ wire [3:0] pcie_dma_write_desc_status_error;
368
+ wire pcie_dma_write_desc_status_valid;
369
+
370
+ wire pcie_dma_enable;
371
+
372
+ // Error handling
373
+ wire [2:0] status_error_uncor_int;
374
+ wire [2:0] status_error_cor_int;
375
+
376
+ wire [31:0] msi_irq;
377
+
378
+ wire ext_tag_enable;
379
+
380
+ // control registers
381
+ reg axil_ctrl_awready_reg = 1'b0, axil_ctrl_awready_next;
382
+ reg axil_ctrl_wready_reg = 1'b0, axil_ctrl_wready_next;
383
+ reg [1:0] axil_ctrl_bresp_reg = 2'b00, axil_ctrl_bresp_next;
384
+ reg axil_ctrl_bvalid_reg = 1'b0, axil_ctrl_bvalid_next;
385
+ reg axil_ctrl_arready_reg = 1'b0, axil_ctrl_arready_next;
386
+ reg [AXIL_DATA_WIDTH-1:0] axil_ctrl_rdata_reg = {AXIL_DATA_WIDTH{1'b0}}, axil_ctrl_rdata_next;
387
+ reg [1:0] axil_ctrl_rresp_reg = 2'b00, axil_ctrl_rresp_next;
388
+ reg axil_ctrl_rvalid_reg = 1'b0, axil_ctrl_rvalid_next;
389
+
390
+ reg [PCIE_ADDR_WIDTH-1:0] pcie_dma_read_desc_pcie_addr_reg = 0, pcie_dma_read_desc_pcie_addr_next;
391
+ reg [AXI_ADDR_WIDTH-1:0] pcie_dma_read_desc_axi_addr_reg = 0, pcie_dma_read_desc_axi_addr_next;
392
+ reg [15:0] pcie_dma_read_desc_len_reg = 0, pcie_dma_read_desc_len_next;
393
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_tag_reg = 0, pcie_dma_read_desc_tag_next;
394
+ reg pcie_dma_read_desc_valid_reg = 0, pcie_dma_read_desc_valid_next;
395
+
396
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_status_tag_reg = 0, pcie_dma_read_desc_status_tag_next;
397
+ reg [31:0] pcie_dma_read_desc_status_error_reg = 0, pcie_dma_read_desc_status_error_next;
398
+ reg pcie_dma_read_desc_status_valid_reg = 0, pcie_dma_read_desc_status_valid_next;
399
+
400
+ reg [PCIE_ADDR_WIDTH-1:0] pcie_dma_write_desc_pcie_addr_reg = 0, pcie_dma_write_desc_pcie_addr_next;
401
+ reg [AXI_ADDR_WIDTH-1:0] pcie_dma_write_desc_axi_addr_reg = 0, pcie_dma_write_desc_axi_addr_next;
402
+ reg [15:0] pcie_dma_write_desc_len_reg = 0, pcie_dma_write_desc_len_next;
403
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_tag_reg = 0, pcie_dma_write_desc_tag_next;
404
+ reg pcie_dma_write_desc_valid_reg = 0, pcie_dma_write_desc_valid_next;
405
+
406
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_status_tag_reg = 0, pcie_dma_write_desc_status_tag_next;
407
+ reg [31:0] pcie_dma_write_desc_status_error_reg = 0, pcie_dma_write_desc_status_error_next;
408
+ reg pcie_dma_write_desc_status_valid_reg = 0, pcie_dma_write_desc_status_valid_next;
409
+
410
+ reg pcie_dma_enable_reg = 0, pcie_dma_enable_next;
411
+
412
+ reg [31:0] pcie_rq_count_reg = 0;
413
+ reg [31:0] pcie_rc_count_reg = 0;
414
+ reg [31:0] pcie_cq_count_reg = 0;
415
+ reg [31:0] pcie_cc_count_reg = 0;
416
+
417
+ assign axil_ctrl_awready = axil_ctrl_awready_reg;
418
+ assign axil_ctrl_wready = axil_ctrl_wready_reg;
419
+ assign axil_ctrl_bresp = axil_ctrl_bresp_reg;
420
+ assign axil_ctrl_bvalid = axil_ctrl_bvalid_reg;
421
+ assign axil_ctrl_arready = axil_ctrl_arready_reg;
422
+ assign axil_ctrl_rdata = axil_ctrl_rdata_reg;
423
+ assign axil_ctrl_rresp = axil_ctrl_rresp_reg;
424
+ assign axil_ctrl_rvalid = axil_ctrl_rvalid_reg;
425
+
426
+ assign pcie_dma_read_desc_pcie_addr = pcie_dma_read_desc_pcie_addr_reg;
427
+ assign pcie_dma_read_desc_axi_addr = pcie_dma_read_desc_axi_addr_reg;
428
+ assign pcie_dma_read_desc_len = pcie_dma_read_desc_len_reg;
429
+ assign pcie_dma_read_desc_tag = pcie_dma_read_desc_tag_reg;
430
+ assign pcie_dma_read_desc_valid = pcie_dma_read_desc_valid_reg;
431
+ assign pcie_dma_write_desc_pcie_addr = pcie_dma_write_desc_pcie_addr_reg;
432
+ assign pcie_dma_write_desc_axi_addr = pcie_dma_write_desc_axi_addr_reg;
433
+ assign pcie_dma_write_desc_len = pcie_dma_write_desc_len_reg;
434
+ assign pcie_dma_write_desc_tag = pcie_dma_write_desc_tag_reg;
435
+ assign pcie_dma_write_desc_valid = pcie_dma_write_desc_valid_reg;
436
+ assign pcie_dma_enable = pcie_dma_enable_reg;
437
+
438
+ assign msi_irq[0] = pcie_dma_read_desc_status_valid || pcie_dma_write_desc_status_valid;
439
+ assign msi_irq[31:1] = 0;
440
+
441
+ always @* begin
442
+ axil_ctrl_awready_next = 1'b0;
443
+ axil_ctrl_wready_next = 1'b0;
444
+ axil_ctrl_bresp_next = 2'b00;
445
+ axil_ctrl_bvalid_next = axil_ctrl_bvalid_reg && !axil_ctrl_bready;
446
+ axil_ctrl_arready_next = 1'b0;
447
+ axil_ctrl_rdata_next = {AXIL_DATA_WIDTH{1'b0}};
448
+ axil_ctrl_rresp_next = 2'b00;
449
+ axil_ctrl_rvalid_next = axil_ctrl_rvalid_reg && !axil_ctrl_rready;
450
+
451
+ pcie_dma_read_desc_pcie_addr_next = pcie_dma_read_desc_pcie_addr_reg;
452
+ pcie_dma_read_desc_axi_addr_next = pcie_dma_read_desc_axi_addr_reg;
453
+ pcie_dma_read_desc_len_next = pcie_dma_read_desc_len_reg;
454
+ pcie_dma_read_desc_tag_next = pcie_dma_read_desc_tag_reg;
455
+ pcie_dma_read_desc_valid_next = pcie_dma_read_desc_valid_reg && !pcie_dma_read_desc_ready;
456
+
457
+ pcie_dma_read_desc_status_tag_next = pcie_dma_read_desc_status_tag_reg;
458
+ pcie_dma_read_desc_status_error_next = pcie_dma_read_desc_status_error_reg;
459
+ pcie_dma_read_desc_status_valid_next = pcie_dma_read_desc_status_valid_reg;
460
+
461
+ pcie_dma_write_desc_pcie_addr_next = pcie_dma_write_desc_pcie_addr_reg;
462
+ pcie_dma_write_desc_axi_addr_next = pcie_dma_write_desc_axi_addr_reg;
463
+ pcie_dma_write_desc_len_next = pcie_dma_write_desc_len_reg;
464
+ pcie_dma_write_desc_tag_next = pcie_dma_write_desc_tag_reg;
465
+ pcie_dma_write_desc_valid_next = pcie_dma_write_desc_valid_reg && !pcie_dma_read_desc_ready;
466
+
467
+ pcie_dma_write_desc_status_tag_next = pcie_dma_write_desc_status_tag_reg;
468
+ pcie_dma_write_desc_status_error_next = pcie_dma_write_desc_status_error_reg;
469
+ pcie_dma_write_desc_status_valid_next = pcie_dma_write_desc_status_valid_reg;
470
+
471
+ pcie_dma_enable_next = pcie_dma_enable_reg;
472
+
473
+ if (axil_ctrl_awvalid && axil_ctrl_wvalid && !axil_ctrl_bvalid) begin
474
+ // write operation
475
+ axil_ctrl_awready_next = 1'b1;
476
+ axil_ctrl_wready_next = 1'b1;
477
+ axil_ctrl_bresp_next = 2'b00;
478
+ axil_ctrl_bvalid_next = 1'b1;
479
+
480
+ case ({axil_ctrl_awaddr[15:2], 2'b00})
481
+ 16'h0000: pcie_dma_enable_next = axil_ctrl_wdata;
482
+ 16'h0100: pcie_dma_read_desc_pcie_addr_next[31:0] = axil_ctrl_wdata;
483
+ 16'h0104: pcie_dma_read_desc_pcie_addr_next[63:32] = axil_ctrl_wdata;
484
+ 16'h0108: pcie_dma_read_desc_axi_addr_next[31:0] = axil_ctrl_wdata;
485
+ //16'h010C: pcie_dma_read_desc_axi_addr_next[63:32] = axil_ctrl_wdata;
486
+ 16'h0110: pcie_dma_read_desc_len_next = axil_ctrl_wdata;
487
+ 16'h0114: begin
488
+ pcie_dma_read_desc_tag_next = axil_ctrl_wdata;
489
+ pcie_dma_read_desc_valid_next = 1'b1;
490
+ end
491
+ 16'h0200: pcie_dma_write_desc_pcie_addr_next[31:0] = axil_ctrl_wdata;
492
+ 16'h0204: pcie_dma_write_desc_pcie_addr_next[63:32] = axil_ctrl_wdata;
493
+ 16'h0208: pcie_dma_write_desc_axi_addr_next[31:0] = axil_ctrl_wdata;
494
+ //16'h020C: pcie_dma_write_desc_axi_addr_next[63:32] = axil_ctrl_wdata;
495
+ 16'h0210: pcie_dma_write_desc_len_next = axil_ctrl_wdata;
496
+ 16'h0214: begin
497
+ pcie_dma_write_desc_tag_next = axil_ctrl_wdata;
498
+ pcie_dma_write_desc_valid_next = 1'b1;
499
+ end
500
+ endcase
501
+ end
502
+
503
+ if (axil_ctrl_arvalid && !axil_ctrl_rvalid) begin
504
+ // read operation
505
+ axil_ctrl_arready_next = 1'b1;
506
+ axil_ctrl_rresp_next = 2'b00;
507
+ axil_ctrl_rvalid_next = 1'b1;
508
+
509
+ case ({axil_ctrl_araddr[15:2], 2'b00})
510
+ 16'h0000: axil_ctrl_rdata_next = pcie_dma_enable_reg;
511
+ 16'h0118: begin
512
+ axil_ctrl_rdata_next[7:0] = pcie_dma_read_desc_status_tag_reg;
513
+ axil_ctrl_rdata_next[15:8] = pcie_dma_read_desc_status_error_reg;
514
+ axil_ctrl_rdata_next[31] = pcie_dma_read_desc_status_valid_reg;
515
+ pcie_dma_read_desc_status_valid_next = 1'b0;
516
+ end
517
+ 16'h0218: begin
518
+ axil_ctrl_rdata_next[7:0] = pcie_dma_write_desc_status_tag_reg;
519
+ axil_ctrl_rdata_next[15:8] = pcie_dma_write_desc_status_error_reg;
520
+ axil_ctrl_rdata_next[31] = pcie_dma_write_desc_status_valid_reg;
521
+ pcie_dma_write_desc_status_valid_next = 1'b0;
522
+ end
523
+ 16'h0400: axil_ctrl_rdata_next = pcie_rq_count_reg;
524
+ 16'h0404: axil_ctrl_rdata_next = pcie_rc_count_reg;
525
+ 16'h0408: axil_ctrl_rdata_next = pcie_cq_count_reg;
526
+ 16'h040C: axil_ctrl_rdata_next = pcie_cc_count_reg;
527
+ endcase
528
+ end
529
+
530
+ if (pcie_dma_read_desc_status_valid) begin
531
+ pcie_dma_read_desc_status_tag_next = pcie_dma_read_desc_status_tag;
532
+ pcie_dma_read_desc_status_error_next = pcie_dma_read_desc_status_error;
533
+ pcie_dma_read_desc_status_valid_next = pcie_dma_read_desc_status_valid;
534
+ end
535
+
536
+ if (pcie_dma_write_desc_status_valid) begin
537
+ pcie_dma_write_desc_status_tag_next = pcie_dma_write_desc_status_tag;
538
+ pcie_dma_write_desc_status_error_next = pcie_dma_write_desc_status_error;
539
+ pcie_dma_write_desc_status_valid_next = pcie_dma_write_desc_status_valid;
540
+ end
541
+ end
542
+
543
+ always @(posedge clk) begin
544
+ axil_ctrl_awready_reg <= axil_ctrl_awready_next;
545
+ axil_ctrl_wready_reg <= axil_ctrl_wready_next;
546
+ axil_ctrl_bresp_reg <= axil_ctrl_bresp_next;
547
+ axil_ctrl_bvalid_reg <= axil_ctrl_bvalid_next;
548
+ axil_ctrl_arready_reg <= axil_ctrl_arready_next;
549
+ axil_ctrl_rdata_reg <= axil_ctrl_rdata_next;
550
+ axil_ctrl_rresp_reg <= axil_ctrl_rresp_next;
551
+ axil_ctrl_rvalid_reg <= axil_ctrl_rvalid_next;
552
+
553
+ pcie_dma_read_desc_pcie_addr_reg <= pcie_dma_read_desc_pcie_addr_next;
554
+ pcie_dma_read_desc_axi_addr_reg <= pcie_dma_read_desc_axi_addr_next;
555
+ pcie_dma_read_desc_len_reg <= pcie_dma_read_desc_len_next;
556
+ pcie_dma_read_desc_tag_reg <= pcie_dma_read_desc_tag_next;
557
+ pcie_dma_read_desc_valid_reg <= pcie_dma_read_desc_valid_next;
558
+
559
+ pcie_dma_read_desc_status_tag_reg <= pcie_dma_read_desc_status_tag_next;
560
+ pcie_dma_read_desc_status_error_reg <= pcie_dma_read_desc_status_error_next;
561
+ pcie_dma_read_desc_status_valid_reg <= pcie_dma_read_desc_status_valid_next;
562
+
563
+ pcie_dma_write_desc_pcie_addr_reg <= pcie_dma_write_desc_pcie_addr_next;
564
+ pcie_dma_write_desc_axi_addr_reg <= pcie_dma_write_desc_axi_addr_next;
565
+ pcie_dma_write_desc_len_reg <= pcie_dma_write_desc_len_next;
566
+ pcie_dma_write_desc_tag_reg <= pcie_dma_write_desc_tag_next;
567
+ pcie_dma_write_desc_valid_reg <= pcie_dma_write_desc_valid_next;
568
+
569
+ pcie_dma_write_desc_status_tag_reg <= pcie_dma_write_desc_status_tag_next;
570
+ pcie_dma_write_desc_status_error_reg <= pcie_dma_write_desc_status_error_next;
571
+ pcie_dma_write_desc_status_valid_reg <= pcie_dma_write_desc_status_valid_next;
572
+
573
+ pcie_dma_enable_reg <= pcie_dma_enable_next;
574
+
575
+ if (m_axis_rq_tready && m_axis_rq_tvalid && m_axis_rq_tlast) begin
576
+ pcie_rq_count_reg <= pcie_rq_count_reg + 1;
577
+ end
578
+
579
+ if (s_axis_rc_tready && s_axis_rc_tvalid && s_axis_rc_tlast) begin
580
+ pcie_rc_count_reg <= pcie_rc_count_reg + 1;
581
+ end
582
+
583
+ if (s_axis_cq_tready && s_axis_cq_tvalid && s_axis_cq_tlast) begin
584
+ pcie_cq_count_reg <= pcie_cq_count_reg + 1;
585
+ end
586
+
587
+ if (m_axis_cc_tready && m_axis_cc_tvalid && m_axis_cc_tlast) begin
588
+ pcie_cc_count_reg <= pcie_cc_count_reg + 1;
589
+ end
590
+
591
+ if (rst) begin
592
+ axil_ctrl_awready_reg <= 1'b0;
593
+ axil_ctrl_wready_reg <= 1'b0;
594
+ axil_ctrl_bvalid_reg <= 1'b0;
595
+ axil_ctrl_arready_reg <= 1'b0;
596
+ axil_ctrl_rvalid_reg <= 1'b0;
597
+
598
+ pcie_dma_read_desc_valid_reg <= 1'b0;
599
+ pcie_dma_read_desc_status_valid_reg <= 1'b0;
600
+ pcie_dma_write_desc_valid_reg <= 1'b0;
601
+ pcie_dma_write_desc_status_valid_reg <= 1'b0;
602
+ pcie_dma_enable_reg <= 1'b0;
603
+
604
+ pcie_rq_count_reg <= 0;
605
+ pcie_rc_count_reg <= 0;
606
+ pcie_cq_count_reg <= 0;
607
+ pcie_cc_count_reg <= 0;
608
+ end
609
+ end
610
+
611
+ assign led = 3'd0;
612
+
613
+ pcie_us_cfg #(
614
+ .PF_COUNT(1),
615
+ .VF_COUNT(0),
616
+ .VF_OFFSET(4),
617
+ .PCIE_CAP_OFFSET(12'h070)
618
+ )
619
+ pcie_us_cfg_inst (
620
+ .clk(clk),
621
+ .rst(rst),
622
+
623
+ /*
624
+ * Configuration outputs
625
+ */
626
+ .ext_tag_enable(ext_tag_enable),
627
+ .max_read_request_size(),
628
+ .max_payload_size(),
629
+
630
+ /*
631
+ * Interface to Ultrascale PCIe IP core
632
+ */
633
+ .cfg_mgmt_addr(cfg_mgmt_addr),
634
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
635
+ .cfg_mgmt_write(cfg_mgmt_write),
636
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
637
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
638
+ .cfg_mgmt_read(cfg_mgmt_read),
639
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
640
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done)
641
+ );
642
+
643
+ pcie_us_axil_master #(
644
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
645
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
646
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
647
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
648
+ .AXI_DATA_WIDTH(AXIL_DATA_WIDTH),
649
+ .AXI_ADDR_WIDTH(AXIL_ADDR_WIDTH),
650
+ .ENABLE_PARITY(0)
651
+ )
652
+ pcie_us_axil_master_inst (
653
+ .clk(clk),
654
+ .rst(rst),
655
+
656
+ /*
657
+ * AXI input (CQ)
658
+ */
659
+ .s_axis_cq_tdata(axis_cq_tdata_bar_0),
660
+ .s_axis_cq_tkeep(axis_cq_tkeep_bar_0),
661
+ .s_axis_cq_tvalid(axis_cq_tvalid_bar_0),
662
+ .s_axis_cq_tready(axis_cq_tready_bar_0),
663
+ .s_axis_cq_tlast(axis_cq_tlast_bar_0),
664
+ .s_axis_cq_tuser(axis_cq_tuser_bar_0),
665
+
666
+ /*
667
+ * AXI input (CC)
668
+ */
669
+ .m_axis_cc_tdata(axis_cc_tdata_bar_0),
670
+ .m_axis_cc_tkeep(axis_cc_tkeep_bar_0),
671
+ .m_axis_cc_tvalid(axis_cc_tvalid_bar_0),
672
+ .m_axis_cc_tready(axis_cc_tready_bar_0),
673
+ .m_axis_cc_tlast(axis_cc_tlast_bar_0),
674
+ .m_axis_cc_tuser(axis_cc_tuser_bar_0),
675
+
676
+ /*
677
+ * AXI Lite Master output
678
+ */
679
+ .m_axil_awaddr(axil_ctrl_awaddr),
680
+ .m_axil_awprot(axil_ctrl_awprot),
681
+ .m_axil_awvalid(axil_ctrl_awvalid),
682
+ .m_axil_awready(axil_ctrl_awready),
683
+ .m_axil_wdata(axil_ctrl_wdata),
684
+ .m_axil_wstrb(axil_ctrl_wstrb),
685
+ .m_axil_wvalid(axil_ctrl_wvalid),
686
+ .m_axil_wready(axil_ctrl_wready),
687
+ .m_axil_bresp(axil_ctrl_bresp),
688
+ .m_axil_bvalid(axil_ctrl_bvalid),
689
+ .m_axil_bready(axil_ctrl_bready),
690
+ .m_axil_araddr(axil_ctrl_araddr),
691
+ .m_axil_arprot(axil_ctrl_arprot),
692
+ .m_axil_arvalid(axil_ctrl_arvalid),
693
+ .m_axil_arready(axil_ctrl_arready),
694
+ .m_axil_rdata(axil_ctrl_rdata),
695
+ .m_axil_rresp(axil_ctrl_rresp),
696
+ .m_axil_rvalid(axil_ctrl_rvalid),
697
+ .m_axil_rready(axil_ctrl_rready),
698
+
699
+ /*
700
+ * Configuration
701
+ */
702
+ .completer_id({8'd0, 5'd0, 3'd0}),
703
+ .completer_id_enable(1'b0),
704
+
705
+ /*
706
+ * Status
707
+ */
708
+ .status_error_cor(status_error_cor_int[0]),
709
+ .status_error_uncor(status_error_uncor_int[0])
710
+ );
711
+
712
+ pcie_us_axi_master #(
713
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
714
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
715
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
716
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
717
+ .AXI_DATA_WIDTH(AXI_DATA_WIDTH),
718
+ .AXI_ADDR_WIDTH(AXI_ADDR_WIDTH),
719
+ .AXI_STRB_WIDTH(AXI_STRB_WIDTH),
720
+ .AXI_ID_WIDTH(AXI_ID_WIDTH)
721
+ )
722
+ pcie_us_axi_master_inst (
723
+ .clk(clk),
724
+ .rst(rst),
725
+
726
+ /*
727
+ * AXI input (CQ)
728
+ */
729
+ .s_axis_cq_tdata(axis_cq_tdata_bar_2),
730
+ .s_axis_cq_tkeep(axis_cq_tkeep_bar_2),
731
+ .s_axis_cq_tvalid(axis_cq_tvalid_bar_2),
732
+ .s_axis_cq_tready(axis_cq_tready_bar_2),
733
+ .s_axis_cq_tlast(axis_cq_tlast_bar_2),
734
+ .s_axis_cq_tuser(axis_cq_tuser_bar_2),
735
+
736
+ /*
737
+ * AXI output (CC)
738
+ */
739
+ .m_axis_cc_tdata(axis_cc_tdata_bar_2),
740
+ .m_axis_cc_tkeep(axis_cc_tkeep_bar_2),
741
+ .m_axis_cc_tvalid(axis_cc_tvalid_bar_2),
742
+ .m_axis_cc_tready(axis_cc_tready_bar_2),
743
+ .m_axis_cc_tlast(axis_cc_tlast_bar_2),
744
+ .m_axis_cc_tuser(axis_cc_tuser_bar_2),
745
+
746
+ /*
747
+ * AXI Master output
748
+ */
749
+ .m_axi_awid(axi_awid),
750
+ .m_axi_awaddr(axi_awaddr),
751
+ .m_axi_awlen(axi_awlen),
752
+ .m_axi_awsize(axi_awsize),
753
+ .m_axi_awburst(axi_awburst),
754
+ .m_axi_awlock(axi_awlock),
755
+ .m_axi_awcache(axi_awcache),
756
+ .m_axi_awprot(axi_awprot),
757
+ .m_axi_awvalid(axi_awvalid),
758
+ .m_axi_awready(axi_awready),
759
+ .m_axi_wdata(axi_wdata),
760
+ .m_axi_wstrb(axi_wstrb),
761
+ .m_axi_wlast(axi_wlast),
762
+ .m_axi_wvalid(axi_wvalid),
763
+ .m_axi_wready(axi_wready),
764
+ .m_axi_bid(axi_bid),
765
+ .m_axi_bresp(axi_bresp),
766
+ .m_axi_bvalid(axi_bvalid),
767
+ .m_axi_bready(axi_bready),
768
+ .m_axi_arid(axi_arid),
769
+ .m_axi_araddr(axi_araddr),
770
+ .m_axi_arlen(axi_arlen),
771
+ .m_axi_arsize(axi_arsize),
772
+ .m_axi_arburst(axi_arburst),
773
+ .m_axi_arlock(axi_arlock),
774
+ .m_axi_arcache(axi_arcache),
775
+ .m_axi_arprot(axi_arprot),
776
+ .m_axi_arvalid(axi_arvalid),
777
+ .m_axi_arready(axi_arready),
778
+ .m_axi_rid(axi_rid),
779
+ .m_axi_rdata(axi_rdata),
780
+ .m_axi_rresp(axi_rresp),
781
+ .m_axi_rlast(axi_rlast),
782
+ .m_axi_rvalid(axi_rvalid),
783
+ .m_axi_rready(axi_rready),
784
+
785
+ /*
786
+ * Configuration
787
+ */
788
+ .completer_id({8'd0, 5'd0, 3'd1}),
789
+ .completer_id_enable(1'b0),
790
+ .max_payload_size(cfg_max_payload),
791
+
792
+ /*
793
+ * Status
794
+ */
795
+ .status_error_cor(status_error_cor_int[1]),
796
+ .status_error_uncor(status_error_uncor_int[1])
797
+ );
798
+
799
+ axi_ram #(
800
+ .DATA_WIDTH(AXI_DATA_WIDTH),
801
+ .ADDR_WIDTH(16),
802
+ .ID_WIDTH(AXI_ID_WIDTH),
803
+ .PIPELINE_OUTPUT(1)
804
+ )
805
+ axi_ram_inst (
806
+ .clk(clk),
807
+ .rst(rst),
808
+ .s_axi_awid(axi_awid),
809
+ .s_axi_awaddr(axi_awaddr),
810
+ .s_axi_awlen(axi_awlen),
811
+ .s_axi_awsize(axi_awsize),
812
+ .s_axi_awburst(axi_awburst),
813
+ .s_axi_awlock(axi_awlock),
814
+ .s_axi_awcache(axi_awcache),
815
+ .s_axi_awprot(axi_awprot),
816
+ .s_axi_awvalid(axi_awvalid),
817
+ .s_axi_awready(axi_awready),
818
+ .s_axi_wdata(axi_wdata),
819
+ .s_axi_wstrb(axi_wstrb),
820
+ .s_axi_wlast(axi_wlast),
821
+ .s_axi_wvalid(axi_wvalid),
822
+ .s_axi_wready(axi_wready),
823
+ .s_axi_bid(axi_bid),
824
+ .s_axi_bresp(axi_bresp),
825
+ .s_axi_bvalid(axi_bvalid),
826
+ .s_axi_bready(axi_bready),
827
+ .s_axi_arid(axi_arid),
828
+ .s_axi_araddr(axi_araddr),
829
+ .s_axi_arlen(axi_arlen),
830
+ .s_axi_arsize(axi_arsize),
831
+ .s_axi_arburst(axi_arburst),
832
+ .s_axi_arlock(axi_arlock),
833
+ .s_axi_arcache(axi_arcache),
834
+ .s_axi_arprot(axi_arprot),
835
+ .s_axi_arvalid(axi_arvalid),
836
+ .s_axi_arready(axi_arready),
837
+ .s_axi_rid(axi_rid),
838
+ .s_axi_rdata(axi_rdata),
839
+ .s_axi_rresp(axi_rresp),
840
+ .s_axi_rlast(axi_rlast),
841
+ .s_axi_rvalid(axi_rvalid),
842
+ .s_axi_rready(axi_rready)
843
+ );
844
+
845
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata_r;
846
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep_r;
847
+ wire axis_rc_tlast_r;
848
+ wire axis_rc_tready_r;
849
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser_r;
850
+ wire axis_rc_tvalid_r;
851
+
852
+ axis_register #(
853
+ .DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
854
+ .KEEP_ENABLE(1),
855
+ .KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
856
+ .LAST_ENABLE(1),
857
+ .ID_ENABLE(0),
858
+ .DEST_ENABLE(0),
859
+ .USER_ENABLE(1),
860
+ .USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH)
861
+ )
862
+ rc_reg (
863
+ .clk(clk),
864
+ .rst(rst),
865
+
866
+ /*
867
+ * AXI input
868
+ */
869
+ .s_axis_tdata(s_axis_rc_tdata),
870
+ .s_axis_tkeep(s_axis_rc_tkeep),
871
+ .s_axis_tvalid(s_axis_rc_tvalid),
872
+ .s_axis_tready(s_axis_rc_tready),
873
+ .s_axis_tlast(s_axis_rc_tlast),
874
+ .s_axis_tid(0),
875
+ .s_axis_tdest(0),
876
+ .s_axis_tuser(s_axis_rc_tuser),
877
+
878
+ /*
879
+ * AXI output
880
+ */
881
+ .m_axis_tdata(axis_rc_tdata_r),
882
+ .m_axis_tkeep(axis_rc_tkeep_r),
883
+ .m_axis_tvalid(axis_rc_tvalid_r),
884
+ .m_axis_tready(axis_rc_tready_r),
885
+ .m_axis_tlast(axis_rc_tlast_r),
886
+ .m_axis_tid(),
887
+ .m_axis_tdest(),
888
+ .m_axis_tuser(axis_rc_tuser_r)
889
+ );
890
+
891
+ pcie_us_axi_dma #(
892
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
893
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
894
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
895
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
896
+ .AXI_DATA_WIDTH(AXI_DATA_WIDTH),
897
+ .AXI_ADDR_WIDTH(AXI_ADDR_WIDTH),
898
+ .AXI_STRB_WIDTH(AXI_STRB_WIDTH),
899
+ .AXI_ID_WIDTH(AXI_ID_WIDTH),
900
+ .AXI_MAX_BURST_LEN(256),
901
+ .PCIE_ADDR_WIDTH(PCIE_ADDR_WIDTH),
902
+ .PCIE_TAG_COUNT(256),
903
+ .LEN_WIDTH(16),
904
+ .TAG_WIDTH(DMA_TAG_WIDTH)
905
+ )
906
+ pcie_us_axi_dma_inst (
907
+ .clk(clk),
908
+ .rst(rst),
909
+
910
+ /*
911
+ * AXI input (RC)
912
+ */
913
+ .s_axis_rc_tdata(axis_rc_tdata_r),
914
+ .s_axis_rc_tkeep(axis_rc_tkeep_r),
915
+ .s_axis_rc_tvalid(axis_rc_tvalid_r),
916
+ .s_axis_rc_tready(axis_rc_tready_r),
917
+ .s_axis_rc_tlast(axis_rc_tlast_r),
918
+ .s_axis_rc_tuser(axis_rc_tuser_r),
919
+
920
+ /*
921
+ * AXI output (RQ)
922
+ */
923
+ .m_axis_rq_tdata(m_axis_rq_tdata),
924
+ .m_axis_rq_tkeep(m_axis_rq_tkeep),
925
+ .m_axis_rq_tvalid(m_axis_rq_tvalid),
926
+ .m_axis_rq_tready(m_axis_rq_tready),
927
+ .m_axis_rq_tlast(m_axis_rq_tlast),
928
+ .m_axis_rq_tuser(m_axis_rq_tuser),
929
+
930
+ /*
931
+ * AXI read descriptor input
932
+ */
933
+ .s_axis_read_desc_pcie_addr(pcie_dma_read_desc_pcie_addr),
934
+ .s_axis_read_desc_axi_addr(pcie_dma_read_desc_axi_addr),
935
+ .s_axis_read_desc_len(pcie_dma_read_desc_len),
936
+ .s_axis_read_desc_tag(pcie_dma_read_desc_tag),
937
+ .s_axis_read_desc_valid(pcie_dma_read_desc_valid),
938
+ .s_axis_read_desc_ready(pcie_dma_read_desc_ready),
939
+
940
+ /*
941
+ * AXI read descriptor status output
942
+ */
943
+ .m_axis_read_desc_status_tag(pcie_dma_read_desc_status_tag),
944
+ .m_axis_read_desc_status_error(pcie_dma_read_desc_status_error),
945
+ .m_axis_read_desc_status_valid(pcie_dma_read_desc_status_valid),
946
+
947
+ /*
948
+ * AXI write descriptor input
949
+ */
950
+ .s_axis_write_desc_pcie_addr(pcie_dma_write_desc_pcie_addr),
951
+ .s_axis_write_desc_axi_addr(pcie_dma_write_desc_axi_addr),
952
+ .s_axis_write_desc_len(pcie_dma_write_desc_len),
953
+ .s_axis_write_desc_tag(pcie_dma_write_desc_tag),
954
+ .s_axis_write_desc_valid(pcie_dma_write_desc_valid),
955
+ .s_axis_write_desc_ready(pcie_dma_write_desc_ready),
956
+
957
+ /*
958
+ * AXI write descriptor status output
959
+ */
960
+ .m_axis_write_desc_status_tag(pcie_dma_write_desc_status_tag),
961
+ .m_axis_write_desc_status_error(pcie_dma_write_desc_status_error),
962
+ .m_axis_write_desc_status_valid(pcie_dma_write_desc_status_valid),
963
+
964
+ /*
965
+ * AXI Master output
966
+ */
967
+ .m_axi_awid(axi_dma_awid),
968
+ .m_axi_awaddr(axi_dma_awaddr),
969
+ .m_axi_awlen(axi_dma_awlen),
970
+ .m_axi_awsize(axi_dma_awsize),
971
+ .m_axi_awburst(axi_dma_awburst),
972
+ .m_axi_awlock(axi_dma_awlock),
973
+ .m_axi_awcache(axi_dma_awcache),
974
+ .m_axi_awprot(axi_dma_awprot),
975
+ .m_axi_awvalid(axi_dma_awvalid),
976
+ .m_axi_awready(axi_dma_awready),
977
+ .m_axi_wdata(axi_dma_wdata),
978
+ .m_axi_wstrb(axi_dma_wstrb),
979
+ .m_axi_wlast(axi_dma_wlast),
980
+ .m_axi_wvalid(axi_dma_wvalid),
981
+ .m_axi_wready(axi_dma_wready),
982
+ .m_axi_bid(axi_dma_bid),
983
+ .m_axi_bresp(axi_dma_bresp),
984
+ .m_axi_bvalid(axi_dma_bvalid),
985
+ .m_axi_bready(axi_dma_bready),
986
+ .m_axi_arid(axi_dma_arid),
987
+ .m_axi_araddr(axi_dma_araddr),
988
+ .m_axi_arlen(axi_dma_arlen),
989
+ .m_axi_arsize(axi_dma_arsize),
990
+ .m_axi_arburst(axi_dma_arburst),
991
+ .m_axi_arlock(axi_dma_arlock),
992
+ .m_axi_arcache(axi_dma_arcache),
993
+ .m_axi_arprot(axi_dma_arprot),
994
+ .m_axi_arvalid(axi_dma_arvalid),
995
+ .m_axi_arready(axi_dma_arready),
996
+ .m_axi_rid(axi_dma_rid),
997
+ .m_axi_rdata(axi_dma_rdata),
998
+ .m_axi_rresp(axi_dma_rresp),
999
+ .m_axi_rlast(axi_dma_rlast),
1000
+ .m_axi_rvalid(axi_dma_rvalid),
1001
+ .m_axi_rready(axi_dma_rready),
1002
+
1003
+ /*
1004
+ * Configuration
1005
+ */
1006
+ .read_enable(pcie_dma_enable),
1007
+ .write_enable(pcie_dma_enable),
1008
+ .ext_tag_enable(ext_tag_enable),
1009
+ .requester_id({8'd0, 5'd0, 3'd0}),
1010
+ .requester_id_enable(1'b0),
1011
+ .max_read_request_size(cfg_max_read_req),
1012
+ .max_payload_size(cfg_max_payload),
1013
+
1014
+ /*
1015
+ * Status
1016
+ */
1017
+ .status_error_cor(status_error_cor_int[2]),
1018
+ .status_error_uncor(status_error_uncor_int[2])
1019
+ );
1020
+
1021
+ axi_ram #(
1022
+ .DATA_WIDTH(AXI_DATA_WIDTH),
1023
+ .ADDR_WIDTH(16),
1024
+ .ID_WIDTH(AXI_ID_WIDTH),
1025
+ .PIPELINE_OUTPUT(1)
1026
+ )
1027
+ axi_dma_ram_inst (
1028
+ .clk(clk),
1029
+ .rst(rst),
1030
+ .s_axi_awid(axi_dma_awid),
1031
+ .s_axi_awaddr(axi_dma_awaddr),
1032
+ .s_axi_awlen(axi_dma_awlen),
1033
+ .s_axi_awsize(axi_dma_awsize),
1034
+ .s_axi_awburst(axi_dma_awburst),
1035
+ .s_axi_awlock(axi_dma_awlock),
1036
+ .s_axi_awcache(axi_dma_awcache),
1037
+ .s_axi_awprot(axi_dma_awprot),
1038
+ .s_axi_awvalid(axi_dma_awvalid),
1039
+ .s_axi_awready(axi_dma_awready),
1040
+ .s_axi_wdata(axi_dma_wdata),
1041
+ .s_axi_wstrb(axi_dma_wstrb),
1042
+ .s_axi_wlast(axi_dma_wlast),
1043
+ .s_axi_wvalid(axi_dma_wvalid),
1044
+ .s_axi_wready(axi_dma_wready),
1045
+ .s_axi_bid(axi_dma_bid),
1046
+ .s_axi_bresp(axi_dma_bresp),
1047
+ .s_axi_bvalid(axi_dma_bvalid),
1048
+ .s_axi_bready(axi_dma_bready),
1049
+ .s_axi_arid(axi_dma_arid),
1050
+ .s_axi_araddr(axi_dma_araddr),
1051
+ .s_axi_arlen(axi_dma_arlen),
1052
+ .s_axi_arsize(axi_dma_arsize),
1053
+ .s_axi_arburst(axi_dma_arburst),
1054
+ .s_axi_arlock(axi_dma_arlock),
1055
+ .s_axi_arcache(axi_dma_arcache),
1056
+ .s_axi_arprot(axi_dma_arprot),
1057
+ .s_axi_arvalid(axi_dma_arvalid),
1058
+ .s_axi_arready(axi_dma_arready),
1059
+ .s_axi_rid(axi_dma_rid),
1060
+ .s_axi_rdata(axi_dma_rdata),
1061
+ .s_axi_rresp(axi_dma_rresp),
1062
+ .s_axi_rlast(axi_dma_rlast),
1063
+ .s_axi_rvalid(axi_dma_rvalid),
1064
+ .s_axi_rready(axi_dma_rready)
1065
+ );
1066
+
1067
+ pulse_merge #(
1068
+ .INPUT_WIDTH(3),
1069
+ .COUNT_WIDTH(4)
1070
+ )
1071
+ status_error_cor_pm_inst (
1072
+ .clk(clk),
1073
+ .rst(rst),
1074
+
1075
+ .pulse_in(status_error_cor_int),
1076
+ .count_out(),
1077
+ .pulse_out(status_error_cor)
1078
+ );
1079
+
1080
+ pulse_merge #(
1081
+ .INPUT_WIDTH(3),
1082
+ .COUNT_WIDTH(4)
1083
+ )
1084
+ status_error_uncor_pm_inst (
1085
+ .clk(clk),
1086
+ .rst(rst),
1087
+
1088
+ .pulse_in(status_error_uncor_int),
1089
+ .count_out(),
1090
+ .pulse_out(status_error_uncor)
1091
+ );
1092
+
1093
+ pcie_us_msi #(
1094
+ .MSI_COUNT(32)
1095
+ )
1096
+ pcie_us_msi_inst (
1097
+ .clk(clk),
1098
+ .rst(rst),
1099
+
1100
+ .msi_irq(msi_irq),
1101
+
1102
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
1103
+ .cfg_interrupt_msi_vf_enable(0),
1104
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
1105
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
1106
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
1107
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
1108
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
1109
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
1110
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
1111
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
1112
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
1113
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
1114
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
1115
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
1116
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
1117
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
1118
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number)
1119
+ );
1120
+
1121
+ endmodule
1122
+
1123
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/sync_reset.v ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an active-high asynchronous reset signal to a given clock by
33
+ * using a pipeline of N registers.
34
+ */
35
+ module sync_reset #(
36
+ parameter N=2 // depth of synchronizer
37
+ )(
38
+ input wire clk,
39
+ input wire rst,
40
+ output wire sync_reset_out
41
+ );
42
+
43
+ reg [N-1:0] sync_reg = {N{1'b1}};
44
+
45
+ assign sync_reset_out = sync_reg[N-1];
46
+
47
+ always @(posedge clk or posedge rst) begin
48
+ if (rst)
49
+ sync_reg <= {N{1'b1}};
50
+ else
51
+ sync_reg <= {sync_reg[N-2:0], 1'b0};
52
+ end
53
+
54
+ endmodule
55
+
56
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/rtl/sync_signal.v ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an asyncronous signal to a given clock by using a pipeline of
33
+ * two registers.
34
+ */
35
+ module sync_signal #(
36
+ parameter WIDTH=1, // width of the input and output signals
37
+ parameter N=2 // depth of synchronizer
38
+ )(
39
+ input wire clk,
40
+ input wire [WIDTH-1:0] in,
41
+ output wire [WIDTH-1:0] out
42
+ );
43
+
44
+ reg [WIDTH-1:0] sync_reg[N-1:0];
45
+
46
+ /*
47
+ * The synchronized output is the last register in the pipeline.
48
+ */
49
+ assign out = sync_reg[N-1];
50
+
51
+ integer k;
52
+
53
+ always @(posedge clk) begin
54
+ sync_reg[0] <= in;
55
+ for (k = 1; k < N; k = k + 1) begin
56
+ sync_reg[k] <= sync_reg[k-1];
57
+ end
58
+ end
59
+
60
+ endmodule
61
+
62
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/tb/fpga_core/Makefile ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020 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
+ TOPLEVEL_LANG = verilog
22
+
23
+ SIM ?= icarus
24
+ WAVES ?= 0
25
+
26
+ COCOTB_HDL_TIMEUNIT = 1ns
27
+ COCOTB_HDL_TIMEPRECISION = 1ps
28
+
29
+ DUT = fpga_core
30
+ TOPLEVEL = $(DUT)
31
+ MODULE = test_$(DUT)
32
+ VERILOG_SOURCES += ../../rtl/$(DUT).v
33
+ VERILOG_SOURCES += ../../rtl/axi_ram.v
34
+ VERILOG_SOURCES += ../../rtl/axis_register.v
35
+ VERILOG_SOURCES += ../../lib/pcie/rtl/axis_arb_mux.v
36
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axil_master.v
37
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma.v
38
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma_rd.v
39
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma_wr.v
40
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master.v
41
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master_rd.v
42
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master_wr.v
43
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axis_cq_demux.v
44
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_cfg.v
45
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_msi.v
46
+ VERILOG_SOURCES += ../../lib/pcie/rtl/arbiter.v
47
+ VERILOG_SOURCES += ../../lib/pcie/rtl/priority_encoder.v
48
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pulse_merge.v
49
+
50
+ # module parameters
51
+ export PARAM_AXIS_PCIE_DATA_WIDTH ?= 512
52
+ export PARAM_AXIS_PCIE_KEEP_WIDTH ?= $(shell expr $(PARAM_AXIS_PCIE_DATA_WIDTH) / 32 )
53
+ export PARAM_AXIS_PCIE_RQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),62,137)
54
+ export PARAM_AXIS_PCIE_RC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),75,161)
55
+ export PARAM_AXIS_PCIE_CQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),88,183)
56
+ export PARAM_AXIS_PCIE_CC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),33,81)
57
+ export PARAM_RQ_SEQ_NUM_WIDTH ?= 6
58
+
59
+ ifeq ($(SIM), icarus)
60
+ PLUSARGS += -fst
61
+
62
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
63
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
64
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
65
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
66
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
67
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
68
+ COMPILE_ARGS += -P $(TOPLEVEL).RQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
69
+
70
+ ifeq ($(WAVES), 1)
71
+ VERILOG_SOURCES += iverilog_dump.v
72
+ COMPILE_ARGS += -s iverilog_dump
73
+ endif
74
+ else ifeq ($(SIM), verilator)
75
+ COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH
76
+
77
+ COMPILE_ARGS += -GAXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
78
+ COMPILE_ARGS += -GAXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
79
+ COMPILE_ARGS += -GAXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
80
+ COMPILE_ARGS += -GAXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
81
+ COMPILE_ARGS += -GAXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
82
+ COMPILE_ARGS += -GAXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
83
+ COMPILE_ARGS += -GRQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
84
+
85
+ ifeq ($(WAVES), 1)
86
+ COMPILE_ARGS += --trace-fst
87
+ endif
88
+ endif
89
+
90
+ include $(shell cocotb-config --makefiles)/Makefile.sim
91
+
92
+ iverilog_dump.v:
93
+ echo 'module iverilog_dump();' > $@
94
+ echo 'initial begin' >> $@
95
+ echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@
96
+ echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@
97
+ echo 'end' >> $@
98
+ echo 'endmodule' >> $@
99
+
100
+ clean::
101
+ @rm -rf iverilog_dump.v
102
+ @rm -rf dump.fst $(TOPLEVEL).fst
snapshots/alexforencich_verilog-pcie_pr20/example/AU250/fpga_axi/tb/fpga_core/test_fpga_core.py ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ """
24
+
25
+ import logging
26
+ import os
27
+
28
+ import cocotb_test.simulator
29
+
30
+ import cocotb
31
+ from cocotb.log import SimLog
32
+ from cocotb.triggers import RisingEdge, FallingEdge, Timer
33
+
34
+ from cocotbext.axi import AxiStreamBus
35
+ from cocotbext.pcie.core import RootComplex
36
+ from cocotbext.pcie.xilinx.us import UltraScalePlusPcieDevice
37
+ from cocotbext.axi.utils import hexdump_str
38
+
39
+
40
+ class TB(object):
41
+ def __init__(self, dut):
42
+ self.dut = dut
43
+
44
+ self.log = SimLog("cocotb.tb")
45
+ self.log.setLevel(logging.DEBUG)
46
+
47
+ # PCIe
48
+ self.rc = RootComplex()
49
+
50
+ self.dev = UltraScalePlusPcieDevice(
51
+ # configuration options
52
+ pcie_generation=3,
53
+ pcie_link_width=16,
54
+ user_clk_frequency=250e6,
55
+ alignment="dword",
56
+ cq_cc_straddle=False,
57
+ rq_rc_straddle=False,
58
+ rc_4tlp_straddle=False,
59
+ enable_pf1=False,
60
+ enable_client_tag=True,
61
+ enable_extended_tag=True,
62
+ enable_parity=False,
63
+ enable_rx_msg_interface=False,
64
+ enable_sriov=False,
65
+ enable_extended_configuration=False,
66
+
67
+ enable_pf0_msi=True,
68
+ enable_pf1_msi=False,
69
+
70
+ # signals
71
+ # Clock and Reset Interface
72
+ user_clk=dut.clk,
73
+ user_reset=dut.rst,
74
+ # user_lnk_up
75
+ # sys_clk
76
+ # sys_clk_gt
77
+ # sys_reset
78
+ # phy_rdy_out
79
+
80
+ # Requester reQuest Interface
81
+ rq_bus=AxiStreamBus.from_prefix(dut, "m_axis_rq"),
82
+ # pcie_rq_seq_num0=dut.s_axis_rq_seq_num_0,
83
+ # pcie_rq_seq_num_vld0=dut.s_axis_rq_seq_num_valid_0,
84
+ # pcie_rq_seq_num1=dut.s_axis_rq_seq_num_1,
85
+ # pcie_rq_seq_num_vld1=dut.s_axis_rq_seq_num_valid_1,
86
+ # pcie_rq_tag0
87
+ # pcie_rq_tag1
88
+ # pcie_rq_tag_av
89
+ # pcie_rq_tag_vld0
90
+ # pcie_rq_tag_vld1
91
+
92
+ # Requester Completion Interface
93
+ rc_bus=AxiStreamBus.from_prefix(dut, "s_axis_rc"),
94
+
95
+ # Completer reQuest Interface
96
+ cq_bus=AxiStreamBus.from_prefix(dut, "s_axis_cq"),
97
+ # pcie_cq_np_req
98
+ # pcie_cq_np_req_count
99
+
100
+ # Completer Completion Interface
101
+ cc_bus=AxiStreamBus.from_prefix(dut, "m_axis_cc"),
102
+
103
+ # Transmit Flow Control Interface
104
+ # pcie_tfc_nph_av=dut.pcie_tfc_nph_av,
105
+ # pcie_tfc_npd_av=dut.pcie_tfc_npd_av,
106
+
107
+ # Configuration Management Interface
108
+ cfg_mgmt_addr=dut.cfg_mgmt_addr,
109
+ cfg_mgmt_function_number=dut.cfg_mgmt_function_number,
110
+ cfg_mgmt_write=dut.cfg_mgmt_write,
111
+ cfg_mgmt_write_data=dut.cfg_mgmt_write_data,
112
+ cfg_mgmt_byte_enable=dut.cfg_mgmt_byte_enable,
113
+ cfg_mgmt_read=dut.cfg_mgmt_read,
114
+ cfg_mgmt_read_data=dut.cfg_mgmt_read_data,
115
+ cfg_mgmt_read_write_done=dut.cfg_mgmt_read_write_done,
116
+ # cfg_mgmt_debug_access
117
+
118
+ # Configuration Status Interface
119
+ # cfg_phy_link_down
120
+ # cfg_phy_link_status
121
+ # cfg_negotiated_width
122
+ # cfg_current_speed
123
+ cfg_max_payload=dut.cfg_max_payload,
124
+ cfg_max_read_req=dut.cfg_max_read_req,
125
+ # cfg_function_status
126
+ # cfg_vf_status
127
+ # cfg_function_power_state
128
+ # cfg_vf_power_state
129
+ # cfg_link_power_state
130
+ # cfg_err_cor_out
131
+ # cfg_err_nonfatal_out
132
+ # cfg_err_fatal_out
133
+ # cfg_local_error_out
134
+ # cfg_local_error_valid
135
+ # cfg_rx_pm_state
136
+ # cfg_tx_pm_state
137
+ # cfg_ltssm_state
138
+ # cfg_rcb_status
139
+ # cfg_obff_enable
140
+ # cfg_pl_status_change
141
+ # cfg_tph_requester_enable
142
+ # cfg_tph_st_mode
143
+ # cfg_vf_tph_requester_enable
144
+ # cfg_vf_tph_st_mode
145
+
146
+ # Configuration Received Message Interface
147
+ # cfg_msg_received
148
+ # cfg_msg_received_data
149
+ # cfg_msg_received_type
150
+
151
+ # Configuration Transmit Message Interface
152
+ # cfg_msg_transmit
153
+ # cfg_msg_transmit_type
154
+ # cfg_msg_transmit_data
155
+ # cfg_msg_transmit_done
156
+
157
+ # Configuration Flow Control Interface
158
+ # cfg_fc_ph=dut.cfg_fc_ph,
159
+ # cfg_fc_pd=dut.cfg_fc_pd,
160
+ # cfg_fc_nph=dut.cfg_fc_nph,
161
+ # cfg_fc_npd=dut.cfg_fc_npd,
162
+ # cfg_fc_cplh=dut.cfg_fc_cplh,
163
+ # cfg_fc_cpld=dut.cfg_fc_cpld,
164
+ # cfg_fc_sel=dut.cfg_fc_sel,
165
+
166
+ # Configuration Control Interface
167
+ # cfg_hot_reset_in
168
+ # cfg_hot_reset_out
169
+ # cfg_config_space_enable
170
+ # cfg_dsn
171
+ # cfg_bus_number
172
+ # cfg_ds_port_number
173
+ # cfg_ds_bus_number
174
+ # cfg_ds_device_number
175
+ # cfg_ds_function_number
176
+ # cfg_power_state_change_ack
177
+ # cfg_power_state_change_interrupt
178
+ cfg_err_cor_in=dut.status_error_cor,
179
+ cfg_err_uncor_in=dut.status_error_uncor,
180
+ # cfg_flr_in_process
181
+ # cfg_flr_done
182
+ # cfg_vf_flr_in_process
183
+ # cfg_vf_flr_func_num
184
+ # cfg_vf_flr_done
185
+ # cfg_pm_aspm_l1_entry_reject
186
+ # cfg_pm_aspm_tx_l0s_entry_disable
187
+ # cfg_req_pm_transition_l23_ready
188
+ # cfg_link_training_enable
189
+
190
+ # Configuration Interrupt Controller Interface
191
+ # cfg_interrupt_int
192
+ # cfg_interrupt_sent
193
+ # cfg_interrupt_pending
194
+ cfg_interrupt_msi_enable=dut.cfg_interrupt_msi_enable,
195
+ cfg_interrupt_msi_mmenable=dut.cfg_interrupt_msi_mmenable,
196
+ cfg_interrupt_msi_mask_update=dut.cfg_interrupt_msi_mask_update,
197
+ cfg_interrupt_msi_data=dut.cfg_interrupt_msi_data,
198
+ # cfg_interrupt_msi_select=dut.cfg_interrupt_msi_select,
199
+ cfg_interrupt_msi_int=dut.cfg_interrupt_msi_int,
200
+ cfg_interrupt_msi_pending_status=dut.cfg_interrupt_msi_pending_status,
201
+ cfg_interrupt_msi_pending_status_data_enable=dut.cfg_interrupt_msi_pending_status_data_enable,
202
+ # cfg_interrupt_msi_pending_status_function_num=dut.cfg_interrupt_msi_pending_status_function_num,
203
+ cfg_interrupt_msi_sent=dut.cfg_interrupt_msi_sent,
204
+ cfg_interrupt_msi_fail=dut.cfg_interrupt_msi_fail,
205
+ # cfg_interrupt_msix_enable
206
+ # cfg_interrupt_msix_mask
207
+ # cfg_interrupt_msix_vf_enable
208
+ # cfg_interrupt_msix_vf_mask
209
+ # cfg_interrupt_msix_address
210
+ # cfg_interrupt_msix_data
211
+ # cfg_interrupt_msix_int
212
+ # cfg_interrupt_msix_vec_pending
213
+ # cfg_interrupt_msix_vec_pending_status
214
+ cfg_interrupt_msi_attr=dut.cfg_interrupt_msi_attr,
215
+ cfg_interrupt_msi_tph_present=dut.cfg_interrupt_msi_tph_present,
216
+ cfg_interrupt_msi_tph_type=dut.cfg_interrupt_msi_tph_type,
217
+ # cfg_interrupt_msi_tph_st_tag=dut.cfg_interrupt_msi_tph_st_tag,
218
+ # cfg_interrupt_msi_function_number=dut.cfg_interrupt_msi_function_number,
219
+
220
+ # Configuration Extend Interface
221
+ # cfg_ext_read_received
222
+ # cfg_ext_write_received
223
+ # cfg_ext_register_number
224
+ # cfg_ext_function_number
225
+ # cfg_ext_write_data
226
+ # cfg_ext_write_byte_enable
227
+ # cfg_ext_read_data
228
+ # cfg_ext_read_data_valid
229
+ )
230
+
231
+ # self.dev.log.setLevel(logging.DEBUG)
232
+
233
+ self.rc.make_port().connect(self.dev)
234
+
235
+ self.dev.functions[0].msi_multiple_message_capable = 5
236
+
237
+ self.dev.functions[0].configure_bar(0, 2**22)
238
+ self.dev.functions[0].configure_bar(2, 2**22)
239
+
240
+ dut.sw.setimmediatevalue(0)
241
+
242
+ async def init(self):
243
+
244
+ await FallingEdge(self.dut.rst)
245
+ await Timer(100, 'ns')
246
+
247
+ await self.rc.enumerate(enable_bus_mastering=True, configure_msi=True)
248
+
249
+
250
+ @cocotb.test()
251
+ async def run_test(dut):
252
+
253
+ tb = TB(dut)
254
+
255
+ await tb.init()
256
+
257
+ mem = tb.rc.mem_pool.alloc_region(16*1024*1024)
258
+ mem_base = mem.get_absolute_address(0)
259
+
260
+ dev_pf0_bar0 = tb.rc.tree[0][0].bar_window[0]
261
+ dev_pf0_bar2 = tb.rc.tree[0][0].bar_window[2]
262
+
263
+ tb.log.info("Test memory write to BAR 2")
264
+
265
+ test_data = b'\x11\x22\x33\x44'
266
+ await dev_pf0_bar2.write(0, test_data)
267
+
268
+ await Timer(100, 'ns')
269
+
270
+ tb.log.info("Test memory read from BAR 2")
271
+
272
+ val = await dev_pf0_bar2.read(0, len(test_data), timeout=1000)
273
+ tb.log.info("Read data: %s", val)
274
+ assert val == test_data
275
+
276
+ tb.log.info("Test DMA")
277
+
278
+ # write packet data
279
+ mem[0:1024] = bytearray([x % 256 for x in range(1024)])
280
+
281
+ # enable DMA
282
+ await dev_pf0_bar0.write_dword(0x000000, 1)
283
+
284
+ # write pcie read descriptor
285
+ await dev_pf0_bar0.write_dword(0x000100, (mem_base+0x0000) & 0xffffffff)
286
+ await dev_pf0_bar0.write_dword(0x000104, (mem_base+0x0000 >> 32) & 0xffffffff)
287
+ await dev_pf0_bar0.write_dword(0x000108, 0x100)
288
+ await dev_pf0_bar0.write_dword(0x000110, 0x400)
289
+ await dev_pf0_bar0.write_dword(0x000114, 0xAA)
290
+
291
+ await Timer(2000, 'ns')
292
+
293
+ # read status
294
+ val = await dev_pf0_bar0.read_dword(0x000118)
295
+ tb.log.info("Status: 0x%x", val)
296
+ assert val == 0x800000AA
297
+
298
+ # write pcie write descriptor
299
+ await dev_pf0_bar0.write_dword(0x000200, (mem_base+0x1000) & 0xffffffff)
300
+ await dev_pf0_bar0.write_dword(0x000204, (mem_base+0x1000 >> 32) & 0xffffffff)
301
+ await dev_pf0_bar0.write_dword(0x000208, 0x100)
302
+ await dev_pf0_bar0.write_dword(0x000210, 0x400)
303
+ await dev_pf0_bar0.write_dword(0x000214, 0x55)
304
+
305
+ await Timer(2000, 'ns')
306
+
307
+ # read status
308
+ val = await dev_pf0_bar0.read_dword(0x000218)
309
+ tb.log.info("Status: 0x%x", val)
310
+ assert val == 0x80000055
311
+
312
+ tb.log.info("%s", mem.hexdump_str(0x1000, 64))
313
+
314
+ assert mem[0:1024] == mem[0x1000:0x1000+1024]
315
+
316
+ await RisingEdge(dut.clk)
317
+ await RisingEdge(dut.clk)
318
+
319
+
320
+ # cocotb-test
321
+
322
+ tests_dir = os.path.dirname(__file__)
323
+ rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))
324
+ lib_dir = os.path.abspath(os.path.join(rtl_dir, '..', 'lib'))
325
+ pcie_rtl_dir = os.path.abspath(os.path.join(lib_dir, 'pcie', 'rtl'))
326
+
327
+
328
+ def test_fpga_core(request):
329
+ dut = "fpga_core"
330
+ module = os.path.splitext(os.path.basename(__file__))[0]
331
+ toplevel = dut
332
+
333
+ verilog_sources = [
334
+ os.path.join(rtl_dir, f"{dut}.v"),
335
+ os.path.join(rtl_dir, "axi_ram.v"),
336
+ os.path.join(rtl_dir, "axis_register.v"),
337
+ os.path.join(pcie_rtl_dir, "axis_arb_mux.v"),
338
+ os.path.join(pcie_rtl_dir, "pcie_us_axil_master.v"),
339
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma.v"),
340
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma_rd.v"),
341
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma_wr.v"),
342
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master.v"),
343
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master_rd.v"),
344
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master_wr.v"),
345
+ os.path.join(pcie_rtl_dir, "pcie_us_axis_cq_demux.v"),
346
+ os.path.join(pcie_rtl_dir, "pcie_us_cfg.v"),
347
+ os.path.join(pcie_rtl_dir, "pcie_us_msi.v"),
348
+ os.path.join(pcie_rtl_dir, "arbiter.v"),
349
+ os.path.join(pcie_rtl_dir, "priority_encoder.v"),
350
+ os.path.join(pcie_rtl_dir, "pulse_merge.v"),
351
+ ]
352
+
353
+ parameters = {}
354
+
355
+ parameters['AXIS_PCIE_DATA_WIDTH'] = 512
356
+ parameters['AXIS_PCIE_KEEP_WIDTH'] = parameters['AXIS_PCIE_DATA_WIDTH'] // 32
357
+ parameters['AXIS_PCIE_RQ_USER_WIDTH'] = 62 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 137
358
+ parameters['AXIS_PCIE_RC_USER_WIDTH'] = 75 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 161
359
+ parameters['AXIS_PCIE_CQ_USER_WIDTH'] = 88 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 183
360
+ parameters['AXIS_PCIE_CC_USER_WIDTH'] = 33 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 81
361
+ parameters['RQ_SEQ_NUM_WIDTH'] = 6
362
+
363
+ extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
364
+
365
+ sim_build = os.path.join(tests_dir, "sim_build",
366
+ request.node.name.replace('[', '-').replace(']', ''))
367
+
368
+ cocotb_test.simulator.run(
369
+ python_search=[tests_dir],
370
+ verilog_sources=verilog_sources,
371
+ toplevel=toplevel,
372
+ module=module,
373
+ parameters=parameters,
374
+ sim_build=sim_build,
375
+ extra_env=extra_env,
376
+ )
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilog PCIe Alveo U50 Example Design
2
+
3
+ ## Introduction
4
+
5
+ This example design targets the Xilinx Alveo U50 FPGA board.
6
+
7
+ The design implements the PCIe AXI lite master module, the PCIe AXI master module, and the PCIe DMA module. A very simple Linux driver is included to test the FPGA design.
8
+
9
+ * FPGA: xcu50-fsvh2104-2-e
10
+
11
+ ## How to build
12
+
13
+ Run `make` to build. Ensure that the Xilinx Vivado components are in PATH.
14
+
15
+ Run `make` to build the driver. Ensure the headers for the running kernel are installed, otherwise the driver cannot be compiled.
16
+
17
+ ## How to test
18
+
19
+ Run `make program` to program the Alveo U50 board with Vivado. Then load the driver with `insmod example.ko`. Check dmesg for the output.
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/common/vivado.mk ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: fpga vivado tmpclean clean distclean
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
+ SYN_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(SYN_FILES))) $(filter /% ./%,$(SYN_FILES))
41
+ INC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(INC_FILES))) $(filter /% ./%,$(INC_FILES))
42
+ XCI_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XCI_FILES))) $(filter /% ./%,$(XCI_FILES))
43
+ IP_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(IP_TCL_FILES))) $(filter /% ./%,$(IP_TCL_FILES))
44
+ CONFIG_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(CONFIG_TCL_FILES))) $(filter /% ./%,$(CONFIG_TCL_FILES))
45
+
46
+ ifdef XDC_FILES
47
+ XDC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XDC_FILES))) $(filter /% ./%,$(XDC_FILES))
48
+ else
49
+ XDC_FILES_REL = $(FPGA_TOP).xdc
50
+ endif
51
+
52
+ ###################################################################
53
+ # Main Targets
54
+ #
55
+ # all: build everything
56
+ # clean: remove output files and project files
57
+ ###################################################################
58
+
59
+ all: fpga
60
+
61
+ fpga: $(FPGA_TOP).bit
62
+
63
+ vivado: $(FPGA_TOP).xpr
64
+ vivado $(FPGA_TOP).xpr
65
+
66
+ tmpclean::
67
+ -rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
68
+ -rm -rf create_project.tcl update_config.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
69
+
70
+ clean:: tmpclean
71
+ -rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
72
+
73
+ distclean:: clean
74
+ -rm -rf rev
75
+
76
+ ###################################################################
77
+ # Target implementations
78
+ ###################################################################
79
+
80
+ # Vivado project file
81
+ create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
82
+ rm -rf defines.v
83
+ touch defines.v
84
+ for x in $(DEFS); do echo '`define' $$x >> defines.v; done
85
+ echo "create_project -force -part $(FPGA_PART) $(FPGA_TOP)" > $@
86
+ echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
87
+ echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
88
+ for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
89
+ for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
90
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
91
+
92
+ update_config.tcl: $(CONFIG_TCL_FILES_REL)
93
+ echo "open_project -quiet $(FPGA_TOP).xpr" > $@
94
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
95
+
96
+ $(FPGA_TOP).xpr: create_project.tcl update_config.tcl
97
+ vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
98
+
99
+ # synthesis run
100
+ %.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL) $(CONFIG_TCL_FILES_REL)
101
+ echo "open_project $*.xpr" > run_synth.tcl
102
+ echo "reset_run synth_1" >> run_synth.tcl
103
+ echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
104
+ echo "wait_on_run synth_1" >> run_synth.tcl
105
+ vivado -nojournal -nolog -mode batch -source run_synth.tcl
106
+
107
+ # implementation run
108
+ %.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
109
+ echo "open_project $*.xpr" > run_impl.tcl
110
+ echo "reset_run impl_1" >> run_impl.tcl
111
+ echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
112
+ echo "wait_on_run impl_1" >> run_impl.tcl
113
+ vivado -nojournal -nolog -mode batch -source run_impl.tcl
114
+
115
+ # bit file
116
+ %.bit: %.runs/impl_1/%_routed.dcp
117
+ echo "open_project $*.xpr" > generate_bit.tcl
118
+ echo "open_run impl_1" >> generate_bit.tcl
119
+ echo "write_bitstream -force $*.bit" >> generate_bit.tcl
120
+ vivado -nojournal -nolog -mode batch -source generate_bit.tcl
121
+ mkdir -p rev
122
+ EXT=bit; COUNT=100; \
123
+ while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
124
+ do COUNT=$$((COUNT+1)); done; \
125
+ cp $@ rev/$*_rev$$COUNT.$$EXT; \
126
+ echo "Output: rev/$*_rev$$COUNT.$$EXT";
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/fpga/Makefile ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # FPGA settings
3
+ FPGA_PART = xcu50-fsvh2104-2-e
4
+ FPGA_TOP = fpga
5
+ FPGA_ARCH = virtexuplus
6
+
7
+ # Files for synthesis
8
+ SYN_FILES = rtl/fpga.v
9
+ SYN_FILES += rtl/fpga_core.v
10
+ SYN_FILES += rtl/sync_reset.v
11
+ SYN_FILES += rtl/sync_signal.v
12
+ SYN_FILES += rtl/common/example_core_pcie_us.v
13
+ SYN_FILES += rtl/common/example_core_pcie.v
14
+ SYN_FILES += rtl/common/example_core.v
15
+ SYN_FILES += rtl/common/axi_ram.v
16
+ SYN_FILES += lib/pcie/rtl/pcie_us_if.v
17
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rc.v
18
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rq.v
19
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cq.v
20
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cc.v
21
+ SYN_FILES += lib/pcie/rtl/pcie_us_cfg.v
22
+ SYN_FILES += lib/pcie/rtl/pcie_us_msi.v
23
+ SYN_FILES += lib/pcie/rtl/pcie_axil_master.v
24
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master.v
25
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_rd.v
26
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_wr.v
27
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux_bar.v
28
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux.v
29
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_mux.v
30
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie.v
31
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_rd.v
32
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_wr.v
33
+ SYN_FILES += lib/pcie/rtl/dma_psdpram.v
34
+ SYN_FILES += lib/pcie/rtl/arbiter.v
35
+ SYN_FILES += lib/pcie/rtl/priority_encoder.v
36
+ SYN_FILES += lib/pcie/rtl/pulse_merge.v
37
+
38
+ # XDC files
39
+ XDC_FILES = fpga.xdc
40
+
41
+ # IP
42
+ IP_TCL_FILES = ip/pcie4c_uscale_plus_0.tcl
43
+
44
+ include ../common/vivado.mk
45
+
46
+ program: $(FPGA_TOP).bit
47
+ echo "open_hw" > program.tcl
48
+ echo "connect_hw_server" >> program.tcl
49
+ echo "open_hw_target" >> program.tcl
50
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
51
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
52
+ echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
53
+ echo "program_hw_devices [current_hw_device]" >> program.tcl
54
+ echo "exit" >> program.tcl
55
+ vivado -nojournal -nolog -mode batch -source program.tcl
56
+
57
+ %.mcs %.prm: %.bit
58
+ echo "write_cfgmem -force -format mcs -size 128 -interface SPIx4 -loadbit {up 0x01002000 $*.bit} -checksum -file $*.mcs" > generate_mcs.tcl
59
+ echo "exit" >> generate_mcs.tcl
60
+ vivado -nojournal -nolog -mode batch -source generate_mcs.tcl
61
+ mkdir -p rev
62
+ COUNT=100; \
63
+ while [ -e rev/$*_rev$$COUNT.bit ]; \
64
+ do COUNT=$$((COUNT+1)); done; \
65
+ COUNT=$$((COUNT-1)); \
66
+ for x in .mcs .prm; \
67
+ do cp $*$$x rev/$*_rev$$COUNT$$x; \
68
+ echo "Output: rev/$*_rev$$COUNT$$x"; done;
69
+
70
+ flash: $(FPGA_TOP).mcs $(FPGA_TOP).prm
71
+ echo "open_hw" > flash.tcl
72
+ echo "connect_hw_server" >> flash.tcl
73
+ echo "open_hw_target" >> flash.tcl
74
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> flash.tcl
75
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> flash.tcl
76
+ echo "create_hw_cfgmem -hw_device [current_hw_device] [lindex [get_cfgmem_parts {mt25qu01g-spi-x1_x2_x4}] 0]" >> flash.tcl
77
+ echo "current_hw_cfgmem -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM [current_hw_device]]" >> flash.tcl
78
+ echo "set_property PROGRAM.FILES [list \"$(FPGA_TOP).mcs\"] [current_hw_cfgmem]" >> flash.tcl
79
+ echo "set_property PROGRAM.PRM_FILES [list \"$(FPGA_TOP).prm\"] [current_hw_cfgmem]" >> flash.tcl
80
+ echo "set_property PROGRAM.ERASE 1 [current_hw_cfgmem]" >> flash.tcl
81
+ echo "set_property PROGRAM.CFG_PROGRAM 1 [current_hw_cfgmem]" >> flash.tcl
82
+ echo "set_property PROGRAM.VERIFY 1 [current_hw_cfgmem]" >> flash.tcl
83
+ echo "set_property PROGRAM.CHECKSUM 0 [current_hw_cfgmem]" >> flash.tcl
84
+ echo "set_property PROGRAM.ADDRESS_RANGE {use_file} [current_hw_cfgmem]" >> flash.tcl
85
+ echo "set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [current_hw_cfgmem]" >> flash.tcl
86
+ echo "create_hw_bitstream -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM_BITFILE [current_hw_device]]" >> flash.tcl
87
+ echo "program_hw_devices [current_hw_device]" >> flash.tcl
88
+ echo "refresh_hw_device [current_hw_device]" >> flash.tcl
89
+ echo "program_hw_cfgmem -hw_cfgmem [current_hw_cfgmem]" >> flash.tcl
90
+ echo "boot_hw_device [current_hw_device]" >> flash.tcl
91
+ echo "exit" >> flash.tcl
92
+ vivado -nojournal -nolog -mode batch -source flash.tcl
93
+
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/ip/pcie4c_uscale_plus_0.tcl ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ create_ip -name pcie4c_uscale_plus -vendor xilinx.com -library ip -module_name pcie4c_uscale_plus_0
3
+
4
+ set_property -dict [list \
5
+ CONFIG.PL_LINK_CAP_MAX_LINK_SPEED {8.0_GT/s} \
6
+ CONFIG.PL_LINK_CAP_MAX_LINK_WIDTH {X16} \
7
+ CONFIG.AXISTEN_IF_EXT_512_RQ_STRADDLE {false} \
8
+ CONFIG.axisten_if_enable_client_tag {true} \
9
+ CONFIG.axisten_if_width {512_bit} \
10
+ CONFIG.axisten_freq {250} \
11
+ CONFIG.PF0_CLASS_CODE {058000} \
12
+ CONFIG.PF0_DEVICE_ID {0001} \
13
+ CONFIG.PF0_MSI_CAP_MULTIMSGCAP {32_vectors} \
14
+ CONFIG.PF0_SUBSYSTEM_ID {9032} \
15
+ CONFIG.PF0_SUBSYSTEM_VENDOR_ID {10ee} \
16
+ CONFIG.pf0_bar0_64bit {true} \
17
+ CONFIG.pf0_bar0_prefetchable {true} \
18
+ CONFIG.pf0_bar0_scale {Megabytes} \
19
+ CONFIG.pf0_bar0_size {16} \
20
+ CONFIG.pf0_bar2_64bit {true} \
21
+ CONFIG.pf0_bar2_prefetchable {true} \
22
+ CONFIG.pf0_bar2_enabled {true} \
23
+ CONFIG.pf0_bar2_type {Memory} \
24
+ CONFIG.pf0_bar2_scale {Megabytes} \
25
+ CONFIG.pf0_bar2_size {16} \
26
+ CONFIG.vendor_id {1234} \
27
+ CONFIG.en_msi_per_vec_masking {true} \
28
+ ] [get_ips pcie4c_uscale_plus_0]
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/fpga.v ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA top-level module
33
+ */
34
+ module fpga (
35
+ /*
36
+ * GPIO
37
+ */
38
+ output wire qsfp_led_act,
39
+ output wire qsfp_led_stat_g,
40
+ output wire qsfp_led_stat_y,
41
+ output wire hbm_cattrip,
42
+
43
+ /*
44
+ * PCI express
45
+ */
46
+ input wire [15:0] pcie_rx_p,
47
+ input wire [15:0] pcie_rx_n,
48
+ output wire [15:0] pcie_tx_p,
49
+ output wire [15:0] pcie_tx_n,
50
+ input wire pcie_refclk_1_p,
51
+ input wire pcie_refclk_1_n,
52
+ input wire pcie_reset_n
53
+ );
54
+
55
+ parameter AXIS_PCIE_DATA_WIDTH = 512;
56
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32);
57
+ parameter AXIS_PCIE_RC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 75 : 161;
58
+ parameter AXIS_PCIE_RQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 60 : 137;
59
+ parameter AXIS_PCIE_CQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 85 : 183;
60
+ parameter AXIS_PCIE_CC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 33 : 81;
61
+
62
+ parameter RQ_SEQ_NUM_WIDTH = AXIS_PCIE_RQ_USER_WIDTH == 60 ? 4 : 6;
63
+ parameter RQ_SEQ_NUM_ENABLE = 1;
64
+
65
+ parameter PCIE_TAG_COUNT = 64;
66
+ parameter BAR0_APERTURE = 24;
67
+ parameter BAR2_APERTURE = 24;
68
+
69
+ // Clock and reset
70
+ wire pcie_user_clk;
71
+ wire pcie_user_reset;
72
+
73
+ // GPIO
74
+ assign hbm_cattrip = 1'b0;
75
+
76
+ // PCIe
77
+ wire pcie_sys_clk;
78
+ wire pcie_sys_clk_gt;
79
+
80
+ IBUFDS_GTE4 #(
81
+ .REFCLK_HROW_CK_SEL(2'b00)
82
+ )
83
+ ibufds_gte4_pcie_mgt_refclk_inst (
84
+ .I (pcie_refclk_1_p),
85
+ .IB (pcie_refclk_1_n),
86
+ .CEB (1'b0),
87
+ .O (pcie_sys_clk_gt),
88
+ .ODIV2 (pcie_sys_clk)
89
+ );
90
+
91
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rq_tdata;
92
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rq_tkeep;
93
+ wire axis_rq_tlast;
94
+ wire axis_rq_tready;
95
+ wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] axis_rq_tuser;
96
+ wire axis_rq_tvalid;
97
+
98
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata;
99
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep;
100
+ wire axis_rc_tlast;
101
+ wire axis_rc_tready;
102
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser;
103
+ wire axis_rc_tvalid;
104
+
105
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata;
106
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep;
107
+ wire axis_cq_tlast;
108
+ wire axis_cq_tready;
109
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser;
110
+ wire axis_cq_tvalid;
111
+
112
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata;
113
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep;
114
+ wire axis_cc_tlast;
115
+ wire axis_cc_tready;
116
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser;
117
+ wire axis_cc_tvalid;
118
+
119
+ wire [RQ_SEQ_NUM_WIDTH-1:0] pcie_rq_seq_num0;
120
+ wire pcie_rq_seq_num_vld0;
121
+ wire [RQ_SEQ_NUM_WIDTH-1:0] pcie_rq_seq_num1;
122
+ wire pcie_rq_seq_num_vld1;
123
+
124
+ // ila_0 rq_ila (
125
+ // .clk(pcie_user_clk),
126
+ // .probe0(axis_rq_tdata),
127
+ // .probe1(axis_rq_tkeep),
128
+ // .probe2(axis_rq_tlast),
129
+ // .probe3(axis_rq_tready),
130
+ // .probe4(axis_rq_tuser),
131
+ // .probe5(axis_rq_tvalid)
132
+ // );
133
+
134
+ // ila_0 rc_ila (
135
+ // .clk(pcie_user_clk),
136
+ // .probe0(axis_rc_tdata),
137
+ // .probe1(axis_rc_tkeep),
138
+ // .probe2(axis_rc_tlast),
139
+ // .probe3(axis_rc_tready),
140
+ // .probe4(axis_rc_tuser),
141
+ // .probe5(axis_rc_tvalid)
142
+ // );
143
+
144
+ wire [2:0] cfg_max_payload;
145
+ wire [2:0] cfg_max_read_req;
146
+
147
+ wire [9:0] cfg_mgmt_addr;
148
+ wire [7:0] cfg_mgmt_function_number;
149
+ wire cfg_mgmt_write;
150
+ wire [31:0] cfg_mgmt_write_data;
151
+ wire [3:0] cfg_mgmt_byte_enable;
152
+ wire cfg_mgmt_read;
153
+ wire [31:0] cfg_mgmt_read_data;
154
+ wire cfg_mgmt_read_write_done;
155
+
156
+ wire [7:0] cfg_fc_ph;
157
+ wire [11:0] cfg_fc_pd;
158
+ wire [7:0] cfg_fc_nph;
159
+ wire [11:0] cfg_fc_npd;
160
+ wire [7:0] cfg_fc_cplh;
161
+ wire [11:0] cfg_fc_cpld;
162
+ wire [2:0] cfg_fc_sel;
163
+
164
+ wire [3:0] cfg_interrupt_msi_enable;
165
+ wire [11:0] cfg_interrupt_msi_mmenable;
166
+ wire cfg_interrupt_msi_mask_update;
167
+ wire [31:0] cfg_interrupt_msi_data;
168
+ wire [3:0] cfg_interrupt_msi_select;
169
+ wire [31:0] cfg_interrupt_msi_int;
170
+ wire [31:0] cfg_interrupt_msi_pending_status;
171
+ wire cfg_interrupt_msi_pending_status_data_enable;
172
+ wire [3:0] cfg_interrupt_msi_pending_status_function_num;
173
+ wire cfg_interrupt_msi_sent;
174
+ wire cfg_interrupt_msi_fail;
175
+ wire [2:0] cfg_interrupt_msi_attr;
176
+ wire cfg_interrupt_msi_tph_present;
177
+ wire [1:0] cfg_interrupt_msi_tph_type;
178
+ wire [8:0] cfg_interrupt_msi_tph_st_tag;
179
+ wire [3:0] cfg_interrupt_msi_function_number;
180
+
181
+ wire status_error_cor;
182
+ wire status_error_uncor;
183
+
184
+ pcie4c_uscale_plus_0
185
+ pcie4c_uscale_plus_inst (
186
+ .pci_exp_txn(pcie_tx_n),
187
+ .pci_exp_txp(pcie_tx_p),
188
+ .pci_exp_rxn(pcie_rx_n),
189
+ .pci_exp_rxp(pcie_rx_p),
190
+ .user_clk(pcie_user_clk),
191
+ .user_reset(pcie_user_reset),
192
+ .user_lnk_up(),
193
+
194
+ .s_axis_rq_tdata(axis_rq_tdata),
195
+ .s_axis_rq_tkeep(axis_rq_tkeep),
196
+ .s_axis_rq_tlast(axis_rq_tlast),
197
+ .s_axis_rq_tready(axis_rq_tready),
198
+ .s_axis_rq_tuser(axis_rq_tuser),
199
+ .s_axis_rq_tvalid(axis_rq_tvalid),
200
+
201
+ .m_axis_rc_tdata(axis_rc_tdata),
202
+ .m_axis_rc_tkeep(axis_rc_tkeep),
203
+ .m_axis_rc_tlast(axis_rc_tlast),
204
+ .m_axis_rc_tready(axis_rc_tready),
205
+ .m_axis_rc_tuser(axis_rc_tuser),
206
+ .m_axis_rc_tvalid(axis_rc_tvalid),
207
+
208
+ .m_axis_cq_tdata(axis_cq_tdata),
209
+ .m_axis_cq_tkeep(axis_cq_tkeep),
210
+ .m_axis_cq_tlast(axis_cq_tlast),
211
+ .m_axis_cq_tready(axis_cq_tready),
212
+ .m_axis_cq_tuser(axis_cq_tuser),
213
+ .m_axis_cq_tvalid(axis_cq_tvalid),
214
+
215
+ .s_axis_cc_tdata(axis_cc_tdata),
216
+ .s_axis_cc_tkeep(axis_cc_tkeep),
217
+ .s_axis_cc_tlast(axis_cc_tlast),
218
+ .s_axis_cc_tready(axis_cc_tready),
219
+ .s_axis_cc_tuser(axis_cc_tuser),
220
+ .s_axis_cc_tvalid(axis_cc_tvalid),
221
+
222
+ .pcie_rq_seq_num0(pcie_rq_seq_num0),
223
+ .pcie_rq_seq_num_vld0(pcie_rq_seq_num_vld0),
224
+ .pcie_rq_seq_num1(pcie_rq_seq_num1),
225
+ .pcie_rq_seq_num_vld1(pcie_rq_seq_num_vld1),
226
+ .pcie_rq_tag0(),
227
+ .pcie_rq_tag1(),
228
+ .pcie_rq_tag_av(),
229
+ .pcie_rq_tag_vld0(),
230
+ .pcie_rq_tag_vld1(),
231
+
232
+ .pcie_tfc_nph_av(),
233
+ .pcie_tfc_npd_av(),
234
+
235
+ .pcie_cq_np_req(1'b1),
236
+ .pcie_cq_np_req_count(),
237
+
238
+ .cfg_phy_link_down(),
239
+ .cfg_phy_link_status(),
240
+ .cfg_negotiated_width(),
241
+ .cfg_current_speed(),
242
+ .cfg_max_payload(cfg_max_payload),
243
+ .cfg_max_read_req(cfg_max_read_req),
244
+ .cfg_function_status(),
245
+ .cfg_function_power_state(),
246
+ .cfg_vf_status(),
247
+ .cfg_vf_power_state(),
248
+ .cfg_link_power_state(),
249
+
250
+ .cfg_mgmt_addr(cfg_mgmt_addr),
251
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
252
+ .cfg_mgmt_write(cfg_mgmt_write),
253
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
254
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
255
+ .cfg_mgmt_read(cfg_mgmt_read),
256
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
257
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
258
+ .cfg_mgmt_debug_access(1'b0),
259
+
260
+ .cfg_err_cor_out(),
261
+ .cfg_err_nonfatal_out(),
262
+ .cfg_err_fatal_out(),
263
+ .cfg_local_error_valid(),
264
+ .cfg_local_error_out(),
265
+ .cfg_ltssm_state(),
266
+ .cfg_rx_pm_state(),
267
+ .cfg_tx_pm_state(),
268
+ .cfg_rcb_status(),
269
+ .cfg_obff_enable(),
270
+ .cfg_pl_status_change(),
271
+ .cfg_tph_requester_enable(),
272
+ .cfg_tph_st_mode(),
273
+ .cfg_vf_tph_requester_enable(),
274
+ .cfg_vf_tph_st_mode(),
275
+
276
+ .cfg_msg_received(),
277
+ .cfg_msg_received_data(),
278
+ .cfg_msg_received_type(),
279
+ .cfg_msg_transmit(1'b0),
280
+ .cfg_msg_transmit_type(3'd0),
281
+ .cfg_msg_transmit_data(32'd0),
282
+ .cfg_msg_transmit_done(),
283
+
284
+ .cfg_fc_ph(cfg_fc_ph),
285
+ .cfg_fc_pd(cfg_fc_pd),
286
+ .cfg_fc_nph(cfg_fc_nph),
287
+ .cfg_fc_npd(cfg_fc_npd),
288
+ .cfg_fc_cplh(cfg_fc_cplh),
289
+ .cfg_fc_cpld(cfg_fc_cpld),
290
+ .cfg_fc_sel(cfg_fc_sel),
291
+
292
+ .cfg_dsn(64'd0),
293
+
294
+ .cfg_bus_number(),
295
+
296
+ .cfg_power_state_change_ack(1'b1),
297
+ .cfg_power_state_change_interrupt(),
298
+
299
+ .cfg_err_cor_in(status_error_cor),
300
+ .cfg_err_uncor_in(status_error_uncor),
301
+ .cfg_flr_in_process(),
302
+ .cfg_flr_done(4'd0),
303
+ .cfg_vf_flr_in_process(),
304
+ .cfg_vf_flr_func_num(8'd0),
305
+ .cfg_vf_flr_done(8'd0),
306
+
307
+ .cfg_link_training_enable(1'b1),
308
+
309
+ .cfg_interrupt_int(4'd0),
310
+ .cfg_interrupt_pending(4'd0),
311
+ .cfg_interrupt_sent(),
312
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
313
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
314
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
315
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
316
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
317
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
318
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
319
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
320
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
321
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
322
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
323
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
324
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
325
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
326
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
327
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
328
+
329
+ .cfg_pm_aspm_l1_entry_reject(1'b0),
330
+ .cfg_pm_aspm_tx_l0s_entry_disable(1'b0),
331
+
332
+ .cfg_hot_reset_out(),
333
+
334
+ .cfg_config_space_enable(1'b1),
335
+ .cfg_req_pm_transition_l23_ready(1'b0),
336
+ .cfg_hot_reset_in(1'b0),
337
+
338
+ .cfg_ds_port_number(8'd0),
339
+ .cfg_ds_bus_number(8'd0),
340
+ .cfg_ds_device_number(5'd0),
341
+
342
+ .sys_clk(pcie_sys_clk),
343
+ .sys_clk_gt(pcie_sys_clk_gt),
344
+ .sys_reset(pcie_reset_n),
345
+
346
+ .phy_rdy_out()
347
+ );
348
+
349
+ fpga_core #(
350
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
351
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
352
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
353
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
354
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
355
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
356
+ .RQ_SEQ_NUM_WIDTH(RQ_SEQ_NUM_WIDTH),
357
+ .RQ_SEQ_NUM_ENABLE(RQ_SEQ_NUM_ENABLE),
358
+ .PCIE_TAG_COUNT(PCIE_TAG_COUNT),
359
+ .BAR0_APERTURE(BAR0_APERTURE),
360
+ .BAR2_APERTURE(BAR2_APERTURE)
361
+ )
362
+ core_inst (
363
+ /*
364
+ * Clock: 250 MHz
365
+ * Synchronous reset
366
+ */
367
+ .clk(pcie_user_clk),
368
+ .rst(pcie_user_reset),
369
+ /*
370
+ * GPIO
371
+ */
372
+ .qsfp_led_act(qsfp_led_act),
373
+ .qsfp_led_stat_g(qsfp_led_stat_g),
374
+ .qsfp_led_stat_y(qsfp_led_stat_y),
375
+ /*
376
+ * PCIe
377
+ */
378
+ .m_axis_rq_tdata(axis_rq_tdata),
379
+ .m_axis_rq_tkeep(axis_rq_tkeep),
380
+ .m_axis_rq_tlast(axis_rq_tlast),
381
+ .m_axis_rq_tready(axis_rq_tready),
382
+ .m_axis_rq_tuser(axis_rq_tuser),
383
+ .m_axis_rq_tvalid(axis_rq_tvalid),
384
+
385
+ .s_axis_rc_tdata(axis_rc_tdata),
386
+ .s_axis_rc_tkeep(axis_rc_tkeep),
387
+ .s_axis_rc_tlast(axis_rc_tlast),
388
+ .s_axis_rc_tready(axis_rc_tready),
389
+ .s_axis_rc_tuser(axis_rc_tuser),
390
+ .s_axis_rc_tvalid(axis_rc_tvalid),
391
+
392
+ .s_axis_cq_tdata(axis_cq_tdata),
393
+ .s_axis_cq_tkeep(axis_cq_tkeep),
394
+ .s_axis_cq_tlast(axis_cq_tlast),
395
+ .s_axis_cq_tready(axis_cq_tready),
396
+ .s_axis_cq_tuser(axis_cq_tuser),
397
+ .s_axis_cq_tvalid(axis_cq_tvalid),
398
+
399
+ .m_axis_cc_tdata(axis_cc_tdata),
400
+ .m_axis_cc_tkeep(axis_cc_tkeep),
401
+ .m_axis_cc_tlast(axis_cc_tlast),
402
+ .m_axis_cc_tready(axis_cc_tready),
403
+ .m_axis_cc_tuser(axis_cc_tuser),
404
+ .m_axis_cc_tvalid(axis_cc_tvalid),
405
+
406
+ .s_axis_rq_seq_num_0(pcie_rq_seq_num0),
407
+ .s_axis_rq_seq_num_valid_0(pcie_rq_seq_num_vld0),
408
+ .s_axis_rq_seq_num_1(pcie_rq_seq_num1),
409
+ .s_axis_rq_seq_num_valid_1(pcie_rq_seq_num_vld1),
410
+
411
+ .cfg_max_payload(cfg_max_payload),
412
+ .cfg_max_read_req(cfg_max_read_req),
413
+
414
+ .cfg_mgmt_addr(cfg_mgmt_addr),
415
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
416
+ .cfg_mgmt_write(cfg_mgmt_write),
417
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
418
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
419
+ .cfg_mgmt_read(cfg_mgmt_read),
420
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
421
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
422
+
423
+ .cfg_fc_ph(cfg_fc_ph),
424
+ .cfg_fc_pd(cfg_fc_pd),
425
+ .cfg_fc_nph(cfg_fc_nph),
426
+ .cfg_fc_npd(cfg_fc_npd),
427
+ .cfg_fc_cplh(cfg_fc_cplh),
428
+ .cfg_fc_cpld(cfg_fc_cpld),
429
+ .cfg_fc_sel(cfg_fc_sel),
430
+
431
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
432
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
433
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
434
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
435
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
436
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
437
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
438
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
439
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
440
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
441
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
442
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
443
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
444
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
445
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
446
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
447
+
448
+ .status_error_cor(status_error_cor),
449
+ .status_error_uncor(status_error_uncor)
450
+ );
451
+
452
+ endmodule
453
+
454
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/fpga_core.v ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA core logic
33
+ */
34
+ module fpga_core #
35
+ (
36
+ parameter AXIS_PCIE_DATA_WIDTH = 512,
37
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32),
38
+ parameter AXIS_PCIE_RC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 75 : 161,
39
+ parameter AXIS_PCIE_RQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 60 : 137,
40
+ parameter AXIS_PCIE_CQ_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 85 : 183,
41
+ parameter AXIS_PCIE_CC_USER_WIDTH = AXIS_PCIE_DATA_WIDTH < 512 ? 33 : 81,
42
+ parameter RQ_SEQ_NUM_WIDTH = AXIS_PCIE_RQ_USER_WIDTH == 60 ? 4 : 6,
43
+ parameter RQ_SEQ_NUM_ENABLE = 1,
44
+ parameter PCIE_TAG_COUNT = 64,
45
+ parameter BAR0_APERTURE = 24,
46
+ parameter BAR2_APERTURE = 24
47
+ )
48
+ (
49
+ /*
50
+ * Clock: 250 MHz
51
+ * Synchronous reset
52
+ */
53
+ input wire clk,
54
+ input wire rst,
55
+
56
+ /*
57
+ * GPIO
58
+ */
59
+ output wire qsfp_led_act,
60
+ output wire qsfp_led_stat_g,
61
+ output wire qsfp_led_stat_y,
62
+
63
+ /*
64
+ * PCIe
65
+ */
66
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_rq_tdata,
67
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_rq_tkeep,
68
+ output wire m_axis_rq_tlast,
69
+ input wire m_axis_rq_tready,
70
+ output wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] m_axis_rq_tuser,
71
+ output wire m_axis_rq_tvalid,
72
+
73
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_rc_tdata,
74
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_rc_tkeep,
75
+ input wire s_axis_rc_tlast,
76
+ output wire s_axis_rc_tready,
77
+ input wire [AXIS_PCIE_RC_USER_WIDTH-1:0] s_axis_rc_tuser,
78
+ input wire s_axis_rc_tvalid,
79
+
80
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_cq_tdata,
81
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_cq_tkeep,
82
+ input wire s_axis_cq_tlast,
83
+ output wire s_axis_cq_tready,
84
+ input wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] s_axis_cq_tuser,
85
+ input wire s_axis_cq_tvalid,
86
+
87
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_cc_tdata,
88
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_cc_tkeep,
89
+ output wire m_axis_cc_tlast,
90
+ input wire m_axis_cc_tready,
91
+ output wire [AXIS_PCIE_CC_USER_WIDTH-1:0] m_axis_cc_tuser,
92
+ output wire m_axis_cc_tvalid,
93
+
94
+ input wire [RQ_SEQ_NUM_WIDTH-1:0] s_axis_rq_seq_num_0,
95
+ input wire s_axis_rq_seq_num_valid_0,
96
+ input wire [RQ_SEQ_NUM_WIDTH-1:0] s_axis_rq_seq_num_1,
97
+ input wire s_axis_rq_seq_num_valid_1,
98
+
99
+ input wire [2:0] cfg_max_payload,
100
+ input wire [2:0] cfg_max_read_req,
101
+
102
+ output wire [9:0] cfg_mgmt_addr,
103
+ output wire [7:0] cfg_mgmt_function_number,
104
+ output wire cfg_mgmt_write,
105
+ output wire [31:0] cfg_mgmt_write_data,
106
+ output wire [3:0] cfg_mgmt_byte_enable,
107
+ output wire cfg_mgmt_read,
108
+ input wire [31:0] cfg_mgmt_read_data,
109
+ input wire cfg_mgmt_read_write_done,
110
+
111
+ input wire [7:0] cfg_fc_ph,
112
+ input wire [11:0] cfg_fc_pd,
113
+ input wire [7:0] cfg_fc_nph,
114
+ input wire [11:0] cfg_fc_npd,
115
+ input wire [7:0] cfg_fc_cplh,
116
+ input wire [11:0] cfg_fc_cpld,
117
+ output wire [2:0] cfg_fc_sel,
118
+
119
+ input wire [3:0] cfg_interrupt_msi_enable,
120
+ input wire [11:0] cfg_interrupt_msi_mmenable,
121
+ input wire cfg_interrupt_msi_mask_update,
122
+ input wire [31:0] cfg_interrupt_msi_data,
123
+ output wire [3:0] cfg_interrupt_msi_select,
124
+ output wire [31:0] cfg_interrupt_msi_int,
125
+ output wire [31:0] cfg_interrupt_msi_pending_status,
126
+ output wire cfg_interrupt_msi_pending_status_data_enable,
127
+ output wire [3:0] cfg_interrupt_msi_pending_status_function_num,
128
+ input wire cfg_interrupt_msi_sent,
129
+ input wire cfg_interrupt_msi_fail,
130
+ output wire [2:0] cfg_interrupt_msi_attr,
131
+ output wire cfg_interrupt_msi_tph_present,
132
+ output wire [1:0] cfg_interrupt_msi_tph_type,
133
+ output wire [8:0] cfg_interrupt_msi_tph_st_tag,
134
+ output wire [3:0] cfg_interrupt_msi_function_number,
135
+
136
+ output wire status_error_cor,
137
+ output wire status_error_uncor
138
+ );
139
+
140
+ assign qsfp_led_act = 1'b0;
141
+ assign qsfp_led_stat_g = 1'b0;
142
+ assign qsfp_led_stat_y = 1'b0;
143
+
144
+ example_core_pcie_us #(
145
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
146
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
147
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
148
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
149
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
150
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
151
+ .RQ_SEQ_NUM_WIDTH(RQ_SEQ_NUM_WIDTH),
152
+ .RQ_SEQ_NUM_ENABLE(RQ_SEQ_NUM_ENABLE),
153
+ .PCIE_TAG_COUNT(PCIE_TAG_COUNT),
154
+ .READ_OP_TABLE_SIZE(PCIE_TAG_COUNT),
155
+ .READ_TX_LIMIT(2**(RQ_SEQ_NUM_WIDTH-1)),
156
+ .READ_TX_FC_ENABLE(1),
157
+ .WRITE_OP_TABLE_SIZE(2**(RQ_SEQ_NUM_WIDTH-1)),
158
+ .WRITE_TX_LIMIT(2**(RQ_SEQ_NUM_WIDTH-1)),
159
+ .WRITE_TX_FC_ENABLE(1),
160
+ .BAR0_APERTURE(BAR0_APERTURE),
161
+ .BAR2_APERTURE(BAR2_APERTURE)
162
+ )
163
+ example_core_pcie_us_inst (
164
+ .clk(clk),
165
+ .rst(rst),
166
+
167
+ /*
168
+ * AXI input (RC)
169
+ */
170
+ .s_axis_rc_tdata(s_axis_rc_tdata),
171
+ .s_axis_rc_tkeep(s_axis_rc_tkeep),
172
+ .s_axis_rc_tvalid(s_axis_rc_tvalid),
173
+ .s_axis_rc_tready(s_axis_rc_tready),
174
+ .s_axis_rc_tlast(s_axis_rc_tlast),
175
+ .s_axis_rc_tuser(s_axis_rc_tuser),
176
+
177
+ /*
178
+ * AXI output (RQ)
179
+ */
180
+ .m_axis_rq_tdata(m_axis_rq_tdata),
181
+ .m_axis_rq_tkeep(m_axis_rq_tkeep),
182
+ .m_axis_rq_tvalid(m_axis_rq_tvalid),
183
+ .m_axis_rq_tready(m_axis_rq_tready),
184
+ .m_axis_rq_tlast(m_axis_rq_tlast),
185
+ .m_axis_rq_tuser(m_axis_rq_tuser),
186
+
187
+ /*
188
+ * AXI input (CQ)
189
+ */
190
+ .s_axis_cq_tdata(s_axis_cq_tdata),
191
+ .s_axis_cq_tkeep(s_axis_cq_tkeep),
192
+ .s_axis_cq_tvalid(s_axis_cq_tvalid),
193
+ .s_axis_cq_tready(s_axis_cq_tready),
194
+ .s_axis_cq_tlast(s_axis_cq_tlast),
195
+ .s_axis_cq_tuser(s_axis_cq_tuser),
196
+
197
+ /*
198
+ * AXI output (CC)
199
+ */
200
+ .m_axis_cc_tdata(m_axis_cc_tdata),
201
+ .m_axis_cc_tkeep(m_axis_cc_tkeep),
202
+ .m_axis_cc_tvalid(m_axis_cc_tvalid),
203
+ .m_axis_cc_tready(m_axis_cc_tready),
204
+ .m_axis_cc_tlast(m_axis_cc_tlast),
205
+ .m_axis_cc_tuser(m_axis_cc_tuser),
206
+
207
+ /*
208
+ * Transmit sequence number input
209
+ */
210
+ .s_axis_rq_seq_num_0(s_axis_rq_seq_num_0),
211
+ .s_axis_rq_seq_num_valid_0(s_axis_rq_seq_num_valid_0),
212
+ .s_axis_rq_seq_num_1(s_axis_rq_seq_num_1),
213
+ .s_axis_rq_seq_num_valid_1(s_axis_rq_seq_num_valid_1),
214
+
215
+ /*
216
+ * Flow control
217
+ */
218
+ .cfg_fc_ph(cfg_fc_ph),
219
+ .cfg_fc_pd(cfg_fc_pd),
220
+ .cfg_fc_nph(cfg_fc_nph),
221
+ .cfg_fc_npd(cfg_fc_npd),
222
+ .cfg_fc_cplh(cfg_fc_cplh),
223
+ .cfg_fc_cpld(cfg_fc_cpld),
224
+ .cfg_fc_sel(cfg_fc_sel),
225
+
226
+ /*
227
+ * Configuration interface
228
+ */
229
+ .cfg_mgmt_addr(cfg_mgmt_addr),
230
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
231
+ .cfg_mgmt_write(cfg_mgmt_write),
232
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
233
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
234
+ .cfg_mgmt_read(cfg_mgmt_read),
235
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
236
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
237
+
238
+ /*
239
+ * Interrupt interface
240
+ */
241
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
242
+ .cfg_interrupt_msi_vf_enable(8'd0),
243
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
244
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
245
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
246
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
247
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
248
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
249
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
250
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
251
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
252
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
253
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
254
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
255
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
256
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
257
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
258
+
259
+ /*
260
+ * Configuration
261
+ */
262
+ .cfg_max_read_req(cfg_max_read_req),
263
+ .cfg_max_payload(cfg_max_payload),
264
+
265
+ /*
266
+ * Status
267
+ */
268
+ .status_error_cor(status_error_cor),
269
+ .status_error_uncor(status_error_uncor)
270
+ );
271
+
272
+ endmodule
273
+
274
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/sync_reset.v ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an active-high asynchronous reset signal to a given clock by
33
+ * using a pipeline of N registers.
34
+ */
35
+ module sync_reset #(
36
+ parameter N=2 // depth of synchronizer
37
+ )(
38
+ input wire clk,
39
+ input wire rst,
40
+ output wire sync_reset_out
41
+ );
42
+
43
+ reg [N-1:0] sync_reg = {N{1'b1}};
44
+
45
+ assign sync_reset_out = sync_reg[N-1];
46
+
47
+ always @(posedge clk or posedge rst) begin
48
+ if (rst)
49
+ sync_reg <= {N{1'b1}};
50
+ else
51
+ sync_reg <= {sync_reg[N-2:0], 1'b0};
52
+ end
53
+
54
+ endmodule
55
+
56
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/rtl/sync_signal.v ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an asyncronous signal to a given clock by using a pipeline of
33
+ * two registers.
34
+ */
35
+ module sync_signal #(
36
+ parameter WIDTH=1, // width of the input and output signals
37
+ parameter N=2 // depth of synchronizer
38
+ )(
39
+ input wire clk,
40
+ input wire [WIDTH-1:0] in,
41
+ output wire [WIDTH-1:0] out
42
+ );
43
+
44
+ reg [WIDTH-1:0] sync_reg[N-1:0];
45
+
46
+ /*
47
+ * The synchronized output is the last register in the pipeline.
48
+ */
49
+ assign out = sync_reg[N-1];
50
+
51
+ integer k;
52
+
53
+ always @(posedge clk) begin
54
+ sync_reg[0] <= in;
55
+ for (k = 1; k < N; k = k + 1) begin
56
+ sync_reg[k] <= sync_reg[k-1];
57
+ end
58
+ end
59
+
60
+ endmodule
61
+
62
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/tb/fpga_core/Makefile ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020 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
+ TOPLEVEL_LANG = verilog
22
+
23
+ SIM ?= icarus
24
+ WAVES ?= 0
25
+
26
+ COCOTB_HDL_TIMEUNIT = 1ns
27
+ COCOTB_HDL_TIMEPRECISION = 1ps
28
+
29
+ DUT = fpga_core
30
+ TOPLEVEL = $(DUT)
31
+ MODULE = test_$(DUT)
32
+ VERILOG_SOURCES += ../../rtl/$(DUT).v
33
+ VERILOG_SOURCES += ../../rtl/common/example_core_pcie_us.v
34
+ VERILOG_SOURCES += ../../rtl/common/example_core_pcie.v
35
+ VERILOG_SOURCES += ../../rtl/common/example_core.v
36
+ VERILOG_SOURCES += ../../rtl/common/axi_ram.v
37
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_if.v
38
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_if_rc.v
39
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_if_rq.v
40
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_if_cq.v
41
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_if_cc.v
42
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_cfg.v
43
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_msi.v
44
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_axil_master.v
45
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_axi_master.v
46
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_axi_master_rd.v
47
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_axi_master_wr.v
48
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_tlp_demux_bar.v
49
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_tlp_demux.v
50
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_tlp_mux.v
51
+ VERILOG_SOURCES += ../../lib/pcie/rtl/dma_if_pcie.v
52
+ VERILOG_SOURCES += ../../lib/pcie/rtl/dma_if_pcie_rd.v
53
+ VERILOG_SOURCES += ../../lib/pcie/rtl/dma_if_pcie_wr.v
54
+ VERILOG_SOURCES += ../../lib/pcie/rtl/dma_psdpram.v
55
+ VERILOG_SOURCES += ../../lib/pcie/rtl/arbiter.v
56
+ VERILOG_SOURCES += ../../lib/pcie/rtl/priority_encoder.v
57
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pulse_merge.v
58
+
59
+ # module parameters
60
+ export PARAM_AXIS_PCIE_DATA_WIDTH ?= 512
61
+ export PARAM_AXIS_PCIE_KEEP_WIDTH ?= $(shell expr $(PARAM_AXIS_PCIE_DATA_WIDTH) / 32 )
62
+ export PARAM_AXIS_PCIE_RQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),62,137)
63
+ export PARAM_AXIS_PCIE_RC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),75,161)
64
+ export PARAM_AXIS_PCIE_CQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),88,183)
65
+ export PARAM_AXIS_PCIE_CC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),33,81)
66
+ export PARAM_RQ_SEQ_NUM_WIDTH ?= 6
67
+ export PARAM_RQ_SEQ_NUM_ENABLE ?= 1
68
+ export PARAM_PCIE_TAG_COUNT ?= 64
69
+ export PARAM_BAR0_APERTURE ?= 24
70
+ export PARAM_BAR2_APERTURE ?= 24
71
+
72
+ ifeq ($(SIM), icarus)
73
+ PLUSARGS += -fst
74
+
75
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
76
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
77
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
78
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
79
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
80
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
81
+ COMPILE_ARGS += -P $(TOPLEVEL).RQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
82
+ COMPILE_ARGS += -P $(TOPLEVEL).RQ_SEQ_NUM_ENABLE=$(PARAM_RQ_SEQ_NUM_ENABLE)
83
+ COMPILE_ARGS += -P $(TOPLEVEL).PCIE_TAG_COUNT=$(PARAM_PCIE_TAG_COUNT)
84
+ COMPILE_ARGS += -P $(TOPLEVEL).BAR0_APERTURE=$(PARAM_BAR0_APERTURE)
85
+ COMPILE_ARGS += -P $(TOPLEVEL).BAR2_APERTURE=$(PARAM_BAR2_APERTURE)
86
+
87
+ ifeq ($(WAVES), 1)
88
+ VERILOG_SOURCES += iverilog_dump.v
89
+ COMPILE_ARGS += -s iverilog_dump
90
+ endif
91
+ else ifeq ($(SIM), verilator)
92
+ COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH
93
+
94
+ COMPILE_ARGS += -GAXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
95
+ COMPILE_ARGS += -GAXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
96
+ COMPILE_ARGS += -GAXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
97
+ COMPILE_ARGS += -GAXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
98
+ COMPILE_ARGS += -GAXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
99
+ COMPILE_ARGS += -GAXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
100
+ COMPILE_ARGS += -GRQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
101
+ COMPILE_ARGS += -GRQ_SEQ_NUM_ENABLE=$(PARAM_RQ_SEQ_NUM_ENABLE)
102
+ COMPILE_ARGS += -GPCIE_TAG_COUNT=$(PARAM_PCIE_TAG_COUNT)
103
+ COMPILE_ARGS += -GBAR0_APERTURE=$(PARAM_BAR0_APERTURE)
104
+ COMPILE_ARGS += -GBAR2_APERTURE=$(PARAM_BAR2_APERTURE)
105
+
106
+ ifeq ($(WAVES), 1)
107
+ COMPILE_ARGS += --trace-fst
108
+ endif
109
+ endif
110
+
111
+ include $(shell cocotb-config --makefiles)/Makefile.sim
112
+
113
+ iverilog_dump.v:
114
+ echo 'module iverilog_dump();' > $@
115
+ echo 'initial begin' >> $@
116
+ echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@
117
+ echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@
118
+ echo 'end' >> $@
119
+ echo 'endmodule' >> $@
120
+
121
+ clean::
122
+ @rm -rf iverilog_dump.v
123
+ @rm -rf dump.fst $(TOPLEVEL).fst
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga/tb/fpga_core/test_fpga_core.py ADDED
@@ -0,0 +1,472 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ """
24
+
25
+ import logging
26
+ import os
27
+
28
+ import cocotb_test.simulator
29
+
30
+ import cocotb
31
+ from cocotb.log import SimLog
32
+ from cocotb.triggers import RisingEdge, FallingEdge, Timer
33
+
34
+ from cocotbext.axi import AxiStreamBus
35
+ from cocotbext.pcie.core import RootComplex
36
+ from cocotbext.pcie.xilinx.us import UltraScalePlusPcieDevice
37
+
38
+
39
+ class TB(object):
40
+ def __init__(self, dut):
41
+ self.dut = dut
42
+
43
+ self.log = SimLog("cocotb.tb")
44
+ self.log.setLevel(logging.DEBUG)
45
+
46
+ # PCIe
47
+ self.rc = RootComplex()
48
+
49
+ self.dev = UltraScalePlusPcieDevice(
50
+ # configuration options
51
+ pcie_generation=3,
52
+ pcie_link_width=16,
53
+ user_clk_frequency=250e6,
54
+ alignment="dword",
55
+ cq_cc_straddle=False,
56
+ rq_rc_straddle=False,
57
+ rc_4tlp_straddle=False,
58
+ enable_pf1=False,
59
+ enable_client_tag=True,
60
+ enable_extended_tag=True,
61
+ enable_parity=False,
62
+ enable_rx_msg_interface=False,
63
+ enable_sriov=False,
64
+ enable_extended_configuration=False,
65
+
66
+ enable_pf0_msi=True,
67
+ enable_pf1_msi=False,
68
+
69
+ # signals
70
+ # Clock and Reset Interface
71
+ user_clk=dut.clk,
72
+ user_reset=dut.rst,
73
+ # user_lnk_up
74
+ # sys_clk
75
+ # sys_clk_gt
76
+ # sys_reset
77
+ # phy_rdy_out
78
+
79
+ # Requester reQuest Interface
80
+ rq_bus=AxiStreamBus.from_prefix(dut, "m_axis_rq"),
81
+ pcie_rq_seq_num0=dut.s_axis_rq_seq_num_0,
82
+ pcie_rq_seq_num_vld0=dut.s_axis_rq_seq_num_valid_0,
83
+ pcie_rq_seq_num1=dut.s_axis_rq_seq_num_1,
84
+ pcie_rq_seq_num_vld1=dut.s_axis_rq_seq_num_valid_1,
85
+ # pcie_rq_tag0
86
+ # pcie_rq_tag1
87
+ # pcie_rq_tag_av
88
+ # pcie_rq_tag_vld0
89
+ # pcie_rq_tag_vld1
90
+
91
+ # Requester Completion Interface
92
+ rc_bus=AxiStreamBus.from_prefix(dut, "s_axis_rc"),
93
+
94
+ # Completer reQuest Interface
95
+ cq_bus=AxiStreamBus.from_prefix(dut, "s_axis_cq"),
96
+ # pcie_cq_np_req
97
+ # pcie_cq_np_req_count
98
+
99
+ # Completer Completion Interface
100
+ cc_bus=AxiStreamBus.from_prefix(dut, "m_axis_cc"),
101
+
102
+ # Transmit Flow Control Interface
103
+ # pcie_tfc_nph_av=dut.pcie_tfc_nph_av,
104
+ # pcie_tfc_npd_av=dut.pcie_tfc_npd_av,
105
+
106
+ # Configuration Management Interface
107
+ cfg_mgmt_addr=dut.cfg_mgmt_addr,
108
+ cfg_mgmt_function_number=dut.cfg_mgmt_function_number,
109
+ cfg_mgmt_write=dut.cfg_mgmt_write,
110
+ cfg_mgmt_write_data=dut.cfg_mgmt_write_data,
111
+ cfg_mgmt_byte_enable=dut.cfg_mgmt_byte_enable,
112
+ cfg_mgmt_read=dut.cfg_mgmt_read,
113
+ cfg_mgmt_read_data=dut.cfg_mgmt_read_data,
114
+ cfg_mgmt_read_write_done=dut.cfg_mgmt_read_write_done,
115
+ # cfg_mgmt_debug_access
116
+
117
+ # Configuration Status Interface
118
+ # cfg_phy_link_down
119
+ # cfg_phy_link_status
120
+ # cfg_negotiated_width
121
+ # cfg_current_speed
122
+ cfg_max_payload=dut.cfg_max_payload,
123
+ cfg_max_read_req=dut.cfg_max_read_req,
124
+ # cfg_function_status
125
+ # cfg_vf_status
126
+ # cfg_function_power_state
127
+ # cfg_vf_power_state
128
+ # cfg_link_power_state
129
+ # cfg_err_cor_out
130
+ # cfg_err_nonfatal_out
131
+ # cfg_err_fatal_out
132
+ # cfg_local_error_out
133
+ # cfg_local_error_valid
134
+ # cfg_rx_pm_state
135
+ # cfg_tx_pm_state
136
+ # cfg_ltssm_state
137
+ # cfg_rcb_status
138
+ # cfg_obff_enable
139
+ # cfg_pl_status_change
140
+ # cfg_tph_requester_enable
141
+ # cfg_tph_st_mode
142
+ # cfg_vf_tph_requester_enable
143
+ # cfg_vf_tph_st_mode
144
+
145
+ # Configuration Received Message Interface
146
+ # cfg_msg_received
147
+ # cfg_msg_received_data
148
+ # cfg_msg_received_type
149
+
150
+ # Configuration Transmit Message Interface
151
+ # cfg_msg_transmit
152
+ # cfg_msg_transmit_type
153
+ # cfg_msg_transmit_data
154
+ # cfg_msg_transmit_done
155
+
156
+ # Configuration Flow Control Interface
157
+ cfg_fc_ph=dut.cfg_fc_ph,
158
+ cfg_fc_pd=dut.cfg_fc_pd,
159
+ cfg_fc_nph=dut.cfg_fc_nph,
160
+ cfg_fc_npd=dut.cfg_fc_npd,
161
+ cfg_fc_cplh=dut.cfg_fc_cplh,
162
+ cfg_fc_cpld=dut.cfg_fc_cpld,
163
+ cfg_fc_sel=dut.cfg_fc_sel,
164
+
165
+ # Configuration Control Interface
166
+ # cfg_hot_reset_in
167
+ # cfg_hot_reset_out
168
+ # cfg_config_space_enable
169
+ # cfg_dsn
170
+ # cfg_bus_number
171
+ # cfg_ds_port_number
172
+ # cfg_ds_bus_number
173
+ # cfg_ds_device_number
174
+ # cfg_ds_function_number
175
+ # cfg_power_state_change_ack
176
+ # cfg_power_state_change_interrupt
177
+ cfg_err_cor_in=dut.status_error_cor,
178
+ cfg_err_uncor_in=dut.status_error_uncor,
179
+ # cfg_flr_in_process
180
+ # cfg_flr_done
181
+ # cfg_vf_flr_in_process
182
+ # cfg_vf_flr_func_num
183
+ # cfg_vf_flr_done
184
+ # cfg_pm_aspm_l1_entry_reject
185
+ # cfg_pm_aspm_tx_l0s_entry_disable
186
+ # cfg_req_pm_transition_l23_ready
187
+ # cfg_link_training_enable
188
+
189
+ # Configuration Interrupt Controller Interface
190
+ # cfg_interrupt_int
191
+ # cfg_interrupt_sent
192
+ # cfg_interrupt_pending
193
+ cfg_interrupt_msi_enable=dut.cfg_interrupt_msi_enable,
194
+ cfg_interrupt_msi_mmenable=dut.cfg_interrupt_msi_mmenable,
195
+ cfg_interrupt_msi_mask_update=dut.cfg_interrupt_msi_mask_update,
196
+ cfg_interrupt_msi_data=dut.cfg_interrupt_msi_data,
197
+ # cfg_interrupt_msi_select=dut.cfg_interrupt_msi_select,
198
+ cfg_interrupt_msi_int=dut.cfg_interrupt_msi_int,
199
+ cfg_interrupt_msi_pending_status=dut.cfg_interrupt_msi_pending_status,
200
+ cfg_interrupt_msi_pending_status_data_enable=dut.cfg_interrupt_msi_pending_status_data_enable,
201
+ # cfg_interrupt_msi_pending_status_function_num=dut.cfg_interrupt_msi_pending_status_function_num,
202
+ cfg_interrupt_msi_sent=dut.cfg_interrupt_msi_sent,
203
+ cfg_interrupt_msi_fail=dut.cfg_interrupt_msi_fail,
204
+ # cfg_interrupt_msix_enable
205
+ # cfg_interrupt_msix_mask
206
+ # cfg_interrupt_msix_vf_enable
207
+ # cfg_interrupt_msix_vf_mask
208
+ # cfg_interrupt_msix_address
209
+ # cfg_interrupt_msix_data
210
+ # cfg_interrupt_msix_int
211
+ # cfg_interrupt_msix_vec_pending
212
+ # cfg_interrupt_msix_vec_pending_status
213
+ cfg_interrupt_msi_attr=dut.cfg_interrupt_msi_attr,
214
+ cfg_interrupt_msi_tph_present=dut.cfg_interrupt_msi_tph_present,
215
+ cfg_interrupt_msi_tph_type=dut.cfg_interrupt_msi_tph_type,
216
+ # cfg_interrupt_msi_tph_st_tag=dut.cfg_interrupt_msi_tph_st_tag,
217
+ # cfg_interrupt_msi_function_number=dut.cfg_interrupt_msi_function_number,
218
+
219
+ # Configuration Extend Interface
220
+ # cfg_ext_read_received
221
+ # cfg_ext_write_received
222
+ # cfg_ext_register_number
223
+ # cfg_ext_function_number
224
+ # cfg_ext_write_data
225
+ # cfg_ext_write_byte_enable
226
+ # cfg_ext_read_data
227
+ # cfg_ext_read_data_valid
228
+ )
229
+
230
+ # self.dev.log.setLevel(logging.DEBUG)
231
+
232
+ self.rc.make_port().connect(self.dev)
233
+
234
+ self.dev.functions[0].msi_multiple_message_capable = 5
235
+
236
+ self.dev.functions[0].configure_bar(0, 2**len(dut.example_core_pcie_us_inst.core_pcie_inst.axil_ctrl_awaddr))
237
+ self.dev.functions[0].configure_bar(2, 2**len(dut.example_core_pcie_us_inst.core_pcie_inst.axi_ram_awaddr))
238
+
239
+ async def init(self):
240
+
241
+ await FallingEdge(self.dut.rst)
242
+ await Timer(100, 'ns')
243
+
244
+ await self.rc.enumerate(enable_bus_mastering=True, configure_msi=True)
245
+
246
+
247
+ @cocotb.test()
248
+ async def run_test(dut):
249
+
250
+ tb = TB(dut)
251
+
252
+ await tb.init()
253
+
254
+ mem = tb.rc.mem_pool.alloc_region(16*1024*1024)
255
+ mem_base = mem.get_absolute_address(0)
256
+
257
+ dev_pf0_bar0 = tb.rc.tree[0][0].bar_window[0]
258
+ dev_pf0_bar2 = tb.rc.tree[0][0].bar_window[2]
259
+
260
+ tb.log.info("Test memory write to BAR 2")
261
+
262
+ test_data = b'\x11\x22\x33\x44'
263
+ await dev_pf0_bar2.write(0, test_data)
264
+
265
+ await Timer(100, 'ns')
266
+
267
+ tb.log.info("Test memory read from BAR 2")
268
+
269
+ val = await dev_pf0_bar2.read(0, len(test_data), timeout=1000)
270
+ tb.log.info("Read data: %s", val)
271
+ assert val == test_data
272
+
273
+ tb.log.info("Test DMA")
274
+
275
+ # write packet data
276
+ mem[0:1024] = bytearray([x % 256 for x in range(1024)])
277
+
278
+ # enable DMA
279
+ await dev_pf0_bar0.write_dword(0x000000, 1)
280
+
281
+ # write pcie read descriptor
282
+ await dev_pf0_bar0.write_dword(0x000100, (mem_base+0x0000) & 0xffffffff)
283
+ await dev_pf0_bar0.write_dword(0x000104, (mem_base+0x0000 >> 32) & 0xffffffff)
284
+ await dev_pf0_bar0.write_dword(0x000108, 0x100)
285
+ await dev_pf0_bar0.write_dword(0x000110, 0x400)
286
+ await dev_pf0_bar0.write_dword(0x000114, 0xAA)
287
+
288
+ await Timer(2000, 'ns')
289
+
290
+ # read status
291
+ val = await dev_pf0_bar0.read_dword(0x000118)
292
+ tb.log.info("Status: 0x%x", val)
293
+ assert val == 0x800000AA
294
+
295
+ # write pcie write descriptor
296
+ await dev_pf0_bar0.write_dword(0x000200, (mem_base+0x1000) & 0xffffffff)
297
+ await dev_pf0_bar0.write_dword(0x000204, (mem_base+0x1000 >> 32) & 0xffffffff)
298
+ await dev_pf0_bar0.write_dword(0x000208, 0x100)
299
+ await dev_pf0_bar0.write_dword(0x000210, 0x400)
300
+ await dev_pf0_bar0.write_dword(0x000214, 0x55)
301
+
302
+ await Timer(2000, 'ns')
303
+
304
+ # read status
305
+ val = await dev_pf0_bar0.read_dword(0x000218)
306
+ tb.log.info("Status: 0x%x", val)
307
+ assert val == 0x80000055
308
+
309
+ tb.log.info("%s", mem.hexdump_str(0x1000, 64))
310
+
311
+ assert mem[0:1024] == mem[0x1000:0x1000+1024]
312
+
313
+ tb.log.info("Test DMA block operations")
314
+
315
+ # write packet data
316
+ mem[0:1024] = bytearray([x % 256 for x in range(1024)])
317
+
318
+ # enable DMA
319
+ await dev_pf0_bar0.write_dword(0x000000, 1)
320
+ # disable interrupts
321
+ await dev_pf0_bar0.write_dword(0x000008, 0)
322
+
323
+ # configure operation (read)
324
+ # DMA base address
325
+ await dev_pf0_bar0.write_dword(0x001080, (mem_base+0x0000) & 0xffffffff)
326
+ await dev_pf0_bar0.write_dword(0x001084, (mem_base+0x0000 >> 32) & 0xffffffff)
327
+ # DMA offset address
328
+ await dev_pf0_bar0.write_dword(0x001088, 0)
329
+ await dev_pf0_bar0.write_dword(0x00108c, 0)
330
+ # DMA offset mask
331
+ await dev_pf0_bar0.write_dword(0x001090, 0x000003ff)
332
+ await dev_pf0_bar0.write_dword(0x001094, 0)
333
+ # DMA stride
334
+ await dev_pf0_bar0.write_dword(0x001098, 256)
335
+ await dev_pf0_bar0.write_dword(0x00109c, 0)
336
+ # RAM base address
337
+ await dev_pf0_bar0.write_dword(0x0010c0, 0)
338
+ await dev_pf0_bar0.write_dword(0x0010c4, 0)
339
+ # RAM offset address
340
+ await dev_pf0_bar0.write_dword(0x0010c8, 0)
341
+ await dev_pf0_bar0.write_dword(0x0010cc, 0)
342
+ # RAM offset mask
343
+ await dev_pf0_bar0.write_dword(0x0010d0, 0x000003ff)
344
+ await dev_pf0_bar0.write_dword(0x0010d4, 0)
345
+ # RAM stride
346
+ await dev_pf0_bar0.write_dword(0x0010d8, 256)
347
+ await dev_pf0_bar0.write_dword(0x0010dc, 0)
348
+ # clear cycle count
349
+ await dev_pf0_bar0.write_dword(0x001008, 0)
350
+ await dev_pf0_bar0.write_dword(0x00100c, 0)
351
+ # block length
352
+ await dev_pf0_bar0.write_dword(0x001010, 256)
353
+ # block count
354
+ await dev_pf0_bar0.write_dword(0x001018, 32)
355
+ await dev_pf0_bar0.write_dword(0x00101c, 0)
356
+ # start
357
+ await dev_pf0_bar0.write_dword(0x001000, 1)
358
+
359
+ await Timer(2000, 'ns')
360
+
361
+ # configure operation (write)
362
+ # DMA base address
363
+ await dev_pf0_bar0.write_dword(0x001180, (mem_base+0x0000) & 0xffffffff)
364
+ await dev_pf0_bar0.write_dword(0x001184, (mem_base+0x0000 >> 32) & 0xffffffff)
365
+ # DMA offset address
366
+ await dev_pf0_bar0.write_dword(0x001188, 0)
367
+ await dev_pf0_bar0.write_dword(0x00118c, 0)
368
+ # DMA offset mask
369
+ await dev_pf0_bar0.write_dword(0x001190, 0x000003ff)
370
+ await dev_pf0_bar0.write_dword(0x001194, 0)
371
+ # DMA stride
372
+ await dev_pf0_bar0.write_dword(0x001198, 256)
373
+ await dev_pf0_bar0.write_dword(0x00119c, 0)
374
+ # RAM base address
375
+ await dev_pf0_bar0.write_dword(0x0011c0, 0)
376
+ await dev_pf0_bar0.write_dword(0x0011c4, 0)
377
+ # RAM offset address
378
+ await dev_pf0_bar0.write_dword(0x0011c8, 0)
379
+ await dev_pf0_bar0.write_dword(0x0011cc, 0)
380
+ # RAM offset mask
381
+ await dev_pf0_bar0.write_dword(0x0011d0, 0x000003ff)
382
+ await dev_pf0_bar0.write_dword(0x0011d4, 0)
383
+ # RAM stride
384
+ await dev_pf0_bar0.write_dword(0x0011d8, 256)
385
+ await dev_pf0_bar0.write_dword(0x0011dc, 0)
386
+ # clear cycle count
387
+ await dev_pf0_bar0.write_dword(0x001108, 0)
388
+ await dev_pf0_bar0.write_dword(0x00110c, 0)
389
+ # block length
390
+ await dev_pf0_bar0.write_dword(0x001110, 256)
391
+ # block count
392
+ await dev_pf0_bar0.write_dword(0x001118, 32)
393
+ await dev_pf0_bar0.write_dword(0x00111c, 0)
394
+ # start
395
+ await dev_pf0_bar0.write_dword(0x001100, 1)
396
+
397
+ await Timer(2000, 'ns')
398
+
399
+ await RisingEdge(dut.clk)
400
+ await RisingEdge(dut.clk)
401
+
402
+
403
+ # cocotb-test
404
+
405
+ tests_dir = os.path.dirname(__file__)
406
+ rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))
407
+ lib_dir = os.path.abspath(os.path.join(rtl_dir, '..', 'lib'))
408
+ pcie_rtl_dir = os.path.abspath(os.path.join(lib_dir, 'pcie', 'rtl'))
409
+
410
+
411
+ def test_fpga_core(request):
412
+ dut = "fpga_core"
413
+ module = os.path.splitext(os.path.basename(__file__))[0]
414
+ toplevel = dut
415
+
416
+ verilog_sources = [
417
+ os.path.join(rtl_dir, f"{dut}.v"),
418
+ os.path.join(rtl_dir, "common", "example_core_pcie_us.v"),
419
+ os.path.join(rtl_dir, "common", "example_core_pcie.v"),
420
+ os.path.join(rtl_dir, "common", "example_core.v"),
421
+ os.path.join(rtl_dir, "common", "axi_ram.v"),
422
+ os.path.join(pcie_rtl_dir, "pcie_us_if.v"),
423
+ os.path.join(pcie_rtl_dir, "pcie_us_if_rc.v"),
424
+ os.path.join(pcie_rtl_dir, "pcie_us_if_rq.v"),
425
+ os.path.join(pcie_rtl_dir, "pcie_us_if_cq.v"),
426
+ os.path.join(pcie_rtl_dir, "pcie_us_if_cc.v"),
427
+ os.path.join(pcie_rtl_dir, "pcie_us_cfg.v"),
428
+ os.path.join(pcie_rtl_dir, "pcie_us_msi.v"),
429
+ os.path.join(pcie_rtl_dir, "pcie_axil_master.v"),
430
+ os.path.join(pcie_rtl_dir, "pcie_axi_master.v"),
431
+ os.path.join(pcie_rtl_dir, "pcie_axi_master_rd.v"),
432
+ os.path.join(pcie_rtl_dir, "pcie_axi_master_wr.v"),
433
+ os.path.join(pcie_rtl_dir, "pcie_tlp_demux_bar.v"),
434
+ os.path.join(pcie_rtl_dir, "pcie_tlp_demux.v"),
435
+ os.path.join(pcie_rtl_dir, "pcie_tlp_mux.v"),
436
+ os.path.join(pcie_rtl_dir, "dma_if_pcie.v"),
437
+ os.path.join(pcie_rtl_dir, "dma_if_pcie_rd.v"),
438
+ os.path.join(pcie_rtl_dir, "dma_if_pcie_wr.v"),
439
+ os.path.join(pcie_rtl_dir, "dma_psdpram.v"),
440
+ os.path.join(pcie_rtl_dir, "arbiter.v"),
441
+ os.path.join(pcie_rtl_dir, "priority_encoder.v"),
442
+ os.path.join(pcie_rtl_dir, "pulse_merge.v"),
443
+ ]
444
+
445
+ parameters = {}
446
+
447
+ parameters['AXIS_PCIE_DATA_WIDTH'] = 512
448
+ parameters['AXIS_PCIE_KEEP_WIDTH'] = parameters['AXIS_PCIE_DATA_WIDTH'] // 32
449
+ parameters['AXIS_PCIE_RQ_USER_WIDTH'] = 62 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 137
450
+ parameters['AXIS_PCIE_RC_USER_WIDTH'] = 75 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 161
451
+ parameters['AXIS_PCIE_CQ_USER_WIDTH'] = 88 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 183
452
+ parameters['AXIS_PCIE_CC_USER_WIDTH'] = 33 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 81
453
+ parameters['RQ_SEQ_NUM_WIDTH'] = 6
454
+ parameters['RQ_SEQ_NUM_ENABLE'] = 1
455
+ parameters['PCIE_TAG_COUNT'] = 64
456
+ parameters['BAR0_APERTURE'] = 24
457
+ parameters['BAR2_APERTURE'] = 24
458
+
459
+ extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
460
+
461
+ sim_build = os.path.join(tests_dir, "sim_build",
462
+ request.node.name.replace('[', '-').replace(']', ''))
463
+
464
+ cocotb_test.simulator.run(
465
+ python_search=[tests_dir],
466
+ verilog_sources=verilog_sources,
467
+ toplevel=toplevel,
468
+ module=module,
469
+ parameters=parameters,
470
+ sim_build=sim_build,
471
+ extra_env=extra_env,
472
+ )
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/common/vivado.mk ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: fpga vivado tmpclean clean distclean
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
+ SYN_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(SYN_FILES))) $(filter /% ./%,$(SYN_FILES))
41
+ INC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(INC_FILES))) $(filter /% ./%,$(INC_FILES))
42
+ XCI_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XCI_FILES))) $(filter /% ./%,$(XCI_FILES))
43
+ IP_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(IP_TCL_FILES))) $(filter /% ./%,$(IP_TCL_FILES))
44
+ CONFIG_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(CONFIG_TCL_FILES))) $(filter /% ./%,$(CONFIG_TCL_FILES))
45
+
46
+ ifdef XDC_FILES
47
+ XDC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XDC_FILES))) $(filter /% ./%,$(XDC_FILES))
48
+ else
49
+ XDC_FILES_REL = $(FPGA_TOP).xdc
50
+ endif
51
+
52
+ ###################################################################
53
+ # Main Targets
54
+ #
55
+ # all: build everything
56
+ # clean: remove output files and project files
57
+ ###################################################################
58
+
59
+ all: fpga
60
+
61
+ fpga: $(FPGA_TOP).bit
62
+
63
+ vivado: $(FPGA_TOP).xpr
64
+ vivado $(FPGA_TOP).xpr
65
+
66
+ tmpclean::
67
+ -rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
68
+ -rm -rf create_project.tcl update_config.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
69
+
70
+ clean:: tmpclean
71
+ -rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
72
+
73
+ distclean:: clean
74
+ -rm -rf rev
75
+
76
+ ###################################################################
77
+ # Target implementations
78
+ ###################################################################
79
+
80
+ # Vivado project file
81
+ create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
82
+ rm -rf defines.v
83
+ touch defines.v
84
+ for x in $(DEFS); do echo '`define' $$x >> defines.v; done
85
+ echo "create_project -force -part $(FPGA_PART) $(FPGA_TOP)" > $@
86
+ echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
87
+ echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
88
+ for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
89
+ for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
90
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
91
+
92
+ update_config.tcl: $(CONFIG_TCL_FILES_REL)
93
+ echo "open_project -quiet $(FPGA_TOP).xpr" > $@
94
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
95
+
96
+ $(FPGA_TOP).xpr: create_project.tcl update_config.tcl
97
+ vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
98
+
99
+ # synthesis run
100
+ %.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL) $(CONFIG_TCL_FILES_REL)
101
+ echo "open_project $*.xpr" > run_synth.tcl
102
+ echo "reset_run synth_1" >> run_synth.tcl
103
+ echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
104
+ echo "wait_on_run synth_1" >> run_synth.tcl
105
+ vivado -nojournal -nolog -mode batch -source run_synth.tcl
106
+
107
+ # implementation run
108
+ %.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
109
+ echo "open_project $*.xpr" > run_impl.tcl
110
+ echo "reset_run impl_1" >> run_impl.tcl
111
+ echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
112
+ echo "wait_on_run impl_1" >> run_impl.tcl
113
+ vivado -nojournal -nolog -mode batch -source run_impl.tcl
114
+
115
+ # bit file
116
+ %.bit: %.runs/impl_1/%_routed.dcp
117
+ echo "open_project $*.xpr" > generate_bit.tcl
118
+ echo "open_run impl_1" >> generate_bit.tcl
119
+ echo "write_bitstream -force $*.bit" >> generate_bit.tcl
120
+ vivado -nojournal -nolog -mode batch -source generate_bit.tcl
121
+ mkdir -p rev
122
+ EXT=bit; COUNT=100; \
123
+ while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
124
+ do COUNT=$$((COUNT+1)); done; \
125
+ cp $@ rev/$*_rev$$COUNT.$$EXT; \
126
+ echo "Output: rev/$*_rev$$COUNT.$$EXT";
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/fpga/Makefile ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # FPGA settings
3
+ FPGA_PART = xcu50-fsvh2104-2-e
4
+ FPGA_TOP = fpga
5
+ FPGA_ARCH = virtexuplus
6
+
7
+ # Files for synthesis
8
+ SYN_FILES = rtl/fpga.v
9
+ SYN_FILES += rtl/fpga_core.v
10
+ SYN_FILES += rtl/sync_reset.v
11
+ SYN_FILES += rtl/sync_signal.v
12
+ SYN_FILES += rtl/axi_ram.v
13
+ SYN_FILES += rtl/axis_register.v
14
+ SYN_FILES += lib/pcie/rtl/axis_arb_mux.v
15
+ SYN_FILES += lib/pcie/rtl/pcie_us_axil_master.v
16
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma.v
17
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma_rd.v
18
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_dma_wr.v
19
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master.v
20
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master_rd.v
21
+ SYN_FILES += lib/pcie/rtl/pcie_us_axi_master_wr.v
22
+ SYN_FILES += lib/pcie/rtl/pcie_us_axis_cq_demux.v
23
+ SYN_FILES += lib/pcie/rtl/pcie_us_cfg.v
24
+ SYN_FILES += lib/pcie/rtl/pcie_us_msi.v
25
+ SYN_FILES += lib/pcie/rtl/arbiter.v
26
+ SYN_FILES += lib/pcie/rtl/priority_encoder.v
27
+ SYN_FILES += lib/pcie/rtl/pulse_merge.v
28
+
29
+ # XDC files
30
+ XDC_FILES = fpga.xdc
31
+
32
+ # IP
33
+ IP_TCL_FILES = ip/pcie4c_uscale_plus_0.tcl
34
+
35
+ include ../common/vivado.mk
36
+
37
+ program: $(FPGA_TOP).bit
38
+ echo "open_hw" > program.tcl
39
+ echo "connect_hw_server" >> program.tcl
40
+ echo "open_hw_target" >> program.tcl
41
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
42
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
43
+ echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
44
+ echo "program_hw_devices [current_hw_device]" >> program.tcl
45
+ echo "exit" >> program.tcl
46
+ vivado -nojournal -nolog -mode batch -source program.tcl
47
+
48
+ %.mcs %.prm: %.bit
49
+ echo "write_cfgmem -force -format mcs -size 128 -interface SPIx4 -loadbit {up 0x01002000 $*.bit} -checksum -file $*.mcs" > generate_mcs.tcl
50
+ echo "exit" >> generate_mcs.tcl
51
+ vivado -nojournal -nolog -mode batch -source generate_mcs.tcl
52
+ mkdir -p rev
53
+ COUNT=100; \
54
+ while [ -e rev/$*_rev$$COUNT.bit ]; \
55
+ do COUNT=$$((COUNT+1)); done; \
56
+ COUNT=$$((COUNT-1)); \
57
+ for x in .mcs .prm; \
58
+ do cp $*$$x rev/$*_rev$$COUNT$$x; \
59
+ echo "Output: rev/$*_rev$$COUNT$$x"; done;
60
+
61
+ flash: $(FPGA_TOP).mcs $(FPGA_TOP).prm
62
+ echo "open_hw" > flash.tcl
63
+ echo "connect_hw_server" >> flash.tcl
64
+ echo "open_hw_target" >> flash.tcl
65
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> flash.tcl
66
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> flash.tcl
67
+ echo "create_hw_cfgmem -hw_device [current_hw_device] [lindex [get_cfgmem_parts {mt25qu01g-spi-x1_x2_x4}] 0]" >> flash.tcl
68
+ echo "current_hw_cfgmem -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM [current_hw_device]]" >> flash.tcl
69
+ echo "set_property PROGRAM.FILES [list \"$(FPGA_TOP).mcs\"] [current_hw_cfgmem]" >> flash.tcl
70
+ echo "set_property PROGRAM.PRM_FILES [list \"$(FPGA_TOP).prm\"] [current_hw_cfgmem]" >> flash.tcl
71
+ echo "set_property PROGRAM.ERASE 1 [current_hw_cfgmem]" >> flash.tcl
72
+ echo "set_property PROGRAM.CFG_PROGRAM 1 [current_hw_cfgmem]" >> flash.tcl
73
+ echo "set_property PROGRAM.VERIFY 1 [current_hw_cfgmem]" >> flash.tcl
74
+ echo "set_property PROGRAM.CHECKSUM 0 [current_hw_cfgmem]" >> flash.tcl
75
+ echo "set_property PROGRAM.ADDRESS_RANGE {use_file} [current_hw_cfgmem]" >> flash.tcl
76
+ echo "set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [current_hw_cfgmem]" >> flash.tcl
77
+ echo "create_hw_bitstream -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM_BITFILE [current_hw_device]]" >> flash.tcl
78
+ echo "program_hw_devices [current_hw_device]" >> flash.tcl
79
+ echo "refresh_hw_device [current_hw_device]" >> flash.tcl
80
+ echo "program_hw_cfgmem -hw_cfgmem [current_hw_cfgmem]" >> flash.tcl
81
+ echo "boot_hw_device [current_hw_device]" >> flash.tcl
82
+ echo "exit" >> flash.tcl
83
+ vivado -nojournal -nolog -mode batch -source flash.tcl
84
+
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/ip/pcie4c_uscale_plus_0.tcl ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ create_ip -name pcie4c_uscale_plus -vendor xilinx.com -library ip -module_name pcie4c_uscale_plus_0
3
+
4
+ set_property -dict [list \
5
+ CONFIG.PL_LINK_CAP_MAX_LINK_SPEED {8.0_GT/s} \
6
+ CONFIG.PL_LINK_CAP_MAX_LINK_WIDTH {X16} \
7
+ CONFIG.AXISTEN_IF_EXT_512_RQ_STRADDLE {false} \
8
+ CONFIG.axisten_if_enable_client_tag {true} \
9
+ CONFIG.axisten_if_width {512_bit} \
10
+ CONFIG.axisten_freq {250} \
11
+ CONFIG.PF0_CLASS_CODE {058000} \
12
+ CONFIG.PF0_DEVICE_ID {0001} \
13
+ CONFIG.PF0_MSI_CAP_MULTIMSGCAP {32_vectors} \
14
+ CONFIG.PF0_SUBSYSTEM_ID {9032} \
15
+ CONFIG.PF0_SUBSYSTEM_VENDOR_ID {10ee} \
16
+ CONFIG.pf0_bar0_64bit {true} \
17
+ CONFIG.pf0_bar0_prefetchable {true} \
18
+ CONFIG.pf0_bar0_scale {Megabytes} \
19
+ CONFIG.pf0_bar0_size {16} \
20
+ CONFIG.pf0_bar2_64bit {true} \
21
+ CONFIG.pf0_bar2_prefetchable {true} \
22
+ CONFIG.pf0_bar2_enabled {true} \
23
+ CONFIG.pf0_bar2_type {Memory} \
24
+ CONFIG.pf0_bar2_scale {Megabytes} \
25
+ CONFIG.pf0_bar2_size {16} \
26
+ CONFIG.vendor_id {1234} \
27
+ CONFIG.en_msi_per_vec_masking {true} \
28
+ ] [get_ips pcie4c_uscale_plus_0]
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/axi_ram.v ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * AXI4 RAM
33
+ */
34
+ module axi_ram #
35
+ (
36
+ parameter DATA_WIDTH = 32, // width of data bus in bits
37
+ parameter ADDR_WIDTH = 16, // width of address bus in bits
38
+ parameter STRB_WIDTH = (DATA_WIDTH/8),
39
+ parameter ID_WIDTH = 8,
40
+ parameter PIPELINE_OUTPUT = 0
41
+ )
42
+ (
43
+ input wire clk,
44
+ input wire rst,
45
+
46
+ input wire [ID_WIDTH-1:0] s_axi_awid,
47
+ input wire [ADDR_WIDTH-1:0] s_axi_awaddr,
48
+ input wire [7:0] s_axi_awlen,
49
+ input wire [2:0] s_axi_awsize,
50
+ input wire [1:0] s_axi_awburst,
51
+ input wire s_axi_awlock,
52
+ input wire [3:0] s_axi_awcache,
53
+ input wire [2:0] s_axi_awprot,
54
+ input wire s_axi_awvalid,
55
+ output wire s_axi_awready,
56
+ input wire [DATA_WIDTH-1:0] s_axi_wdata,
57
+ input wire [STRB_WIDTH-1:0] s_axi_wstrb,
58
+ input wire s_axi_wlast,
59
+ input wire s_axi_wvalid,
60
+ output wire s_axi_wready,
61
+ output wire [ID_WIDTH-1:0] s_axi_bid,
62
+ output wire [1:0] s_axi_bresp,
63
+ output wire s_axi_bvalid,
64
+ input wire s_axi_bready,
65
+ input wire [ID_WIDTH-1:0] s_axi_arid,
66
+ input wire [ADDR_WIDTH-1:0] s_axi_araddr,
67
+ input wire [7:0] s_axi_arlen,
68
+ input wire [2:0] s_axi_arsize,
69
+ input wire [1:0] s_axi_arburst,
70
+ input wire s_axi_arlock,
71
+ input wire [3:0] s_axi_arcache,
72
+ input wire [2:0] s_axi_arprot,
73
+ input wire s_axi_arvalid,
74
+ output wire s_axi_arready,
75
+ output wire [ID_WIDTH-1:0] s_axi_rid,
76
+ output wire [DATA_WIDTH-1:0] s_axi_rdata,
77
+ output wire [1:0] s_axi_rresp,
78
+ output wire s_axi_rlast,
79
+ output wire s_axi_rvalid,
80
+ input wire s_axi_rready
81
+ );
82
+
83
+ parameter VALID_ADDR_WIDTH = ADDR_WIDTH - $clog2(STRB_WIDTH);
84
+ parameter WORD_WIDTH = STRB_WIDTH;
85
+ parameter WORD_SIZE = DATA_WIDTH/WORD_WIDTH;
86
+
87
+ // bus width assertions
88
+ initial begin
89
+ if (WORD_SIZE * STRB_WIDTH != DATA_WIDTH) begin
90
+ $error("Error: AXI data width not evenly divisble");
91
+ $finish;
92
+ end
93
+
94
+ if (2**$clog2(WORD_WIDTH) != WORD_WIDTH) begin
95
+ $error("Error: AXI word width must be even power of two");
96
+ $finish;
97
+ end
98
+ end
99
+
100
+ localparam [0:0]
101
+ READ_STATE_IDLE = 1'd0,
102
+ READ_STATE_BURST = 1'd1;
103
+
104
+ reg [0:0] read_state_reg = READ_STATE_IDLE, read_state_next;
105
+
106
+ localparam [1:0]
107
+ WRITE_STATE_IDLE = 2'd0,
108
+ WRITE_STATE_BURST = 2'd1,
109
+ WRITE_STATE_RESP = 2'd2;
110
+
111
+ reg [1:0] write_state_reg = WRITE_STATE_IDLE, write_state_next;
112
+
113
+ reg mem_wr_en;
114
+ reg mem_rd_en;
115
+
116
+ reg [ID_WIDTH-1:0] read_id_reg = {ID_WIDTH{1'b0}}, read_id_next;
117
+ reg [ADDR_WIDTH-1:0] read_addr_reg = {ADDR_WIDTH{1'b0}}, read_addr_next;
118
+ reg [7:0] read_count_reg = 8'd0, read_count_next;
119
+ reg [2:0] read_size_reg = 3'd0, read_size_next;
120
+ reg [1:0] read_burst_reg = 2'd0, read_burst_next;
121
+ reg [ID_WIDTH-1:0] write_id_reg = {ID_WIDTH{1'b0}}, write_id_next;
122
+ reg [ADDR_WIDTH-1:0] write_addr_reg = {ADDR_WIDTH{1'b0}}, write_addr_next;
123
+ reg [7:0] write_count_reg = 8'd0, write_count_next;
124
+ reg [2:0] write_size_reg = 3'd0, write_size_next;
125
+ reg [1:0] write_burst_reg = 2'd0, write_burst_next;
126
+
127
+ reg s_axi_awready_reg = 1'b0, s_axi_awready_next;
128
+ reg s_axi_wready_reg = 1'b0, s_axi_wready_next;
129
+ reg [ID_WIDTH-1:0] s_axi_bid_reg = {ID_WIDTH{1'b0}}, s_axi_bid_next;
130
+ reg s_axi_bvalid_reg = 1'b0, s_axi_bvalid_next;
131
+ reg s_axi_arready_reg = 1'b0, s_axi_arready_next;
132
+ reg [ID_WIDTH-1:0] s_axi_rid_reg = {ID_WIDTH{1'b0}}, s_axi_rid_next;
133
+ reg [DATA_WIDTH-1:0] s_axi_rdata_reg = {DATA_WIDTH{1'b0}}, s_axi_rdata_next;
134
+ reg s_axi_rlast_reg = 1'b0, s_axi_rlast_next;
135
+ reg s_axi_rvalid_reg = 1'b0, s_axi_rvalid_next;
136
+ reg [ID_WIDTH-1:0] s_axi_rid_pipe_reg = {ID_WIDTH{1'b0}};
137
+ reg [DATA_WIDTH-1:0] s_axi_rdata_pipe_reg = {DATA_WIDTH{1'b0}};
138
+ reg s_axi_rlast_pipe_reg = 1'b0;
139
+ reg s_axi_rvalid_pipe_reg = 1'b0;
140
+
141
+ // (* RAM_STYLE="BLOCK" *)
142
+ reg [DATA_WIDTH-1:0] mem[(2**VALID_ADDR_WIDTH)-1:0];
143
+
144
+ wire [VALID_ADDR_WIDTH-1:0] s_axi_awaddr_valid = s_axi_awaddr >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
145
+ wire [VALID_ADDR_WIDTH-1:0] s_axi_araddr_valid = s_axi_araddr >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
146
+ wire [VALID_ADDR_WIDTH-1:0] read_addr_valid = read_addr_reg >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
147
+ wire [VALID_ADDR_WIDTH-1:0] write_addr_valid = write_addr_reg >> (ADDR_WIDTH - VALID_ADDR_WIDTH);
148
+
149
+ assign s_axi_awready = s_axi_awready_reg;
150
+ assign s_axi_wready = s_axi_wready_reg;
151
+ assign s_axi_bid = s_axi_bid_reg;
152
+ assign s_axi_bresp = 2'b00;
153
+ assign s_axi_bvalid = s_axi_bvalid_reg;
154
+ assign s_axi_arready = s_axi_arready_reg;
155
+ assign s_axi_rid = PIPELINE_OUTPUT ? s_axi_rid_pipe_reg : s_axi_rid_reg;
156
+ assign s_axi_rdata = PIPELINE_OUTPUT ? s_axi_rdata_pipe_reg : s_axi_rdata_reg;
157
+ assign s_axi_rresp = 2'b00;
158
+ assign s_axi_rlast = PIPELINE_OUTPUT ? s_axi_rlast_pipe_reg : s_axi_rlast_reg;
159
+ assign s_axi_rvalid = PIPELINE_OUTPUT ? s_axi_rvalid_pipe_reg : s_axi_rvalid_reg;
160
+
161
+ integer i, j;
162
+
163
+ initial begin
164
+ // two nested loops for smaller number of iterations per loop
165
+ // workaround for synthesizer complaints about large loop counts
166
+ for (i = 0; i < 2**ADDR_WIDTH; i = i + 2**(ADDR_WIDTH/2)) begin
167
+ for (j = i; j < i + 2**(ADDR_WIDTH/2); j = j + 1) begin
168
+ mem[j] = 0;
169
+ end
170
+ end
171
+ end
172
+
173
+ always @* begin
174
+ write_state_next = WRITE_STATE_IDLE;
175
+
176
+ mem_wr_en = 1'b0;
177
+
178
+ write_id_next = write_id_reg;
179
+ write_addr_next = write_addr_reg;
180
+ write_count_next = write_count_reg;
181
+ write_size_next = write_size_reg;
182
+ write_burst_next = write_burst_reg;
183
+
184
+ s_axi_awready_next = 1'b0;
185
+ s_axi_wready_next = 1'b0;
186
+ s_axi_bid_next = s_axi_bid_reg;
187
+ s_axi_bvalid_next = s_axi_bvalid_reg && !s_axi_bready;
188
+
189
+ case (write_state_reg)
190
+ WRITE_STATE_IDLE: begin
191
+ s_axi_awready_next = 1'b1;
192
+
193
+ if (s_axi_awready && s_axi_awvalid) begin
194
+ write_id_next = s_axi_awid;
195
+ write_addr_next = s_axi_awaddr;
196
+ write_count_next = s_axi_awlen;
197
+ write_size_next = s_axi_awsize < $clog2(STRB_WIDTH) ? s_axi_awsize : $clog2(STRB_WIDTH);
198
+ write_burst_next = s_axi_awburst;
199
+
200
+ s_axi_awready_next = 1'b0;
201
+ s_axi_wready_next = 1'b1;
202
+ write_state_next = WRITE_STATE_BURST;
203
+ end else begin
204
+ write_state_next = WRITE_STATE_IDLE;
205
+ end
206
+ end
207
+ WRITE_STATE_BURST: begin
208
+ s_axi_wready_next = 1'b1;
209
+
210
+ if (s_axi_wready && s_axi_wvalid) begin
211
+ mem_wr_en = 1'b1;
212
+ if (write_burst_reg != 2'b00) begin
213
+ write_addr_next = write_addr_reg + (1 << write_size_reg);
214
+ end
215
+ write_count_next = write_count_reg - 1;
216
+ if (write_count_reg > 0) begin
217
+ write_state_next = WRITE_STATE_BURST;
218
+ end else begin
219
+ s_axi_wready_next = 1'b0;
220
+ if (s_axi_bready || !s_axi_bvalid) begin
221
+ s_axi_bid_next = write_id_reg;
222
+ s_axi_bvalid_next = 1'b1;
223
+ s_axi_awready_next = 1'b1;
224
+ write_state_next = WRITE_STATE_IDLE;
225
+ end else begin
226
+ write_state_next = WRITE_STATE_RESP;
227
+ end
228
+ end
229
+ end else begin
230
+ write_state_next = WRITE_STATE_BURST;
231
+ end
232
+ end
233
+ WRITE_STATE_RESP: begin
234
+ if (s_axi_bready || !s_axi_bvalid) begin
235
+ s_axi_bid_next = write_id_reg;
236
+ s_axi_bvalid_next = 1'b1;
237
+ s_axi_awready_next = 1'b1;
238
+ write_state_next = WRITE_STATE_IDLE;
239
+ end else begin
240
+ write_state_next = WRITE_STATE_RESP;
241
+ end
242
+ end
243
+ endcase
244
+ end
245
+
246
+ always @(posedge clk) begin
247
+ if (rst) begin
248
+ write_state_reg <= WRITE_STATE_IDLE;
249
+ s_axi_awready_reg <= 1'b0;
250
+ s_axi_wready_reg <= 1'b0;
251
+ s_axi_bvalid_reg <= 1'b0;
252
+ end else begin
253
+ write_state_reg <= write_state_next;
254
+ s_axi_awready_reg <= s_axi_awready_next;
255
+ s_axi_wready_reg <= s_axi_wready_next;
256
+ s_axi_bvalid_reg <= s_axi_bvalid_next;
257
+ end
258
+
259
+ write_id_reg <= write_id_next;
260
+ write_addr_reg <= write_addr_next;
261
+ write_count_reg <= write_count_next;
262
+ write_size_reg <= write_size_next;
263
+ write_burst_reg <= write_burst_next;
264
+
265
+ s_axi_bid_reg <= s_axi_bid_next;
266
+
267
+ for (i = 0; i < WORD_WIDTH; i = i + 1) begin
268
+ if (mem_wr_en & s_axi_wstrb[i]) begin
269
+ mem[write_addr_valid][WORD_SIZE*i +: WORD_SIZE] <= s_axi_wdata[WORD_SIZE*i +: WORD_SIZE];
270
+ end
271
+ end
272
+ end
273
+
274
+ always @* begin
275
+ read_state_next = READ_STATE_IDLE;
276
+
277
+ mem_rd_en = 1'b0;
278
+
279
+ s_axi_rid_next = s_axi_rid_reg;
280
+ s_axi_rlast_next = s_axi_rlast_reg;
281
+ s_axi_rvalid_next = s_axi_rvalid_reg && !(s_axi_rready || (PIPELINE_OUTPUT && !s_axi_rvalid_pipe_reg));
282
+
283
+ read_id_next = read_id_reg;
284
+ read_addr_next = read_addr_reg;
285
+ read_count_next = read_count_reg;
286
+ read_size_next = read_size_reg;
287
+ read_burst_next = read_burst_reg;
288
+
289
+ s_axi_arready_next = 1'b0;
290
+
291
+ case (read_state_reg)
292
+ READ_STATE_IDLE: begin
293
+ s_axi_arready_next = 1'b1;
294
+
295
+ if (s_axi_arready && s_axi_arvalid) begin
296
+ read_id_next = s_axi_arid;
297
+ read_addr_next = s_axi_araddr;
298
+ read_count_next = s_axi_arlen;
299
+ read_size_next = s_axi_arsize < $clog2(STRB_WIDTH) ? s_axi_arsize : $clog2(STRB_WIDTH);
300
+ read_burst_next = s_axi_arburst;
301
+
302
+ s_axi_arready_next = 1'b0;
303
+ read_state_next = READ_STATE_BURST;
304
+ end else begin
305
+ read_state_next = READ_STATE_IDLE;
306
+ end
307
+ end
308
+ READ_STATE_BURST: begin
309
+ if (s_axi_rready || (PIPELINE_OUTPUT && !s_axi_rvalid_pipe_reg) || !s_axi_rvalid_reg) begin
310
+ mem_rd_en = 1'b1;
311
+ s_axi_rvalid_next = 1'b1;
312
+ s_axi_rid_next = read_id_reg;
313
+ s_axi_rlast_next = read_count_reg == 0;
314
+ if (read_burst_reg != 2'b00) begin
315
+ read_addr_next = read_addr_reg + (1 << read_size_reg);
316
+ end
317
+ read_count_next = read_count_reg - 1;
318
+ if (read_count_reg > 0) begin
319
+ read_state_next = READ_STATE_BURST;
320
+ end else begin
321
+ s_axi_arready_next = 1'b1;
322
+ read_state_next = READ_STATE_IDLE;
323
+ end
324
+ end else begin
325
+ read_state_next = READ_STATE_BURST;
326
+ end
327
+ end
328
+ endcase
329
+ end
330
+
331
+ always @(posedge clk) begin
332
+ if (rst) begin
333
+ read_state_reg <= READ_STATE_IDLE;
334
+ s_axi_arready_reg <= 1'b0;
335
+ s_axi_rvalid_reg <= 1'b0;
336
+ s_axi_rvalid_pipe_reg <= 1'b0;
337
+ end else begin
338
+ read_state_reg <= read_state_next;
339
+ s_axi_arready_reg <= s_axi_arready_next;
340
+ s_axi_rvalid_reg <= s_axi_rvalid_next;
341
+
342
+ if (!s_axi_rvalid_pipe_reg || s_axi_rready) begin
343
+ s_axi_rvalid_pipe_reg <= s_axi_rvalid_reg;
344
+ end
345
+ end
346
+
347
+ read_id_reg <= read_id_next;
348
+ read_addr_reg <= read_addr_next;
349
+ read_count_reg <= read_count_next;
350
+ read_size_reg <= read_size_next;
351
+ read_burst_reg <= read_burst_next;
352
+
353
+ s_axi_rid_reg <= s_axi_rid_next;
354
+ s_axi_rlast_reg <= s_axi_rlast_next;
355
+
356
+ if (mem_rd_en) begin
357
+ s_axi_rdata_reg <= mem[read_addr_valid];
358
+ end
359
+
360
+ if (!s_axi_rvalid_pipe_reg || s_axi_rready) begin
361
+ s_axi_rid_pipe_reg <= s_axi_rid_reg;
362
+ s_axi_rdata_pipe_reg <= s_axi_rdata_reg;
363
+ s_axi_rlast_pipe_reg <= s_axi_rlast_reg;
364
+ end
365
+ end
366
+
367
+ endmodule
368
+
369
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/axis_register.v ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * AXI4-Stream register
33
+ */
34
+ module axis_register #
35
+ (
36
+ parameter DATA_WIDTH = 8,
37
+ parameter KEEP_ENABLE = (DATA_WIDTH>8),
38
+ parameter KEEP_WIDTH = (DATA_WIDTH/8),
39
+ parameter LAST_ENABLE = 1,
40
+ parameter ID_ENABLE = 0,
41
+ parameter ID_WIDTH = 8,
42
+ parameter DEST_ENABLE = 0,
43
+ parameter DEST_WIDTH = 8,
44
+ parameter USER_ENABLE = 1,
45
+ parameter USER_WIDTH = 1,
46
+ parameter REG_TYPE = 2
47
+ )
48
+ (
49
+ input wire clk,
50
+ input wire rst,
51
+
52
+ /*
53
+ * AXI Stream input
54
+ */
55
+ input wire [DATA_WIDTH-1:0] s_axis_tdata,
56
+ input wire [KEEP_WIDTH-1:0] s_axis_tkeep,
57
+ input wire s_axis_tvalid,
58
+ output wire s_axis_tready,
59
+ input wire s_axis_tlast,
60
+ input wire [ID_WIDTH-1:0] s_axis_tid,
61
+ input wire [DEST_WIDTH-1:0] s_axis_tdest,
62
+ input wire [USER_WIDTH-1:0] s_axis_tuser,
63
+
64
+ /*
65
+ * AXI Stream output
66
+ */
67
+ output wire [DATA_WIDTH-1:0] m_axis_tdata,
68
+ output wire [KEEP_WIDTH-1:0] m_axis_tkeep,
69
+ output wire m_axis_tvalid,
70
+ input wire m_axis_tready,
71
+ output wire m_axis_tlast,
72
+ output wire [ID_WIDTH-1:0] m_axis_tid,
73
+ output wire [DEST_WIDTH-1:0] m_axis_tdest,
74
+ output wire [USER_WIDTH-1:0] m_axis_tuser
75
+ );
76
+
77
+ generate
78
+
79
+ if (REG_TYPE > 1) begin
80
+ // skid buffer, no bubble cycles
81
+
82
+ // datapath registers
83
+ reg s_axis_tready_reg = 1'b0;
84
+
85
+ reg [DATA_WIDTH-1:0] m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
86
+ reg [KEEP_WIDTH-1:0] m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
87
+ reg m_axis_tvalid_reg = 1'b0, m_axis_tvalid_next;
88
+ reg m_axis_tlast_reg = 1'b0;
89
+ reg [ID_WIDTH-1:0] m_axis_tid_reg = {ID_WIDTH{1'b0}};
90
+ reg [DEST_WIDTH-1:0] m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
91
+ reg [USER_WIDTH-1:0] m_axis_tuser_reg = {USER_WIDTH{1'b0}};
92
+
93
+ reg [DATA_WIDTH-1:0] temp_m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
94
+ reg [KEEP_WIDTH-1:0] temp_m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
95
+ reg temp_m_axis_tvalid_reg = 1'b0, temp_m_axis_tvalid_next;
96
+ reg temp_m_axis_tlast_reg = 1'b0;
97
+ reg [ID_WIDTH-1:0] temp_m_axis_tid_reg = {ID_WIDTH{1'b0}};
98
+ reg [DEST_WIDTH-1:0] temp_m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
99
+ reg [USER_WIDTH-1:0] temp_m_axis_tuser_reg = {USER_WIDTH{1'b0}};
100
+
101
+ // datapath control
102
+ reg store_axis_input_to_output;
103
+ reg store_axis_input_to_temp;
104
+ reg store_axis_temp_to_output;
105
+
106
+ assign s_axis_tready = s_axis_tready_reg;
107
+
108
+ assign m_axis_tdata = m_axis_tdata_reg;
109
+ assign m_axis_tkeep = KEEP_ENABLE ? m_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
110
+ assign m_axis_tvalid = m_axis_tvalid_reg;
111
+ assign m_axis_tlast = LAST_ENABLE ? m_axis_tlast_reg : 1'b1;
112
+ assign m_axis_tid = ID_ENABLE ? m_axis_tid_reg : {ID_WIDTH{1'b0}};
113
+ assign m_axis_tdest = DEST_ENABLE ? m_axis_tdest_reg : {DEST_WIDTH{1'b0}};
114
+ assign m_axis_tuser = USER_ENABLE ? m_axis_tuser_reg : {USER_WIDTH{1'b0}};
115
+
116
+ // enable ready input next cycle if output is ready or the temp reg will not be filled on the next cycle (output reg empty or no input)
117
+ wire s_axis_tready_early = m_axis_tready || (!temp_m_axis_tvalid_reg && (!m_axis_tvalid_reg || !s_axis_tvalid));
118
+
119
+ always @* begin
120
+ // transfer sink ready state to source
121
+ m_axis_tvalid_next = m_axis_tvalid_reg;
122
+ temp_m_axis_tvalid_next = temp_m_axis_tvalid_reg;
123
+
124
+ store_axis_input_to_output = 1'b0;
125
+ store_axis_input_to_temp = 1'b0;
126
+ store_axis_temp_to_output = 1'b0;
127
+
128
+ if (s_axis_tready_reg) begin
129
+ // input is ready
130
+ if (m_axis_tready || !m_axis_tvalid_reg) begin
131
+ // output is ready or currently not valid, transfer data to output
132
+ m_axis_tvalid_next = s_axis_tvalid;
133
+ store_axis_input_to_output = 1'b1;
134
+ end else begin
135
+ // output is not ready, store input in temp
136
+ temp_m_axis_tvalid_next = s_axis_tvalid;
137
+ store_axis_input_to_temp = 1'b1;
138
+ end
139
+ end else if (m_axis_tready) begin
140
+ // input is not ready, but output is ready
141
+ m_axis_tvalid_next = temp_m_axis_tvalid_reg;
142
+ temp_m_axis_tvalid_next = 1'b0;
143
+ store_axis_temp_to_output = 1'b1;
144
+ end
145
+ end
146
+
147
+ always @(posedge clk) begin
148
+ if (rst) begin
149
+ s_axis_tready_reg <= 1'b0;
150
+ m_axis_tvalid_reg <= 1'b0;
151
+ temp_m_axis_tvalid_reg <= 1'b0;
152
+ end else begin
153
+ s_axis_tready_reg <= s_axis_tready_early;
154
+ m_axis_tvalid_reg <= m_axis_tvalid_next;
155
+ temp_m_axis_tvalid_reg <= temp_m_axis_tvalid_next;
156
+ end
157
+
158
+ // datapath
159
+ if (store_axis_input_to_output) begin
160
+ m_axis_tdata_reg <= s_axis_tdata;
161
+ m_axis_tkeep_reg <= s_axis_tkeep;
162
+ m_axis_tlast_reg <= s_axis_tlast;
163
+ m_axis_tid_reg <= s_axis_tid;
164
+ m_axis_tdest_reg <= s_axis_tdest;
165
+ m_axis_tuser_reg <= s_axis_tuser;
166
+ end else if (store_axis_temp_to_output) begin
167
+ m_axis_tdata_reg <= temp_m_axis_tdata_reg;
168
+ m_axis_tkeep_reg <= temp_m_axis_tkeep_reg;
169
+ m_axis_tlast_reg <= temp_m_axis_tlast_reg;
170
+ m_axis_tid_reg <= temp_m_axis_tid_reg;
171
+ m_axis_tdest_reg <= temp_m_axis_tdest_reg;
172
+ m_axis_tuser_reg <= temp_m_axis_tuser_reg;
173
+ end
174
+
175
+ if (store_axis_input_to_temp) begin
176
+ temp_m_axis_tdata_reg <= s_axis_tdata;
177
+ temp_m_axis_tkeep_reg <= s_axis_tkeep;
178
+ temp_m_axis_tlast_reg <= s_axis_tlast;
179
+ temp_m_axis_tid_reg <= s_axis_tid;
180
+ temp_m_axis_tdest_reg <= s_axis_tdest;
181
+ temp_m_axis_tuser_reg <= s_axis_tuser;
182
+ end
183
+ end
184
+
185
+ end else if (REG_TYPE == 1) begin
186
+ // simple register, inserts bubble cycles
187
+
188
+ // datapath registers
189
+ reg s_axis_tready_reg = 1'b0;
190
+
191
+ reg [DATA_WIDTH-1:0] m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
192
+ reg [KEEP_WIDTH-1:0] m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
193
+ reg m_axis_tvalid_reg = 1'b0, m_axis_tvalid_next;
194
+ reg m_axis_tlast_reg = 1'b0;
195
+ reg [ID_WIDTH-1:0] m_axis_tid_reg = {ID_WIDTH{1'b0}};
196
+ reg [DEST_WIDTH-1:0] m_axis_tdest_reg = {DEST_WIDTH{1'b0}};
197
+ reg [USER_WIDTH-1:0] m_axis_tuser_reg = {USER_WIDTH{1'b0}};
198
+
199
+ // datapath control
200
+ reg store_axis_input_to_output;
201
+
202
+ assign s_axis_tready = s_axis_tready_reg;
203
+
204
+ assign m_axis_tdata = m_axis_tdata_reg;
205
+ assign m_axis_tkeep = KEEP_ENABLE ? m_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
206
+ assign m_axis_tvalid = m_axis_tvalid_reg;
207
+ assign m_axis_tlast = LAST_ENABLE ? m_axis_tlast_reg : 1'b1;
208
+ assign m_axis_tid = ID_ENABLE ? m_axis_tid_reg : {ID_WIDTH{1'b0}};
209
+ assign m_axis_tdest = DEST_ENABLE ? m_axis_tdest_reg : {DEST_WIDTH{1'b0}};
210
+ assign m_axis_tuser = USER_ENABLE ? m_axis_tuser_reg : {USER_WIDTH{1'b0}};
211
+
212
+ // enable ready input next cycle if output buffer will be empty
213
+ wire s_axis_tready_early = !m_axis_tvalid_next;
214
+
215
+ always @* begin
216
+ // transfer sink ready state to source
217
+ m_axis_tvalid_next = m_axis_tvalid_reg;
218
+
219
+ store_axis_input_to_output = 1'b0;
220
+
221
+ if (s_axis_tready_reg) begin
222
+ m_axis_tvalid_next = s_axis_tvalid;
223
+ store_axis_input_to_output = 1'b1;
224
+ end else if (m_axis_tready) begin
225
+ m_axis_tvalid_next = 1'b0;
226
+ end
227
+ end
228
+
229
+ always @(posedge clk) begin
230
+ if (rst) begin
231
+ s_axis_tready_reg <= 1'b0;
232
+ m_axis_tvalid_reg <= 1'b0;
233
+ end else begin
234
+ s_axis_tready_reg <= s_axis_tready_early;
235
+ m_axis_tvalid_reg <= m_axis_tvalid_next;
236
+ end
237
+
238
+ // datapath
239
+ if (store_axis_input_to_output) begin
240
+ m_axis_tdata_reg <= s_axis_tdata;
241
+ m_axis_tkeep_reg <= s_axis_tkeep;
242
+ m_axis_tlast_reg <= s_axis_tlast;
243
+ m_axis_tid_reg <= s_axis_tid;
244
+ m_axis_tdest_reg <= s_axis_tdest;
245
+ m_axis_tuser_reg <= s_axis_tuser;
246
+ end
247
+ end
248
+
249
+ end else begin
250
+ // bypass
251
+
252
+ assign m_axis_tdata = s_axis_tdata;
253
+ assign m_axis_tkeep = KEEP_ENABLE ? s_axis_tkeep : {KEEP_WIDTH{1'b1}};
254
+ assign m_axis_tvalid = s_axis_tvalid;
255
+ assign m_axis_tlast = LAST_ENABLE ? s_axis_tlast : 1'b1;
256
+ assign m_axis_tid = ID_ENABLE ? s_axis_tid : {ID_WIDTH{1'b0}};
257
+ assign m_axis_tdest = DEST_ENABLE ? s_axis_tdest : {DEST_WIDTH{1'b0}};
258
+ assign m_axis_tuser = USER_ENABLE ? s_axis_tuser : {USER_WIDTH{1'b0}};
259
+
260
+ assign s_axis_tready = m_axis_tready;
261
+
262
+ end
263
+
264
+ endgenerate
265
+
266
+ endmodule
267
+
268
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/fpga.v ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA top-level module
33
+ */
34
+ module fpga (
35
+ /*
36
+ * GPIO
37
+ */
38
+ output wire qsfp_led_act,
39
+ output wire qsfp_led_stat_g,
40
+ output wire qsfp_led_stat_y,
41
+ output wire hbm_cattrip,
42
+
43
+ /*
44
+ * PCI express
45
+ */
46
+ input wire [15:0] pcie_rx_p,
47
+ input wire [15:0] pcie_rx_n,
48
+ output wire [15:0] pcie_tx_p,
49
+ output wire [15:0] pcie_tx_n,
50
+ input wire pcie_refclk_1_p,
51
+ input wire pcie_refclk_1_n,
52
+ input wire pcie_reset_n
53
+ );
54
+
55
+ parameter AXIS_PCIE_DATA_WIDTH = 512;
56
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32);
57
+ parameter AXIS_PCIE_RC_USER_WIDTH = 161;
58
+ parameter AXIS_PCIE_RQ_USER_WIDTH = 137;
59
+ parameter AXIS_PCIE_CQ_USER_WIDTH = 183;
60
+ parameter AXIS_PCIE_CC_USER_WIDTH = 81;
61
+
62
+ // Clock and reset
63
+ wire pcie_user_clk;
64
+ wire pcie_user_reset;
65
+
66
+ // GPIO
67
+ assign hbm_cattrip = 1'b0;
68
+
69
+ // PCIe
70
+ wire pcie_sys_clk;
71
+ wire pcie_sys_clk_gt;
72
+
73
+ IBUFDS_GTE4 #(
74
+ .REFCLK_HROW_CK_SEL(2'b00)
75
+ )
76
+ ibufds_gte4_pcie_mgt_refclk_inst (
77
+ .I (pcie_refclk_1_p),
78
+ .IB (pcie_refclk_1_n),
79
+ .CEB (1'b0),
80
+ .O (pcie_sys_clk_gt),
81
+ .ODIV2 (pcie_sys_clk)
82
+ );
83
+
84
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rq_tdata;
85
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rq_tkeep;
86
+ wire axis_rq_tlast;
87
+ wire axis_rq_tready;
88
+ wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] axis_rq_tuser;
89
+ wire axis_rq_tvalid;
90
+
91
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata;
92
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep;
93
+ wire axis_rc_tlast;
94
+ wire axis_rc_tready;
95
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser;
96
+ wire axis_rc_tvalid;
97
+
98
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata;
99
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep;
100
+ wire axis_cq_tlast;
101
+ wire axis_cq_tready;
102
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser;
103
+ wire axis_cq_tvalid;
104
+
105
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata;
106
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep;
107
+ wire axis_cc_tlast;
108
+ wire axis_cc_tready;
109
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser;
110
+ wire axis_cc_tvalid;
111
+
112
+ // ila_0 rq_ila (
113
+ // .clk(pcie_user_clk),
114
+ // .probe0(axis_rq_tdata),
115
+ // .probe1(axis_rq_tkeep),
116
+ // .probe2(axis_rq_tlast),
117
+ // .probe3(axis_rq_tready),
118
+ // .probe4(axis_rq_tuser),
119
+ // .probe5(axis_rq_tvalid)
120
+ // );
121
+
122
+ // ila_0 rc_ila (
123
+ // .clk(pcie_user_clk),
124
+ // .probe0(axis_rc_tdata),
125
+ // .probe1(axis_rc_tkeep),
126
+ // .probe2(axis_rc_tlast),
127
+ // .probe3(axis_rc_tready),
128
+ // .probe4(axis_rc_tuser),
129
+ // .probe5(axis_rc_tvalid)
130
+ // );
131
+
132
+ wire [2:0] cfg_max_payload;
133
+ wire [2:0] cfg_max_read_req;
134
+
135
+ wire [9:0] cfg_mgmt_addr;
136
+ wire [7:0] cfg_mgmt_function_number;
137
+ wire cfg_mgmt_write;
138
+ wire [31:0] cfg_mgmt_write_data;
139
+ wire [3:0] cfg_mgmt_byte_enable;
140
+ wire cfg_mgmt_read;
141
+ wire [31:0] cfg_mgmt_read_data;
142
+ wire cfg_mgmt_read_write_done;
143
+
144
+ wire [3:0] cfg_interrupt_msi_enable;
145
+ wire [11:0] cfg_interrupt_msi_mmenable;
146
+ wire cfg_interrupt_msi_mask_update;
147
+ wire [31:0] cfg_interrupt_msi_data;
148
+ wire [3:0] cfg_interrupt_msi_select;
149
+ wire [31:0] cfg_interrupt_msi_int;
150
+ wire [31:0] cfg_interrupt_msi_pending_status;
151
+ wire cfg_interrupt_msi_pending_status_data_enable;
152
+ wire [3:0] cfg_interrupt_msi_pending_status_function_num;
153
+ wire cfg_interrupt_msi_sent;
154
+ wire cfg_interrupt_msi_fail;
155
+ wire [2:0] cfg_interrupt_msi_attr;
156
+ wire cfg_interrupt_msi_tph_present;
157
+ wire [1:0] cfg_interrupt_msi_tph_type;
158
+ wire [8:0] cfg_interrupt_msi_tph_st_tag;
159
+ wire [3:0] cfg_interrupt_msi_function_number;
160
+
161
+ wire status_error_cor;
162
+ wire status_error_uncor;
163
+
164
+ pcie4c_uscale_plus_0
165
+ pcie4c_uscale_plus_inst (
166
+ .pci_exp_txn(pcie_tx_n),
167
+ .pci_exp_txp(pcie_tx_p),
168
+ .pci_exp_rxn(pcie_rx_n),
169
+ .pci_exp_rxp(pcie_rx_p),
170
+ .user_clk(pcie_user_clk),
171
+ .user_reset(pcie_user_reset),
172
+ .user_lnk_up(),
173
+
174
+ .s_axis_rq_tdata(axis_rq_tdata),
175
+ .s_axis_rq_tkeep(axis_rq_tkeep),
176
+ .s_axis_rq_tlast(axis_rq_tlast),
177
+ .s_axis_rq_tready(axis_rq_tready),
178
+ .s_axis_rq_tuser(axis_rq_tuser),
179
+ .s_axis_rq_tvalid(axis_rq_tvalid),
180
+
181
+ .m_axis_rc_tdata(axis_rc_tdata),
182
+ .m_axis_rc_tkeep(axis_rc_tkeep),
183
+ .m_axis_rc_tlast(axis_rc_tlast),
184
+ .m_axis_rc_tready(axis_rc_tready),
185
+ .m_axis_rc_tuser(axis_rc_tuser),
186
+ .m_axis_rc_tvalid(axis_rc_tvalid),
187
+
188
+ .m_axis_cq_tdata(axis_cq_tdata),
189
+ .m_axis_cq_tkeep(axis_cq_tkeep),
190
+ .m_axis_cq_tlast(axis_cq_tlast),
191
+ .m_axis_cq_tready(axis_cq_tready),
192
+ .m_axis_cq_tuser(axis_cq_tuser),
193
+ .m_axis_cq_tvalid(axis_cq_tvalid),
194
+
195
+ .s_axis_cc_tdata(axis_cc_tdata),
196
+ .s_axis_cc_tkeep(axis_cc_tkeep),
197
+ .s_axis_cc_tlast(axis_cc_tlast),
198
+ .s_axis_cc_tready(axis_cc_tready),
199
+ .s_axis_cc_tuser(axis_cc_tuser),
200
+ .s_axis_cc_tvalid(axis_cc_tvalid),
201
+
202
+ .pcie_rq_seq_num0(),
203
+ .pcie_rq_seq_num_vld0(),
204
+ .pcie_rq_seq_num1(),
205
+ .pcie_rq_seq_num_vld1(),
206
+ .pcie_rq_tag0(),
207
+ .pcie_rq_tag1(),
208
+ .pcie_rq_tag_av(),
209
+ .pcie_rq_tag_vld0(),
210
+ .pcie_rq_tag_vld1(),
211
+
212
+ .pcie_tfc_nph_av(),
213
+ .pcie_tfc_npd_av(),
214
+
215
+ .pcie_cq_np_req(1'b1),
216
+ .pcie_cq_np_req_count(),
217
+
218
+ .cfg_phy_link_down(),
219
+ .cfg_phy_link_status(),
220
+ .cfg_negotiated_width(),
221
+ .cfg_current_speed(),
222
+ .cfg_max_payload(cfg_max_payload),
223
+ .cfg_max_read_req(cfg_max_read_req),
224
+ .cfg_function_status(),
225
+ .cfg_function_power_state(),
226
+ .cfg_vf_status(),
227
+ .cfg_vf_power_state(),
228
+ .cfg_link_power_state(),
229
+
230
+ .cfg_mgmt_addr(cfg_mgmt_addr),
231
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
232
+ .cfg_mgmt_write(cfg_mgmt_write),
233
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
234
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
235
+ .cfg_mgmt_read(cfg_mgmt_read),
236
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
237
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
238
+ .cfg_mgmt_debug_access(1'b0),
239
+
240
+ .cfg_err_cor_out(),
241
+ .cfg_err_nonfatal_out(),
242
+ .cfg_err_fatal_out(),
243
+ .cfg_local_error_valid(),
244
+ .cfg_local_error_out(),
245
+ .cfg_ltssm_state(),
246
+ .cfg_rx_pm_state(),
247
+ .cfg_tx_pm_state(),
248
+ .cfg_rcb_status(),
249
+ .cfg_obff_enable(),
250
+ .cfg_pl_status_change(),
251
+ .cfg_tph_requester_enable(),
252
+ .cfg_tph_st_mode(),
253
+ .cfg_vf_tph_requester_enable(),
254
+ .cfg_vf_tph_st_mode(),
255
+
256
+ .cfg_msg_received(),
257
+ .cfg_msg_received_data(),
258
+ .cfg_msg_received_type(),
259
+ .cfg_msg_transmit(1'b0),
260
+ .cfg_msg_transmit_type(3'd0),
261
+ .cfg_msg_transmit_data(32'd0),
262
+ .cfg_msg_transmit_done(),
263
+
264
+ .cfg_fc_ph(),
265
+ .cfg_fc_pd(),
266
+ .cfg_fc_nph(),
267
+ .cfg_fc_npd(),
268
+ .cfg_fc_cplh(),
269
+ .cfg_fc_cpld(),
270
+ .cfg_fc_sel(3'd0),
271
+
272
+ .cfg_dsn(64'd0),
273
+
274
+ .cfg_bus_number(),
275
+
276
+ .cfg_power_state_change_ack(1'b1),
277
+ .cfg_power_state_change_interrupt(),
278
+
279
+ .cfg_err_cor_in(status_error_cor),
280
+ .cfg_err_uncor_in(status_error_uncor),
281
+ .cfg_flr_in_process(),
282
+ .cfg_flr_done(4'd0),
283
+ .cfg_vf_flr_in_process(),
284
+ .cfg_vf_flr_func_num(8'd0),
285
+ .cfg_vf_flr_done(8'd0),
286
+
287
+ .cfg_link_training_enable(1'b1),
288
+
289
+ .cfg_interrupt_int(4'd0),
290
+ .cfg_interrupt_pending(4'd0),
291
+ .cfg_interrupt_sent(),
292
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
293
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
294
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
295
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
296
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
297
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
298
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
299
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
300
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
301
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
302
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
303
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
304
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
305
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
306
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
307
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
308
+
309
+ .cfg_pm_aspm_l1_entry_reject(1'b0),
310
+ .cfg_pm_aspm_tx_l0s_entry_disable(1'b0),
311
+
312
+ .cfg_hot_reset_out(),
313
+
314
+ .cfg_config_space_enable(1'b1),
315
+ .cfg_req_pm_transition_l23_ready(1'b0),
316
+ .cfg_hot_reset_in(1'b0),
317
+
318
+ .cfg_ds_port_number(8'd0),
319
+ .cfg_ds_bus_number(8'd0),
320
+ .cfg_ds_device_number(5'd0),
321
+
322
+ .sys_clk(pcie_sys_clk),
323
+ .sys_clk_gt(pcie_sys_clk_gt),
324
+ .sys_reset(pcie_reset_n),
325
+
326
+ .phy_rdy_out()
327
+ );
328
+
329
+ fpga_core #(
330
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
331
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
332
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
333
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
334
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
335
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH)
336
+ )
337
+ core_inst (
338
+ /*
339
+ * Clock: 250 MHz
340
+ * Synchronous reset
341
+ */
342
+ .clk(pcie_user_clk),
343
+ .rst(pcie_user_reset),
344
+ /*
345
+ * GPIO
346
+ */
347
+ .qsfp_led_act(qsfp_led_act),
348
+ .qsfp_led_stat_g(qsfp_led_stat_g),
349
+ .qsfp_led_stat_y(qsfp_led_stat_y),
350
+ /*
351
+ * PCIe
352
+ */
353
+ .m_axis_rq_tdata(axis_rq_tdata),
354
+ .m_axis_rq_tkeep(axis_rq_tkeep),
355
+ .m_axis_rq_tlast(axis_rq_tlast),
356
+ .m_axis_rq_tready(axis_rq_tready),
357
+ .m_axis_rq_tuser(axis_rq_tuser),
358
+ .m_axis_rq_tvalid(axis_rq_tvalid),
359
+
360
+ .s_axis_rc_tdata(axis_rc_tdata),
361
+ .s_axis_rc_tkeep(axis_rc_tkeep),
362
+ .s_axis_rc_tlast(axis_rc_tlast),
363
+ .s_axis_rc_tready(axis_rc_tready),
364
+ .s_axis_rc_tuser(axis_rc_tuser),
365
+ .s_axis_rc_tvalid(axis_rc_tvalid),
366
+
367
+ .s_axis_cq_tdata(axis_cq_tdata),
368
+ .s_axis_cq_tkeep(axis_cq_tkeep),
369
+ .s_axis_cq_tlast(axis_cq_tlast),
370
+ .s_axis_cq_tready(axis_cq_tready),
371
+ .s_axis_cq_tuser(axis_cq_tuser),
372
+ .s_axis_cq_tvalid(axis_cq_tvalid),
373
+
374
+ .m_axis_cc_tdata(axis_cc_tdata),
375
+ .m_axis_cc_tkeep(axis_cc_tkeep),
376
+ .m_axis_cc_tlast(axis_cc_tlast),
377
+ .m_axis_cc_tready(axis_cc_tready),
378
+ .m_axis_cc_tuser(axis_cc_tuser),
379
+ .m_axis_cc_tvalid(axis_cc_tvalid),
380
+
381
+ .cfg_max_payload(cfg_max_payload),
382
+ .cfg_max_read_req(cfg_max_read_req),
383
+
384
+ .cfg_mgmt_addr(cfg_mgmt_addr),
385
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
386
+ .cfg_mgmt_write(cfg_mgmt_write),
387
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
388
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
389
+ .cfg_mgmt_read(cfg_mgmt_read),
390
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
391
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done),
392
+
393
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
394
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
395
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
396
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
397
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
398
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
399
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
400
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
401
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
402
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
403
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
404
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
405
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
406
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
407
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
408
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number),
409
+
410
+ .status_error_cor(status_error_cor),
411
+ .status_error_uncor(status_error_uncor)
412
+ );
413
+
414
+ endmodule
415
+
416
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/fpga_core.v ADDED
@@ -0,0 +1,1126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog 2001
26
+
27
+ `resetall
28
+ `timescale 1ns / 1ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * FPGA core logic
33
+ */
34
+ module fpga_core #
35
+ (
36
+ parameter AXIS_PCIE_DATA_WIDTH = 512,
37
+ parameter AXIS_PCIE_KEEP_WIDTH = (AXIS_PCIE_DATA_WIDTH/32),
38
+ parameter AXIS_PCIE_RC_USER_WIDTH = 161,
39
+ parameter AXIS_PCIE_RQ_USER_WIDTH = 137,
40
+ parameter AXIS_PCIE_CQ_USER_WIDTH = 183,
41
+ parameter AXIS_PCIE_CC_USER_WIDTH = 81
42
+ )
43
+ (
44
+ /*
45
+ * Clock: 250 MHz
46
+ * Synchronous reset
47
+ */
48
+ input wire clk,
49
+ input wire rst,
50
+
51
+ /*
52
+ * GPIO
53
+ */
54
+ output wire qsfp_led_act,
55
+ output wire qsfp_led_stat_g,
56
+ output wire qsfp_led_stat_y,
57
+
58
+ /*
59
+ * PCIe
60
+ */
61
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_rq_tdata,
62
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_rq_tkeep,
63
+ output wire m_axis_rq_tlast,
64
+ input wire m_axis_rq_tready,
65
+ output wire [AXIS_PCIE_RQ_USER_WIDTH-1:0] m_axis_rq_tuser,
66
+ output wire m_axis_rq_tvalid,
67
+
68
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_rc_tdata,
69
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_rc_tkeep,
70
+ input wire s_axis_rc_tlast,
71
+ output wire s_axis_rc_tready,
72
+ input wire [AXIS_PCIE_RC_USER_WIDTH-1:0] s_axis_rc_tuser,
73
+ input wire s_axis_rc_tvalid,
74
+
75
+ input wire [AXIS_PCIE_DATA_WIDTH-1:0] s_axis_cq_tdata,
76
+ input wire [AXIS_PCIE_KEEP_WIDTH-1:0] s_axis_cq_tkeep,
77
+ input wire s_axis_cq_tlast,
78
+ output wire s_axis_cq_tready,
79
+ input wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] s_axis_cq_tuser,
80
+ input wire s_axis_cq_tvalid,
81
+
82
+ output wire [AXIS_PCIE_DATA_WIDTH-1:0] m_axis_cc_tdata,
83
+ output wire [AXIS_PCIE_KEEP_WIDTH-1:0] m_axis_cc_tkeep,
84
+ output wire m_axis_cc_tlast,
85
+ input wire m_axis_cc_tready,
86
+ output wire [AXIS_PCIE_CC_USER_WIDTH-1:0] m_axis_cc_tuser,
87
+ output wire m_axis_cc_tvalid,
88
+
89
+ input wire [2:0] cfg_max_payload,
90
+ input wire [2:0] cfg_max_read_req,
91
+
92
+ output wire [9:0] cfg_mgmt_addr,
93
+ output wire [7:0] cfg_mgmt_function_number,
94
+ output wire cfg_mgmt_write,
95
+ output wire [31:0] cfg_mgmt_write_data,
96
+ output wire [3:0] cfg_mgmt_byte_enable,
97
+ output wire cfg_mgmt_read,
98
+ input wire [31:0] cfg_mgmt_read_data,
99
+ input wire cfg_mgmt_read_write_done,
100
+
101
+ input wire [3:0] cfg_interrupt_msi_enable,
102
+ input wire [11:0] cfg_interrupt_msi_mmenable,
103
+ input wire cfg_interrupt_msi_mask_update,
104
+ input wire [31:0] cfg_interrupt_msi_data,
105
+ output wire [3:0] cfg_interrupt_msi_select,
106
+ output wire [31:0] cfg_interrupt_msi_int,
107
+ output wire [31:0] cfg_interrupt_msi_pending_status,
108
+ output wire cfg_interrupt_msi_pending_status_data_enable,
109
+ output wire [3:0] cfg_interrupt_msi_pending_status_function_num,
110
+ input wire cfg_interrupt_msi_sent,
111
+ input wire cfg_interrupt_msi_fail,
112
+ output wire [2:0] cfg_interrupt_msi_attr,
113
+ output wire cfg_interrupt_msi_tph_present,
114
+ output wire [1:0] cfg_interrupt_msi_tph_type,
115
+ output wire [8:0] cfg_interrupt_msi_tph_st_tag,
116
+ output wire [3:0] cfg_interrupt_msi_function_number,
117
+
118
+ output wire status_error_cor,
119
+ output wire status_error_uncor
120
+ );
121
+
122
+ parameter PCIE_ADDR_WIDTH = 64;
123
+
124
+ parameter AXIL_DATA_WIDTH = 32;
125
+ parameter AXIL_STRB_WIDTH = (AXIL_DATA_WIDTH/8);
126
+ parameter AXIL_ADDR_WIDTH = 32;
127
+
128
+ parameter AXI_DATA_WIDTH = AXIS_PCIE_DATA_WIDTH;
129
+ parameter AXI_STRB_WIDTH = (AXI_DATA_WIDTH/8);
130
+ parameter AXI_ADDR_WIDTH = 32;
131
+ parameter AXI_ID_WIDTH = 8;
132
+
133
+ parameter DMA_TAG_WIDTH = 8;
134
+
135
+ // Completer mux/demux
136
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata_bar_0;
137
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep_bar_0;
138
+ wire axis_cq_tvalid_bar_0;
139
+ wire axis_cq_tready_bar_0;
140
+ wire axis_cq_tlast_bar_0;
141
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser_bar_0;
142
+
143
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata_bar_0;
144
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep_bar_0;
145
+ wire axis_cc_tvalid_bar_0;
146
+ wire axis_cc_tready_bar_0;
147
+ wire axis_cc_tlast_bar_0;
148
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser_bar_0;
149
+
150
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cq_tdata_bar_2;
151
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cq_tkeep_bar_2;
152
+ wire axis_cq_tvalid_bar_2;
153
+ wire axis_cq_tready_bar_2;
154
+ wire axis_cq_tlast_bar_2;
155
+ wire [AXIS_PCIE_CQ_USER_WIDTH-1:0] axis_cq_tuser_bar_2;
156
+
157
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_cc_tdata_bar_2;
158
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_cc_tkeep_bar_2;
159
+ wire axis_cc_tvalid_bar_2;
160
+ wire axis_cc_tready_bar_2;
161
+ wire axis_cc_tlast_bar_2;
162
+ wire [AXIS_PCIE_CC_USER_WIDTH-1:0] axis_cc_tuser_bar_2;
163
+
164
+ wire [2:0] bar_id;
165
+ wire [1:0] select;
166
+
167
+ pcie_us_axis_cq_demux #(
168
+ .M_COUNT(2),
169
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
170
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
171
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH)
172
+ )
173
+ cq_demux_inst (
174
+ .clk(clk),
175
+ .rst(rst),
176
+
177
+ /*
178
+ * AXI input (CQ)
179
+ */
180
+ .s_axis_cq_tdata(s_axis_cq_tdata),
181
+ .s_axis_cq_tkeep(s_axis_cq_tkeep),
182
+ .s_axis_cq_tvalid(s_axis_cq_tvalid),
183
+ .s_axis_cq_tready(s_axis_cq_tready),
184
+ .s_axis_cq_tlast(s_axis_cq_tlast),
185
+ .s_axis_cq_tuser(s_axis_cq_tuser),
186
+
187
+ /*
188
+ * AXI output (CQ)
189
+ */
190
+ .m_axis_cq_tdata({axis_cq_tdata_bar_2, axis_cq_tdata_bar_0}),
191
+ .m_axis_cq_tkeep({axis_cq_tkeep_bar_2, axis_cq_tkeep_bar_0}),
192
+ .m_axis_cq_tvalid({axis_cq_tvalid_bar_2, axis_cq_tvalid_bar_0}),
193
+ .m_axis_cq_tready({axis_cq_tready_bar_2, axis_cq_tready_bar_0}),
194
+ .m_axis_cq_tlast({axis_cq_tlast_bar_2, axis_cq_tlast_bar_0}),
195
+ .m_axis_cq_tuser({axis_cq_tuser_bar_2, axis_cq_tuser_bar_0}),
196
+
197
+ /*
198
+ * Fields
199
+ */
200
+ .req_type(),
201
+ .target_function(),
202
+ .bar_id(bar_id),
203
+ .msg_code(),
204
+ .msg_routing(),
205
+
206
+ /*
207
+ * Control
208
+ */
209
+ .enable(1),
210
+ .drop(0),
211
+ .select(select)
212
+ );
213
+
214
+ assign select[1] = bar_id == 3'd2;
215
+ assign select[0] = bar_id == 3'd0;
216
+
217
+ axis_arb_mux #(
218
+ .S_COUNT(2),
219
+ .DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
220
+ .KEEP_ENABLE(1),
221
+ .KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
222
+ .ID_ENABLE(0),
223
+ .DEST_ENABLE(0),
224
+ .USER_ENABLE(1),
225
+ .USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH)
226
+ )
227
+ cc_mux_inst (
228
+ .clk(clk),
229
+ .rst(rst),
230
+
231
+ /*
232
+ * AXI inputs
233
+ */
234
+ .s_axis_tdata({axis_cc_tdata_bar_2, axis_cc_tdata_bar_0}),
235
+ .s_axis_tkeep({axis_cc_tkeep_bar_2, axis_cc_tkeep_bar_0}),
236
+ .s_axis_tvalid({axis_cc_tvalid_bar_2, axis_cc_tvalid_bar_0}),
237
+ .s_axis_tready({axis_cc_tready_bar_2, axis_cc_tready_bar_0}),
238
+ .s_axis_tlast({axis_cc_tlast_bar_2, axis_cc_tlast_bar_0}),
239
+ .s_axis_tid(0),
240
+ .s_axis_tdest(0),
241
+ .s_axis_tuser({axis_cc_tuser_bar_2, axis_cc_tuser_bar_0}),
242
+
243
+ /*
244
+ * AXI output
245
+ */
246
+ .m_axis_tdata(m_axis_cc_tdata),
247
+ .m_axis_tkeep(m_axis_cc_tkeep),
248
+ .m_axis_tvalid(m_axis_cc_tvalid),
249
+ .m_axis_tready(m_axis_cc_tready),
250
+ .m_axis_tlast(m_axis_cc_tlast),
251
+ .m_axis_tid(),
252
+ .m_axis_tdest(),
253
+ .m_axis_tuser(m_axis_cc_tuser)
254
+ );
255
+
256
+ wire [AXIL_ADDR_WIDTH-1:0] axil_ctrl_awaddr;
257
+ wire [2:0] axil_ctrl_awprot;
258
+ wire axil_ctrl_awvalid;
259
+ wire axil_ctrl_awready;
260
+ wire [AXIL_DATA_WIDTH-1:0] axil_ctrl_wdata;
261
+ wire [AXIL_STRB_WIDTH-1:0] axil_ctrl_wstrb;
262
+ wire axil_ctrl_wvalid;
263
+ wire axil_ctrl_wready;
264
+ wire [1:0] axil_ctrl_bresp;
265
+ wire axil_ctrl_bvalid;
266
+ wire axil_ctrl_bready;
267
+ wire [AXIL_ADDR_WIDTH-1:0] axil_ctrl_araddr;
268
+ wire [2:0] axil_ctrl_arprot;
269
+ wire axil_ctrl_arvalid;
270
+ wire axil_ctrl_arready;
271
+ wire [AXIL_DATA_WIDTH-1:0] axil_ctrl_rdata;
272
+ wire [1:0] axil_ctrl_rresp;
273
+ wire axil_ctrl_rvalid;
274
+ wire axil_ctrl_rready;
275
+
276
+ wire [AXI_ID_WIDTH-1:0] axi_awid;
277
+ wire [AXI_ADDR_WIDTH-1:0] axi_awaddr;
278
+ wire [7:0] axi_awlen;
279
+ wire [2:0] axi_awsize;
280
+ wire [1:0] axi_awburst;
281
+ wire axi_awlock;
282
+ wire [3:0] axi_awcache;
283
+ wire [2:0] axi_awprot;
284
+ wire axi_awvalid;
285
+ wire axi_awready;
286
+ wire [AXI_DATA_WIDTH-1:0] axi_wdata;
287
+ wire [AXI_STRB_WIDTH-1:0] axi_wstrb;
288
+ wire axi_wlast;
289
+ wire axi_wvalid;
290
+ wire axi_wready;
291
+ wire [AXI_ID_WIDTH-1:0] axi_bid;
292
+ wire [1:0] axi_bresp;
293
+ wire axi_bvalid;
294
+ wire axi_bready;
295
+ wire [AXI_ID_WIDTH-1:0] axi_arid;
296
+ wire [AXI_ADDR_WIDTH-1:0] axi_araddr;
297
+ wire [7:0] axi_arlen;
298
+ wire [2:0] axi_arsize;
299
+ wire [1:0] axi_arburst;
300
+ wire axi_arlock;
301
+ wire [3:0] axi_arcache;
302
+ wire [2:0] axi_arprot;
303
+ wire axi_arvalid;
304
+ wire axi_arready;
305
+ wire [AXI_ID_WIDTH-1:0] axi_rid;
306
+ wire [AXI_DATA_WIDTH-1:0] axi_rdata;
307
+ wire [1:0] axi_rresp;
308
+ wire axi_rlast;
309
+ wire axi_rvalid;
310
+ wire axi_rready;
311
+
312
+ wire [AXI_ID_WIDTH-1:0] axi_dma_awid;
313
+ wire [AXI_ADDR_WIDTH-1:0] axi_dma_awaddr;
314
+ wire [7:0] axi_dma_awlen;
315
+ wire [2:0] axi_dma_awsize;
316
+ wire [1:0] axi_dma_awburst;
317
+ wire axi_dma_awlock;
318
+ wire [3:0] axi_dma_awcache;
319
+ wire [2:0] axi_dma_awprot;
320
+ wire axi_dma_awvalid;
321
+ wire axi_dma_awready;
322
+ wire [AXI_DATA_WIDTH-1:0] axi_dma_wdata;
323
+ wire [AXI_STRB_WIDTH-1:0] axi_dma_wstrb;
324
+ wire axi_dma_wlast;
325
+ wire axi_dma_wvalid;
326
+ wire axi_dma_wready;
327
+ wire [AXI_ID_WIDTH-1:0] axi_dma_bid;
328
+ wire [1:0] axi_dma_bresp;
329
+ wire axi_dma_bvalid;
330
+ wire axi_dma_bready;
331
+ wire [AXI_ID_WIDTH-1:0] axi_dma_arid;
332
+ wire [AXI_ADDR_WIDTH-1:0] axi_dma_araddr;
333
+ wire [7:0] axi_dma_arlen;
334
+ wire [2:0] axi_dma_arsize;
335
+ wire [1:0] axi_dma_arburst;
336
+ wire axi_dma_arlock;
337
+ wire [3:0] axi_dma_arcache;
338
+ wire [2:0] axi_dma_arprot;
339
+ wire axi_dma_arvalid;
340
+ wire axi_dma_arready;
341
+ wire [AXI_ID_WIDTH-1:0] axi_dma_rid;
342
+ wire [AXI_DATA_WIDTH-1:0] axi_dma_rdata;
343
+ wire [1:0] axi_dma_rresp;
344
+ wire axi_dma_rlast;
345
+ wire axi_dma_rvalid;
346
+ wire axi_dma_rready;
347
+
348
+ // PCIe DMA control
349
+ wire [PCIE_ADDR_WIDTH-1:0] pcie_dma_read_desc_pcie_addr;
350
+ wire [AXI_ADDR_WIDTH-1:0] pcie_dma_read_desc_axi_addr;
351
+ wire [15:0] pcie_dma_read_desc_len;
352
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_tag;
353
+ wire pcie_dma_read_desc_valid;
354
+ wire pcie_dma_read_desc_ready;
355
+
356
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_status_tag;
357
+ wire [3:0] pcie_dma_read_desc_status_error;
358
+ wire pcie_dma_read_desc_status_valid;
359
+
360
+ wire [PCIE_ADDR_WIDTH-1:0] pcie_dma_write_desc_pcie_addr;
361
+ wire [AXI_ADDR_WIDTH-1:0] pcie_dma_write_desc_axi_addr;
362
+ wire [15:0] pcie_dma_write_desc_len;
363
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_tag;
364
+ wire pcie_dma_write_desc_valid;
365
+ wire pcie_dma_write_desc_ready;
366
+
367
+ wire [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_status_tag;
368
+ wire [3:0] pcie_dma_write_desc_status_error;
369
+ wire pcie_dma_write_desc_status_valid;
370
+
371
+ wire pcie_dma_enable;
372
+
373
+ // Error handling
374
+ wire [2:0] status_error_uncor_int;
375
+ wire [2:0] status_error_cor_int;
376
+
377
+ wire [31:0] msi_irq;
378
+
379
+ wire ext_tag_enable;
380
+
381
+ // control registers
382
+ reg axil_ctrl_awready_reg = 1'b0, axil_ctrl_awready_next;
383
+ reg axil_ctrl_wready_reg = 1'b0, axil_ctrl_wready_next;
384
+ reg [1:0] axil_ctrl_bresp_reg = 2'b00, axil_ctrl_bresp_next;
385
+ reg axil_ctrl_bvalid_reg = 1'b0, axil_ctrl_bvalid_next;
386
+ reg axil_ctrl_arready_reg = 1'b0, axil_ctrl_arready_next;
387
+ reg [AXIL_DATA_WIDTH-1:0] axil_ctrl_rdata_reg = {AXIL_DATA_WIDTH{1'b0}}, axil_ctrl_rdata_next;
388
+ reg [1:0] axil_ctrl_rresp_reg = 2'b00, axil_ctrl_rresp_next;
389
+ reg axil_ctrl_rvalid_reg = 1'b0, axil_ctrl_rvalid_next;
390
+
391
+ reg [PCIE_ADDR_WIDTH-1:0] pcie_dma_read_desc_pcie_addr_reg = 0, pcie_dma_read_desc_pcie_addr_next;
392
+ reg [AXI_ADDR_WIDTH-1:0] pcie_dma_read_desc_axi_addr_reg = 0, pcie_dma_read_desc_axi_addr_next;
393
+ reg [15:0] pcie_dma_read_desc_len_reg = 0, pcie_dma_read_desc_len_next;
394
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_tag_reg = 0, pcie_dma_read_desc_tag_next;
395
+ reg pcie_dma_read_desc_valid_reg = 0, pcie_dma_read_desc_valid_next;
396
+
397
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_read_desc_status_tag_reg = 0, pcie_dma_read_desc_status_tag_next;
398
+ reg [31:0] pcie_dma_read_desc_status_error_reg = 0, pcie_dma_read_desc_status_error_next;
399
+ reg pcie_dma_read_desc_status_valid_reg = 0, pcie_dma_read_desc_status_valid_next;
400
+
401
+ reg [PCIE_ADDR_WIDTH-1:0] pcie_dma_write_desc_pcie_addr_reg = 0, pcie_dma_write_desc_pcie_addr_next;
402
+ reg [AXI_ADDR_WIDTH-1:0] pcie_dma_write_desc_axi_addr_reg = 0, pcie_dma_write_desc_axi_addr_next;
403
+ reg [15:0] pcie_dma_write_desc_len_reg = 0, pcie_dma_write_desc_len_next;
404
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_tag_reg = 0, pcie_dma_write_desc_tag_next;
405
+ reg pcie_dma_write_desc_valid_reg = 0, pcie_dma_write_desc_valid_next;
406
+
407
+ reg [DMA_TAG_WIDTH-1:0] pcie_dma_write_desc_status_tag_reg = 0, pcie_dma_write_desc_status_tag_next;
408
+ reg [31:0] pcie_dma_write_desc_status_error_reg = 0, pcie_dma_write_desc_status_error_next;
409
+ reg pcie_dma_write_desc_status_valid_reg = 0, pcie_dma_write_desc_status_valid_next;
410
+
411
+ reg pcie_dma_enable_reg = 0, pcie_dma_enable_next;
412
+
413
+ reg [31:0] pcie_rq_count_reg = 0;
414
+ reg [31:0] pcie_rc_count_reg = 0;
415
+ reg [31:0] pcie_cq_count_reg = 0;
416
+ reg [31:0] pcie_cc_count_reg = 0;
417
+
418
+ assign axil_ctrl_awready = axil_ctrl_awready_reg;
419
+ assign axil_ctrl_wready = axil_ctrl_wready_reg;
420
+ assign axil_ctrl_bresp = axil_ctrl_bresp_reg;
421
+ assign axil_ctrl_bvalid = axil_ctrl_bvalid_reg;
422
+ assign axil_ctrl_arready = axil_ctrl_arready_reg;
423
+ assign axil_ctrl_rdata = axil_ctrl_rdata_reg;
424
+ assign axil_ctrl_rresp = axil_ctrl_rresp_reg;
425
+ assign axil_ctrl_rvalid = axil_ctrl_rvalid_reg;
426
+
427
+ assign pcie_dma_read_desc_pcie_addr = pcie_dma_read_desc_pcie_addr_reg;
428
+ assign pcie_dma_read_desc_axi_addr = pcie_dma_read_desc_axi_addr_reg;
429
+ assign pcie_dma_read_desc_len = pcie_dma_read_desc_len_reg;
430
+ assign pcie_dma_read_desc_tag = pcie_dma_read_desc_tag_reg;
431
+ assign pcie_dma_read_desc_valid = pcie_dma_read_desc_valid_reg;
432
+ assign pcie_dma_write_desc_pcie_addr = pcie_dma_write_desc_pcie_addr_reg;
433
+ assign pcie_dma_write_desc_axi_addr = pcie_dma_write_desc_axi_addr_reg;
434
+ assign pcie_dma_write_desc_len = pcie_dma_write_desc_len_reg;
435
+ assign pcie_dma_write_desc_tag = pcie_dma_write_desc_tag_reg;
436
+ assign pcie_dma_write_desc_valid = pcie_dma_write_desc_valid_reg;
437
+ assign pcie_dma_enable = pcie_dma_enable_reg;
438
+
439
+ assign msi_irq[0] = pcie_dma_read_desc_status_valid || pcie_dma_write_desc_status_valid;
440
+ assign msi_irq[31:1] = 0;
441
+
442
+ always @* begin
443
+ axil_ctrl_awready_next = 1'b0;
444
+ axil_ctrl_wready_next = 1'b0;
445
+ axil_ctrl_bresp_next = 2'b00;
446
+ axil_ctrl_bvalid_next = axil_ctrl_bvalid_reg && !axil_ctrl_bready;
447
+ axil_ctrl_arready_next = 1'b0;
448
+ axil_ctrl_rdata_next = {AXIL_DATA_WIDTH{1'b0}};
449
+ axil_ctrl_rresp_next = 2'b00;
450
+ axil_ctrl_rvalid_next = axil_ctrl_rvalid_reg && !axil_ctrl_rready;
451
+
452
+ pcie_dma_read_desc_pcie_addr_next = pcie_dma_read_desc_pcie_addr_reg;
453
+ pcie_dma_read_desc_axi_addr_next = pcie_dma_read_desc_axi_addr_reg;
454
+ pcie_dma_read_desc_len_next = pcie_dma_read_desc_len_reg;
455
+ pcie_dma_read_desc_tag_next = pcie_dma_read_desc_tag_reg;
456
+ pcie_dma_read_desc_valid_next = pcie_dma_read_desc_valid_reg && !pcie_dma_read_desc_ready;
457
+
458
+ pcie_dma_read_desc_status_tag_next = pcie_dma_read_desc_status_tag_reg;
459
+ pcie_dma_read_desc_status_error_next = pcie_dma_read_desc_status_error_reg;
460
+ pcie_dma_read_desc_status_valid_next = pcie_dma_read_desc_status_valid_reg;
461
+
462
+ pcie_dma_write_desc_pcie_addr_next = pcie_dma_write_desc_pcie_addr_reg;
463
+ pcie_dma_write_desc_axi_addr_next = pcie_dma_write_desc_axi_addr_reg;
464
+ pcie_dma_write_desc_len_next = pcie_dma_write_desc_len_reg;
465
+ pcie_dma_write_desc_tag_next = pcie_dma_write_desc_tag_reg;
466
+ pcie_dma_write_desc_valid_next = pcie_dma_write_desc_valid_reg && !pcie_dma_read_desc_ready;
467
+
468
+ pcie_dma_write_desc_status_tag_next = pcie_dma_write_desc_status_tag_reg;
469
+ pcie_dma_write_desc_status_error_next = pcie_dma_write_desc_status_error_reg;
470
+ pcie_dma_write_desc_status_valid_next = pcie_dma_write_desc_status_valid_reg;
471
+
472
+ pcie_dma_enable_next = pcie_dma_enable_reg;
473
+
474
+ if (axil_ctrl_awvalid && axil_ctrl_wvalid && !axil_ctrl_bvalid) begin
475
+ // write operation
476
+ axil_ctrl_awready_next = 1'b1;
477
+ axil_ctrl_wready_next = 1'b1;
478
+ axil_ctrl_bresp_next = 2'b00;
479
+ axil_ctrl_bvalid_next = 1'b1;
480
+
481
+ case ({axil_ctrl_awaddr[15:2], 2'b00})
482
+ 16'h0000: pcie_dma_enable_next = axil_ctrl_wdata;
483
+ 16'h0100: pcie_dma_read_desc_pcie_addr_next[31:0] = axil_ctrl_wdata;
484
+ 16'h0104: pcie_dma_read_desc_pcie_addr_next[63:32] = axil_ctrl_wdata;
485
+ 16'h0108: pcie_dma_read_desc_axi_addr_next[31:0] = axil_ctrl_wdata;
486
+ //16'h010C: pcie_dma_read_desc_axi_addr_next[63:32] = axil_ctrl_wdata;
487
+ 16'h0110: pcie_dma_read_desc_len_next = axil_ctrl_wdata;
488
+ 16'h0114: begin
489
+ pcie_dma_read_desc_tag_next = axil_ctrl_wdata;
490
+ pcie_dma_read_desc_valid_next = 1'b1;
491
+ end
492
+ 16'h0200: pcie_dma_write_desc_pcie_addr_next[31:0] = axil_ctrl_wdata;
493
+ 16'h0204: pcie_dma_write_desc_pcie_addr_next[63:32] = axil_ctrl_wdata;
494
+ 16'h0208: pcie_dma_write_desc_axi_addr_next[31:0] = axil_ctrl_wdata;
495
+ //16'h020C: pcie_dma_write_desc_axi_addr_next[63:32] = axil_ctrl_wdata;
496
+ 16'h0210: pcie_dma_write_desc_len_next = axil_ctrl_wdata;
497
+ 16'h0214: begin
498
+ pcie_dma_write_desc_tag_next = axil_ctrl_wdata;
499
+ pcie_dma_write_desc_valid_next = 1'b1;
500
+ end
501
+ endcase
502
+ end
503
+
504
+ if (axil_ctrl_arvalid && !axil_ctrl_rvalid) begin
505
+ // read operation
506
+ axil_ctrl_arready_next = 1'b1;
507
+ axil_ctrl_rresp_next = 2'b00;
508
+ axil_ctrl_rvalid_next = 1'b1;
509
+
510
+ case ({axil_ctrl_araddr[15:2], 2'b00})
511
+ 16'h0000: axil_ctrl_rdata_next = pcie_dma_enable_reg;
512
+ 16'h0118: begin
513
+ axil_ctrl_rdata_next[7:0] = pcie_dma_read_desc_status_tag_reg;
514
+ axil_ctrl_rdata_next[15:8] = pcie_dma_read_desc_status_error_reg;
515
+ axil_ctrl_rdata_next[31] = pcie_dma_read_desc_status_valid_reg;
516
+ pcie_dma_read_desc_status_valid_next = 1'b0;
517
+ end
518
+ 16'h0218: begin
519
+ axil_ctrl_rdata_next[7:0] = pcie_dma_write_desc_status_tag_reg;
520
+ axil_ctrl_rdata_next[15:8] = pcie_dma_write_desc_status_error_reg;
521
+ axil_ctrl_rdata_next[31] = pcie_dma_write_desc_status_valid_reg;
522
+ pcie_dma_write_desc_status_valid_next = 1'b0;
523
+ end
524
+ 16'h0400: axil_ctrl_rdata_next = pcie_rq_count_reg;
525
+ 16'h0404: axil_ctrl_rdata_next = pcie_rc_count_reg;
526
+ 16'h0408: axil_ctrl_rdata_next = pcie_cq_count_reg;
527
+ 16'h040C: axil_ctrl_rdata_next = pcie_cc_count_reg;
528
+ endcase
529
+ end
530
+
531
+ if (pcie_dma_read_desc_status_valid) begin
532
+ pcie_dma_read_desc_status_tag_next = pcie_dma_read_desc_status_tag;
533
+ pcie_dma_read_desc_status_error_next = pcie_dma_read_desc_status_error;
534
+ pcie_dma_read_desc_status_valid_next = pcie_dma_read_desc_status_valid;
535
+ end
536
+
537
+ if (pcie_dma_write_desc_status_valid) begin
538
+ pcie_dma_write_desc_status_tag_next = pcie_dma_write_desc_status_tag;
539
+ pcie_dma_write_desc_status_error_next = pcie_dma_write_desc_status_error;
540
+ pcie_dma_write_desc_status_valid_next = pcie_dma_write_desc_status_valid;
541
+ end
542
+ end
543
+
544
+ always @(posedge clk) begin
545
+ axil_ctrl_awready_reg <= axil_ctrl_awready_next;
546
+ axil_ctrl_wready_reg <= axil_ctrl_wready_next;
547
+ axil_ctrl_bresp_reg <= axil_ctrl_bresp_next;
548
+ axil_ctrl_bvalid_reg <= axil_ctrl_bvalid_next;
549
+ axil_ctrl_arready_reg <= axil_ctrl_arready_next;
550
+ axil_ctrl_rdata_reg <= axil_ctrl_rdata_next;
551
+ axil_ctrl_rresp_reg <= axil_ctrl_rresp_next;
552
+ axil_ctrl_rvalid_reg <= axil_ctrl_rvalid_next;
553
+
554
+ pcie_dma_read_desc_pcie_addr_reg <= pcie_dma_read_desc_pcie_addr_next;
555
+ pcie_dma_read_desc_axi_addr_reg <= pcie_dma_read_desc_axi_addr_next;
556
+ pcie_dma_read_desc_len_reg <= pcie_dma_read_desc_len_next;
557
+ pcie_dma_read_desc_tag_reg <= pcie_dma_read_desc_tag_next;
558
+ pcie_dma_read_desc_valid_reg <= pcie_dma_read_desc_valid_next;
559
+
560
+ pcie_dma_read_desc_status_tag_reg <= pcie_dma_read_desc_status_tag_next;
561
+ pcie_dma_read_desc_status_error_reg <= pcie_dma_read_desc_status_error_next;
562
+ pcie_dma_read_desc_status_valid_reg <= pcie_dma_read_desc_status_valid_next;
563
+
564
+ pcie_dma_write_desc_pcie_addr_reg <= pcie_dma_write_desc_pcie_addr_next;
565
+ pcie_dma_write_desc_axi_addr_reg <= pcie_dma_write_desc_axi_addr_next;
566
+ pcie_dma_write_desc_len_reg <= pcie_dma_write_desc_len_next;
567
+ pcie_dma_write_desc_tag_reg <= pcie_dma_write_desc_tag_next;
568
+ pcie_dma_write_desc_valid_reg <= pcie_dma_write_desc_valid_next;
569
+
570
+ pcie_dma_write_desc_status_tag_reg <= pcie_dma_write_desc_status_tag_next;
571
+ pcie_dma_write_desc_status_error_reg <= pcie_dma_write_desc_status_error_next;
572
+ pcie_dma_write_desc_status_valid_reg <= pcie_dma_write_desc_status_valid_next;
573
+
574
+ pcie_dma_enable_reg <= pcie_dma_enable_next;
575
+
576
+ if (m_axis_rq_tready && m_axis_rq_tvalid && m_axis_rq_tlast) begin
577
+ pcie_rq_count_reg <= pcie_rq_count_reg + 1;
578
+ end
579
+
580
+ if (s_axis_rc_tready && s_axis_rc_tvalid && s_axis_rc_tlast) begin
581
+ pcie_rc_count_reg <= pcie_rc_count_reg + 1;
582
+ end
583
+
584
+ if (s_axis_cq_tready && s_axis_cq_tvalid && s_axis_cq_tlast) begin
585
+ pcie_cq_count_reg <= pcie_cq_count_reg + 1;
586
+ end
587
+
588
+ if (m_axis_cc_tready && m_axis_cc_tvalid && m_axis_cc_tlast) begin
589
+ pcie_cc_count_reg <= pcie_cc_count_reg + 1;
590
+ end
591
+
592
+ if (rst) begin
593
+ axil_ctrl_awready_reg <= 1'b0;
594
+ axil_ctrl_wready_reg <= 1'b0;
595
+ axil_ctrl_bvalid_reg <= 1'b0;
596
+ axil_ctrl_arready_reg <= 1'b0;
597
+ axil_ctrl_rvalid_reg <= 1'b0;
598
+
599
+ pcie_dma_read_desc_valid_reg <= 1'b0;
600
+ pcie_dma_read_desc_status_valid_reg <= 1'b0;
601
+ pcie_dma_write_desc_valid_reg <= 1'b0;
602
+ pcie_dma_write_desc_status_valid_reg <= 1'b0;
603
+ pcie_dma_enable_reg <= 1'b0;
604
+
605
+ pcie_rq_count_reg <= 0;
606
+ pcie_rc_count_reg <= 0;
607
+ pcie_cq_count_reg <= 0;
608
+ pcie_cc_count_reg <= 0;
609
+ end
610
+ end
611
+
612
+ assign qsfp_led_act = 1'b0;
613
+ assign qsfp_led_stat_g = 1'b0;
614
+ assign qsfp_led_stat_y = 1'b0;
615
+
616
+ pcie_us_cfg #(
617
+ .PF_COUNT(1),
618
+ .VF_COUNT(0),
619
+ .VF_OFFSET(4),
620
+ .PCIE_CAP_OFFSET(12'h070)
621
+ )
622
+ pcie_us_cfg_inst (
623
+ .clk(clk),
624
+ .rst(rst),
625
+
626
+ /*
627
+ * Configuration outputs
628
+ */
629
+ .ext_tag_enable(ext_tag_enable),
630
+ .max_read_request_size(),
631
+ .max_payload_size(),
632
+
633
+ /*
634
+ * Interface to Ultrascale PCIe IP core
635
+ */
636
+ .cfg_mgmt_addr(cfg_mgmt_addr),
637
+ .cfg_mgmt_function_number(cfg_mgmt_function_number),
638
+ .cfg_mgmt_write(cfg_mgmt_write),
639
+ .cfg_mgmt_write_data(cfg_mgmt_write_data),
640
+ .cfg_mgmt_byte_enable(cfg_mgmt_byte_enable),
641
+ .cfg_mgmt_read(cfg_mgmt_read),
642
+ .cfg_mgmt_read_data(cfg_mgmt_read_data),
643
+ .cfg_mgmt_read_write_done(cfg_mgmt_read_write_done)
644
+ );
645
+
646
+ pcie_us_axil_master #(
647
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
648
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
649
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
650
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
651
+ .AXI_DATA_WIDTH(AXIL_DATA_WIDTH),
652
+ .AXI_ADDR_WIDTH(AXIL_ADDR_WIDTH),
653
+ .ENABLE_PARITY(0)
654
+ )
655
+ pcie_us_axil_master_inst (
656
+ .clk(clk),
657
+ .rst(rst),
658
+
659
+ /*
660
+ * AXI input (CQ)
661
+ */
662
+ .s_axis_cq_tdata(axis_cq_tdata_bar_0),
663
+ .s_axis_cq_tkeep(axis_cq_tkeep_bar_0),
664
+ .s_axis_cq_tvalid(axis_cq_tvalid_bar_0),
665
+ .s_axis_cq_tready(axis_cq_tready_bar_0),
666
+ .s_axis_cq_tlast(axis_cq_tlast_bar_0),
667
+ .s_axis_cq_tuser(axis_cq_tuser_bar_0),
668
+
669
+ /*
670
+ * AXI input (CC)
671
+ */
672
+ .m_axis_cc_tdata(axis_cc_tdata_bar_0),
673
+ .m_axis_cc_tkeep(axis_cc_tkeep_bar_0),
674
+ .m_axis_cc_tvalid(axis_cc_tvalid_bar_0),
675
+ .m_axis_cc_tready(axis_cc_tready_bar_0),
676
+ .m_axis_cc_tlast(axis_cc_tlast_bar_0),
677
+ .m_axis_cc_tuser(axis_cc_tuser_bar_0),
678
+
679
+ /*
680
+ * AXI Lite Master output
681
+ */
682
+ .m_axil_awaddr(axil_ctrl_awaddr),
683
+ .m_axil_awprot(axil_ctrl_awprot),
684
+ .m_axil_awvalid(axil_ctrl_awvalid),
685
+ .m_axil_awready(axil_ctrl_awready),
686
+ .m_axil_wdata(axil_ctrl_wdata),
687
+ .m_axil_wstrb(axil_ctrl_wstrb),
688
+ .m_axil_wvalid(axil_ctrl_wvalid),
689
+ .m_axil_wready(axil_ctrl_wready),
690
+ .m_axil_bresp(axil_ctrl_bresp),
691
+ .m_axil_bvalid(axil_ctrl_bvalid),
692
+ .m_axil_bready(axil_ctrl_bready),
693
+ .m_axil_araddr(axil_ctrl_araddr),
694
+ .m_axil_arprot(axil_ctrl_arprot),
695
+ .m_axil_arvalid(axil_ctrl_arvalid),
696
+ .m_axil_arready(axil_ctrl_arready),
697
+ .m_axil_rdata(axil_ctrl_rdata),
698
+ .m_axil_rresp(axil_ctrl_rresp),
699
+ .m_axil_rvalid(axil_ctrl_rvalid),
700
+ .m_axil_rready(axil_ctrl_rready),
701
+
702
+ /*
703
+ * Configuration
704
+ */
705
+ .completer_id({8'd0, 5'd0, 3'd0}),
706
+ .completer_id_enable(1'b0),
707
+
708
+ /*
709
+ * Status
710
+ */
711
+ .status_error_cor(status_error_cor_int[0]),
712
+ .status_error_uncor(status_error_uncor_int[0])
713
+ );
714
+
715
+ pcie_us_axi_master #(
716
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
717
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
718
+ .AXIS_PCIE_CQ_USER_WIDTH(AXIS_PCIE_CQ_USER_WIDTH),
719
+ .AXIS_PCIE_CC_USER_WIDTH(AXIS_PCIE_CC_USER_WIDTH),
720
+ .AXI_DATA_WIDTH(AXI_DATA_WIDTH),
721
+ .AXI_ADDR_WIDTH(AXI_ADDR_WIDTH),
722
+ .AXI_STRB_WIDTH(AXI_STRB_WIDTH),
723
+ .AXI_ID_WIDTH(AXI_ID_WIDTH)
724
+ )
725
+ pcie_us_axi_master_inst (
726
+ .clk(clk),
727
+ .rst(rst),
728
+
729
+ /*
730
+ * AXI input (CQ)
731
+ */
732
+ .s_axis_cq_tdata(axis_cq_tdata_bar_2),
733
+ .s_axis_cq_tkeep(axis_cq_tkeep_bar_2),
734
+ .s_axis_cq_tvalid(axis_cq_tvalid_bar_2),
735
+ .s_axis_cq_tready(axis_cq_tready_bar_2),
736
+ .s_axis_cq_tlast(axis_cq_tlast_bar_2),
737
+ .s_axis_cq_tuser(axis_cq_tuser_bar_2),
738
+
739
+ /*
740
+ * AXI output (CC)
741
+ */
742
+ .m_axis_cc_tdata(axis_cc_tdata_bar_2),
743
+ .m_axis_cc_tkeep(axis_cc_tkeep_bar_2),
744
+ .m_axis_cc_tvalid(axis_cc_tvalid_bar_2),
745
+ .m_axis_cc_tready(axis_cc_tready_bar_2),
746
+ .m_axis_cc_tlast(axis_cc_tlast_bar_2),
747
+ .m_axis_cc_tuser(axis_cc_tuser_bar_2),
748
+
749
+ /*
750
+ * AXI Master output
751
+ */
752
+ .m_axi_awid(axi_awid),
753
+ .m_axi_awaddr(axi_awaddr),
754
+ .m_axi_awlen(axi_awlen),
755
+ .m_axi_awsize(axi_awsize),
756
+ .m_axi_awburst(axi_awburst),
757
+ .m_axi_awlock(axi_awlock),
758
+ .m_axi_awcache(axi_awcache),
759
+ .m_axi_awprot(axi_awprot),
760
+ .m_axi_awvalid(axi_awvalid),
761
+ .m_axi_awready(axi_awready),
762
+ .m_axi_wdata(axi_wdata),
763
+ .m_axi_wstrb(axi_wstrb),
764
+ .m_axi_wlast(axi_wlast),
765
+ .m_axi_wvalid(axi_wvalid),
766
+ .m_axi_wready(axi_wready),
767
+ .m_axi_bid(axi_bid),
768
+ .m_axi_bresp(axi_bresp),
769
+ .m_axi_bvalid(axi_bvalid),
770
+ .m_axi_bready(axi_bready),
771
+ .m_axi_arid(axi_arid),
772
+ .m_axi_araddr(axi_araddr),
773
+ .m_axi_arlen(axi_arlen),
774
+ .m_axi_arsize(axi_arsize),
775
+ .m_axi_arburst(axi_arburst),
776
+ .m_axi_arlock(axi_arlock),
777
+ .m_axi_arcache(axi_arcache),
778
+ .m_axi_arprot(axi_arprot),
779
+ .m_axi_arvalid(axi_arvalid),
780
+ .m_axi_arready(axi_arready),
781
+ .m_axi_rid(axi_rid),
782
+ .m_axi_rdata(axi_rdata),
783
+ .m_axi_rresp(axi_rresp),
784
+ .m_axi_rlast(axi_rlast),
785
+ .m_axi_rvalid(axi_rvalid),
786
+ .m_axi_rready(axi_rready),
787
+
788
+ /*
789
+ * Configuration
790
+ */
791
+ .completer_id({8'd0, 5'd0, 3'd1}),
792
+ .completer_id_enable(1'b0),
793
+ .max_payload_size(cfg_max_payload),
794
+
795
+ /*
796
+ * Status
797
+ */
798
+ .status_error_cor(status_error_cor_int[1]),
799
+ .status_error_uncor(status_error_uncor_int[1])
800
+ );
801
+
802
+ axi_ram #(
803
+ .DATA_WIDTH(AXI_DATA_WIDTH),
804
+ .ADDR_WIDTH(16),
805
+ .ID_WIDTH(AXI_ID_WIDTH),
806
+ .PIPELINE_OUTPUT(1)
807
+ )
808
+ axi_ram_inst (
809
+ .clk(clk),
810
+ .rst(rst),
811
+ .s_axi_awid(axi_awid),
812
+ .s_axi_awaddr(axi_awaddr),
813
+ .s_axi_awlen(axi_awlen),
814
+ .s_axi_awsize(axi_awsize),
815
+ .s_axi_awburst(axi_awburst),
816
+ .s_axi_awlock(axi_awlock),
817
+ .s_axi_awcache(axi_awcache),
818
+ .s_axi_awprot(axi_awprot),
819
+ .s_axi_awvalid(axi_awvalid),
820
+ .s_axi_awready(axi_awready),
821
+ .s_axi_wdata(axi_wdata),
822
+ .s_axi_wstrb(axi_wstrb),
823
+ .s_axi_wlast(axi_wlast),
824
+ .s_axi_wvalid(axi_wvalid),
825
+ .s_axi_wready(axi_wready),
826
+ .s_axi_bid(axi_bid),
827
+ .s_axi_bresp(axi_bresp),
828
+ .s_axi_bvalid(axi_bvalid),
829
+ .s_axi_bready(axi_bready),
830
+ .s_axi_arid(axi_arid),
831
+ .s_axi_araddr(axi_araddr),
832
+ .s_axi_arlen(axi_arlen),
833
+ .s_axi_arsize(axi_arsize),
834
+ .s_axi_arburst(axi_arburst),
835
+ .s_axi_arlock(axi_arlock),
836
+ .s_axi_arcache(axi_arcache),
837
+ .s_axi_arprot(axi_arprot),
838
+ .s_axi_arvalid(axi_arvalid),
839
+ .s_axi_arready(axi_arready),
840
+ .s_axi_rid(axi_rid),
841
+ .s_axi_rdata(axi_rdata),
842
+ .s_axi_rresp(axi_rresp),
843
+ .s_axi_rlast(axi_rlast),
844
+ .s_axi_rvalid(axi_rvalid),
845
+ .s_axi_rready(axi_rready)
846
+ );
847
+
848
+ wire [AXIS_PCIE_DATA_WIDTH-1:0] axis_rc_tdata_r;
849
+ wire [AXIS_PCIE_KEEP_WIDTH-1:0] axis_rc_tkeep_r;
850
+ wire axis_rc_tlast_r;
851
+ wire axis_rc_tready_r;
852
+ wire [AXIS_PCIE_RC_USER_WIDTH-1:0] axis_rc_tuser_r;
853
+ wire axis_rc_tvalid_r;
854
+
855
+ axis_register #(
856
+ .DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
857
+ .KEEP_ENABLE(1),
858
+ .KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
859
+ .LAST_ENABLE(1),
860
+ .ID_ENABLE(0),
861
+ .DEST_ENABLE(0),
862
+ .USER_ENABLE(1),
863
+ .USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH)
864
+ )
865
+ rc_reg (
866
+ .clk(clk),
867
+ .rst(rst),
868
+
869
+ /*
870
+ * AXI input
871
+ */
872
+ .s_axis_tdata(s_axis_rc_tdata),
873
+ .s_axis_tkeep(s_axis_rc_tkeep),
874
+ .s_axis_tvalid(s_axis_rc_tvalid),
875
+ .s_axis_tready(s_axis_rc_tready),
876
+ .s_axis_tlast(s_axis_rc_tlast),
877
+ .s_axis_tid(0),
878
+ .s_axis_tdest(0),
879
+ .s_axis_tuser(s_axis_rc_tuser),
880
+
881
+ /*
882
+ * AXI output
883
+ */
884
+ .m_axis_tdata(axis_rc_tdata_r),
885
+ .m_axis_tkeep(axis_rc_tkeep_r),
886
+ .m_axis_tvalid(axis_rc_tvalid_r),
887
+ .m_axis_tready(axis_rc_tready_r),
888
+ .m_axis_tlast(axis_rc_tlast_r),
889
+ .m_axis_tid(),
890
+ .m_axis_tdest(),
891
+ .m_axis_tuser(axis_rc_tuser_r)
892
+ );
893
+
894
+ pcie_us_axi_dma #(
895
+ .AXIS_PCIE_DATA_WIDTH(AXIS_PCIE_DATA_WIDTH),
896
+ .AXIS_PCIE_KEEP_WIDTH(AXIS_PCIE_KEEP_WIDTH),
897
+ .AXIS_PCIE_RC_USER_WIDTH(AXIS_PCIE_RC_USER_WIDTH),
898
+ .AXIS_PCIE_RQ_USER_WIDTH(AXIS_PCIE_RQ_USER_WIDTH),
899
+ .AXI_DATA_WIDTH(AXI_DATA_WIDTH),
900
+ .AXI_ADDR_WIDTH(AXI_ADDR_WIDTH),
901
+ .AXI_STRB_WIDTH(AXI_STRB_WIDTH),
902
+ .AXI_ID_WIDTH(AXI_ID_WIDTH),
903
+ .AXI_MAX_BURST_LEN(256),
904
+ .PCIE_ADDR_WIDTH(PCIE_ADDR_WIDTH),
905
+ .PCIE_TAG_COUNT(256),
906
+ .LEN_WIDTH(16),
907
+ .TAG_WIDTH(DMA_TAG_WIDTH)
908
+ )
909
+ pcie_us_axi_dma_inst (
910
+ .clk(clk),
911
+ .rst(rst),
912
+
913
+ /*
914
+ * AXI input (RC)
915
+ */
916
+ .s_axis_rc_tdata(axis_rc_tdata_r),
917
+ .s_axis_rc_tkeep(axis_rc_tkeep_r),
918
+ .s_axis_rc_tvalid(axis_rc_tvalid_r),
919
+ .s_axis_rc_tready(axis_rc_tready_r),
920
+ .s_axis_rc_tlast(axis_rc_tlast_r),
921
+ .s_axis_rc_tuser(axis_rc_tuser_r),
922
+
923
+ /*
924
+ * AXI output (RQ)
925
+ */
926
+ .m_axis_rq_tdata(m_axis_rq_tdata),
927
+ .m_axis_rq_tkeep(m_axis_rq_tkeep),
928
+ .m_axis_rq_tvalid(m_axis_rq_tvalid),
929
+ .m_axis_rq_tready(m_axis_rq_tready),
930
+ .m_axis_rq_tlast(m_axis_rq_tlast),
931
+ .m_axis_rq_tuser(m_axis_rq_tuser),
932
+
933
+ /*
934
+ * AXI read descriptor input
935
+ */
936
+ .s_axis_read_desc_pcie_addr(pcie_dma_read_desc_pcie_addr),
937
+ .s_axis_read_desc_axi_addr(pcie_dma_read_desc_axi_addr),
938
+ .s_axis_read_desc_len(pcie_dma_read_desc_len),
939
+ .s_axis_read_desc_tag(pcie_dma_read_desc_tag),
940
+ .s_axis_read_desc_valid(pcie_dma_read_desc_valid),
941
+ .s_axis_read_desc_ready(pcie_dma_read_desc_ready),
942
+
943
+ /*
944
+ * AXI read descriptor status output
945
+ */
946
+ .m_axis_read_desc_status_tag(pcie_dma_read_desc_status_tag),
947
+ .m_axis_read_desc_status_error(pcie_dma_read_desc_status_error),
948
+ .m_axis_read_desc_status_valid(pcie_dma_read_desc_status_valid),
949
+
950
+ /*
951
+ * AXI write descriptor input
952
+ */
953
+ .s_axis_write_desc_pcie_addr(pcie_dma_write_desc_pcie_addr),
954
+ .s_axis_write_desc_axi_addr(pcie_dma_write_desc_axi_addr),
955
+ .s_axis_write_desc_len(pcie_dma_write_desc_len),
956
+ .s_axis_write_desc_tag(pcie_dma_write_desc_tag),
957
+ .s_axis_write_desc_valid(pcie_dma_write_desc_valid),
958
+ .s_axis_write_desc_ready(pcie_dma_write_desc_ready),
959
+
960
+ /*
961
+ * AXI write descriptor status output
962
+ */
963
+ .m_axis_write_desc_status_tag(pcie_dma_write_desc_status_tag),
964
+ .m_axis_write_desc_status_error(pcie_dma_write_desc_status_error),
965
+ .m_axis_write_desc_status_valid(pcie_dma_write_desc_status_valid),
966
+
967
+ /*
968
+ * AXI Master output
969
+ */
970
+ .m_axi_awid(axi_dma_awid),
971
+ .m_axi_awaddr(axi_dma_awaddr),
972
+ .m_axi_awlen(axi_dma_awlen),
973
+ .m_axi_awsize(axi_dma_awsize),
974
+ .m_axi_awburst(axi_dma_awburst),
975
+ .m_axi_awlock(axi_dma_awlock),
976
+ .m_axi_awcache(axi_dma_awcache),
977
+ .m_axi_awprot(axi_dma_awprot),
978
+ .m_axi_awvalid(axi_dma_awvalid),
979
+ .m_axi_awready(axi_dma_awready),
980
+ .m_axi_wdata(axi_dma_wdata),
981
+ .m_axi_wstrb(axi_dma_wstrb),
982
+ .m_axi_wlast(axi_dma_wlast),
983
+ .m_axi_wvalid(axi_dma_wvalid),
984
+ .m_axi_wready(axi_dma_wready),
985
+ .m_axi_bid(axi_dma_bid),
986
+ .m_axi_bresp(axi_dma_bresp),
987
+ .m_axi_bvalid(axi_dma_bvalid),
988
+ .m_axi_bready(axi_dma_bready),
989
+ .m_axi_arid(axi_dma_arid),
990
+ .m_axi_araddr(axi_dma_araddr),
991
+ .m_axi_arlen(axi_dma_arlen),
992
+ .m_axi_arsize(axi_dma_arsize),
993
+ .m_axi_arburst(axi_dma_arburst),
994
+ .m_axi_arlock(axi_dma_arlock),
995
+ .m_axi_arcache(axi_dma_arcache),
996
+ .m_axi_arprot(axi_dma_arprot),
997
+ .m_axi_arvalid(axi_dma_arvalid),
998
+ .m_axi_arready(axi_dma_arready),
999
+ .m_axi_rid(axi_dma_rid),
1000
+ .m_axi_rdata(axi_dma_rdata),
1001
+ .m_axi_rresp(axi_dma_rresp),
1002
+ .m_axi_rlast(axi_dma_rlast),
1003
+ .m_axi_rvalid(axi_dma_rvalid),
1004
+ .m_axi_rready(axi_dma_rready),
1005
+
1006
+ /*
1007
+ * Configuration
1008
+ */
1009
+ .read_enable(pcie_dma_enable),
1010
+ .write_enable(pcie_dma_enable),
1011
+ .ext_tag_enable(ext_tag_enable),
1012
+ .requester_id({8'd0, 5'd0, 3'd0}),
1013
+ .requester_id_enable(1'b0),
1014
+ .max_read_request_size(cfg_max_read_req),
1015
+ .max_payload_size(cfg_max_payload),
1016
+
1017
+ /*
1018
+ * Status
1019
+ */
1020
+ .status_error_cor(status_error_cor_int[2]),
1021
+ .status_error_uncor(status_error_uncor_int[2])
1022
+ );
1023
+
1024
+ axi_ram #(
1025
+ .DATA_WIDTH(AXI_DATA_WIDTH),
1026
+ .ADDR_WIDTH(16),
1027
+ .ID_WIDTH(AXI_ID_WIDTH),
1028
+ .PIPELINE_OUTPUT(1)
1029
+ )
1030
+ axi_dma_ram_inst (
1031
+ .clk(clk),
1032
+ .rst(rst),
1033
+ .s_axi_awid(axi_dma_awid),
1034
+ .s_axi_awaddr(axi_dma_awaddr),
1035
+ .s_axi_awlen(axi_dma_awlen),
1036
+ .s_axi_awsize(axi_dma_awsize),
1037
+ .s_axi_awburst(axi_dma_awburst),
1038
+ .s_axi_awlock(axi_dma_awlock),
1039
+ .s_axi_awcache(axi_dma_awcache),
1040
+ .s_axi_awprot(axi_dma_awprot),
1041
+ .s_axi_awvalid(axi_dma_awvalid),
1042
+ .s_axi_awready(axi_dma_awready),
1043
+ .s_axi_wdata(axi_dma_wdata),
1044
+ .s_axi_wstrb(axi_dma_wstrb),
1045
+ .s_axi_wlast(axi_dma_wlast),
1046
+ .s_axi_wvalid(axi_dma_wvalid),
1047
+ .s_axi_wready(axi_dma_wready),
1048
+ .s_axi_bid(axi_dma_bid),
1049
+ .s_axi_bresp(axi_dma_bresp),
1050
+ .s_axi_bvalid(axi_dma_bvalid),
1051
+ .s_axi_bready(axi_dma_bready),
1052
+ .s_axi_arid(axi_dma_arid),
1053
+ .s_axi_araddr(axi_dma_araddr),
1054
+ .s_axi_arlen(axi_dma_arlen),
1055
+ .s_axi_arsize(axi_dma_arsize),
1056
+ .s_axi_arburst(axi_dma_arburst),
1057
+ .s_axi_arlock(axi_dma_arlock),
1058
+ .s_axi_arcache(axi_dma_arcache),
1059
+ .s_axi_arprot(axi_dma_arprot),
1060
+ .s_axi_arvalid(axi_dma_arvalid),
1061
+ .s_axi_arready(axi_dma_arready),
1062
+ .s_axi_rid(axi_dma_rid),
1063
+ .s_axi_rdata(axi_dma_rdata),
1064
+ .s_axi_rresp(axi_dma_rresp),
1065
+ .s_axi_rlast(axi_dma_rlast),
1066
+ .s_axi_rvalid(axi_dma_rvalid),
1067
+ .s_axi_rready(axi_dma_rready)
1068
+ );
1069
+
1070
+ pulse_merge #(
1071
+ .INPUT_WIDTH(3),
1072
+ .COUNT_WIDTH(4)
1073
+ )
1074
+ status_error_cor_pm_inst (
1075
+ .clk(clk),
1076
+ .rst(rst),
1077
+
1078
+ .pulse_in(status_error_cor_int),
1079
+ .count_out(),
1080
+ .pulse_out(status_error_cor)
1081
+ );
1082
+
1083
+ pulse_merge #(
1084
+ .INPUT_WIDTH(3),
1085
+ .COUNT_WIDTH(4)
1086
+ )
1087
+ status_error_uncor_pm_inst (
1088
+ .clk(clk),
1089
+ .rst(rst),
1090
+
1091
+ .pulse_in(status_error_uncor_int),
1092
+ .count_out(),
1093
+ .pulse_out(status_error_uncor)
1094
+ );
1095
+
1096
+ pcie_us_msi #(
1097
+ .MSI_COUNT(32)
1098
+ )
1099
+ pcie_us_msi_inst (
1100
+ .clk(clk),
1101
+ .rst(rst),
1102
+
1103
+ .msi_irq(msi_irq),
1104
+
1105
+ .cfg_interrupt_msi_enable(cfg_interrupt_msi_enable),
1106
+ .cfg_interrupt_msi_vf_enable(0),
1107
+ .cfg_interrupt_msi_mmenable(cfg_interrupt_msi_mmenable),
1108
+ .cfg_interrupt_msi_mask_update(cfg_interrupt_msi_mask_update),
1109
+ .cfg_interrupt_msi_data(cfg_interrupt_msi_data),
1110
+ .cfg_interrupt_msi_select(cfg_interrupt_msi_select),
1111
+ .cfg_interrupt_msi_int(cfg_interrupt_msi_int),
1112
+ .cfg_interrupt_msi_pending_status(cfg_interrupt_msi_pending_status),
1113
+ .cfg_interrupt_msi_pending_status_data_enable(cfg_interrupt_msi_pending_status_data_enable),
1114
+ .cfg_interrupt_msi_pending_status_function_num(cfg_interrupt_msi_pending_status_function_num),
1115
+ .cfg_interrupt_msi_sent(cfg_interrupt_msi_sent),
1116
+ .cfg_interrupt_msi_fail(cfg_interrupt_msi_fail),
1117
+ .cfg_interrupt_msi_attr(cfg_interrupt_msi_attr),
1118
+ .cfg_interrupt_msi_tph_present(cfg_interrupt_msi_tph_present),
1119
+ .cfg_interrupt_msi_tph_type(cfg_interrupt_msi_tph_type),
1120
+ .cfg_interrupt_msi_tph_st_tag(cfg_interrupt_msi_tph_st_tag),
1121
+ .cfg_interrupt_msi_function_number(cfg_interrupt_msi_function_number)
1122
+ );
1123
+
1124
+ endmodule
1125
+
1126
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/sync_reset.v ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an active-high asynchronous reset signal to a given clock by
33
+ * using a pipeline of N registers.
34
+ */
35
+ module sync_reset #(
36
+ parameter N=2 // depth of synchronizer
37
+ )(
38
+ input wire clk,
39
+ input wire rst,
40
+ output wire sync_reset_out
41
+ );
42
+
43
+ reg [N-1:0] sync_reg = {N{1'b1}};
44
+
45
+ assign sync_reset_out = sync_reg[N-1];
46
+
47
+ always @(posedge clk or posedge rst) begin
48
+ if (rst)
49
+ sync_reg <= {N{1'b1}};
50
+ else
51
+ sync_reg <= {sync_reg[N-2:0], 1'b0};
52
+ end
53
+
54
+ endmodule
55
+
56
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/rtl/sync_signal.v ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ Copyright (c) 2014-2018 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ */
24
+
25
+ // Language: Verilog-2001
26
+
27
+ `resetall
28
+ `timescale 1 ns / 1 ps
29
+ `default_nettype none
30
+
31
+ /*
32
+ * Synchronizes an asyncronous signal to a given clock by using a pipeline of
33
+ * two registers.
34
+ */
35
+ module sync_signal #(
36
+ parameter WIDTH=1, // width of the input and output signals
37
+ parameter N=2 // depth of synchronizer
38
+ )(
39
+ input wire clk,
40
+ input wire [WIDTH-1:0] in,
41
+ output wire [WIDTH-1:0] out
42
+ );
43
+
44
+ reg [WIDTH-1:0] sync_reg[N-1:0];
45
+
46
+ /*
47
+ * The synchronized output is the last register in the pipeline.
48
+ */
49
+ assign out = sync_reg[N-1];
50
+
51
+ integer k;
52
+
53
+ always @(posedge clk) begin
54
+ sync_reg[0] <= in;
55
+ for (k = 1; k < N; k = k + 1) begin
56
+ sync_reg[k] <= sync_reg[k-1];
57
+ end
58
+ end
59
+
60
+ endmodule
61
+
62
+ `resetall
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/tb/fpga_core/Makefile ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020 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
+ TOPLEVEL_LANG = verilog
22
+
23
+ SIM ?= icarus
24
+ WAVES ?= 0
25
+
26
+ COCOTB_HDL_TIMEUNIT = 1ns
27
+ COCOTB_HDL_TIMEPRECISION = 1ps
28
+
29
+ DUT = fpga_core
30
+ TOPLEVEL = $(DUT)
31
+ MODULE = test_$(DUT)
32
+ VERILOG_SOURCES += ../../rtl/$(DUT).v
33
+ VERILOG_SOURCES += ../../rtl/axi_ram.v
34
+ VERILOG_SOURCES += ../../rtl/axis_register.v
35
+ VERILOG_SOURCES += ../../lib/pcie/rtl/axis_arb_mux.v
36
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axil_master.v
37
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma.v
38
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma_rd.v
39
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_dma_wr.v
40
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master.v
41
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master_rd.v
42
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axi_master_wr.v
43
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_axis_cq_demux.v
44
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_cfg.v
45
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pcie_us_msi.v
46
+ VERILOG_SOURCES += ../../lib/pcie/rtl/arbiter.v
47
+ VERILOG_SOURCES += ../../lib/pcie/rtl/priority_encoder.v
48
+ VERILOG_SOURCES += ../../lib/pcie/rtl/pulse_merge.v
49
+
50
+ # module parameters
51
+ export PARAM_AXIS_PCIE_DATA_WIDTH ?= 512
52
+ export PARAM_AXIS_PCIE_KEEP_WIDTH ?= $(shell expr $(PARAM_AXIS_PCIE_DATA_WIDTH) / 32 )
53
+ export PARAM_AXIS_PCIE_RQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),62,137)
54
+ export PARAM_AXIS_PCIE_RC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),75,161)
55
+ export PARAM_AXIS_PCIE_CQ_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),88,183)
56
+ export PARAM_AXIS_PCIE_CC_USER_WIDTH ?= $(if $(filter-out 512,$(PARAM_AXIS_PCIE_DATA_WIDTH)),33,81)
57
+ export PARAM_RQ_SEQ_NUM_WIDTH ?= 6
58
+
59
+ ifeq ($(SIM), icarus)
60
+ PLUSARGS += -fst
61
+
62
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
63
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
64
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
65
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
66
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
67
+ COMPILE_ARGS += -P $(TOPLEVEL).AXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
68
+ COMPILE_ARGS += -P $(TOPLEVEL).RQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
69
+
70
+ ifeq ($(WAVES), 1)
71
+ VERILOG_SOURCES += iverilog_dump.v
72
+ COMPILE_ARGS += -s iverilog_dump
73
+ endif
74
+ else ifeq ($(SIM), verilator)
75
+ COMPILE_ARGS += -Wno-SELRANGE -Wno-WIDTH
76
+
77
+ COMPILE_ARGS += -GAXIS_PCIE_DATA_WIDTH=$(PARAM_AXIS_PCIE_DATA_WIDTH)
78
+ COMPILE_ARGS += -GAXIS_PCIE_KEEP_WIDTH=$(PARAM_AXIS_PCIE_KEEP_WIDTH)
79
+ COMPILE_ARGS += -GAXIS_PCIE_RQ_USER_WIDTH=$(PARAM_AXIS_PCIE_RQ_USER_WIDTH)
80
+ COMPILE_ARGS += -GAXIS_PCIE_RC_USER_WIDTH=$(PARAM_AXIS_PCIE_RC_USER_WIDTH)
81
+ COMPILE_ARGS += -GAXIS_PCIE_CQ_USER_WIDTH=$(PARAM_AXIS_PCIE_CQ_USER_WIDTH)
82
+ COMPILE_ARGS += -GAXIS_PCIE_CC_USER_WIDTH=$(PARAM_AXIS_PCIE_CC_USER_WIDTH)
83
+ COMPILE_ARGS += -GRQ_SEQ_NUM_WIDTH=$(PARAM_RQ_SEQ_NUM_WIDTH)
84
+
85
+ ifeq ($(WAVES), 1)
86
+ COMPILE_ARGS += --trace-fst
87
+ endif
88
+ endif
89
+
90
+ include $(shell cocotb-config --makefiles)/Makefile.sim
91
+
92
+ iverilog_dump.v:
93
+ echo 'module iverilog_dump();' > $@
94
+ echo 'initial begin' >> $@
95
+ echo ' $$dumpfile("$(TOPLEVEL).fst");' >> $@
96
+ echo ' $$dumpvars(0, $(TOPLEVEL));' >> $@
97
+ echo 'end' >> $@
98
+ echo 'endmodule' >> $@
99
+
100
+ clean::
101
+ @rm -rf iverilog_dump.v
102
+ @rm -rf dump.fst $(TOPLEVEL).fst
snapshots/alexforencich_verilog-pcie_pr20/example/AU50/fpga_axi/tb/fpga_core/test_fpga_core.py ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+
3
+ Copyright (c) 2020 Alex Forencich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ """
24
+
25
+ import logging
26
+ import os
27
+
28
+ import cocotb_test.simulator
29
+
30
+ import cocotb
31
+ from cocotb.log import SimLog
32
+ from cocotb.triggers import RisingEdge, FallingEdge, Timer
33
+
34
+ from cocotbext.axi import AxiStreamBus
35
+ from cocotbext.pcie.core import RootComplex
36
+ from cocotbext.pcie.xilinx.us import UltraScalePlusPcieDevice
37
+ from cocotbext.axi.utils import hexdump_str
38
+
39
+
40
+ class TB(object):
41
+ def __init__(self, dut):
42
+ self.dut = dut
43
+
44
+ self.log = SimLog("cocotb.tb")
45
+ self.log.setLevel(logging.DEBUG)
46
+
47
+ # PCIe
48
+ self.rc = RootComplex()
49
+
50
+ self.dev = UltraScalePlusPcieDevice(
51
+ # configuration options
52
+ pcie_generation=3,
53
+ pcie_link_width=16,
54
+ user_clk_frequency=250e6,
55
+ alignment="dword",
56
+ cq_cc_straddle=False,
57
+ rq_rc_straddle=False,
58
+ rc_4tlp_straddle=False,
59
+ enable_pf1=False,
60
+ enable_client_tag=True,
61
+ enable_extended_tag=True,
62
+ enable_parity=False,
63
+ enable_rx_msg_interface=False,
64
+ enable_sriov=False,
65
+ enable_extended_configuration=False,
66
+
67
+ enable_pf0_msi=True,
68
+ enable_pf1_msi=False,
69
+
70
+ # signals
71
+ # Clock and Reset Interface
72
+ user_clk=dut.clk,
73
+ user_reset=dut.rst,
74
+ # user_lnk_up
75
+ # sys_clk
76
+ # sys_clk_gt
77
+ # sys_reset
78
+ # phy_rdy_out
79
+
80
+ # Requester reQuest Interface
81
+ rq_bus=AxiStreamBus.from_prefix(dut, "m_axis_rq"),
82
+ # pcie_rq_seq_num0=dut.s_axis_rq_seq_num_0,
83
+ # pcie_rq_seq_num_vld0=dut.s_axis_rq_seq_num_valid_0,
84
+ # pcie_rq_seq_num1=dut.s_axis_rq_seq_num_1,
85
+ # pcie_rq_seq_num_vld1=dut.s_axis_rq_seq_num_valid_1,
86
+ # pcie_rq_tag0
87
+ # pcie_rq_tag1
88
+ # pcie_rq_tag_av
89
+ # pcie_rq_tag_vld0
90
+ # pcie_rq_tag_vld1
91
+
92
+ # Requester Completion Interface
93
+ rc_bus=AxiStreamBus.from_prefix(dut, "s_axis_rc"),
94
+
95
+ # Completer reQuest Interface
96
+ cq_bus=AxiStreamBus.from_prefix(dut, "s_axis_cq"),
97
+ # pcie_cq_np_req
98
+ # pcie_cq_np_req_count
99
+
100
+ # Completer Completion Interface
101
+ cc_bus=AxiStreamBus.from_prefix(dut, "m_axis_cc"),
102
+
103
+ # Transmit Flow Control Interface
104
+ # pcie_tfc_nph_av=dut.pcie_tfc_nph_av,
105
+ # pcie_tfc_npd_av=dut.pcie_tfc_npd_av,
106
+
107
+ # Configuration Management Interface
108
+ cfg_mgmt_addr=dut.cfg_mgmt_addr,
109
+ cfg_mgmt_function_number=dut.cfg_mgmt_function_number,
110
+ cfg_mgmt_write=dut.cfg_mgmt_write,
111
+ cfg_mgmt_write_data=dut.cfg_mgmt_write_data,
112
+ cfg_mgmt_byte_enable=dut.cfg_mgmt_byte_enable,
113
+ cfg_mgmt_read=dut.cfg_mgmt_read,
114
+ cfg_mgmt_read_data=dut.cfg_mgmt_read_data,
115
+ cfg_mgmt_read_write_done=dut.cfg_mgmt_read_write_done,
116
+ # cfg_mgmt_debug_access
117
+
118
+ # Configuration Status Interface
119
+ # cfg_phy_link_down
120
+ # cfg_phy_link_status
121
+ # cfg_negotiated_width
122
+ # cfg_current_speed
123
+ cfg_max_payload=dut.cfg_max_payload,
124
+ cfg_max_read_req=dut.cfg_max_read_req,
125
+ # cfg_function_status
126
+ # cfg_vf_status
127
+ # cfg_function_power_state
128
+ # cfg_vf_power_state
129
+ # cfg_link_power_state
130
+ # cfg_err_cor_out
131
+ # cfg_err_nonfatal_out
132
+ # cfg_err_fatal_out
133
+ # cfg_local_error_out
134
+ # cfg_local_error_valid
135
+ # cfg_rx_pm_state
136
+ # cfg_tx_pm_state
137
+ # cfg_ltssm_state
138
+ # cfg_rcb_status
139
+ # cfg_obff_enable
140
+ # cfg_pl_status_change
141
+ # cfg_tph_requester_enable
142
+ # cfg_tph_st_mode
143
+ # cfg_vf_tph_requester_enable
144
+ # cfg_vf_tph_st_mode
145
+
146
+ # Configuration Received Message Interface
147
+ # cfg_msg_received
148
+ # cfg_msg_received_data
149
+ # cfg_msg_received_type
150
+
151
+ # Configuration Transmit Message Interface
152
+ # cfg_msg_transmit
153
+ # cfg_msg_transmit_type
154
+ # cfg_msg_transmit_data
155
+ # cfg_msg_transmit_done
156
+
157
+ # Configuration Flow Control Interface
158
+ # cfg_fc_ph=dut.cfg_fc_ph,
159
+ # cfg_fc_pd=dut.cfg_fc_pd,
160
+ # cfg_fc_nph=dut.cfg_fc_nph,
161
+ # cfg_fc_npd=dut.cfg_fc_npd,
162
+ # cfg_fc_cplh=dut.cfg_fc_cplh,
163
+ # cfg_fc_cpld=dut.cfg_fc_cpld,
164
+ # cfg_fc_sel=dut.cfg_fc_sel,
165
+
166
+ # Configuration Control Interface
167
+ # cfg_hot_reset_in
168
+ # cfg_hot_reset_out
169
+ # cfg_config_space_enable
170
+ # cfg_dsn
171
+ # cfg_bus_number
172
+ # cfg_ds_port_number
173
+ # cfg_ds_bus_number
174
+ # cfg_ds_device_number
175
+ # cfg_ds_function_number
176
+ # cfg_power_state_change_ack
177
+ # cfg_power_state_change_interrupt
178
+ cfg_err_cor_in=dut.status_error_cor,
179
+ cfg_err_uncor_in=dut.status_error_uncor,
180
+ # cfg_flr_in_process
181
+ # cfg_flr_done
182
+ # cfg_vf_flr_in_process
183
+ # cfg_vf_flr_func_num
184
+ # cfg_vf_flr_done
185
+ # cfg_pm_aspm_l1_entry_reject
186
+ # cfg_pm_aspm_tx_l0s_entry_disable
187
+ # cfg_req_pm_transition_l23_ready
188
+ # cfg_link_training_enable
189
+
190
+ # Configuration Interrupt Controller Interface
191
+ # cfg_interrupt_int
192
+ # cfg_interrupt_sent
193
+ # cfg_interrupt_pending
194
+ cfg_interrupt_msi_enable=dut.cfg_interrupt_msi_enable,
195
+ cfg_interrupt_msi_mmenable=dut.cfg_interrupt_msi_mmenable,
196
+ cfg_interrupt_msi_mask_update=dut.cfg_interrupt_msi_mask_update,
197
+ cfg_interrupt_msi_data=dut.cfg_interrupt_msi_data,
198
+ # cfg_interrupt_msi_select=dut.cfg_interrupt_msi_select,
199
+ cfg_interrupt_msi_int=dut.cfg_interrupt_msi_int,
200
+ cfg_interrupt_msi_pending_status=dut.cfg_interrupt_msi_pending_status,
201
+ cfg_interrupt_msi_pending_status_data_enable=dut.cfg_interrupt_msi_pending_status_data_enable,
202
+ # cfg_interrupt_msi_pending_status_function_num=dut.cfg_interrupt_msi_pending_status_function_num,
203
+ cfg_interrupt_msi_sent=dut.cfg_interrupt_msi_sent,
204
+ cfg_interrupt_msi_fail=dut.cfg_interrupt_msi_fail,
205
+ # cfg_interrupt_msix_enable
206
+ # cfg_interrupt_msix_mask
207
+ # cfg_interrupt_msix_vf_enable
208
+ # cfg_interrupt_msix_vf_mask
209
+ # cfg_interrupt_msix_address
210
+ # cfg_interrupt_msix_data
211
+ # cfg_interrupt_msix_int
212
+ # cfg_interrupt_msix_vec_pending
213
+ # cfg_interrupt_msix_vec_pending_status
214
+ cfg_interrupt_msi_attr=dut.cfg_interrupt_msi_attr,
215
+ cfg_interrupt_msi_tph_present=dut.cfg_interrupt_msi_tph_present,
216
+ cfg_interrupt_msi_tph_type=dut.cfg_interrupt_msi_tph_type,
217
+ # cfg_interrupt_msi_tph_st_tag=dut.cfg_interrupt_msi_tph_st_tag,
218
+ # cfg_interrupt_msi_function_number=dut.cfg_interrupt_msi_function_number,
219
+
220
+ # Configuration Extend Interface
221
+ # cfg_ext_read_received
222
+ # cfg_ext_write_received
223
+ # cfg_ext_register_number
224
+ # cfg_ext_function_number
225
+ # cfg_ext_write_data
226
+ # cfg_ext_write_byte_enable
227
+ # cfg_ext_read_data
228
+ # cfg_ext_read_data_valid
229
+ )
230
+
231
+ # self.dev.log.setLevel(logging.DEBUG)
232
+
233
+ self.rc.make_port().connect(self.dev)
234
+
235
+ self.dev.functions[0].msi_multiple_message_capable = 5
236
+
237
+ self.dev.functions[0].configure_bar(0, 2**22)
238
+ self.dev.functions[0].configure_bar(2, 2**22)
239
+
240
+ async def init(self):
241
+
242
+ await FallingEdge(self.dut.rst)
243
+ await Timer(100, 'ns')
244
+
245
+ await self.rc.enumerate(enable_bus_mastering=True, configure_msi=True)
246
+
247
+
248
+ @cocotb.test()
249
+ async def run_test(dut):
250
+
251
+ tb = TB(dut)
252
+
253
+ await tb.init()
254
+
255
+ mem = tb.rc.mem_pool.alloc_region(16*1024*1024)
256
+ mem_base = mem.get_absolute_address(0)
257
+
258
+ dev_pf0_bar0 = tb.rc.tree[0][0].bar_window[0]
259
+ dev_pf0_bar2 = tb.rc.tree[0][0].bar_window[2]
260
+
261
+ tb.log.info("Test memory write to BAR 2")
262
+
263
+ test_data = b'\x11\x22\x33\x44'
264
+ await dev_pf0_bar2.write(0, test_data)
265
+
266
+ await Timer(100, 'ns')
267
+
268
+ tb.log.info("Test memory read from BAR 2")
269
+
270
+ val = await dev_pf0_bar2.read(0, len(test_data), timeout=1000)
271
+ tb.log.info("Read data: %s", val)
272
+ assert val == test_data
273
+
274
+ tb.log.info("Test DMA")
275
+
276
+ # write packet data
277
+ mem[0:1024] = bytearray([x % 256 for x in range(1024)])
278
+
279
+ # enable DMA
280
+ await dev_pf0_bar0.write_dword(0x000000, 1)
281
+
282
+ # write pcie read descriptor
283
+ await dev_pf0_bar0.write_dword(0x000100, (mem_base+0x0000) & 0xffffffff)
284
+ await dev_pf0_bar0.write_dword(0x000104, (mem_base+0x0000 >> 32) & 0xffffffff)
285
+ await dev_pf0_bar0.write_dword(0x000108, 0x100)
286
+ await dev_pf0_bar0.write_dword(0x000110, 0x400)
287
+ await dev_pf0_bar0.write_dword(0x000114, 0xAA)
288
+
289
+ await Timer(2000, 'ns')
290
+
291
+ # read status
292
+ val = await dev_pf0_bar0.read_dword(0x000118)
293
+ tb.log.info("Status: 0x%x", val)
294
+ assert val == 0x800000AA
295
+
296
+ # write pcie write descriptor
297
+ await dev_pf0_bar0.write_dword(0x000200, (mem_base+0x1000) & 0xffffffff)
298
+ await dev_pf0_bar0.write_dword(0x000204, (mem_base+0x1000 >> 32) & 0xffffffff)
299
+ await dev_pf0_bar0.write_dword(0x000208, 0x100)
300
+ await dev_pf0_bar0.write_dword(0x000210, 0x400)
301
+ await dev_pf0_bar0.write_dword(0x000214, 0x55)
302
+
303
+ await Timer(2000, 'ns')
304
+
305
+ # read status
306
+ val = await dev_pf0_bar0.read_dword(0x000218)
307
+ tb.log.info("Status: 0x%x", val)
308
+ assert val == 0x80000055
309
+
310
+ tb.log.info("%s", mem.hexdump_str(0x1000, 64))
311
+
312
+ assert mem[0:1024] == mem[0x1000:0x1000+1024]
313
+
314
+ await RisingEdge(dut.clk)
315
+ await RisingEdge(dut.clk)
316
+
317
+
318
+ # cocotb-test
319
+
320
+ tests_dir = os.path.dirname(__file__)
321
+ rtl_dir = os.path.abspath(os.path.join(tests_dir, '..', '..', 'rtl'))
322
+ lib_dir = os.path.abspath(os.path.join(rtl_dir, '..', 'lib'))
323
+ pcie_rtl_dir = os.path.abspath(os.path.join(lib_dir, 'pcie', 'rtl'))
324
+
325
+
326
+ def test_fpga_core(request):
327
+ dut = "fpga_core"
328
+ module = os.path.splitext(os.path.basename(__file__))[0]
329
+ toplevel = dut
330
+
331
+ verilog_sources = [
332
+ os.path.join(rtl_dir, f"{dut}.v"),
333
+ os.path.join(rtl_dir, "axi_ram.v"),
334
+ os.path.join(rtl_dir, "axis_register.v"),
335
+ os.path.join(pcie_rtl_dir, "axis_arb_mux.v"),
336
+ os.path.join(pcie_rtl_dir, "pcie_us_axil_master.v"),
337
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma.v"),
338
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma_rd.v"),
339
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_dma_wr.v"),
340
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master.v"),
341
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master_rd.v"),
342
+ os.path.join(pcie_rtl_dir, "pcie_us_axi_master_wr.v"),
343
+ os.path.join(pcie_rtl_dir, "pcie_us_axis_cq_demux.v"),
344
+ os.path.join(pcie_rtl_dir, "pcie_us_cfg.v"),
345
+ os.path.join(pcie_rtl_dir, "pcie_us_msi.v"),
346
+ os.path.join(pcie_rtl_dir, "arbiter.v"),
347
+ os.path.join(pcie_rtl_dir, "priority_encoder.v"),
348
+ os.path.join(pcie_rtl_dir, "pulse_merge.v"),
349
+ ]
350
+
351
+ parameters = {}
352
+
353
+ parameters['AXIS_PCIE_DATA_WIDTH'] = 512
354
+ parameters['AXIS_PCIE_KEEP_WIDTH'] = parameters['AXIS_PCIE_DATA_WIDTH'] // 32
355
+ parameters['AXIS_PCIE_RQ_USER_WIDTH'] = 62 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 137
356
+ parameters['AXIS_PCIE_RC_USER_WIDTH'] = 75 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 161
357
+ parameters['AXIS_PCIE_CQ_USER_WIDTH'] = 88 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 183
358
+ parameters['AXIS_PCIE_CC_USER_WIDTH'] = 33 if parameters['AXIS_PCIE_DATA_WIDTH'] < 512 else 81
359
+ parameters['RQ_SEQ_NUM_WIDTH'] = 6
360
+
361
+ extra_env = {f'PARAM_{k}': str(v) for k, v in parameters.items()}
362
+
363
+ sim_build = os.path.join(tests_dir, "sim_build",
364
+ request.node.name.replace('[', '-').replace(']', ''))
365
+
366
+ cocotb_test.simulator.run(
367
+ python_search=[tests_dir],
368
+ verilog_sources=verilog_sources,
369
+ toplevel=toplevel,
370
+ module=module,
371
+ parameters=parameters,
372
+ sim_build=sim_build,
373
+ extra_env=extra_env,
374
+ )
snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilog PCIe ExaNIC X25 Example Design
2
+
3
+ ## Introduction
4
+
5
+ This example design targets the Exablaze ExaNIC X25 FPGA board.
6
+
7
+ The design implements the PCIe AXI lite master module, the PCIe AXI master module, and the PCIe DMA module. A very simple Linux driver is included to test the FPGA design.
8
+
9
+ * FPGA: xcku3p-ffvb676-2-e
10
+
11
+ ## How to build
12
+
13
+ Run `make` to build. Ensure that the Xilinx Vivado components are in PATH.
14
+
15
+ Run `make` to build the driver. Ensure the headers for the running kernel are installed, otherwise the driver cannot be compiled.
16
+
17
+ ## How to test
18
+
19
+ Run `make program` to program the ExaNIC X25 board with Vivado. Then load the driver with `insmod example.ko`. Check dmesg for the output.
snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/common/vivado.mk ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: fpga vivado tmpclean clean distclean
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
+ SYN_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(SYN_FILES))) $(filter /% ./%,$(SYN_FILES))
41
+ INC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(INC_FILES))) $(filter /% ./%,$(INC_FILES))
42
+ XCI_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XCI_FILES))) $(filter /% ./%,$(XCI_FILES))
43
+ IP_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(IP_TCL_FILES))) $(filter /% ./%,$(IP_TCL_FILES))
44
+ CONFIG_TCL_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(CONFIG_TCL_FILES))) $(filter /% ./%,$(CONFIG_TCL_FILES))
45
+
46
+ ifdef XDC_FILES
47
+ XDC_FILES_REL = $(patsubst %, ../%, $(filter-out /% ./%,$(XDC_FILES))) $(filter /% ./%,$(XDC_FILES))
48
+ else
49
+ XDC_FILES_REL = $(FPGA_TOP).xdc
50
+ endif
51
+
52
+ ###################################################################
53
+ # Main Targets
54
+ #
55
+ # all: build everything
56
+ # clean: remove output files and project files
57
+ ###################################################################
58
+
59
+ all: fpga
60
+
61
+ fpga: $(FPGA_TOP).bit
62
+
63
+ vivado: $(FPGA_TOP).xpr
64
+ vivado $(FPGA_TOP).xpr
65
+
66
+ tmpclean::
67
+ -rm -rf *.log *.jou *.cache *.gen *.hbs *.hw *.ip_user_files *.runs *.xpr *.html *.xml *.sim *.srcs *.str .Xil defines.v
68
+ -rm -rf create_project.tcl update_config.tcl run_synth.tcl run_impl.tcl generate_bit.tcl
69
+
70
+ clean:: tmpclean
71
+ -rm -rf *.bit program.tcl generate_mcs.tcl *.mcs *.prm flash.tcl
72
+
73
+ distclean:: clean
74
+ -rm -rf rev
75
+
76
+ ###################################################################
77
+ # Target implementations
78
+ ###################################################################
79
+
80
+ # Vivado project file
81
+ create_project.tcl: Makefile $(XCI_FILES_REL) $(IP_TCL_FILES_REL)
82
+ rm -rf defines.v
83
+ touch defines.v
84
+ for x in $(DEFS); do echo '`define' $$x >> defines.v; done
85
+ echo "create_project -force -part $(FPGA_PART) $(FPGA_TOP)" > $@
86
+ echo "add_files -fileset sources_1 defines.v $(SYN_FILES_REL)" >> $@
87
+ echo "add_files -fileset constrs_1 $(XDC_FILES_REL)" >> $@
88
+ for x in $(XCI_FILES_REL); do echo "import_ip $$x" >> $@; done
89
+ for x in $(IP_TCL_FILES_REL); do echo "source $$x" >> $@; done
90
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
91
+
92
+ update_config.tcl: $(CONFIG_TCL_FILES_REL)
93
+ echo "open_project -quiet $(FPGA_TOP).xpr" > $@
94
+ for x in $(CONFIG_TCL_FILES_REL); do echo "source $$x" >> $@; done
95
+
96
+ $(FPGA_TOP).xpr: create_project.tcl update_config.tcl
97
+ vivado -nojournal -nolog -mode batch $(foreach x,$?,-source $x)
98
+
99
+ # synthesis run
100
+ %.runs/synth_1/%.dcp: %.xpr $(SYN_FILES_REL) $(INC_FILES_REL) $(XDC_FILES_REL) $(CONFIG_TCL_FILES_REL)
101
+ echo "open_project $*.xpr" > run_synth.tcl
102
+ echo "reset_run synth_1" >> run_synth.tcl
103
+ echo "launch_runs -jobs 4 synth_1" >> run_synth.tcl
104
+ echo "wait_on_run synth_1" >> run_synth.tcl
105
+ vivado -nojournal -nolog -mode batch -source run_synth.tcl
106
+
107
+ # implementation run
108
+ %.runs/impl_1/%_routed.dcp: %.runs/synth_1/%.dcp
109
+ echo "open_project $*.xpr" > run_impl.tcl
110
+ echo "reset_run impl_1" >> run_impl.tcl
111
+ echo "launch_runs -jobs 4 impl_1" >> run_impl.tcl
112
+ echo "wait_on_run impl_1" >> run_impl.tcl
113
+ vivado -nojournal -nolog -mode batch -source run_impl.tcl
114
+
115
+ # bit file
116
+ %.bit: %.runs/impl_1/%_routed.dcp
117
+ echo "open_project $*.xpr" > generate_bit.tcl
118
+ echo "open_run impl_1" >> generate_bit.tcl
119
+ echo "write_bitstream -force $*.bit" >> generate_bit.tcl
120
+ vivado -nojournal -nolog -mode batch -source generate_bit.tcl
121
+ mkdir -p rev
122
+ EXT=bit; COUNT=100; \
123
+ while [ -e rev/$*_rev$$COUNT.$$EXT ]; \
124
+ do COUNT=$$((COUNT+1)); done; \
125
+ cp $@ rev/$*_rev$$COUNT.$$EXT; \
126
+ echo "Output: rev/$*_rev$$COUNT.$$EXT";
snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/fpga.xdc ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # XDC constraints for the ExaNIC X25
2
+ # part: xcku3p-ffvb676-2-e
3
+
4
+ # General configuration
5
+ set_property CFGBVS GND [current_design]
6
+ set_property CONFIG_VOLTAGE 1.8 [current_design]
7
+ set_property BITSTREAM.GENERAL.COMPRESS true [current_design]
8
+ set_property BITSTREAM.CONFIG.UNUSEDPIN Pullup [current_design]
9
+ set_property BITSTREAM.CONFIG.CONFIGRATE 31.9 [current_design]
10
+ set_property BITSTREAM.CONFIG.BPI_PAGE_SIZE 8 [current_design]
11
+ set_property BITSTREAM.CONFIG.BPI_1ST_READ_CYCLE 4 [current_design]
12
+ set_property CONFIG_MODE BPI16 [current_design]
13
+ set_property BITSTREAM.CONFIG.OVERTEMPSHUTDOWN Enable [current_design]
14
+
15
+ # 10 MHz TXCO
16
+ #set_property -dict {LOC D14 IOSTANDARD LVCMOS33} [get_ports clk_10mhz]
17
+ #create_clock -period 100 -name clk_100mhz [get_ports clk_10mhz]
18
+
19
+ # LEDs
20
+ set_property -dict {LOC J12 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sfp_1_led[0]}]
21
+ set_property -dict {LOC H12 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sfp_1_led[1]}]
22
+ set_property -dict {LOC J13 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sfp_2_led[0]}]
23
+ set_property -dict {LOC H13 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sfp_2_led[1]}]
24
+ set_property -dict {LOC J14 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sma_led[0]}]
25
+ set_property -dict {LOC G12 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports {sma_led[1]}]
26
+
27
+ set_false_path -to [get_ports {sfp_1_led[*] sfp_2_led[*] sma_led[*]}]
28
+ set_output_delay 0 [get_ports {sfp_1_led[*] sfp_2_led[*] sma_led[*]}]
29
+
30
+ # GPIO
31
+ #set_property -dict {LOC F9 IOSTANDARD LVCMOS18} [get_ports gpio[0]]
32
+ #set_property -dict {LOC F10 IOSTANDARD LVCMOS18} [get_ports gpio[1]]
33
+ #set_property -dict {LOC G9 IOSTANDARD LVCMOS18} [get_ports gpio[2]]
34
+ #set_property -dict {LOC G10 IOSTANDARD LVCMOS18} [get_ports gpio[3]]
35
+
36
+ # SMA
37
+ #set_property -dict {LOC A14 IOSTANDARD LVCMOS33} [get_ports sma_in]
38
+ #set_property -dict {LOC A12 IOSTANDARD LVCMOS33 SLEW FAST DRIVE 12} [get_ports sma_out]
39
+ #set_property -dict {LOC A13 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports sma_out_en]
40
+ #set_property -dict {LOC B12 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports sma_term_en]
41
+
42
+ #set_false_path -to [get_ports {sma_out sma_term sma_term_en}]
43
+ #set_output_delay 0 [get_ports {sma_out sma_term sma_term_en}]
44
+ #set_false_path -from [get_ports {sma_in}]
45
+ #set_input_delay 0 [get_ports {sma_in}]
46
+
47
+ # Config
48
+ #set_property -dict {LOC C14 IOSTANDARD LVCMOS33} [get_ports ddr_npres]
49
+
50
+ # SFP28 Interfaces
51
+ #set_property -dict {LOC D2 } [get_ports sfp_1_rx_p] ;# MGTYRXP0_227 GTYE4_CHANNEL_X0Y12 / GTYE4_COMMON_X0Y3
52
+ #set_property -dict {LOC D1 } [get_ports sfp_1_rx_n] ;# MGTYRXN0_227 GTYE4_CHANNEL_X0Y12 / GTYE4_COMMON_X0Y3
53
+ #set_property -dict {LOC A4 } [get_ports sfp_2_rx_p] ;# MGTYRXP3_227 GTYE4_CHANNEL_X0Y15 / GTYE4_COMMON_X0Y3
54
+ #set_property -dict {LOC A3 } [get_ports sfp_2_rx_n] ;# MGTYRXN3_227 GTYE4_CHANNEL_X0Y15 / GTYE4_COMMON_X0Y3
55
+ #set_property -dict {LOC F7 } [get_ports sfp_1_tx_p] ;# MGTYTXP0_227 GTYE4_CHANNEL_X0Y12 / GTYE4_COMMON_X0Y3
56
+ #set_property -dict {LOC F6 } [get_ports sfp_1_tx_n] ;# MGTYTXN0_227 GTYE4_CHANNEL_X0Y12 / GTYE4_COMMON_X0Y3
57
+ #set_property -dict {LOC B7 } [get_ports sfp_2_tx_p] ;# MGTYTXP3_227 GTYE4_CHANNEL_X0Y15 / GTYE4_COMMON_X0Y3
58
+ #set_property -dict {LOC B6 } [get_ports sfp_2_tx_n] ;# MGTYTXN3_227 GTYE4_CHANNEL_X0Y15 / GTYE4_COMMON_X0Y3
59
+ #set_property -dict {LOC K7 } [get_ports sfp_mgt_refclk_p] ;# MGTREFCLK0P_227 from X2
60
+ #set_property -dict {LOC K6 } [get_ports sfp_mgt_refclk_n] ;# MGTREFCLK0N_227 from X2
61
+ #set_property -dict {LOC AC17 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 12} [get_ports sfp_1_tx_disable]
62
+ #set_property -dict {LOC AA17 IOSTANDARD LVCMOS18 SLEW SLOW DRIVE 12} [get_ports sfp_2_tx_disable]
63
+ #set_property -dict {LOC F12 IOSTANDARD LVCMOS33 PULLUP true} [get_ports sfp_1_npres]
64
+ #set_property -dict {LOC F14 IOSTANDARD LVCMOS33 PULLUP true} [get_ports sfp_2_npres]
65
+ #set_property -dict {LOC AC16 IOSTANDARD LVCMOS18 PULLUP true} [get_ports sfp_1_los]
66
+ #set_property -dict {LOC Y17 IOSTANDARD LVCMOS18 PULLUP true} [get_ports sfp_2_los]
67
+ #set_property -dict {LOC G14 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports sfp_1_rs]
68
+ #set_property -dict {LOC H14 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12} [get_ports sfp_2_rs]
69
+ #set_property -dict {LOC A10 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12 PULLUP true} [get_ports sfp_i2c_scl]
70
+ #set_property -dict {LOC C11 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12 PULLUP true} [get_ports sfp_1_i2c_sda]
71
+ #set_property -dict {LOC B11 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12 PULLUP true} [get_ports sfp_2_i2c_sda]
72
+
73
+ # 161.1328125 MHz MGT reference clock
74
+ #create_clock -period 6.206 -name sfp_mgt_refclk [get_ports sfp_mgt_refclk_p]
75
+
76
+ #set_false_path -to [get_ports {sfp_1_tx_disable sfp_2_tx_disable sfp_1_rs sfp_2_rs}]
77
+ #set_output_delay 0 [get_ports {sfp_1_tx_disable sfp_2_tx_disable sfp_1_rs sfp_2_rs}]
78
+ #set_false_path -from [get_ports {sfp_1_npres sfp_2_npres sfp_1_los sfp_2_los}]
79
+ #set_input_delay 0 [get_ports {sfp_1_npres sfp_2_npres sfp_1_los sfp_2_los}]
80
+
81
+ #set_false_path -to [get_ports {sfp_1_i2c_sda sfp_2_i2c_sda sfp_i2c_scl}]
82
+ #set_output_delay 0 [get_ports {sfp_1_i2c_sda sfp_2_i2c_sda sfp_i2c_scl}]
83
+ #set_false_path -from [get_ports {sfp_1_i2c_sda sfp_2_i2c_sda sfp_i2c_scl}]
84
+ #set_input_delay 0 [get_ports {sfp_1_i2c_sda sfp_2_i2c_sda sfp_i2c_scl}]
85
+
86
+ # I2C interface
87
+ #set_property -dict {LOC B9 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12 PULLUP true} [get_ports eeprom_i2c_scl]
88
+ #set_property -dict {LOC A9 IOSTANDARD LVCMOS33 SLEW SLOW DRIVE 12 PULLUP true} [get_ports eeprom_i2c_sda]
89
+
90
+ #set_false_path -to [get_ports {eeprom_i2c_sda eeprom_i2c_scl}]
91
+ #set_output_delay 0 [get_ports {eeprom_i2c_sda eeprom_i2c_scl}]
92
+ #set_false_path -from [get_ports {eeprom_i2c_sda eeprom_i2c_scl}]
93
+ #set_input_delay 0 [get_ports {eeprom_i2c_sda eeprom_i2c_scl}]
94
+
95
+ # PCIe Interface
96
+ set_property -dict {LOC P2 } [get_ports {pcie_rx_p[0]}] ;# MGTYRXP3_225 GTYE4_CHANNEL_X0Y7 / GTYE4_COMMON_X0Y1
97
+ set_property -dict {LOC P1 } [get_ports {pcie_rx_n[0]}] ;# MGTYRXN3_225 GTYE4_CHANNEL_X0Y7 / GTYE4_COMMON_X0Y1
98
+ set_property -dict {LOC R5 } [get_ports {pcie_tx_p[0]}] ;# MGTYTXP3_225 GTYE4_CHANNEL_X0Y7 / GTYE4_COMMON_X0Y1
99
+ set_property -dict {LOC R4 } [get_ports {pcie_tx_n[0]}] ;# MGTYTXN3_225 GTYE4_CHANNEL_X0Y7 / GTYE4_COMMON_X0Y1
100
+ set_property -dict {LOC T2 } [get_ports {pcie_rx_p[1]}] ;# MGTYRXP2_225 GTYE4_CHANNEL_X0Y6 / GTYE4_COMMON_X0Y1
101
+ set_property -dict {LOC T1 } [get_ports {pcie_rx_n[1]}] ;# MGTYRXN2_225 GTYE4_CHANNEL_X0Y6 / GTYE4_COMMON_X0Y1
102
+ set_property -dict {LOC U5 } [get_ports {pcie_tx_p[1]}] ;# MGTYTXP2_225 GTYE4_CHANNEL_X0Y6 / GTYE4_COMMON_X0Y1
103
+ set_property -dict {LOC U4 } [get_ports {pcie_tx_n[1]}] ;# MGTYTXN2_225 GTYE4_CHANNEL_X0Y6 / GTYE4_COMMON_X0Y1
104
+ set_property -dict {LOC V2 } [get_ports {pcie_rx_p[2]}] ;# MGTYRXP1_225 GTYE4_CHANNEL_X0Y5 / GTYE4_COMMON_X0Y1
105
+ set_property -dict {LOC V1 } [get_ports {pcie_rx_n[2]}] ;# MGTYRXN1_225 GTYE4_CHANNEL_X0Y5 / GTYE4_COMMON_X0Y1
106
+ set_property -dict {LOC W5 } [get_ports {pcie_tx_p[2]}] ;# MGTYTXP1_225 GTYE4_CHANNEL_X0Y5 / GTYE4_COMMON_X0Y1
107
+ set_property -dict {LOC W4 } [get_ports {pcie_tx_n[2]}] ;# MGTYTXN1_225 GTYE4_CHANNEL_X0Y5 / GTYE4_COMMON_X0Y1
108
+ set_property -dict {LOC Y2 } [get_ports {pcie_rx_p[3]}] ;# MGTYRXP0_225 GTYE4_CHANNEL_X0Y4 / GTYE4_COMMON_X0Y1
109
+ set_property -dict {LOC Y1 } [get_ports {pcie_rx_n[3]}] ;# MGTYRXN0_225 GTYE4_CHANNEL_X0Y4 / GTYE4_COMMON_X0Y1
110
+ set_property -dict {LOC AA5 } [get_ports {pcie_tx_p[3]}] ;# MGTYTXP0_225 GTYE4_CHANNEL_X0Y4 / GTYE4_COMMON_X0Y1
111
+ set_property -dict {LOC AA4 } [get_ports {pcie_tx_n[3]}] ;# MGTYTXN0_225 GTYE4_CHANNEL_X0Y4 / GTYE4_COMMON_X0Y1
112
+ set_property -dict {LOC AB2 } [get_ports {pcie_rx_p[4]}] ;# MGTYRXP3_224 GTYE4_CHANNEL_X0Y3 / GTYE4_COMMON_X0Y0
113
+ set_property -dict {LOC AB1 } [get_ports {pcie_rx_n[4]}] ;# MGTYRXN3_224 GTYE4_CHANNEL_X0Y3 / GTYE4_COMMON_X0Y0
114
+ set_property -dict {LOC AC5 } [get_ports {pcie_tx_p[4]}] ;# MGTYTXP3_224 GTYE4_CHANNEL_X0Y3 / GTYE4_COMMON_X0Y0
115
+ set_property -dict {LOC AC4 } [get_ports {pcie_tx_n[4]}] ;# MGTYTXN3_224 GTYE4_CHANNEL_X0Y3 / GTYE4_COMMON_X0Y0
116
+ set_property -dict {LOC AD2 } [get_ports {pcie_rx_p[5]}] ;# MGTYRXP2_224 GTYE4_CHANNEL_X0Y2 / GTYE4_COMMON_X0Y0
117
+ set_property -dict {LOC AD1 } [get_ports {pcie_rx_n[5]}] ;# MGTYRXN2_224 GTYE4_CHANNEL_X0Y2 / GTYE4_COMMON_X0Y0
118
+ set_property -dict {LOC AD7 } [get_ports {pcie_tx_p[5]}] ;# MGTYTXP2_224 GTYE4_CHANNEL_X0Y2 / GTYE4_COMMON_X0Y0
119
+ set_property -dict {LOC AD6 } [get_ports {pcie_tx_n[5]}] ;# MGTYTXN2_224 GTYE4_CHANNEL_X0Y2 / GTYE4_COMMON_X0Y0
120
+ set_property -dict {LOC AE4 } [get_ports {pcie_rx_p[6]}] ;# MGTYRXP1_224 GTYE4_CHANNEL_X0Y1 / GTYE4_COMMON_X0Y0
121
+ set_property -dict {LOC AE3 } [get_ports {pcie_rx_n[6]}] ;# MGTYRXN1_224 GTYE4_CHANNEL_X0Y1 / GTYE4_COMMON_X0Y0
122
+ set_property -dict {LOC AE9 } [get_ports {pcie_tx_p[6]}] ;# MGTYTXP1_224 GTYE4_CHANNEL_X0Y1 / GTYE4_COMMON_X0Y0
123
+ set_property -dict {LOC AE8 } [get_ports {pcie_tx_n[6]}] ;# MGTYTXN1_224 GTYE4_CHANNEL_X0Y1 / GTYE4_COMMON_X0Y0
124
+ set_property -dict {LOC AF2 } [get_ports {pcie_rx_p[7]}] ;# MGTYRXP0_224 GTYE4_CHANNEL_X0Y0 / GTYE4_COMMON_X0Y0
125
+ set_property -dict {LOC AF1 } [get_ports {pcie_rx_n[7]}] ;# MGTYRXN0_224 GTYE4_CHANNEL_X0Y0 / GTYE4_COMMON_X0Y0
126
+ set_property -dict {LOC AF7 } [get_ports {pcie_tx_p[7]}] ;# MGTYTXP0_224 GTYE4_CHANNEL_X0Y0 / GTYE4_COMMON_X0Y0
127
+ set_property -dict {LOC AF6 } [get_ports {pcie_tx_n[7]}] ;# MGTYTXN0_224 GTYE4_CHANNEL_X0Y0 / GTYE4_COMMON_X0Y0
128
+ set_property -dict {LOC V7 } [get_ports pcie_refclk_p] ;# MGTREFCLK0P_225
129
+ set_property -dict {LOC V6 } [get_ports pcie_refclk_n] ;# MGTREFCLK0N_225
130
+ set_property -dict {LOC T19 IOSTANDARD LVCMOS18 PULLUP true} [get_ports pcie_reset_n]
131
+
132
+ set_false_path -from [get_ports {pcie_reset_n}]
133
+ set_input_delay 0 [get_ports {pcie_reset_n}]
134
+
135
+ # 100 MHz MGT reference clock
136
+ create_clock -period 10 -name pcie_mgt_refclk [get_ports pcie_refclk_p]
137
+
138
+ # BPI flash
139
+ #set_property -dict {LOC AF20 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[0]}]
140
+ #set_property -dict {LOC AE18 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[1]}]
141
+ #set_property -dict {LOC AF19 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[2]}]
142
+ #set_property -dict {LOC AF17 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[3]}]
143
+ #set_property -dict {LOC AB19 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[4]}]
144
+ #set_property -dict {LOC AD19 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[5]}]
145
+ #set_property -dict {LOC AB17 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[6]}]
146
+ #set_property -dict {LOC AE17 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[7]}]
147
+ #set_property -dict {LOC AD16 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[8]}]
148
+ #set_property -dict {LOC AE16 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[9]}]
149
+ #set_property -dict {LOC AD18 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[10]}]
150
+ #set_property -dict {LOC AC21 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[11]}]
151
+ #set_property -dict {LOC AE22 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[12]}]
152
+ #set_property -dict {LOC AF22 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[13]}]
153
+ #set_property -dict {LOC AF25 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[14]}]
154
+ #set_property -dict {LOC AF24 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_dq[15]}]
155
+ #set_property -dict {LOC AE20 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[0]}]
156
+ #set_property -dict {LOC AE26 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[1]}]
157
+ #set_property -dict {LOC AD24 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[2]}]
158
+ #set_property -dict {LOC AC23 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[3]}]
159
+ #set_property -dict {LOC AE23 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[4]}]
160
+ #set_property -dict {LOC AD20 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[5]}]
161
+ #set_property -dict {LOC AC24 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[6]}]
162
+ #set_property -dict {LOC AC22 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[7]}]
163
+ #set_property -dict {LOC AD23 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[8]}]
164
+ #set_property -dict {LOC AD21 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[9]}]
165
+ #set_property -dict {LOC AB22 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[10]}]
166
+ #set_property -dict {LOC AA22 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[11]}]
167
+ #set_property -dict {LOC AE25 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[12]}]
168
+ #set_property -dict {LOC AD26 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[13]}]
169
+ #set_property -dict {LOC AB25 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[14]}]
170
+ #set_property -dict {LOC AB26 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[15]}]
171
+ #set_property -dict {LOC AD25 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[16]}]
172
+ #set_property -dict {LOC AC26 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[17]}]
173
+ #set_property -dict {LOC AB21 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[18]}]
174
+ #set_property -dict {LOC AB24 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[19]}]
175
+ #set_property -dict {LOC Y18 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[20]}]
176
+ #set_property -dict {LOC AA20 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[21]}]
177
+ #set_property -dict {LOC AC19 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_addr[22]}]
178
+ #set_property -dict {LOC Y20 IOSTANDARD LVCMOS18 PULLUP true} [get_ports {flash_region}]
179
+ #set_property -dict {LOC AF18 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_ce_n}]
180
+ #set_property -dict {LOC Y21 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_oe_n}]
181
+ #set_property -dict {LOC AB20 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_we_n}]
182
+ #set_property -dict {LOC AF23 IOSTANDARD LVCMOS18 DRIVE 12} [get_ports {flash_adv_n}]
183
+
184
+ #set_false_path -to [get_ports {flash_dq[*] flash_addr[*] flash_region flash_ce_n flash_oe_n flash_we_n flash_adv_n}]
185
+ #set_output_delay 0 [get_ports {flash_dq[*] flash_addr[*] flash_region flash_ce_n flash_oe_n flash_we_n flash_adv_n}]
186
+ #set_false_path -from [get_ports {flash_dq[*]}]
187
+ #set_input_delay 0 [get_ports {flash_dq[*]}]
snapshots/alexforencich_verilog-pcie_pr20/example/ExaNIC_X25/fpga/fpga/Makefile ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # FPGA settings
3
+ FPGA_PART = xcku3p-ffvb676-2-e
4
+ FPGA_TOP = fpga
5
+ FPGA_ARCH = kintexuplus
6
+
7
+ # Files for synthesis
8
+ SYN_FILES = rtl/fpga.v
9
+ SYN_FILES += rtl/fpga_core.v
10
+ SYN_FILES += rtl/debounce_switch.v
11
+ SYN_FILES += rtl/sync_reset.v
12
+ SYN_FILES += rtl/sync_signal.v
13
+ SYN_FILES += rtl/common/example_core_pcie_us.v
14
+ SYN_FILES += rtl/common/example_core_pcie.v
15
+ SYN_FILES += rtl/common/example_core.v
16
+ SYN_FILES += rtl/common/axi_ram.v
17
+ SYN_FILES += lib/pcie/rtl/pcie_us_if.v
18
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rc.v
19
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_rq.v
20
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cq.v
21
+ SYN_FILES += lib/pcie/rtl/pcie_us_if_cc.v
22
+ SYN_FILES += lib/pcie/rtl/pcie_us_cfg.v
23
+ SYN_FILES += lib/pcie/rtl/pcie_us_msi.v
24
+ SYN_FILES += lib/pcie/rtl/pcie_axil_master.v
25
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master.v
26
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_rd.v
27
+ SYN_FILES += lib/pcie/rtl/pcie_axi_master_wr.v
28
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux_bar.v
29
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_demux.v
30
+ SYN_FILES += lib/pcie/rtl/pcie_tlp_mux.v
31
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie.v
32
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_rd.v
33
+ SYN_FILES += lib/pcie/rtl/dma_if_pcie_wr.v
34
+ SYN_FILES += lib/pcie/rtl/dma_psdpram.v
35
+ SYN_FILES += lib/pcie/rtl/arbiter.v
36
+ SYN_FILES += lib/pcie/rtl/priority_encoder.v
37
+ SYN_FILES += lib/pcie/rtl/pulse_merge.v
38
+
39
+ # XDC files
40
+ XDC_FILES = fpga.xdc
41
+
42
+ # IP
43
+ IP_TCL_FILES = ip/pcie4_uscale_plus_0.tcl
44
+
45
+ include ../common/vivado.mk
46
+
47
+ program: $(FPGA_TOP).bit
48
+ echo "open_hw" > program.tcl
49
+ echo "connect_hw_server" >> program.tcl
50
+ echo "open_hw_target" >> program.tcl
51
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> program.tcl
52
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> program.tcl
53
+ echo "set_property PROGRAM.FILE {$(FPGA_TOP).bit} [current_hw_device]" >> program.tcl
54
+ echo "program_hw_devices [current_hw_device]" >> program.tcl
55
+ echo "exit" >> program.tcl
56
+ vivado -nojournal -nolog -mode batch -source program.tcl
57
+
58
+ %.mcs %.prm: %.bit
59
+ echo "write_cfgmem -force -format mcs -size 32 -interface BPIx16 -loadbit {up 0x00800000 $*.bit} -checksum -file $*.mcs" > generate_mcs.tcl
60
+ echo "exit" >> generate_mcs.tcl
61
+ vivado -nojournal -nolog -mode batch -source generate_mcs.tcl
62
+ mkdir -p rev
63
+ COUNT=100; \
64
+ while [ -e rev/$*_rev$$COUNT.bit ]; \
65
+ do COUNT=$$((COUNT+1)); done; \
66
+ COUNT=$$((COUNT-1)); \
67
+ for x in .mcs .prm; \
68
+ do cp $*$$x rev/$*_rev$$COUNT$$x; \
69
+ echo "Output: rev/$*_rev$$COUNT$$x"; done;
70
+
71
+ flash: $(FPGA_TOP).mcs $(FPGA_TOP).prm
72
+ echo "open_hw" > flash.tcl
73
+ echo "connect_hw_server" >> flash.tcl
74
+ echo "open_hw_target" >> flash.tcl
75
+ echo "current_hw_device [lindex [get_hw_devices] 0]" >> flash.tcl
76
+ echo "refresh_hw_device -update_hw_probes false [current_hw_device]" >> flash.tcl
77
+ echo "create_hw_cfgmem -hw_device [current_hw_device] [lindex [get_cfgmem_parts {s29gl256p-bpi-x16}] 0]" >> flash.tcl
78
+ echo "current_hw_cfgmem -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM [current_hw_device]]" >> flash.tcl
79
+ echo "set_property PROGRAM.FILES [list \"$(FPGA_TOP).mcs\"] [current_hw_cfgmem]" >> flash.tcl
80
+ echo "set_property PROGRAM.PRM_FILES [list \"$(FPGA_TOP).prm\"] [current_hw_cfgmem]" >> flash.tcl
81
+ echo "set_property PROGRAM.ERASE 1 [current_hw_cfgmem]" >> flash.tcl
82
+ echo "set_property PROGRAM.CFG_PROGRAM 1 [current_hw_cfgmem]" >> flash.tcl
83
+ echo "set_property PROGRAM.VERIFY 1 [current_hw_cfgmem]" >> flash.tcl
84
+ echo "set_property PROGRAM.CHECKSUM 0 [current_hw_cfgmem]" >> flash.tcl
85
+ echo "set_property PROGRAM.ADDRESS_RANGE {use_file} [current_hw_cfgmem]" >> flash.tcl
86
+ echo "set_property PROGRAM.BPI_RS_PINS {24:23} [current_hw_cfgmem]" >> flash.tcl
87
+ echo "set_property PROGRAM.UNUSED_PIN_TERMINATION {pull-none} [current_hw_cfgmem]" >> flash.tcl
88
+ echo "create_hw_bitstream -hw_device [current_hw_device] [get_property PROGRAM.HW_CFGMEM_BITFILE [current_hw_device]]" >> flash.tcl
89
+ echo "program_hw_devices [current_hw_device]" >> flash.tcl
90
+ echo "refresh_hw_device [current_hw_device]" >> flash.tcl
91
+ echo "program_hw_cfgmem -hw_cfgmem [current_hw_cfgmem]" >> flash.tcl
92
+ echo "boot_hw_device [current_hw_device]" >> flash.tcl
93
+ echo "exit" >> flash.tcl
94
+ vivado -nojournal -nolog -mode batch -source flash.tcl
95
+