data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v
1: b"%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:180: Cannot find file containing module: 'fallthrough_small_fifo'\n   fallthrough_small_fifo #(.WIDTH(C_M_AXIS_DATA_WIDTH+C_M_AXIS_TUSER_WIDTH+C_M_AXIS_DATA_WIDTH/8+1), .MAX_DEPTH_BITS(3))\n   ^~~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl,data/full_repos/permissive/498471995/fallthrough_small_fifo\n             data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl,data/full_repos/permissive/498471995/fallthrough_small_fifo.v\n             data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl,data/full_repos/permissive/498471995/fallthrough_small_fifo.sv\n             fallthrough_small_fifo\n             fallthrough_small_fifo.v\n             fallthrough_small_fifo.sv\n             obj_dir/fallthrough_small_fifo\n             obj_dir/fallthrough_small_fifo.v\n             obj_dir/fallthrough_small_fifo.sv\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:194: Cannot find file containing module: 'preprocess_control'\n  preprocess_control\n  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:214: Cannot find file containing module: 'eth_parser'\n   eth_parser\n   ^~~~~~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:254: Cannot find file containing module: 'ip_lpm'\n   ip_lpm\n   ^~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:311: Cannot find file containing module: 'ip_arp'\n   ip_arp\n   ^~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:349: Cannot find file containing module: 'dest_ip_filter'\n   dest_ip_filter\n   ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:382: Cannot find file containing module: 'ip_checksum_ttl'\n   ip_checksum_ttl\n   ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:408: Cannot find file containing module: 'op_lut_hdr_parser'\n   op_lut_hdr_parser\n   ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/498471995/sume/felix/simple_sume_switch/test/ip_repo/std/cores/router_output_port_lookup_v1_0_0/hdl/output_port_lookup.v:433: Cannot find file containing module: 'op_lut_process_sm'\n   op_lut_process_sm\n   ^~~~~~~~~~~~~~~~~\n%Error: Exiting due to 9 error(s)\n"
module output_port_lookup
#(

    parameter C_M_AXIS_DATA_WIDTH	= 256,
    parameter C_S_AXIS_DATA_WIDTH	= 256,
    parameter C_M_AXIS_TUSER_WIDTH	= 128,
    parameter C_S_AXIS_TUSER_WIDTH	= 128,
    parameter NUM_OUTPUT_QUEUES		= 8,
    parameter NUM_OUTPUT_QUEUES_WIDTH	= log2(NUM_OUTPUT_QUEUES),
    parameter LPM_LUT_DEPTH		= 32,
    parameter LPM_LUT_DEPTH_BITS 	= log2(LPM_LUT_DEPTH),
    parameter ARP_LUT_DEPTH 		= 32,
    parameter ARP_LUT_DEPTH_BITS	= log2(ARP_LUT_DEPTH),
    parameter FILTER_DEPTH		= 32,
    parameter FILTER_DEPTH_BITS		= log2(FILTER_DEPTH)
)
(

    input axis_aclk,
    input axis_resetn,


    output [C_M_AXIS_DATA_WIDTH - 1:0]		m_axis_tdata,
    output [((C_M_AXIS_DATA_WIDTH / 8)) - 1:0]	m_axis_tkeep,
    output [C_M_AXIS_TUSER_WIDTH-1:0]		m_axis_tuser,
    output m_axis_tvalid,
    input  m_axis_tready,
    output m_axis_tlast,


    input [C_S_AXIS_DATA_WIDTH - 1:0]		s_axis_tdata,
    input [((C_S_AXIS_DATA_WIDTH / 8)) - 1:0]	s_axis_tkeep,
    input [C_S_AXIS_TUSER_WIDTH-1:0]		s_axis_tuser,
    input  s_axis_tvalid,
    output s_axis_tready,
    input  s_axis_tlast,


    output                               pkt_sent_from_cpu,
    output                               pkt_sent_to_cpu_options_ver,
    output                               pkt_sent_to_cpu_bad_ttl,
    output                               pkt_sent_to_cpu_dest_ip_hit,
    output                               pkt_forwarded     ,
    output                               pkt_dropped_checksum,
    output                               pkt_sent_to_cpu_non_ip,
    output                               pkt_sent_to_cpu_arp_miss,
    output                               pkt_sent_to_cpu_lpm_miss,
    output                               pkt_dropped_wrong_dst_mac,


    input [LPM_LUT_DEPTH_BITS-1:0]       lpm_rd_addr,
    input                                lpm_rd_req,
    output [31:0]                        lpm_rd_ip,
    output [31:0]                        lpm_rd_mask,
    output [NUM_OUTPUT_QUEUES-1:0]       lpm_rd_oq,
    output [31:0]                        lpm_rd_next_hop_ip,
    output                               lpm_rd_ack,
    input [LPM_LUT_DEPTH_BITS-1:0]       lpm_wr_addr,
    input                                lpm_wr_req,
    input [NUM_OUTPUT_QUEUES-1:0]        lpm_wr_oq,
    input [31:0]                         lpm_wr_next_hop_ip,
    input [31:0]                         lpm_wr_ip,
    input [31:0]                         lpm_wr_mask,
    output                               lpm_wr_ack,


    input [ARP_LUT_DEPTH_BITS-1:0]       arp_rd_addr,
    input                                arp_rd_req,
    output  [47:0]                       arp_rd_mac,
    output  [31:0]                       arp_rd_ip,
    output                               arp_rd_ack,
    input [ARP_LUT_DEPTH_BITS-1:0]       arp_wr_addr,
    input                                arp_wr_req,
    input [47:0]                         arp_wr_mac,
    input [31:0]                         arp_wr_ip,
    output                               arp_wr_ack,


    input [FILTER_DEPTH_BITS-1:0]        dest_ip_filter_rd_addr,
    input                                dest_ip_filter_rd_req,
    output [31:0]                        dest_ip_filter_rd_ip,
    output                               dest_ip_filter_rd_ack,
    input [FILTER_DEPTH_BITS-1:0]        dest_ip_filter_wr_addr,
    input                                dest_ip_filter_wr_req,
    input [31:0]                         dest_ip_filter_wr_ip,
    output                               dest_ip_filter_wr_ack,


    input [47:0]                         mac_0,
    input [47:0]                         mac_1,
    input [47:0]                         mac_2,
    input [47:0]                         mac_3,


    input [3:0]				 reset_tables

);

   function integer log2;
      input integer number;
      begin
         log2=0;
         while(2**log2<number) begin
            log2=log2+1;
         end
      end
   endfunction






   wire [NUM_OUTPUT_QUEUES_WIDTH-1:0] 	mac_dst_port_num;
   wire [31:0]                 		next_hop_ip;

   wire [NUM_OUTPUT_QUEUES-1:0]       	lpm_output_port;

   wire [47:0]                 		next_hop_mac;
   wire [NUM_OUTPUT_QUEUES-1:0]       	output_port;
   
   wire [7:0]                  		ip_new_ttl;
   wire [15:0]                 		ip_new_checksum;

   wire [NUM_OUTPUT_QUEUES-1:0]       	to_cpu_output_port;
   wire [NUM_OUTPUT_QUEUES-1:0]       	from_cpu_output_port;
   wire [NUM_OUTPUT_QUEUES_WIDTH-1:0] 	input_port_num;

   wire [C_M_AXIS_DATA_WIDTH-1:0]	in_fifo_tdata;
   wire [C_M_AXIS_TUSER_WIDTH-1:0]	in_fifo_tuser;
   wire [C_M_AXIS_DATA_WIDTH/8-1:0]	in_fifo_tkeep;
   wire					in_fifo_tlast;

   wire                        		in_fifo_nearly_full;
   wire			       		arp_done;
   wire			       		dest_fifo_nearly_full;


   assign s_axis_tready = ~in_fifo_nearly_full & ~dest_fifo_nearly_full;
   

   

   fallthrough_small_fifo #(.WIDTH(C_M_AXIS_DATA_WIDTH+C_M_AXIS_TUSER_WIDTH+C_M_AXIS_DATA_WIDTH/8+1), .MAX_DEPTH_BITS(3))
      input_fifo
        (.din ({s_axis_tlast, s_axis_tuser, s_axis_tkeep, s_axis_tdata}),
         .wr_en (s_axis_tvalid & ~in_fifo_nearly_full),
         .rd_en (in_fifo_rd_en),
         .dout ({in_fifo_tlast, in_fifo_tuser, in_fifo_tkeep, in_fifo_tdata}),
         .full (),
         .prog_full (),
         .nearly_full (in_fifo_nearly_full),
         .empty (in_fifo_empty),
         .reset (~axis_resetn),
         .clk (axis_aclk)
         );

  preprocess_control
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH)
       ) preprocess_control
       (

	  .tdata		    (s_axis_tdata),
          .valid		    (s_axis_tvalid & ~in_fifo_nearly_full),
	  .tlast		    (s_axis_tlast),



         .word_IP_DST_HI            (word_IP_DST_HI),
         .word_IP_DST_LO            (word_IP_DST_LO),



         .reset                     (~axis_resetn),
         .clk                       (axis_aclk)
         );

   eth_parser
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) eth_parser
       (

	 .tdata			(s_axis_tdata),



         .is_arp_pkt            (is_arp_pkt), 
         .is_ip_pkt             (is_ip_pkt),
         .is_for_us             (is_for_us),
         .is_broadcast          (is_broadcast),
         .mac_dst_port_num      (mac_dst_port_num),


         .eth_parser_rd_info    (rd_preprocess_info),


         .eth_parser_info_vld   (eth_parser_info_vld),



         .word_IP_DST_HI        (word_IP_DST_HI),



         .mac_0                 (mac_0),
         .mac_1                 (mac_1),
         .mac_2                 (mac_2),
         .mac_3                 (mac_3),



         .reset                 (~axis_resetn),
         .clk                   (axis_aclk)
         );


   ip_lpm
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) ip_lpm
       (

	 .tdata		       (s_axis_tdata),



         .next_hop_ip          (next_hop_ip),
         .lpm_output_port      (lpm_output_port),
         .lpm_vld              (lpm_vld),
         .lpm_hit              (lpm_hit),


         .arp_done	       (arp_done),


         .dest_fifo_nearly_full(dest_fifo_nearly_full),



         .word_IP_DST_HI       (word_IP_DST_HI),
         .word_IP_DST_LO       (word_IP_DST_LO),




         .lpm_rd_addr          (lpm_rd_addr),
         .lpm_rd_req           (lpm_rd_req),


         .lpm_rd_ip            (lpm_rd_ip),
         .lpm_rd_mask          (lpm_rd_mask),
         .lpm_rd_oq            (lpm_rd_oq),
         .lpm_rd_next_hop_ip   (lpm_rd_next_hop_ip),
         .lpm_rd_ack           (lpm_rd_ack),



         .lpm_wr_addr          (lpm_wr_addr),
         .lpm_wr_req           (lpm_wr_req),
         .lpm_wr_oq            (lpm_wr_oq),
         .lpm_wr_next_hop_ip   (lpm_wr_next_hop_ip),
         .lpm_wr_ip            (lpm_wr_ip),
         .lpm_wr_mask          (lpm_wr_mask),

         .lpm_wr_ack           (lpm_wr_ack),



         .reset                (~axis_resetn | reset_tables[1]),
         .clk                  (axis_aclk)
         );


   ip_arp
     #(.NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) ip_arp
       (
         .next_hop_ip       (next_hop_ip),
         .lpm_output_port   (lpm_output_port),
         .lpm_vld           (lpm_vld),
         .lpm_hit           (lpm_hit),
         .arp_done	    (arp_done),


         .next_hop_mac      (next_hop_mac),
         .output_port       (output_port),
         .arp_mac_vld       (arp_mac_vld),
         .rd_arp_result     (rd_preprocess_info),
         .arp_lookup_hit    (arp_lookup_hit),
         .lpm_lookup_hit    (lpm_lookup_hit),



         .arp_rd_addr       (arp_rd_addr),
         .arp_rd_req        (arp_rd_req),
         .arp_rd_mac        (arp_rd_mac),
         .arp_rd_ip         (arp_rd_ip),
         .arp_rd_ack        (arp_rd_ack),


         .arp_wr_addr       (arp_wr_addr),
         .arp_wr_req        (arp_wr_req),
         .arp_wr_mac        (arp_wr_mac),
         .arp_wr_ip         (arp_wr_ip),
         .arp_wr_ack        (arp_wr_ack),


         .reset             (~axis_resetn | reset_tables[2]),
         .clk               (axis_aclk)
         );

   dest_ip_filter
     dest_ip_filter
       (
	 .tdata		       	   (s_axis_tdata),


         .word_IP_DST_HI           (word_IP_DST_HI),
         .word_IP_DST_LO           (word_IP_DST_LO),


         .dest_ip_hit              (dest_ip_hit),
         .dest_ip_filter_vld       (dest_ip_filter_vld),
         .rd_dest_ip_filter_result (rd_preprocess_info),



         .dest_ip_filter_rd_addr   (dest_ip_filter_rd_addr),
         .dest_ip_filter_rd_req    (dest_ip_filter_rd_req),
         .dest_ip_filter_rd_ip     (dest_ip_filter_rd_ip),
         .dest_ip_filter_rd_ack    (dest_ip_filter_rd_ack),


         .dest_ip_filter_wr_addr   (dest_ip_filter_wr_addr),
         .dest_ip_filter_wr_req    (dest_ip_filter_wr_req),
         .dest_ip_filter_wr_ip     (dest_ip_filter_wr_ip),
         .dest_ip_filter_wr_ack    (dest_ip_filter_wr_ack),


         .reset                    (~axis_resetn | reset_tables[3]),
         .clk                      (axis_aclk)
         );


   ip_checksum_ttl
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH)
       ) ip_checksum_ttl
       (
	 .tdata		       	    (s_axis_tdata),
         .valid		    	    (s_axis_tvalid & ~in_fifo_nearly_full),


         .word_IP_DST_HI            (word_IP_DST_HI),
         .word_IP_DST_LO            (word_IP_DST_LO),


         .ip_checksum_vld           (ip_checksum_vld),
         .ip_checksum_is_good       (ip_checksum_is_good),
         .ip_hdr_has_options        (ip_hdr_has_options),
         .ip_ttl_is_good            (ip_ttl_is_good),
         .ip_new_ttl                (ip_new_ttl),
         .ip_new_checksum           (ip_new_checksum),
         .rd_checksum               (rd_preprocess_info),


         .reset                     (~axis_resetn),
         .clk                       (axis_aclk)
         );


   op_lut_hdr_parser
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .C_S_AXIS_TUSER_WIDTH (C_S_AXIS_TUSER_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) op_lut_hdr_parser
       (
	  .tdata		(s_axis_tdata),
          .tuser		(s_axis_tuser),
          .valid		(s_axis_tvalid & ~in_fifo_nearly_full),
	  .tlast		(s_axis_tlast),


         .is_from_cpu           (is_from_cpu),
         .to_cpu_output_port    (to_cpu_output_port),
         .from_cpu_output_port  (from_cpu_output_port),
         .input_port_num        (input_port_num),
         .rd_hdr_parser         (rd_preprocess_info),
         .is_from_cpu_vld       (is_from_cpu_vld),


         .reset                 (~axis_resetn),
         .clk                   (axis_aclk)
         );


   op_lut_process_sm
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .C_S_AXIS_TUSER_WIDTH (C_S_AXIS_TUSER_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) op_lut_process_sm
       (
         .in_fifo_vld                   (!in_fifo_empty),
         .in_fifo_tdata                 (in_fifo_tdata),
	 .in_fifo_tlast			(in_fifo_tlast),
	 .in_fifo_tuser			(in_fifo_tuser),
	 .in_fifo_keep			(in_fifo_tkeep),
         .in_fifo_rd_en                 (in_fifo_rd_en),


         .is_arp_pkt                    (is_arp_pkt),
         .is_ip_pkt                     (is_ip_pkt),
         .is_for_us                     (is_for_us),
         .is_broadcast                  (is_broadcast),
         .mac_dst_port_num              (mac_dst_port_num),
         .eth_parser_info_vld           (eth_parser_info_vld),


         .next_hop_mac                  (next_hop_mac),
         .output_port                   (output_port),
         .arp_mac_vld                   (arp_mac_vld),
         .arp_lookup_hit                (arp_lookup_hit),
         .lpm_lookup_hit                (lpm_lookup_hit),


         .is_from_cpu                   (is_from_cpu),
         .to_cpu_output_port            (to_cpu_output_port),
         .from_cpu_output_port          (from_cpu_output_port),
         .is_from_cpu_vld               (is_from_cpu_vld),
         .input_port_num                (input_port_num),


         .dest_ip_hit                   (dest_ip_hit),
         .dest_ip_filter_vld            (dest_ip_filter_vld),


         .ip_checksum_vld               (ip_checksum_vld),
         .ip_checksum_is_good           (ip_checksum_is_good),
         .ip_new_checksum               (ip_new_checksum),
         .ip_ttl_is_good                (ip_ttl_is_good),
         .ip_new_ttl                    (ip_new_ttl),
         .ip_hdr_has_options            (ip_hdr_has_options),


         .rd_preprocess_info            (rd_preprocess_info),


         .out_tvalid                    (m_axis_tvalid),
         .out_tlast 	                (m_axis_tlast),
         .out_tdata                     (m_axis_tdata),
         .out_tuser                     (m_axis_tuser),
         .out_tready                    (m_axis_tready),
	 .out_keep			(m_axis_tkeep),


         .pkt_sent_from_cpu             (pkt_sent_from_cpu),
         .pkt_sent_to_cpu_options_ver   (pkt_sent_to_cpu_options_ver),
         .pkt_sent_to_cpu_bad_ttl       (pkt_sent_to_cpu_bad_ttl),
         .pkt_sent_to_cpu_dest_ip_hit   (pkt_sent_to_cpu_dest_ip_hit),
         .pkt_forwarded                 (pkt_forwarded),
         .pkt_dropped_checksum          (pkt_dropped_checksum),
         .pkt_sent_to_cpu_non_ip        (pkt_sent_to_cpu_non_ip),
         .pkt_sent_to_cpu_arp_miss      (pkt_sent_to_cpu_arp_miss),
         .pkt_sent_to_cpu_lpm_miss      (pkt_sent_to_cpu_lpm_miss),
         .pkt_dropped_wrong_dst_mac     (pkt_dropped_wrong_dst_mac),
         .mac_0                         (mac_0),
         .mac_1                         (mac_1),
         .mac_2                         (mac_2),
         .mac_3                         (mac_3),


         .reset                         (~axis_resetn),
         .clk                           (axis_aclk)
         );



