1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

Improve classifier logic by registering payload select signals

This commit is contained in:
Alex Forencich 2015-02-28 19:14:22 -08:00
parent d57c857d88
commit 14e71d568d
4 changed files with 110 additions and 18 deletions

View File

@ -197,12 +197,37 @@ wire input_select_ip = (input_eth_type == 16'h0800);
wire input_select_arp = (input_eth_type == 16'h0806);
wire input_select_none = ~(input_select_ip | input_select_arp);
reg input_select_ip_reg = 0;
reg input_select_arp_reg = 0;
reg input_select_none_reg = 0;
always @(posedge clk) begin
if (rst) begin
input_select_ip_reg <= 0;
input_select_arp_reg <= 0;
input_select_none_reg <= 0;
end else begin
if (input_eth_payload_tvalid) begin
if ((~input_select_ip_reg & ~input_select_arp_reg & ~input_select_none_reg) |
(input_eth_payload_tvalid & input_eth_payload_tready & input_eth_payload_tlast)) begin
input_select_ip_reg <= input_select_ip;
input_select_arp_reg <= input_select_arp;
input_select_none_reg <= input_select_none;
end
end else begin
input_select_ip_reg <= 0;
input_select_arp_reg <= 0;
input_select_none_reg <= 0;
end
end
end
assign ip_rx_eth_hdr_valid = input_select_ip & input_eth_hdr_valid;
assign ip_rx_eth_dest_mac = input_eth_dest_mac;
assign ip_rx_eth_src_mac = input_eth_src_mac;
assign ip_rx_eth_type = 16'h0800;
assign ip_rx_eth_payload_tdata = input_eth_payload_tdata;
assign ip_rx_eth_payload_tvalid = input_select_ip & input_eth_payload_tvalid;
assign ip_rx_eth_payload_tvalid = input_select_ip_reg & input_eth_payload_tvalid;
assign ip_rx_eth_payload_tlast = input_eth_payload_tlast;
assign ip_rx_eth_payload_tuser = input_eth_payload_tuser;
@ -211,15 +236,15 @@ assign arp_rx_eth_dest_mac = input_eth_dest_mac;
assign arp_rx_eth_src_mac = input_eth_src_mac;
assign arp_rx_eth_type = 16'h0806;
assign arp_rx_eth_payload_tdata = input_eth_payload_tdata;
assign arp_rx_eth_payload_tvalid = input_select_arp & input_eth_payload_tvalid;
assign arp_rx_eth_payload_tvalid = input_select_arp_reg & input_eth_payload_tvalid;
assign arp_rx_eth_payload_tlast = input_eth_payload_tlast;
assign arp_rx_eth_payload_tuser = input_eth_payload_tuser;
assign input_eth_hdr_ready = arp_rx_eth_hdr_ready & ip_rx_eth_hdr_ready;
assign input_eth_payload_tready = (input_select_ip & ip_rx_eth_payload_tready) |
(input_select_arp & arp_rx_eth_payload_tready) |
input_select_none;
assign input_eth_payload_tready = (input_select_ip_reg & ip_rx_eth_payload_tready) |
(input_select_arp_reg & arp_rx_eth_payload_tready) |
input_select_none_reg;
/*
* Output arbiter

View File

@ -205,13 +205,38 @@ wire input_select_ip = (input_eth_type == 16'h0800);
wire input_select_arp = (input_eth_type == 16'h0806);
wire input_select_none = ~(input_select_ip | input_select_arp);
reg input_select_ip_reg = 0;
reg input_select_arp_reg = 0;
reg input_select_none_reg = 0;
always @(posedge clk) begin
if (rst) begin
input_select_ip_reg <= 0;
input_select_arp_reg <= 0;
input_select_none_reg <= 0;
end else begin
if (input_eth_payload_tvalid) begin
if ((~input_select_ip_reg & ~input_select_arp_reg & ~input_select_none_reg) |
(input_eth_payload_tvalid & input_eth_payload_tready & input_eth_payload_tlast)) begin
input_select_ip_reg <= input_select_ip;
input_select_arp_reg <= input_select_arp;
input_select_none_reg <= input_select_none;
end
end else begin
input_select_ip_reg <= 0;
input_select_arp_reg <= 0;
input_select_none_reg <= 0;
end
end
end
assign ip_rx_eth_hdr_valid = input_select_ip & input_eth_hdr_valid;
assign ip_rx_eth_dest_mac = input_eth_dest_mac;
assign ip_rx_eth_src_mac = input_eth_src_mac;
assign ip_rx_eth_type = 16'h0800;
assign ip_rx_eth_payload_tdata = input_eth_payload_tdata;
assign ip_rx_eth_payload_tkeep = input_eth_payload_tkeep;
assign ip_rx_eth_payload_tvalid = input_select_ip & input_eth_payload_tvalid;
assign ip_rx_eth_payload_tvalid = input_select_ip_reg & input_eth_payload_tvalid;
assign ip_rx_eth_payload_tlast = input_eth_payload_tlast;
assign ip_rx_eth_payload_tuser = input_eth_payload_tuser;
@ -221,15 +246,15 @@ assign arp_rx_eth_src_mac = input_eth_src_mac;
assign arp_rx_eth_type = 16'h0806;
assign arp_rx_eth_payload_tdata = input_eth_payload_tdata;
assign arp_rx_eth_payload_tkeep = input_eth_payload_tkeep;
assign arp_rx_eth_payload_tvalid = input_select_arp & input_eth_payload_tvalid;
assign arp_rx_eth_payload_tvalid = input_select_arp_reg & input_eth_payload_tvalid;
assign arp_rx_eth_payload_tlast = input_eth_payload_tlast;
assign arp_rx_eth_payload_tuser = input_eth_payload_tuser;
assign input_eth_hdr_ready = arp_rx_eth_hdr_ready & ip_rx_eth_hdr_ready;
assign input_eth_payload_tready = (input_select_ip & ip_rx_eth_payload_tready) |
(input_select_arp & arp_rx_eth_payload_tready) |
input_select_none;
assign input_eth_payload_tready = (input_select_ip_reg & ip_rx_eth_payload_tready) |
(input_select_arp_reg & arp_rx_eth_payload_tready) |
input_select_none_reg;
/*
* Output arbiter

View File

@ -277,6 +277,27 @@ wire udp_tx_ip_payload_tready;
wire input_select_udp = (ip_rx_ip_protocol == 8'h11);
wire input_select_ip = ~input_select_udp;
reg input_select_udp_reg = 0;
reg input_select_ip_reg = 0;
always @(posedge clk) begin
if (rst) begin
input_select_udp_reg <= 0;
input_select_ip_reg <= 0;
end else begin
if (ip_rx_ip_payload_tvalid) begin
if ((~input_select_udp_reg & ~input_select_ip_reg) |
(ip_rx_ip_payload_tvalid & ip_rx_ip_payload_tready & ip_rx_ip_payload_tlast)) begin
input_select_udp_reg <= input_select_udp;
input_select_ip_reg <= input_select_ip;
end
end else begin
input_select_udp_reg <= 0;
input_select_ip_reg <= 0;
end
end
end
// IP frame to UDP module
assign udp_rx_ip_hdr_valid = input_select_udp & ip_rx_ip_hdr_valid;
assign udp_rx_ip_eth_dest_mac = ip_rx_ip_eth_dest_mac;
@ -296,7 +317,7 @@ assign udp_rx_ip_header_checksum = ip_rx_ip_header_checksum;
assign udp_rx_ip_source_ip = ip_rx_ip_source_ip;
assign udp_rx_ip_dest_ip = ip_rx_ip_dest_ip;
assign udp_rx_ip_payload_tdata = ip_rx_ip_payload_tdata;
assign udp_rx_ip_payload_tvalid = input_select_udp & ip_rx_ip_payload_tvalid;
assign udp_rx_ip_payload_tvalid = input_select_udp_reg & ip_rx_ip_payload_tvalid;
assign udp_rx_ip_payload_tlast = ip_rx_ip_payload_tlast;
assign udp_rx_ip_payload_tuser = ip_rx_ip_payload_tuser;
@ -319,14 +340,14 @@ assign output_ip_header_checksum = ip_rx_ip_header_checksum;
assign output_ip_source_ip = ip_rx_ip_source_ip;
assign output_ip_dest_ip = ip_rx_ip_dest_ip;
assign output_ip_payload_tdata = ip_rx_ip_payload_tdata;
assign output_ip_payload_tvalid = input_select_ip & ip_rx_ip_payload_tvalid;
assign output_ip_payload_tvalid = input_select_ip_reg & ip_rx_ip_payload_tvalid;
assign output_ip_payload_tlast = ip_rx_ip_payload_tlast;
assign output_ip_payload_tuser = ip_rx_ip_payload_tuser;
assign ip_rx_ip_hdr_ready = udp_rx_ip_hdr_ready & output_ip_hdr_ready;
assign ip_rx_ip_payload_tready = (input_select_udp & udp_rx_ip_payload_tready) |
(input_select_ip & output_ip_payload_tready);
assign ip_rx_ip_payload_tready = (input_select_udp_reg & udp_rx_ip_payload_tready) |
(input_select_ip_reg & output_ip_payload_tready);
/*
* Output arbiter

View File

@ -287,6 +287,27 @@ wire udp_tx_ip_payload_tready;
wire input_select_udp = (ip_rx_ip_protocol == 8'h11);
wire input_select_ip = ~input_select_udp;
reg input_select_udp_reg = 0;
reg input_select_ip_reg = 0;
always @(posedge clk) begin
if (rst) begin
input_select_udp_reg <= 0;
input_select_ip_reg <= 0;
end else begin
if (ip_rx_ip_payload_tvalid) begin
if ((~input_select_udp_reg & ~input_select_ip_reg) |
(ip_rx_ip_payload_tvalid & ip_rx_ip_payload_tready & ip_rx_ip_payload_tlast)) begin
input_select_udp_reg <= input_select_udp;
input_select_ip_reg <= input_select_ip;
end
end else begin
input_select_udp_reg <= 0;
input_select_ip_reg <= 0;
end
end
end
// IP frame to UDP module
assign udp_rx_ip_hdr_valid = input_select_udp & ip_rx_ip_hdr_valid;
assign udp_rx_ip_eth_dest_mac = ip_rx_ip_eth_dest_mac;
@ -307,7 +328,7 @@ assign udp_rx_ip_source_ip = ip_rx_ip_source_ip;
assign udp_rx_ip_dest_ip = ip_rx_ip_dest_ip;
assign udp_rx_ip_payload_tdata = ip_rx_ip_payload_tdata;
assign udp_rx_ip_payload_tkeep = ip_rx_ip_payload_tkeep;
assign udp_rx_ip_payload_tvalid = input_select_udp & ip_rx_ip_payload_tvalid;
assign udp_rx_ip_payload_tvalid = input_select_udp_reg & ip_rx_ip_payload_tvalid;
assign udp_rx_ip_payload_tlast = ip_rx_ip_payload_tlast;
assign udp_rx_ip_payload_tuser = ip_rx_ip_payload_tuser;
@ -331,14 +352,14 @@ assign output_ip_source_ip = ip_rx_ip_source_ip;
assign output_ip_dest_ip = ip_rx_ip_dest_ip;
assign output_ip_payload_tdata = ip_rx_ip_payload_tdata;
assign output_ip_payload_tkeep = ip_rx_ip_payload_tkeep;
assign output_ip_payload_tvalid = input_select_ip & ip_rx_ip_payload_tvalid;
assign output_ip_payload_tvalid = input_select_ip_reg & ip_rx_ip_payload_tvalid;
assign output_ip_payload_tlast = ip_rx_ip_payload_tlast;
assign output_ip_payload_tuser = ip_rx_ip_payload_tuser;
assign ip_rx_ip_hdr_ready = udp_rx_ip_hdr_ready & output_ip_hdr_ready;
assign ip_rx_ip_payload_tready = (input_select_udp & udp_rx_ip_payload_tready) |
(input_select_ip & output_ip_payload_tready);
assign ip_rx_ip_payload_tready = (input_select_udp_reg & udp_rx_ip_payload_tready) |
(input_select_ip_reg & output_ip_payload_tready);
/*
* Output arbiter