eth: Optimize frame length enforcement logic in BASE-R MACs
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
@@ -130,7 +130,9 @@ logic is_mcast_reg = 1'b0, is_mcast_next;
|
||||
logic is_bcast_reg = 1'b0, is_bcast_next;
|
||||
logic is_8021q_reg = 1'b0, is_8021q_next;
|
||||
logic [15:0] frame_len_reg = '0, frame_len_next;
|
||||
logic [15:0] frame_len_lim_reg = '0, frame_len_lim_next;
|
||||
logic [13:0] frame_len_lim_cyc_reg = '0, frame_len_lim_cyc_next;
|
||||
logic [1:0] frame_len_lim_last_reg = '0, frame_len_lim_last_next;
|
||||
logic frame_len_lim_check_reg = '0, frame_len_lim_check_next;
|
||||
|
||||
logic [DATA_W-1:0] m_axis_rx_tdata_reg = '0, m_axis_rx_tdata_next;
|
||||
logic [KEEP_W-1:0] m_axis_rx_tkeep_reg = '0, m_axis_rx_tkeep_next;
|
||||
@@ -231,7 +233,9 @@ always_comb begin
|
||||
is_bcast_next = is_bcast_reg;
|
||||
is_8021q_next = is_8021q_reg;
|
||||
frame_len_next = frame_len_reg;
|
||||
frame_len_lim_next = frame_len_lim_reg;
|
||||
frame_len_lim_cyc_next = frame_len_lim_cyc_reg;
|
||||
frame_len_lim_last_next = frame_len_lim_last_reg;
|
||||
frame_len_lim_check_next = frame_len_lim_check_reg;
|
||||
|
||||
m_axis_rx_tdata_next = xgmii_rxd_d2;
|
||||
m_axis_rx_tkeep_next = {KEEP_W{1'b1}};
|
||||
@@ -275,10 +279,14 @@ always_comb begin
|
||||
end
|
||||
|
||||
// counter for max frame length enforcement
|
||||
if (frame_len_lim_reg[15:2] != 0) begin
|
||||
frame_len_lim_next = frame_len_lim_reg - 16'(CTRL_W);
|
||||
if (frame_len_lim_cyc_reg != 0) begin
|
||||
frame_len_lim_cyc_next = frame_len_lim_cyc_reg - 1;
|
||||
end else begin
|
||||
frame_len_lim_next = '0;
|
||||
frame_len_lim_cyc_next = '0;
|
||||
end
|
||||
|
||||
if (frame_len_lim_cyc_reg == 2) begin
|
||||
frame_len_lim_check_next = 1'b1;
|
||||
end
|
||||
|
||||
// address and ethertype checks
|
||||
@@ -303,8 +311,10 @@ always_comb begin
|
||||
// idle state - wait for packet
|
||||
reset_crc = 1'b1;
|
||||
|
||||
frame_oversize_next = 1'b0;
|
||||
frame_len_next = 16'(CTRL_W);
|
||||
frame_len_lim_next = cfg_rx_max_pkt_len;
|
||||
{frame_len_lim_cyc_next, frame_len_lim_last_next} = cfg_rx_max_pkt_len;
|
||||
frame_len_lim_check_next = 1'b0;
|
||||
hdr_ptr_next = 0;
|
||||
|
||||
pre_ok_next = xgmii_rxd_d2[31:8] == 24'h555555;
|
||||
@@ -330,7 +340,6 @@ always_comb begin
|
||||
STATE_PREAMBLE: begin
|
||||
// drop preamble
|
||||
|
||||
frame_len_lim_next = cfg_rx_max_pkt_len;
|
||||
hdr_ptr_next = 0;
|
||||
|
||||
pre_ok_next = pre_ok_reg && xgmii_rxd_d2 == 32'hD5555555;
|
||||
@@ -355,10 +364,17 @@ always_comb begin
|
||||
|
||||
if (term_present_reg) begin
|
||||
stat_rx_byte_next = 3'(term_lane_reg);
|
||||
frame_oversize_next = frame_len_lim_reg < 16'(4+4+term_lane_reg);
|
||||
if (frame_len_lim_check_reg) begin
|
||||
if (frame_len_lim_last_reg < term_lane_reg) begin
|
||||
frame_oversize_next = 1'b1;
|
||||
end
|
||||
end
|
||||
end else begin
|
||||
stat_rx_byte_next = 3'(CTRL_W);
|
||||
frame_oversize_next = frame_len_lim_reg < 4+4;
|
||||
if (frame_len_lim_check_reg) begin
|
||||
// at the limit but this isn't a termination character
|
||||
frame_oversize_next = 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
if (framing_error_reg) begin
|
||||
@@ -477,7 +493,9 @@ always_ff @(posedge clk) begin
|
||||
is_bcast_reg <= is_bcast_next;
|
||||
is_8021q_reg <= is_8021q_next;
|
||||
frame_len_reg <= frame_len_next;
|
||||
frame_len_lim_reg <= frame_len_lim_next;
|
||||
frame_len_lim_cyc_reg <= frame_len_lim_cyc_next;
|
||||
frame_len_lim_last_reg <= frame_len_lim_last_next;
|
||||
frame_len_lim_check_reg <= frame_len_lim_check_next;
|
||||
|
||||
m_axis_rx_tdata_reg <= m_axis_rx_tdata_next;
|
||||
m_axis_rx_tkeep_reg <= m_axis_rx_tkeep_next;
|
||||
|
||||
Reference in New Issue
Block a user