endmodule
module output_port_lookup
#(

    parameter C_M_AXIS_DATA_WIDTH	= 256,
    parameter C_S_AXIS_DATA_WIDTH	= 256,
    parameter C_M_AXIS_TUSER_WIDTH	= 128,
    parameter C_S_AXIS_TUSER_WIDTH	= 128,
    parameter NUM_OUTPUT_QUEUES		= 8,
    parameter NUM_OUTPUT_QUEUES_WIDTH	= log2(NUM_OUTPUT_QUEUES),
    parameter LPM_LUT_DEPTH		= 32,
    parameter LPM_LUT_DEPTH_BITS 	= log2(LPM_LUT_DEPTH),
    parameter ARP_LUT_DEPTH 		= 32,
    parameter ARP_LUT_DEPTH_BITS	= log2(ARP_LUT_DEPTH),
    parameter FILTER_DEPTH		= 32,
    parameter FILTER_DEPTH_BITS		= log2(FILTER_DEPTH)
)
(

    input axis_aclk,
    input axis_resetn,


    output [C_M_AXIS_DATA_WIDTH - 1:0]		m_axis_tdata,
    output [((C_M_AXIS_DATA_WIDTH / 8)) - 1:0]	m_axis_tkeep,
    output [C_M_AXIS_TUSER_WIDTH-1:0]		m_axis_tuser,
    output m_axis_tvalid,
    input  m_axis_tready,
    output m_axis_tlast,


    input [C_S_AXIS_DATA_WIDTH - 1:0]		s_axis_tdata,
    input [((C_S_AXIS_DATA_WIDTH / 8)) - 1:0]	s_axis_tkeep,
    input [C_S_AXIS_TUSER_WIDTH-1:0]		s_axis_tuser,
    input  s_axis_tvalid,
    output s_axis_tready,
    input  s_axis_tlast,


    output                               pkt_sent_from_cpu,
    output                               pkt_sent_to_cpu_options_ver,
    output                               pkt_sent_to_cpu_bad_ttl,
    output                               pkt_sent_to_cpu_dest_ip_hit,
    output                               pkt_forwarded     ,
    output                               pkt_dropped_checksum,
    output                               pkt_sent_to_cpu_non_ip,
    output                               pkt_sent_to_cpu_arp_miss,
    output                               pkt_sent_to_cpu_lpm_miss,
    output                               pkt_dropped_wrong_dst_mac,


    input [LPM_LUT_DEPTH_BITS-1:0]       lpm_rd_addr,
    input                                lpm_rd_req,
    output [31:0]                        lpm_rd_ip,
    output [31:0]                        lpm_rd_mask,
    output [NUM_OUTPUT_QUEUES-1:0]       lpm_rd_oq,
    output [31:0]                        lpm_rd_next_hop_ip,
    output                               lpm_rd_ack,
    input [LPM_LUT_DEPTH_BITS-1:0]       lpm_wr_addr,
    input                                lpm_wr_req,
    input [NUM_OUTPUT_QUEUES-1:0]        lpm_wr_oq,
    input [31:0]                         lpm_wr_next_hop_ip,
    input [31:0]                         lpm_wr_ip,
    input [31:0]                         lpm_wr_mask,
    output                               lpm_wr_ack,


    input [ARP_LUT_DEPTH_BITS-1:0]       arp_rd_addr,
    input                                arp_rd_req,
    output  [47:0]                       arp_rd_mac,
    output  [31:0]                       arp_rd_ip,
    output                               arp_rd_ack,
    input [ARP_LUT_DEPTH_BITS-1:0]       arp_wr_addr,
    input                                arp_wr_req,
    input [47:0]                         arp_wr_mac,
    input [31:0]                         arp_wr_ip,
    output                               arp_wr_ack,


    input [FILTER_DEPTH_BITS-1:0]        dest_ip_filter_rd_addr,
    input                                dest_ip_filter_rd_req,
    output [31:0]                        dest_ip_filter_rd_ip,
    output                               dest_ip_filter_rd_ack,
    input [FILTER_DEPTH_BITS-1:0]        dest_ip_filter_wr_addr,
    input                                dest_ip_filter_wr_req,
    input [31:0]                         dest_ip_filter_wr_ip,
    output                               dest_ip_filter_wr_ack,


    input [47:0]                         mac_0,
    input [47:0]                         mac_1,
    input [47:0]                         mac_2,
    input [47:0]                         mac_3,


    input [3:0]				 reset_tables

);


   function integer log2;
      input integer number;
      begin
         log2=0;
         while(2**log2<number) begin
            log2=log2+1;
         end
      end
   endfunction






   wire [NUM_OUTPUT_QUEUES_WIDTH-1:0] 	mac_dst_port_num;
   wire [31:0]                 		next_hop_ip;

   wire [NUM_OUTPUT_QUEUES-1:0]       	lpm_output_port;

   wire [47:0]                 		next_hop_mac;
   wire [NUM_OUTPUT_QUEUES-1:0]       	output_port;
   
   wire [7:0]                  		ip_new_ttl;
   wire [15:0]                 		ip_new_checksum;

   wire [NUM_OUTPUT_QUEUES-1:0]       	to_cpu_output_port;
   wire [NUM_OUTPUT_QUEUES-1:0]       	from_cpu_output_port;
   wire [NUM_OUTPUT_QUEUES_WIDTH-1:0] 	input_port_num;

   wire [C_M_AXIS_DATA_WIDTH-1:0]	in_fifo_tdata;
   wire [C_M_AXIS_TUSER_WIDTH-1:0]	in_fifo_tuser;
   wire [C_M_AXIS_DATA_WIDTH/8-1:0]	in_fifo_tkeep;
   wire					in_fifo_tlast;

   wire                        		in_fifo_nearly_full;
   wire			       		arp_done;
   wire			       		dest_fifo_nearly_full;


   assign s_axis_tready = ~in_fifo_nearly_full & ~dest_fifo_nearly_full;
   

   

   fallthrough_small_fifo #(.WIDTH(C_M_AXIS_DATA_WIDTH+C_M_AXIS_TUSER_WIDTH+C_M_AXIS_DATA_WIDTH/8+1), .MAX_DEPTH_BITS(3))
      input_fifo
        (.din ({s_axis_tlast, s_axis_tuser, s_axis_tkeep, s_axis_tdata}),
         .wr_en (s_axis_tvalid & ~in_fifo_nearly_full),
         .rd_en (in_fifo_rd_en),
         .dout ({in_fifo_tlast, in_fifo_tuser, in_fifo_tkeep, in_fifo_tdata}),
         .full (),
         .prog_full (),
         .nearly_full (in_fifo_nearly_full),
         .empty (in_fifo_empty),
         .reset (~axis_resetn),
         .clk (axis_aclk)
         );

  preprocess_control
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH)
       ) preprocess_control
       (

	  .tdata		    (s_axis_tdata),
          .valid		    (s_axis_tvalid & ~in_fifo_nearly_full),
	  .tlast		    (s_axis_tlast),



         .word_IP_DST_HI            (word_IP_DST_HI),
         .word_IP_DST_LO            (word_IP_DST_LO),



         .reset                     (~axis_resetn),
         .clk                       (axis_aclk)
         );

   eth_parser
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) eth_parser
       (

	 .tdata			(s_axis_tdata),



         .is_arp_pkt            (is_arp_pkt), 
         .is_ip_pkt             (is_ip_pkt),
         .is_for_us             (is_for_us),
         .is_broadcast          (is_broadcast),
         .mac_dst_port_num      (mac_dst_port_num),


         .eth_parser_rd_info    (rd_preprocess_info),


         .eth_parser_info_vld   (eth_parser_info_vld),



         .word_IP_DST_HI        (word_IP_DST_HI),



         .mac_0                 (mac_0),
         .mac_1                 (mac_1),
         .mac_2                 (mac_2),
         .mac_3                 (mac_3),



         .reset                 (~axis_resetn),
         .clk                   (axis_aclk)
         );


   ip_lpm
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) ip_lpm
       (

	 .tdata		       (s_axis_tdata),



         .next_hop_ip          (next_hop_ip),
         .lpm_output_port      (lpm_output_port),
         .lpm_vld              (lpm_vld),
         .lpm_hit              (lpm_hit),


         .arp_done	       (arp_done),


         .dest_fifo_nearly_full(dest_fifo_nearly_full),



         .word_IP_DST_HI       (word_IP_DST_HI),
         .word_IP_DST_LO       (word_IP_DST_LO),




         .lpm_rd_addr          (lpm_rd_addr),
         .lpm_rd_req           (lpm_rd_req),


         .lpm_rd_ip            (lpm_rd_ip),
         .lpm_rd_mask          (lpm_rd_mask),
         .lpm_rd_oq            (lpm_rd_oq),
         .lpm_rd_next_hop_ip   (lpm_rd_next_hop_ip),
         .lpm_rd_ack           (lpm_rd_ack),



         .lpm_wr_addr          (lpm_wr_addr),
         .lpm_wr_req           (lpm_wr_req),
         .lpm_wr_oq            (lpm_wr_oq),
         .lpm_wr_next_hop_ip   (lpm_wr_next_hop_ip),
         .lpm_wr_ip            (lpm_wr_ip),
         .lpm_wr_mask          (lpm_wr_mask),

         .lpm_wr_ack           (lpm_wr_ack),



         .reset                (~axis_resetn | reset_tables[1]),
         .clk                  (axis_aclk)
         );


   ip_arp
     #(.NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) ip_arp
       (
         .next_hop_ip       (next_hop_ip),
         .lpm_output_port   (lpm_output_port),
         .lpm_vld           (lpm_vld),
         .lpm_hit           (lpm_hit),
         .arp_done	    (arp_done),


         .next_hop_mac      (next_hop_mac),
         .output_port       (output_port),
         .arp_mac_vld       (arp_mac_vld),
         .rd_arp_result     (rd_preprocess_info),
         .arp_lookup_hit    (arp_lookup_hit),
         .lpm_lookup_hit    (lpm_lookup_hit),



         .arp_rd_addr       (arp_rd_addr),
         .arp_rd_req        (arp_rd_req),
         .arp_rd_mac        (arp_rd_mac),
         .arp_rd_ip         (arp_rd_ip),
         .arp_rd_ack        (arp_rd_ack),


         .arp_wr_addr       (arp_wr_addr),
         .arp_wr_req        (arp_wr_req),
         .arp_wr_mac        (arp_wr_mac),
         .arp_wr_ip         (arp_wr_ip),
         .arp_wr_ack        (arp_wr_ack),


         .reset             (~axis_resetn | reset_tables[2]),
         .clk               (axis_aclk)
         );

   dest_ip_filter
     dest_ip_filter
       (
	 .tdata		       	   (s_axis_tdata),


         .word_IP_DST_HI           (word_IP_DST_HI),
         .word_IP_DST_LO           (word_IP_DST_LO),


         .dest_ip_hit              (dest_ip_hit),
         .dest_ip_filter_vld       (dest_ip_filter_vld),
         .rd_dest_ip_filter_result (rd_preprocess_info),



         .dest_ip_filter_rd_addr   (dest_ip_filter_rd_addr),
         .dest_ip_filter_rd_req    (dest_ip_filter_rd_req),
         .dest_ip_filter_rd_ip     (dest_ip_filter_rd_ip),
         .dest_ip_filter_rd_ack    (dest_ip_filter_rd_ack),


         .dest_ip_filter_wr_addr   (dest_ip_filter_wr_addr),
         .dest_ip_filter_wr_req    (dest_ip_filter_wr_req),
         .dest_ip_filter_wr_ip     (dest_ip_filter_wr_ip),
         .dest_ip_filter_wr_ack    (dest_ip_filter_wr_ack),


         .reset                    (~axis_resetn | reset_tables[3]),
         .clk                      (axis_aclk)
         );


   ip_checksum_ttl
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH)
       ) ip_checksum_ttl
       (
	 .tdata		       	    (s_axis_tdata),
         .valid		    	    (s_axis_tvalid & ~in_fifo_nearly_full),


         .word_IP_DST_HI            (word_IP_DST_HI),
         .word_IP_DST_LO            (word_IP_DST_LO),


         .ip_checksum_vld           (ip_checksum_vld),
         .ip_checksum_is_good       (ip_checksum_is_good),
         .ip_hdr_has_options        (ip_hdr_has_options),
         .ip_ttl_is_good            (ip_ttl_is_good),
         .ip_new_ttl                (ip_new_ttl),
         .ip_new_checksum           (ip_new_checksum),
         .rd_checksum               (rd_preprocess_info),


         .reset                     (~axis_resetn),
         .clk                       (axis_aclk)
         );


   op_lut_hdr_parser
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .C_S_AXIS_TUSER_WIDTH (C_S_AXIS_TUSER_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) op_lut_hdr_parser
       (
	  .tdata		(s_axis_tdata),
          .tuser		(s_axis_tuser),
          .valid		(s_axis_tvalid & ~in_fifo_nearly_full),
	  .tlast		(s_axis_tlast),


         .is_from_cpu           (is_from_cpu),
         .to_cpu_output_port    (to_cpu_output_port),
         .from_cpu_output_port  (from_cpu_output_port),
         .input_port_num        (input_port_num),
         .rd_hdr_parser         (rd_preprocess_info),
         .is_from_cpu_vld       (is_from_cpu_vld),


         .reset                 (~axis_resetn),
         .clk                   (axis_aclk)
         );


   op_lut_process_sm
     #(.C_S_AXIS_DATA_WIDTH (C_S_AXIS_DATA_WIDTH),
       .C_S_AXIS_TUSER_WIDTH (C_S_AXIS_TUSER_WIDTH),
       .NUM_QUEUES(NUM_OUTPUT_QUEUES)
       ) op_lut_process_sm
       (
         .in_fifo_vld                   (!in_fifo_empty),
         .in_fifo_tdata                 (in_fifo_tdata),
	 .in_fifo_tlast			(in_fifo_tlast),
	 .in_fifo_tuser			(in_fifo_tuser),
	 .in_fifo_keep			(in_fifo_tkeep),
         .in_fifo_rd_en                 (in_fifo_rd_en),


         .is_arp_pkt                    (is_arp_pkt),
         .is_ip_pkt                     (is_ip_pkt),
         .is_for_us                     (is_for_us),
         .is_broadcast                  (is_broadcast),
         .mac_dst_port_num              (mac_dst_port_num),
         .eth_parser_info_vld           (eth_parser_info_vld),


         .next_hop_mac                  (next_hop_mac),
         .output_port                   (output_port),
         .arp_mac_vld                   (arp_mac_vld),
         .arp_lookup_hit                (arp_lookup_hit),
         .lpm_lookup_hit                (lpm_lookup_hit),


         .is_from_cpu                   (is_from_cpu),
         .to_cpu_output_port            (to_cpu_output_port),
         .from_cpu_output_port          (from_cpu_output_port),
         .is_from_cpu_vld               (is_from_cpu_vld),
         .input_port_num                (input_port_num),


         .dest_ip_hit                   (dest_ip_hit),
         .dest_ip_filter_vld            (dest_ip_filter_vld),


         .ip_checksum_vld               (ip_checksum_vld),
         .ip_checksum_is_good           (ip_checksum_is_good),
         .ip_new_checksum               (ip_new_checksum),
         .ip_ttl_is_good                (ip_ttl_is_good),
         .ip_new_ttl                    (ip_new_ttl),
         .ip_hdr_has_options            (ip_hdr_has_options),


         .rd_preprocess_info            (rd_preprocess_info),


         .out_tvalid                    (m_axis_tvalid),
         .out_tlast 	                (m_axis_tlast),
         .out_tdata                     (m_axis_tdata),
         .out_tuser                     (m_axis_tuser),
         .out_tready                    (m_axis_tready),
	 .out_keep			(m_axis_tkeep),


         .pkt_sent_from_cpu             (pkt_sent_from_cpu),
         .pkt_sent_to_cpu_options_ver   (pkt_sent_to_cpu_options_ver),
         .pkt_sent_to_cpu_bad_ttl       (pkt_sent_to_cpu_bad_ttl),
         .pkt_sent_to_cpu_dest_ip_hit   (pkt_sent_to_cpu_dest_ip_hit),
         .pkt_forwarded                 (pkt_forwarded),
         .pkt_dropped_checksum          (pkt_dropped_checksum),
         .pkt_sent_to_cpu_non_ip        (pkt_sent_to_cpu_non_ip),
         .pkt_sent_to_cpu_arp_miss      (pkt_sent_to_cpu_arp_miss),
         .pkt_sent_to_cpu_lpm_miss      (pkt_sent_to_cpu_lpm_miss),
         .pkt_dropped_wrong_dst_mac     (pkt_dropped_wrong_dst_mac),
         .mac_0                         (mac_0),
         .mac_1                         (mac_1),
         .mac_2                         (mac_2),
         .mac_3                         (mac_3),


         .reset                         (~axis_resetn),
         .clk                           (axis_aclk)
         );



endmodule