summaryrefslogtreecommitdiffhomepage
path: root/manufacturer/altera/cyclone10_lp/src/betsy.v
diff options
context:
space:
mode:
Diffstat (limited to 'manufacturer/altera/cyclone10_lp/src/betsy.v')
-rw-r--r--manufacturer/altera/cyclone10_lp/src/betsy.v387
1 files changed, 283 insertions, 104 deletions
diff --git a/manufacturer/altera/cyclone10_lp/src/betsy.v b/manufacturer/altera/cyclone10_lp/src/betsy.v
index ea83223..cd3555b 100644
--- a/manufacturer/altera/cyclone10_lp/src/betsy.v
+++ b/manufacturer/altera/cyclone10_lp/src/betsy.v
@@ -21,6 +21,7 @@
*/
// `define PASSTHROUGH
+// `define ENABLE_TAP_ON_PHY2
module betsy (
input rstn,
@@ -104,7 +105,7 @@ module betsy (
parameter NUM_PHYS = 3;
parameter NUM_PLLS = 1;
parameter MDIO_ROM_ADDR_SZ = 7;
- parameter NUM_ML_IF = 3;
+ parameter NUM_ML_IF = 2; // PHY0 and PHY1
wire reset, pll_locked;
reg sys_rstn;
@@ -158,17 +159,17 @@ module betsy (
// MAC asserts when it determines RX data should be kept
- wire [NUM_PHYS-1:0] rx_mac_keep;
+ wire [NUM_PHYS-1:0] rx_mac_trigger;
wire [NUM_PHYS-1:0] rx_mac_wr_done;
// drop filter outputs
wire rx_df_fifo_we_01, rx_df_fifo_we_02, rx_df_fifo_we_0u;
wire rx_df_fifo_we_10, rx_df_fifo_we_12;
- wire rx_df_fifo_we_20, rx_df_fifo_we_21;
+ wire rx_df_fifo_we_20, rx_df_fifo_we_21, rx_df_fifo_we_2u;
wire [8:0] rx_df_fifo_d_01, rx_df_fifo_d_02, rx_df_fifo_d_0u;
wire [8:0] rx_df_fifo_d_10, rx_df_fifo_d_12;
- wire [8:0] rx_df_fifo_d_20, rx_df_fifo_d_21;
+ wire [8:0] rx_df_fifo_d_20, rx_df_fifo_d_21, rx_df_fifo_d_2u;
wire [8:0] rx_df_fifo_d_u0;
// pkt filter
@@ -187,25 +188,24 @@ module betsy (
// Read Enable from Switch to FIFO for transmit data
wire rx_sw_fifo_re_01, rx_sw_fifo_re_02, rx_sw_fifo_re_0u;
wire rx_sw_fifo_re_10, rx_sw_fifo_re_12;
- wire rx_sw_fifo_re_20, rx_sw_fifo_re_21;
- wire rx_sw_fifo_re_u0;
+ wire rx_sw_fifo_re_20, rx_sw_fifo_re_21, rx_sw_fifo_re_2u;
+ wire rx_sw_fifo_re_u;
// FIFO empty flags from FIFO to switch
wire rx_sf_fifo_empty_01, rx_sf_fifo_empty_02, rx_sf_fifo_empty_0u;
wire rx_sf_fifo_empty_10, rx_sf_fifo_empty_12;
- wire rx_sf_fifo_empty_20, rx_sf_fifo_empty_21;
- wire rx_uc_fifo_empty_u0;
+ wire rx_sf_fifo_empty_20, rx_sf_fifo_empty_21, rx_sf_fifo_empty_2u;
+ wire rx_uc_fifo_empty_u;
wire rx_sf_almost_full_01;
wire rx_sf_almost_full_10;
wire rx_sf_almost_full_20;
- wire rx_sf_almost_full_0u;
// data from FIFO to switch
wire [8:0] rx_sf_fifo_d_01, rx_sf_fifo_d_02, rx_sf_fifo_d_0u;
wire [8:0] rx_sf_fifo_d_10, rx_sf_fifo_d_12;
- wire [8:0] rx_sf_fifo_d_20, rx_sf_fifo_d_21;
- wire [8:0] rx_uc_fifo_d_u0;
+ wire [8:0] rx_sf_fifo_d_20, rx_sf_fifo_d_21, rx_sf_fifo_d_2u;
+ wire [8:0] rx_uc_fifo_d_u;
// data from MAC
wire [8:0] rx_mac_fifo_d0, rx_mac_fifo_d1, rx_mac_fifo_d2;
@@ -216,23 +216,23 @@ module betsy (
wire [10:0] rx0_mac_byte_cnt;
wire [10:0] rx1_mac_byte_cnt;
wire [10:0] rx2_mac_byte_cnt;
- wire [10:0] rxu_byte_cnt, rx_mle_byte_cnt;
+ wire [10:0] rxu_byte_cnt, rx_mle_byte_cnt, rx_pkt_gen_byte_cnt;
// ml_engine
wire mle_evt_start, mle_evt_active;
wire [NUM_ML_IF-1:0] mle_enable, mle_empty, mle_we;
- wire mle_oe;
- wire [8:0] mle_d_0, mle_d_1, mle_d_2, mle_d_3;
+ wire [8:0] mle_d_0, mle_d_1;
reg [8:0] mle_d_i;
wire mle_fifo_empty, mle_fifo_re;
- wire [8:0] mle_fifo_d_o;
+ wire pkt_gen_fifo_empty, pkt_gen_fifo_re;
+ wire [8:0] mle_fifo_d_o, pkt_gen_fifo_d_o;
// TX between switch and MAC
wire [8:0] tx_sw_fifo_d0, tx_sw_fifo_d1, tx_sw_fifo_d2, tx_sw_fifo_du;
wire [NUM_PHYS-1:0] tx_mac_fifo_re;
wire tx_uc_fifo_re;
wire [NUM_PHYS-1:0] tx_sw_fifo_empty;
- wire tx_sw_fifo_we; // for controller path
+ wire tx_sw_fifo_we_u; // for controller path
wire [2:0] tx_sw_mode0, tx_sw_mode1, tx_sw_mode2;
wire [2:0] tx_modeu;
wire [NUM_PHYS-1:0] tx_mac_done;
@@ -242,12 +242,13 @@ module betsy (
// TX between L3/L4 controller and MAC
wire tx_uc_fifo_empty, tx_mle_fifo_empty;
wire [8:0] tx_uc_fifo_d0, tx_mle_fifo_d0;
+ wire [8:0] tx_uc_fifo_d2, tx_mle_fifo_d2;
// 100 Mbit
wire [NUM_PHYS-1:0] mode_100Mbit;
// Controller Peripheral Address Decode and Select
- wire mac_sel, pkt_filter_sel, mle_sel;
+ wire mac_sel, pkt_filter_sel, mle_sel, pkt_gen_sel;
wire [1:0] mac_addr;
wire [15:0] pkt_filter_addr;
@@ -267,8 +268,9 @@ module betsy (
wire [NUM_PHYS-1:0] ipv4_pkt_start;
wire [NUM_PHYS-1:0] ipv4_pkt_complete;
wire [NUM_PHYS-1:0] ipv4_rx_keep;
- wire [NUM_PHYS-1:0] ipv4_trigger_dst_addr;
- wire ipv4_pkt_complete_c, ipv4_addr_match_c;
+ wire [NUM_PHYS-1:0] ipv4_trigger_src_addr, ipv4_trigger_dst_addr;
+ wire ipv4_pkt_complete_c0, ipv4_addr_match_c0;
+ wire ipv4_pkt_complete_c2, ipv4_addr_match_c2;
// UDP
wire udp_port_match_c;
@@ -291,7 +293,7 @@ module betsy (
wire mem_we, mem_oe;
wire mem_tgt_ready, mem_tgt_ready_mac_0, mem_tgt_ready_mac_1;
wire [15:0] mac_0_d_o, mac_1_d_o, mac_2_d_o;
- wire [15:0] mle_d_o;
+ wire [15:0] mle_d_o, pkt_gen_d_o;
wire [10:0] hfifo_d_o;
// half FIFO / Interface for Controller
@@ -368,10 +370,7 @@ module betsy (
assign phy_int = {~phy2_intn, ~phy1_intn, ~phy0_intn};
- // TODO: This will be replaced when the SPI master peripheral is ready
- assign flash_d = 8'hab;
- assign flash_seln = 1'b1;
- assign flash_clk = cont_clk;
+
assign param_sel = 3'b000;
@@ -383,6 +382,18 @@ module betsy (
assign phy2_gpio[0] = gpio_ipv4[0];
assign phy2_gpio[1] = gpio_ipv4[1];
+`ifndef SIMULATION
+ rsu rsu_0 (
+ .busy(), // busy.busy
+ .clock(clk_25), // clock.clk
+ .data_out(), // data_out.data_out
+ .param(3'b000), // param.param
+ .read_param(1'b0), // read_param.read_param
+ .reconfig(1'b0), // reconfig.reconfig
+ .reset(reset), // reset.reset
+ .reset_timer(1'b0) // reset_timer.reset_timer
+ );
+`endif
// Bits 3:0 on the positive edge of RX_CLK and bits 7:4 on the negative edge of RX_CLK.
ddri rgmi_rx_0 (
@@ -522,13 +533,14 @@ module betsy (
.pkt_filter_sel(pkt_filter_sel),
.mac_sel(mac_sel),
.mle_sel(mle_sel),
+ .pkt_gen_sel(pkt_gen_sel),
.hf_ptrs_sel(hf_ptrs_sel),
.hf_rx_sel(hf_rx_sel),
.hf_tx_sel(hf_tx_sel),
// half FIFO interface
.rx_fifo_int(hf_rx_fifo_int),
.rx_fifo_int_acked(hf_rx_fifo_int_acked),
- .tx_fifo_empty(rx_uc_fifo_empty_u0),
+ .tx_fifo_empty(rx_uc_fifo_empty_u),
// mdio_controller interface
.mdio_cont_start(mdio_cont_work_start),
.mdio_cont_done(mdio_cont_work_done),
@@ -547,21 +559,21 @@ module betsy (
.mac_reset(mac_reset),
// Debug
.gpio(gpio_controller)
-
);
assign mem_tgt_ready = mem_tgt_ready_mac_0 && mem_tgt_ready_mac_1;
// controller data mux
always @(*)
- casex({ hf_tx_sel, hf_rx_sel, hf_ptrs_sel, mle_sel, mac_sel, mac_addr})
- 7'b0000100: mem_d_i = {16'h0000, mac_0_d_o};
- 7'b0000101: mem_d_i = {16'h0000, mac_1_d_o};
- 7'b0000110: mem_d_i = {16'h0000, mac_2_d_o};
- 7'b00010??: mem_d_i = {16'h0000, mle_d_o};
- 7'b00100??: mem_d_i = {21'h0000, hfifo_d_o};
- 7'b01000??: mem_d_i = {21'h0000, hfifo_d_o};
- 7'b10000??: mem_d_i = {21'h0000, hfifo_d_o};
+ casex({ hf_tx_sel, hf_rx_sel, hf_ptrs_sel, pkt_gen_sel, mle_sel, mac_sel, mac_addr})
+ 8'b00000100: mem_d_i = {16'h0000, mac_0_d_o};
+ 8'b00000101: mem_d_i = {16'h0000, mac_1_d_o};
+ 8'b00000110: mem_d_i = {16'h0000, mac_2_d_o};
+ 8'b000010??: mem_d_i = {16'h0000, mle_d_o};
+ 8'b000100??: mem_d_i = {16'h0000, pkt_gen_d_o};
+ 8'b001000??: mem_d_i = {21'h0000, hfifo_d_o};
+ 8'b010000??: mem_d_i = {21'h0000, hfifo_d_o};
+ 8'b100000??: mem_d_i = {21'h0000, hfifo_d_o};
default: mem_d_i = 32'd0;
endcase
@@ -589,13 +601,13 @@ module betsy (
.dpram_tx_sel(hf_tx_sel),
.dpram_rx_sel(hf_rx_sel),
// TX: switch -> hfifo -> controller
- .fifo_we(tx_sw_fifo_we),
+ .fifo_we(tx_sw_fifo_we_u),
.fifo_d_in(tx_sw_fifo_du),
// RX: controller -> hfifo -> switch
- .fifo_re(rx_sw_fifo_re_u0),
+ .fifo_re(rx_sw_fifo_re_u),
.tx_byte_cnt(rxu_byte_cnt),
- .fifo_d_out(rx_uc_fifo_d_u0),
- .tx_empty(rx_uc_fifo_empty_u0)
+ .fifo_d_out(rx_uc_fifo_d_u),
+ .tx_empty(rx_uc_fifo_empty_u)
);
mdio_cont #(.ADDR_SZ(MDIO_ROM_ADDR_SZ)) mdio_cont_0(
@@ -662,13 +674,11 @@ module betsy (
always@(*)
case(mle_enable)
- 3'b001: mle_d_i = mle_d_0;
- 3'b010: mle_d_i = mle_d_1;
- 3'b100: mle_d_i = mle_d_2;
- default: mle_d_i = 'd0;
+ 2'b01: mle_d_i = mle_d_0;
+ 2'b10: mle_d_i = mle_d_1;
+ default: mle_d_i = 9'h100; // EOF set
endcase
-
ml_engine #(.NUM_IF(NUM_ML_IF)) ml_engine_0(
.rstn(sys_rstn),
.clk(pclk),
@@ -679,20 +689,38 @@ module betsy (
.cont_addr(mem_addr),
.cont_d_i(mem_d_o[15:0]),
.cont_d_o(mle_d_o),
- .cont_tgt_ready(),
+ .cont_tgt_ready_o(),
// module interface
- .evt_start(mle_evt_start),
- .evt_active(mle_evt_active),
- .enable(mle_enable),
- .clk_e(1'b1),
- .we(|mle_we),
- .empty(mle_empty),
- .d_i(mle_d_i),
+ .rx_evt_start_o(mle_evt_start),
+ .rx_evt_active_o(),
+ .rx_enable_o(mle_enable),
+ .rx_empty_i(mle_empty),
+ .rx_clk_e_i(1'b1),
+ .rx_we_i(|mle_we),
+ .rx_d_i(mle_d_i),
+ // switch interface
+ .sw_fifo_empty_o(mle_fifo_empty),
+ .sw_fifo_re_i(mle_fifo_re),
+ .sw_fifo_d_o(mle_fifo_d_o),
+ .sw_byte_cnt_o(rx_mle_byte_cnt)
+ );
+
+ pkt_gen pkt_gen_0(
+ .rstn(sys_rstn),
+ // controller interface
+ .cont_clk(cont_clk),
+ .cont_sel(pkt_gen_sel),
+ .cont_we(mem_we),
+ .cont_addr(mem_addr),
+ .cont_d_i(mem_d_o[15:0]),
+ .cont_d_o(pkt_gen_d_o),
+ .cont_tgt_ready(mem_tgt_ready_pkt_gen),
// switch interface
- .fifo_empty_o(mle_fifo_empty),
- .fifo_re(mle_fifo_re),
- .fifo_d_o(mle_fifo_d_o),
- .byte_cnt(rx_mle_byte_cnt)
+ .sw_fifo_clk(pclk),
+ .sw_fifo_empty_o(pkt_gen_fifo_empty),
+ .sw_fifo_re_i(pkt_gen_fifo_re),
+ .sw_fifo_d_o(pkt_gen_fifo_d_o),
+ .sw_byte_cnt_o(rx_pkt_gen_byte_cnt)
);
/*
@@ -712,8 +740,10 @@ module betsy (
.rx_d_12(rx_sf_fifo_d_12),
.rx_d_20(rx_sf_fifo_d_20),
.rx_d_21(rx_sf_fifo_d_21),
- .rx_d_u0(rx_uc_fifo_d_u0),
+ .rx_d_2u(rx_sf_fifo_d_2u),
+ .rx_d_u(rx_uc_fifo_d_u),
.rx_mle_fifo_d(mle_fifo_d_o),
+ .rx_pkt_gen_fifo_d(pkt_gen_fifo_d_o),
// RX FIFO read enables
.rx_fifo_re_01(rx_sw_fifo_re_01),
.rx_fifo_re_02(rx_sw_fifo_re_02),
@@ -722,8 +752,10 @@ module betsy (
.rx_fifo_re_12(rx_sw_fifo_re_12),
.rx_fifo_re_20(rx_sw_fifo_re_20),
.rx_fifo_re_21(rx_sw_fifo_re_21),
- .rx_fifo_re_u0(rx_sw_fifo_re_u0),
+ .rx_fifo_re_2u(rx_sw_fifo_re_2u),
+ .rx_fifo_re_u(rx_sw_fifo_re_u),
.rx_fifo_re_mle(mle_fifo_re),
+ .rx_fifo_re_pkt_gen(pkt_gen_fifo_re),
// RX FIFO Empty flags
.rx_fifo_empty_01(rx_sf_fifo_empty_01),
.rx_fifo_empty_02(rx_sf_fifo_empty_02),
@@ -732,8 +764,10 @@ module betsy (
.rx_fifo_empty_12(rx_sf_fifo_empty_12),
.rx_fifo_empty_20(rx_sf_fifo_empty_20),
.rx_fifo_empty_21(rx_sf_fifo_empty_21),
- .rx_fifo_empty_u0(rx_uc_fifo_empty_u0),
+ .rx_fifo_empty_2u(rx_sf_fifo_empty_2u),
+ .rx_fifo_empty_u(rx_uc_fifo_empty_u),
.rx_fifo_empty_mle(mle_fifo_empty),
+ .rx_fifo_empty_pkt_gen(pkt_gen_fifo_empty),
// Write done event
.rx_wr_done(rx_mac_wr_done),
// RX Byte Count
@@ -742,6 +776,7 @@ module betsy (
.rx2_byte_cnt(rx2_mac_byte_cnt),
.rxu_byte_cnt(rxu_byte_cnt),
.rx_mle_byte_cnt(rx_mle_byte_cnt),
+ .rx_pkt_gen_byte_cnt(rx_pkt_gen_byte_cnt),
// TX FIFO data output
.tx_d0(tx_sw_fifo_d0),
.tx_d1(tx_sw_fifo_d1),
@@ -749,7 +784,7 @@ module betsy (
.tx_du(tx_sw_fifo_du),
// TX FIFO read enable
.tx_fifo_re(tx_mac_fifo_re),
- .tx_fifo_we_u (tx_sw_fifo_we),
+ .tx_fifo_we_u (tx_sw_fifo_we_u),
// TX FIFO Empty Flags
.tx_fifo_empty(tx_sw_fifo_empty),
// TX modes for the PHYs and uc
@@ -775,11 +810,12 @@ module betsy (
* PHY0 IEEE 802.3 ETHERNET for Interface to 1000BASE-T LAN
*
*/
- mac_rgmii #(.PHY_NUM(0)) mac_0(
+ mac_rgmii #(.MLE_EOD_FLAG(0), .PHY_NUM(0)) mac_0(
.rstn(sys_rstn),
.phy_resetn (phy_resetn[0]),
.rx_clk(phy0_rx_clk),
.tx_clk(pclk),
+ .mle_clk(pclk),
.tap_port (1'b0),
// controller interface
.cont_clk(cont_clk),
@@ -790,9 +826,7 @@ module betsy (
.cont_d_o(mac_0_d_o),
.cont_tgt_ready(mem_tgt_ready_mac_0),
// ML engine interface
- .mle_active(mle_evt_active),
.mle_if_enable(mle_enable[0]),
- .mle_if_oe(mle_oe),
.mle_if_we(mle_we[0]),
.mle_if_empty(mle_empty[0]),
.mle_if_d_o(mle_d_0),
@@ -823,7 +857,7 @@ module betsy (
// MAC RX / FIFO Write
.rx_fifo_we(rx_mac_fifo_we[0]),
.rx_fifo_d(rx_mac_fifo_d0),
- .rx_keep(rx_mac_keep[0]),
+ .rx_trigger(rx_mac_trigger[0]),
.rx_wr_done(rx_mac_wr_done[0]),
.rx_byte_cnt(rx0_mac_byte_cnt),
.rx_idle(rx_idle[0]),
@@ -889,7 +923,7 @@ module betsy (
.rx_data_m4(rx0_d_m4),
// flags
.pkt_complete(ipv4_pkt_complete[0]),
- .trigger_src_addr(),
+ .trigger_src_addr(ipv4_trigger_src_addr[0]),
.trigger_dst_addr(ipv4_trigger_dst_addr[0]),
.keep(ipv4_rx_keep[0])
);
@@ -936,7 +970,7 @@ module betsy (
.new_frame (rx_sop[0]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[0]),
+ .trigger(rx_mac_trigger[0]),
.keep(rx_pf_keep_01)
);
@@ -980,7 +1014,8 @@ module betsy (
`ifdef PHY2_PRESENT
- // PHY0 MAC -> PHY1
+
+ // PHY0 MAC -> PHY2
pkt_filter pkt_filter_02(
.rstn(sys_rstn),
.clk(phy0_rx_clk),
@@ -1000,7 +1035,7 @@ module betsy (
.new_frame (rx_sop[0]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[0]),
+ .trigger(rx_mac_trigger[0]),
.keep(rx_pf_keep_02)
);
@@ -1009,7 +1044,11 @@ module betsy (
.phy_up(phy_up[0]),
.rx_clk(phy0_rx_clk),
.tx_clk(pclk),
- .enable(1'b1), // ipv4_rx_keep[0]
+`ifdef ENABLE_TAP_ON_PHY2
+ .enable(1'b1),
+`else
+ .enable(1'b0),
+`endif
// control
.keep (rx_pf_keep_02),
.passthrough(1'b0),
@@ -1041,7 +1080,8 @@ module betsy (
// debug
.active(sync_rx0_active[2])
);
-`endif
+
+`else // PHY2_PRESENT
ipv4_rx_c #(.IP_DST_MATCH_4(100)) ipv4_rx_c_0(
.rstn(sys_rstn),
@@ -1057,8 +1097,8 @@ module betsy (
.rx_data_m3(rx0_d_m3),
.rx_data_m4(rx0_d_m4),
// flags
- .pkt_complete(ipv4_pkt_complete_c),
- .ip_addr_match(ipv4_addr_match_c)
+ .pkt_complete(ipv4_pkt_complete_c0),
+ .ip_addr_match(ipv4_addr_match_c0)
);
udp_rx_c udp_rx_c_0(
@@ -1085,7 +1125,7 @@ module betsy (
.phy_up(phy_up[0]),
.rx_clk(phy0_rx_clk),
.tx_clk(pclk),
- .enable(ipv4_addr_match_c),
+ .enable(ipv4_addr_match_c0),
// control
.keep (udp_port_match_c),
.passthrough(1'b0),
@@ -1111,12 +1151,14 @@ module betsy (
.re (rx_sw_fifo_re_0u),
.d_out(rx_sf_fifo_d_0u),
.empty(rx_sf_fifo_empty_0u),
- .almost_full(rx_sf_almost_full_0u),
+ .almost_full(),
.reset_ptrs(1'b0),
// debug
.active(sync_rx0_active_u )
);
+`endif // PHY2_PRESENT
+
dpram_inf #(.ADDR_WIDTH(10), .DPRAM_INIT("param_ram_0.txt")) param_ram_0(
.rstn(sys_rstn),
// Port A
@@ -1157,6 +1199,7 @@ module betsy (
.dout(fcs_tx_dout0)
);
+`ifndef PHY2_PRESENT
ipv4_tx_c ipv4_tx_c_0(
.rstn(sys_rstn),
.phy_resetn(phy_resetn[0]),
@@ -1207,17 +1250,19 @@ module betsy (
.fifo_d_o(tx_mle_fifo_d0)
);
+`endif
/*
*
* PHY1 IEEE 802.3 ETHERNET for Interface to 1000BASE-T LAN
*
*/
- mac_rgmii #(.PHY_NUM(1)) mac_1(
+ mac_rgmii #(.MLE_EOD_FLAG(1), .PHY_NUM(1)) mac_1(
.rstn(sys_rstn),
.phy_resetn (phy_resetn[1]),
.rx_clk(phy1_rx_clk),
.tx_clk(pclk),
+ .mle_clk(pclk),
.tap_port (1'b0),
// Control Interface
.cont_clk(cont_clk),
@@ -1228,9 +1273,7 @@ module betsy (
.cont_d_o(mac_1_d_o),
.cont_tgt_ready(mem_tgt_ready_mac_1),
// ML engine interface
- .mle_active(mle_evt_active),
.mle_if_enable(mle_enable[1]),
- .mle_if_oe(mle_oe),
.mle_if_we(mle_we[1]),
.mle_if_empty(mle_empty[1]),
.mle_if_d_o(mle_d_1),
@@ -1261,7 +1304,7 @@ module betsy (
// MAC RX / FIFO Write
.rx_fifo_we(rx_mac_fifo_we[1]),
.rx_fifo_d(rx_mac_fifo_d1),
- .rx_keep(rx_mac_keep[1]),
+ .rx_trigger(rx_mac_trigger[1]),
.rx_wr_done(rx_mac_wr_done[1]),
.rx_byte_cnt(rx1_mac_byte_cnt),
.rx_idle(rx_idle[1]),
@@ -1325,7 +1368,7 @@ module betsy (
.rx_data_m4(rx1_d_m4),
// flags
.pkt_complete(ipv4_pkt_complete[1]),
- .trigger_src_addr(),
+ .trigger_src_addr(ipv4_trigger_src_addr[1]),
.trigger_dst_addr(ipv4_trigger_dst_addr[1]),
.keep(ipv4_rx_keep[1])
);
@@ -1372,7 +1415,7 @@ module betsy (
.new_frame (rx_sop[1]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[1]),
+ .trigger(rx_mac_trigger[1]),
.keep(rx_pf_keep_10)
);
@@ -1436,7 +1479,7 @@ module betsy (
.new_frame (rx_sop[1]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[1]),
+ .trigger(rx_mac_trigger[1]),
.keep(rx_pf_keep_12)
);
@@ -1445,7 +1488,11 @@ module betsy (
.phy_up(phy_up[1]),
.rx_clk(phy1_rx_clk),
.tx_clk(pclk),
- .enable(1'b1), // ipv4_rx_keep[1]
+`ifdef ENABLE_TAP_ON_PHY2
+ .enable(1'b1),
+`else
+ .enable(1'b0),
+`endif
// control
.keep (rx_pf_keep_12),
.passthrough(1'b0),
@@ -1521,6 +1568,7 @@ module betsy (
);
`ifdef PHY2_PRESENT
+
/*
*
* PHY2 IEEE 802.3 ETHERNET for Interface to 1000BASE-T LAN
@@ -1531,6 +1579,7 @@ module betsy (
.phy_resetn (phy_resetn[2]),
.rx_clk(phy2_rx_clk),
.tx_clk(pclk),
+ .mle_clk(pclk),
.tap_port (1'b0),
// Control Interface
.cont_clk(cont_clk),
@@ -1540,13 +1589,12 @@ module betsy (
.cont_d_i(mem_d_o[15:0]),
.cont_d_o(mac_2_d_o),
.cont_tgt_ready(mem_tgt_ready_mac_2),
- // ML engine interface
- .mle_active(mle_evt_active),
- .mle_if_enable(mle_enable[2]),
- .mle_if_oe(mle_oe),
- .mle_if_we(mle_we[2]),
- .mle_if_empty(mle_empty[2]),
- .mle_if_d_o(mle_d_2),
+ // ML engine interface
+ // When PHY2 is enabled, it is assumed to be the controller port and MLE is disabled on it
+ .mle_if_enable(1'b0),
+ .mle_if_we(),
+ .mle_if_empty(),
+ .mle_if_d_o(),
// Line State
.fixed_speed(1'b1),
.mode_100Mbit(mode_100Mbit[2]),
@@ -1574,7 +1622,7 @@ module betsy (
// MAC RX / FIFO Write
.rx_fifo_we(rx_mac_fifo_we[2]),
.rx_fifo_d(rx_mac_fifo_d2),
- .rx_keep(rx_mac_keep[2]),
+ .rx_trigger(rx_mac_trigger[2]),
.rx_wr_done(rx_mac_wr_done[2]),
.rx_byte_cnt(rx2_mac_byte_cnt),
.rx_idle(rx_idle[2]),
@@ -1585,11 +1633,12 @@ module betsy (
.tx_fifo_re(tx_mac_fifo_re[2]),
.tx_fifo_d(tx_sw_fifo_d2),
.tx_fifo_empty(tx_sw_fifo_empty[2]),
- // Alternate TX Port
- .tx_uc_fifo_empty(1'b1), // tie off to disable port
- .tx_uc_fifo_d(9'd0),
- .tx_mle_fifo_empty(1'b1),
- .tx_mle_fifo_d(9'd0),
+ // Alternate TX Port (uC)
+ .tx_uc_fifo_empty(tx_uc_fifo_empty),
+ .tx_uc_fifo_d(tx_uc_fifo_d2),
+ // Alternate TX Port (MLE)
+ .tx_mle_fifo_empty(tx_mle_fifo_empty),
+ .tx_mle_fifo_d(tx_mle_fifo_d2),
// Packet Filter
.rx_sample(rx_sample[2]),
.ipv4_pkt_start(ipv4_pkt_start[2]),
@@ -1638,7 +1687,7 @@ module betsy (
.rx_data_m4(rx2_d_m4),
// flags
.pkt_complete(ipv4_pkt_complete[2]),
- .trigger_src_addr(),
+ .trigger_src_addr(ipv4_trigger_src_addr[2]),
.trigger_dst_addr(ipv4_trigger_dst_addr[2]),
.keep(ipv4_rx_keep[2])
);
@@ -1685,7 +1734,7 @@ module betsy (
.new_frame (rx_sop[2]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[2]),
+ .trigger(rx_mac_trigger[2]),
.keep(rx_pf_keep_20)
);
@@ -1694,7 +1743,7 @@ module betsy (
.phy_up(phy_up[2]),
.rx_clk(phy2_rx_clk),
.tx_clk(pclk),
- .enable(1'b1), // ipv4_rx_keep[2]
+ .enable(~ipv4_addr_match_c2),
// control
.keep (rx_pf_keep_20),
.passthrough(1'b0),
@@ -1728,7 +1777,7 @@ module betsy (
);
- // PHY1 MAC -> PHY2
+ // PHY2 MAC -> PHY1
pkt_filter pkt_filter_21(
.rstn(sys_rstn),
.clk(phy2_rx_clk),
@@ -1748,7 +1797,7 @@ module betsy (
.new_frame (rx_sop[2]),
.block(1'b0),
.invert(1'b1),
- .trigger(rx_mac_keep[2]),
+ .trigger(rx_mac_trigger[2]),
.keep(rx_pf_keep_21)
);
@@ -1757,7 +1806,7 @@ module betsy (
.phy_up(phy_up[2]),
.rx_clk(phy2_rx_clk),
.tx_clk(pclk),
- .enable(1'b1), // ipv4_rx_keep[1]
+ .enable(~ipv4_addr_match_c2),
// control
.keep (rx_pf_keep_21),
.passthrough(1'b0),
@@ -1790,8 +1839,80 @@ module betsy (
.active(sync_rx2_active[2])
);
-`endif
+
+ ipv4_rx_c #(.IP_DST_MATCH_4(100)) ipv4_rx_c_2(
+ .rstn(sys_rstn),
+ .clk(phy2_rx_clk),
+ // control
+ .phy_up(phy_up[2]),
+ // packet data
+ .pkt_start(ipv4_pkt_start[2]),
+ .rx_sample(rx_sample[2]),
+ .rx_eop(rx_eop[2]),
+ .rx_data_m1(rx2_d_m1),
+ .rx_data_m2(rx2_d_m2),
+ .rx_data_m3(rx2_d_m3),
+ .rx_data_m4(rx2_d_m4),
+ // flags
+ .pkt_complete(ipv4_pkt_complete_c2),
+ .ip_addr_match(ipv4_addr_match_c2)
+ );
+ udp_rx_c udp_rx_c_2(
+ .rstn(sys_rstn),
+ .clk(phy2_rx_clk),
+ // control
+ .phy_up(phy_up[2]),
+ // packet data
+ .rx_sample(1'b1),
+ .pkt_start(ipv4_trigger_dst_addr[2]),
+ .rx_eop(rx_eop[2]),
+ .rx_data_m1(rx2_d_m1),
+ .rx_data_m2(rx2_d_m2),
+ .rx_data_m3(rx2_d_m3),
+ .rx_data_m4(rx2_d_m4),
+ // flags
+ .pkt_complete(),
+ .udp_port_match(udp_port_match_c)
+ );
+
+ drop_fifo drop_fifo_2u(
+ .rstn(sys_rstn),
+ .phy_up(phy_up[2]),
+ .rx_clk(phy2_rx_clk),
+ .tx_clk(pclk),
+ .enable(ipv4_addr_match_c2),
+ // control
+ .keep (udp_port_match_c),
+ .passthrough(1'b0),
+ // input
+ .we_in(rx_mac_fifo_we[2]),
+ .wr_done(rx_mac_wr_done[2]),
+ .rx_idle(rx_idle[2]),
+ .rx_error(rx_mac_error[2]),
+ .d_in(rx_mac_fifo_d2),
+ // output
+ .we_out(rx_df_fifo_we_2u),
+ .d_out(rx_df_fifo_d_2u),
+ .active(drop_rx2_active_u)
+ );
+
+ sync_fifo sync_fifo_rx_2u(
+ .rstn(sys_rstn),
+ .clk (pclk),
+ // input
+ .we (rx_df_fifo_we_2u),
+ .d_in (rx_df_fifo_d_2u),
+ // output
+ .re (rx_sw_fifo_re_2u),
+ .d_out(rx_sf_fifo_d_2u),
+ .empty(rx_sf_fifo_empty_2u),
+ .almost_full(rx_sf_almost_full_2u),
+ .reset_ptrs(1'b0),
+ // debug
+ .active(sync_rx2_active_u )
+ );
+
dpram_inf #(.ADDR_WIDTH(10), .DPRAM_INIT("param_ram_2.txt")) param_ram_2(
.rstn(sys_rstn),
// Port A
@@ -1831,6 +1952,60 @@ module betsy (
.din(fcs_tx_din2),
.dout(fcs_tx_dout2)
);
+
+
+ ipv4_tx_c ipv4_tx_c_2(
+ .rstn(sys_rstn),
+ .phy_resetn(phy_resetn[2]),
+ .clk(pclk),
+ // Control Interface
+ .cont_clk(cont_clk),
+ .cont_sel(ipv4_tx_c_sel),
+ .cont_we(mem_we),
+ .cont_addr(mem_addr[7:0]),
+ .cont_d_i(mem_d_o[15:0]),
+ .cont_d_o(),
+ // Line State
+ .mode_100Mbit(mode_100Mbit[2]),
+ .phy_up(phy_up[2]),
+ // Switch I/F
+ .tx_mode(tx_sw_mode2),
+ .tx_src_sel(tx_src_sel2),
+ .byte_cnt_i(tx2_byte_cnt),
+ // MAC Interface
+ .fifo_re_i(tx_mac_fifo_re[2]),
+ .fifo_empty_o(tx_uc_fifo_empty),
+ .fifo_d_o(tx_uc_fifo_d2),
+ // Debug
+ .gpio(gpio_ipv4)
+ );
+
+ ipv4_tx_mle ipv4_tx_mle_2(
+ .rstn(sys_rstn),
+ .phy_resetn(phy_resetn[2]),
+ .clk(pclk),
+ // Control Interface
+ .cont_clk(cont_clk),
+ .cont_sel(ipv4_tx_mle_sel),
+ .cont_we(mem_we),
+ .cont_addr(mem_addr[7:0]),
+ .cont_d_i(mem_d_o[15:0]),
+ .cont_d_o(),
+ // Line State
+ .mode_100Mbit(mode_100Mbit[2]),
+ .phy_up(phy_up[2]),
+ // Switch I/F
+ .tx_mode(tx_sw_mode2),
+ .tx_src_sel(tx_src_sel2),
+ .byte_cnt_i(tx2_byte_cnt),
+ // MAC Interface
+ .fifo_re_i(tx_mac_fifo_re[2]),
+ .fifo_empty_o(tx_mle_fifo_empty),
+ .fifo_d_o(tx_mle_fifo_d2)
+ );
+
+`endif // PHY2_PRESENT
+
`ifdef PASSTHROUGH
@@ -1906,8 +2081,12 @@ module betsy (
else if (mle_evt_start)
evt_toggle <= ~evt_toggle;
- assign fpga_led[0] = heart_beat_cnt[22];
- assign fpga_led[1] = heart_beat_cnt[23];
- assign fpga_led[2] = evt_toggle;
+ assign fpga_led[0] = heart_beat_cnt[24];
+ assign fpga_led[1] = heart_beat_cnt[25];
+ assign fpga_led[2] = |flash_d;
+
+ // TODO: This will be replaced when the SPI master peripheral is ready
+ assign flash_seln = 1'b0;
+ assign flash_clk = cont_clk;
endmodule



Join the Betsy Beta