mirror of
https://github.com/fpganinja/taxi.git
synced 2025-12-09 08:58:40 -08:00
example: Add example design for Arty A7
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
290
example/Arty/fpga/rtl/fpga.sv
Normal file
290
example/Arty/fpga/rtl/fpga.sv
Normal file
@@ -0,0 +1,290 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
/*
|
||||
|
||||
Copyright (c) 2014-2025 FPGA Ninja, LLC
|
||||
|
||||
Authors:
|
||||
- Alex Forencich
|
||||
|
||||
*/
|
||||
|
||||
`resetall
|
||||
`timescale 1ns / 1ps
|
||||
`default_nettype none
|
||||
|
||||
/*
|
||||
* FPGA top-level module
|
||||
*/
|
||||
module fpga #
|
||||
(
|
||||
// simulation (set to avoid vendor primitives)
|
||||
parameter logic SIM = 1'b0,
|
||||
// vendor ("GENERIC", "XILINX", "ALTERA")
|
||||
parameter VENDOR = "XILINX",
|
||||
// device family
|
||||
parameter FAMILY = "artix7"
|
||||
)
|
||||
(
|
||||
/*
|
||||
* Clock: 100MHz
|
||||
* Reset: Push button, active low
|
||||
*/
|
||||
input wire logic clk,
|
||||
input wire logic reset_n,
|
||||
|
||||
/*
|
||||
* GPIO
|
||||
*/
|
||||
input wire logic [3:0] sw,
|
||||
input wire logic [3:0] btn,
|
||||
output wire logic led0_r,
|
||||
output wire logic led0_g,
|
||||
output wire logic led0_b,
|
||||
output wire logic led1_r,
|
||||
output wire logic led1_g,
|
||||
output wire logic led1_b,
|
||||
output wire logic led2_r,
|
||||
output wire logic led2_g,
|
||||
output wire logic led2_b,
|
||||
output wire logic led3_r,
|
||||
output wire logic led3_g,
|
||||
output wire logic led3_b,
|
||||
output wire logic led4,
|
||||
output wire logic led5,
|
||||
output wire logic led6,
|
||||
output wire logic led7,
|
||||
|
||||
/*
|
||||
* UART: 115200 bps, 8N1
|
||||
*/
|
||||
input wire logic uart_rxd,
|
||||
output wire logic uart_txd,
|
||||
|
||||
/*
|
||||
* Ethernet: 100BASE-T MII
|
||||
*/
|
||||
output wire logic phy_ref_clk,
|
||||
input wire logic phy_rx_clk,
|
||||
input wire logic [3:0] phy_rxd,
|
||||
input wire logic phy_rx_dv,
|
||||
input wire logic phy_rx_er,
|
||||
input wire logic phy_tx_clk,
|
||||
output wire logic [3:0] phy_txd,
|
||||
output wire logic phy_tx_en,
|
||||
input wire logic phy_col,
|
||||
input wire logic phy_crs,
|
||||
output wire logic phy_reset_n
|
||||
);
|
||||
|
||||
// Clock and reset
|
||||
|
||||
wire clk_ibufg;
|
||||
|
||||
// Internal 125 MHz clock
|
||||
wire clk_mmcm_out;
|
||||
wire clk_int;
|
||||
wire rst_int;
|
||||
|
||||
wire mmcm_rst = ~reset_n;
|
||||
wire mmcm_locked;
|
||||
wire mmcm_clkfb;
|
||||
|
||||
IBUFG
|
||||
clk_ibufg_inst(
|
||||
.I(clk),
|
||||
.O(clk_ibufg)
|
||||
);
|
||||
|
||||
wire clk_25mhz_mmcm_out;
|
||||
wire clk_25mhz_int;
|
||||
|
||||
// MMCM instance
|
||||
MMCME2_BASE #(
|
||||
// 100 MHz input
|
||||
.CLKIN1_PERIOD(10.0),
|
||||
.REF_JITTER1(0.010),
|
||||
// 100 MHz input / 1 = 100 MHz PFD (range 10 MHz to 550 MHz)
|
||||
.DIVCLK_DIVIDE(1),
|
||||
// 100 MHz PFD * 10 = 1000 MHz VCO (range 600 MHz to 1200 MHz)
|
||||
.CLKFBOUT_MULT_F(10),
|
||||
.CLKFBOUT_PHASE(0),
|
||||
// 1250 MHz VCO / 8 = 128 MHz, 0 degrees
|
||||
.CLKOUT0_DIVIDE_F(8),
|
||||
.CLKOUT0_DUTY_CYCLE(0.5),
|
||||
.CLKOUT0_PHASE(0),
|
||||
// 1250 MHz VCO / 40 = 25 MHz, 0 degrees
|
||||
.CLKOUT1_DIVIDE(40),
|
||||
.CLKOUT1_DUTY_CYCLE(0.5),
|
||||
.CLKOUT1_PHASE(0),
|
||||
// Not used
|
||||
.CLKOUT2_DIVIDE(1),
|
||||
.CLKOUT2_DUTY_CYCLE(0.5),
|
||||
.CLKOUT2_PHASE(0),
|
||||
// Not used
|
||||
.CLKOUT3_DIVIDE(1),
|
||||
.CLKOUT3_DUTY_CYCLE(0.5),
|
||||
.CLKOUT3_PHASE(0),
|
||||
// Not used
|
||||
.CLKOUT4_DIVIDE(1),
|
||||
.CLKOUT4_DUTY_CYCLE(0.5),
|
||||
.CLKOUT4_PHASE(0),
|
||||
.CLKOUT4_CASCADE("FALSE"),
|
||||
// Not used
|
||||
.CLKOUT5_DIVIDE(1),
|
||||
.CLKOUT5_DUTY_CYCLE(0.5),
|
||||
.CLKOUT5_PHASE(0),
|
||||
// Not used
|
||||
.CLKOUT6_DIVIDE(1),
|
||||
.CLKOUT6_DUTY_CYCLE(0.5),
|
||||
.CLKOUT6_PHASE(0),
|
||||
|
||||
// optimized bandwidth
|
||||
.BANDWIDTH("OPTIMIZED"),
|
||||
// don't wait for lock during startup
|
||||
.STARTUP_WAIT("FALSE")
|
||||
)
|
||||
clk_mmcm_inst (
|
||||
// 100 MHz input
|
||||
.CLKIN1(clk_ibufg),
|
||||
// direct clkfb feedback
|
||||
.CLKFBIN(mmcm_clkfb),
|
||||
.CLKFBOUT(mmcm_clkfb),
|
||||
.CLKFBOUTB(),
|
||||
// 125 MHz, 0 degrees
|
||||
.CLKOUT0(clk_mmcm_out),
|
||||
.CLKOUT0B(),
|
||||
// 25 MHz, 0 degrees
|
||||
.CLKOUT1(clk_25mhz_mmcm_out),
|
||||
.CLKOUT1B(),
|
||||
// Not used
|
||||
.CLKOUT2(),
|
||||
.CLKOUT2B(),
|
||||
// Not used
|
||||
.CLKOUT3(),
|
||||
.CLKOUT3B(),
|
||||
// Not used
|
||||
.CLKOUT4(),
|
||||
// Not used
|
||||
.CLKOUT5(),
|
||||
// Not used
|
||||
.CLKOUT6(),
|
||||
// reset input
|
||||
.RST(mmcm_rst),
|
||||
// don't power down
|
||||
.PWRDWN(1'b0),
|
||||
// locked output
|
||||
.LOCKED(mmcm_locked)
|
||||
);
|
||||
|
||||
BUFG
|
||||
clk_bufg_inst (
|
||||
.I(clk_mmcm_out),
|
||||
.O(clk_int)
|
||||
);
|
||||
|
||||
BUFG
|
||||
clk_25mhz_bufg_inst (
|
||||
.I(clk_25mhz_mmcm_out),
|
||||
.O(clk_25mhz_int)
|
||||
);
|
||||
|
||||
taxi_sync_reset #(
|
||||
.N(4)
|
||||
)
|
||||
sync_reset_inst (
|
||||
.clk(clk_int),
|
||||
.rst(~mmcm_locked),
|
||||
.out(rst_int)
|
||||
);
|
||||
|
||||
// GPIO
|
||||
wire [3:0] btn_int;
|
||||
wire [3:0] sw_int;
|
||||
|
||||
taxi_debounce_switch #(
|
||||
.WIDTH(8),
|
||||
.N(4),
|
||||
.RATE(125000)
|
||||
)
|
||||
debounce_switch_inst (
|
||||
.clk(clk_int),
|
||||
.rst(rst_int),
|
||||
.in({btn,
|
||||
sw}),
|
||||
.out({btn_int,
|
||||
sw_int})
|
||||
);
|
||||
|
||||
wire uart_rxd_int;
|
||||
|
||||
taxi_sync_signal #(
|
||||
.WIDTH(1),
|
||||
.N(2)
|
||||
)
|
||||
sync_signal_inst (
|
||||
.clk(clk_int),
|
||||
.in({uart_rxd}),
|
||||
.out({uart_rxd_int})
|
||||
);
|
||||
|
||||
assign phy_ref_clk = clk_25mhz_int;
|
||||
|
||||
fpga_core #(
|
||||
.SIM(SIM),
|
||||
.VENDOR(VENDOR),
|
||||
.FAMILY(FAMILY)
|
||||
)
|
||||
core_inst (
|
||||
/*
|
||||
* Clock: 125MHz
|
||||
* Synchronous reset
|
||||
*/
|
||||
.clk(clk_int),
|
||||
.rst(rst_int),
|
||||
|
||||
/*
|
||||
* GPIO
|
||||
*/
|
||||
.btn(btn_int),
|
||||
.sw(sw_int),
|
||||
.led0_r(led0_r),
|
||||
.led0_g(led0_g),
|
||||
.led0_b(led0_b),
|
||||
.led1_r(led1_r),
|
||||
.led1_g(led1_g),
|
||||
.led1_b(led1_b),
|
||||
.led2_r(led2_r),
|
||||
.led2_g(led2_g),
|
||||
.led2_b(led2_b),
|
||||
.led3_r(led3_r),
|
||||
.led3_g(led3_g),
|
||||
.led3_b(led3_b),
|
||||
.led4(led4),
|
||||
.led5(led5),
|
||||
.led6(led6),
|
||||
.led7(led7),
|
||||
|
||||
/*
|
||||
* UART: 115200 bps, 8N1
|
||||
*/
|
||||
.uart_rxd(uart_rxd_int),
|
||||
.uart_txd(uart_txd),
|
||||
|
||||
/*
|
||||
* Ethernet: 100BASE-T MII
|
||||
*/
|
||||
.phy_rx_clk(phy_rx_clk),
|
||||
.phy_rxd(phy_rxd),
|
||||
.phy_rx_dv(phy_rx_dv),
|
||||
.phy_rx_er(phy_rx_er),
|
||||
.phy_tx_clk(phy_tx_clk),
|
||||
.phy_txd(phy_txd),
|
||||
.phy_tx_en(phy_tx_en),
|
||||
.phy_col(phy_col),
|
||||
.phy_crs(phy_crs),
|
||||
.phy_reset_n(phy_reset_n)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
`resetall
|
||||
204
example/Arty/fpga/rtl/fpga_core.sv
Normal file
204
example/Arty/fpga/rtl/fpga_core.sv
Normal file
@@ -0,0 +1,204 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
/*
|
||||
|
||||
Copyright (c) 2014-2025 FPGA Ninja, LLC
|
||||
|
||||
Authors:
|
||||
- Alex Forencich
|
||||
|
||||
*/
|
||||
|
||||
`resetall
|
||||
`timescale 1ns / 1ps
|
||||
`default_nettype none
|
||||
|
||||
/*
|
||||
* FPGA core logic
|
||||
*/
|
||||
module fpga_core #
|
||||
(
|
||||
// simulation (set to avoid vendor primitives)
|
||||
parameter logic SIM = 1'b0,
|
||||
// vendor ("GENERIC", "XILINX", "ALTERA")
|
||||
parameter VENDOR = "XILINX",
|
||||
// device family
|
||||
parameter FAMILY = "artix7"
|
||||
)
|
||||
(
|
||||
/*
|
||||
* Clock: 125MHz
|
||||
* Synchronous reset
|
||||
*/
|
||||
input wire logic clk,
|
||||
input wire logic rst,
|
||||
|
||||
/*
|
||||
* GPIO
|
||||
*/
|
||||
input wire logic [3:0] btn,
|
||||
input wire logic [3:0] sw,
|
||||
output wire logic led0_r,
|
||||
output wire logic led0_g,
|
||||
output wire logic led0_b,
|
||||
output wire logic led1_r,
|
||||
output wire logic led1_g,
|
||||
output wire logic led1_b,
|
||||
output wire logic led2_r,
|
||||
output wire logic led2_g,
|
||||
output wire logic led2_b,
|
||||
output wire logic led3_r,
|
||||
output wire logic led3_g,
|
||||
output wire logic led3_b,
|
||||
output wire logic led4,
|
||||
output wire logic led5,
|
||||
output wire logic led6,
|
||||
output wire logic led7,
|
||||
|
||||
/*
|
||||
* UART: 115200 bps, 8N1
|
||||
*/
|
||||
input wire logic uart_rxd,
|
||||
output wire logic uart_txd,
|
||||
|
||||
/*
|
||||
* Ethernet: 100BASE-T MII
|
||||
*/
|
||||
input wire logic phy_rx_clk,
|
||||
input wire logic [3:0] phy_rxd,
|
||||
input wire logic phy_rx_dv,
|
||||
input wire logic phy_rx_er,
|
||||
input wire logic phy_tx_clk,
|
||||
output wire logic [3:0] phy_txd,
|
||||
output wire logic phy_tx_en,
|
||||
input wire logic phy_col,
|
||||
input wire logic phy_crs,
|
||||
output wire logic phy_reset_n
|
||||
);
|
||||
|
||||
// // Place first payload byte onto LEDs
|
||||
// reg valid_last = 0;
|
||||
// reg [7:0] led_reg = 0;
|
||||
|
||||
// always @(posedge clk) begin
|
||||
// if (rst) begin
|
||||
// led_reg <= 0;
|
||||
// end else begin
|
||||
// if (tx_udp_payload_axis_tvalid) begin
|
||||
// if (!valid_last) begin
|
||||
// led_reg <= tx_udp_payload_axis_tdata;
|
||||
// valid_last <= 1'b1;
|
||||
// end
|
||||
// if (tx_udp_payload_axis_tlast) begin
|
||||
// valid_last <= 1'b0;
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
// end
|
||||
|
||||
//assign led = sw;
|
||||
assign {led0_g, led1_g, led2_g, led3_g, led4, led5, led6, led7} = 0;
|
||||
assign phy_reset_n = !rst;
|
||||
|
||||
taxi_axis_if #(.DATA_W(8)) axis_uart();
|
||||
|
||||
taxi_uart
|
||||
uut (
|
||||
.clk(clk),
|
||||
.rst(rst),
|
||||
|
||||
/*
|
||||
* AXI4-Stream input (sink)
|
||||
*/
|
||||
.s_axis_tx(axis_uart),
|
||||
|
||||
/*
|
||||
* AXI4-Stream output (source)
|
||||
*/
|
||||
.m_axis_rx(axis_uart),
|
||||
|
||||
/*
|
||||
* UART interface
|
||||
*/
|
||||
.rxd(uart_rxd),
|
||||
.txd(uart_txd),
|
||||
|
||||
/*
|
||||
* Status
|
||||
*/
|
||||
.tx_busy(),
|
||||
.rx_busy(),
|
||||
.rx_overrun_error(),
|
||||
.rx_frame_error(),
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
.prescale(16'(125000000/115200/8))
|
||||
);
|
||||
|
||||
taxi_axis_if #(.DATA_W(8), .ID_W(8)) axis_eth();
|
||||
taxi_axis_if #(.DATA_W(96), .KEEP_W(1), .ID_W(8)) axis_tx_cpl();
|
||||
|
||||
taxi_eth_mac_mii_fifo #(
|
||||
.SIM(SIM),
|
||||
.VENDOR(VENDOR),
|
||||
.FAMILY(FAMILY),
|
||||
.PADDING_EN(1),
|
||||
.MIN_FRAME_LEN(64),
|
||||
.TX_FIFO_DEPTH(16384),
|
||||
.TX_FRAME_FIFO(1),
|
||||
.RX_FIFO_DEPTH(16384),
|
||||
.RX_FRAME_FIFO(1)
|
||||
)
|
||||
eth_mac_inst (
|
||||
.rst(rst),
|
||||
.logic_clk(clk),
|
||||
.logic_rst(rst),
|
||||
|
||||
/*
|
||||
* Transmit interface (AXI stream)
|
||||
*/
|
||||
.s_axis_tx(axis_eth),
|
||||
.m_axis_tx_cpl(axis_tx_cpl),
|
||||
|
||||
/*
|
||||
* Receive interface (AXI stream)
|
||||
*/
|
||||
.m_axis_rx(axis_eth),
|
||||
|
||||
/*
|
||||
* MII interface
|
||||
*/
|
||||
.mii_rx_clk(phy_rx_clk),
|
||||
.mii_rxd(phy_rxd),
|
||||
.mii_rx_dv(phy_rx_dv),
|
||||
.mii_rx_er(phy_rx_er),
|
||||
.mii_tx_clk(phy_tx_clk),
|
||||
.mii_txd(phy_txd),
|
||||
.mii_tx_en(phy_tx_en),
|
||||
.mii_tx_er(),
|
||||
|
||||
/*
|
||||
* Status
|
||||
*/
|
||||
.tx_error_underflow(),
|
||||
.tx_fifo_overflow(),
|
||||
.tx_fifo_bad_frame(),
|
||||
.tx_fifo_good_frame(),
|
||||
.rx_error_bad_frame(),
|
||||
.rx_error_bad_fcs(),
|
||||
.rx_fifo_overflow(),
|
||||
.rx_fifo_bad_frame(),
|
||||
.rx_fifo_good_frame(),
|
||||
|
||||
/*
|
||||
* Configuration
|
||||
*/
|
||||
.cfg_ifg(8'd12),
|
||||
.cfg_tx_enable(1'b1),
|
||||
.cfg_rx_enable(1'b1)
|
||||
);
|
||||
|
||||
endmodule
|
||||
|
||||
`resetall
|
||||
Reference in New Issue
Block a user