data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v
[Errno 2] No such file or directory: 'preprocess.output'
1: b"%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:89: Define or directive not defined: '`LOG2_FUNC'\n   `LOG2_FUNC\n   ^~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:90: Define or directive not defined: '`CEILDIV_FUNC'\n   `CEILDIV_FUNC\n   ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:95: Define or directive not defined: '`OPENFLOW_ACTION_WIDTH'\n   localparam OPENFLOW_ACTION_WIDTH          = `OPENFLOW_ACTION_WIDTH ;\n                                               ^~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:95: syntax error, unexpected ';', expecting TYPE-IDENTIFIER\n   localparam OPENFLOW_ACTION_WIDTH          = `OPENFLOW_ACTION_WIDTH ;\n                                                                      ^\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:96: Define or directive not defined: '`OPENFLOW_ENTRY_SRC_PORT_WIDTH'\n   localparam OPENFLOW_ENTRY_SRC_PORT_WIDTH  = `OPENFLOW_ENTRY_SRC_PORT_WIDTH ;\n                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:96: syntax error, unexpected ';', expecting TYPE-IDENTIFIER\n   localparam OPENFLOW_ENTRY_SRC_PORT_WIDTH  = `OPENFLOW_ENTRY_SRC_PORT_WIDTH ;\n                                                                              ^\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:97: Define or directive not defined: '`PRIO_WIDTH'\n   localparam PRIO_WIDTH                     = `PRIO_WIDTH ;\n                                               ^~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:97: syntax error, unexpected ';', expecting TYPE-IDENTIFIER\n   localparam PRIO_WIDTH                     = `PRIO_WIDTH ;\n                                                           ^\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:98: Define or directive not defined: '`ACTION_WIDTH'\n   localparam ACTION_WIDTH                   = `ACTION_WIDTH ;\n                                               ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:98: syntax error, unexpected ';', expecting TYPE-IDENTIFIER\n   localparam ACTION_WIDTH                   = `ACTION_WIDTH ;\n                                                             ^\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:99: Define or directive not defined: '`OPENFLOW_ENTRY_WIDTH_ALL'\n   localparam OPENFLOW_ENTRY_WIDTH_ALL       = `OPENFLOW_ENTRY_WIDTH_ALL ;\n                                               ^~~~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:99: syntax error, unexpected ';', expecting TYPE-IDENTIFIER\n   localparam OPENFLOW_ENTRY_WIDTH_ALL       = `OPENFLOW_ENTRY_WIDTH_ALL ;\n                                                                         ^\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:139: Define or directive not defined: '`PRIO_WIDTH'\n   wire  [`PRIO_WIDTH-1:0]                             bram_addr            ;\n          ^~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:143: Define or directive not defined: '`PRIO_WIDTH'\n   wire  [`PRIO_WIDTH - 1:0]                           tcam_addr_out        ;\n          ^~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:205: Define or directive not defined: '`OPENFLOW_ENTRY_VLAN_ID_WIDTH'\n     .ADDITIONAL_WORD_SIZE        (`OPENFLOW_ENTRY_VLAN_ID_WIDTH),\n                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:206: Define or directive not defined: '`OPENFLOW_ENTRY_VLAN_ID_POS'\n     .ADDITIONAL_WORD_POS         (`OPENFLOW_ENTRY_VLAN_ID_POS),\n                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:208: Define or directive not defined: '`VLAN_CTRL_WORD'\n     .ADDITIONAL_WORD_CTRL        (`VLAN_CTRL_WORD),\n                                   ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/121277233/ons20-app52-ref_ofshw/vivado/onets_7020_4x_ref_ofshw/ip/packet_pipeline_v1_0/src/user_data_path/output_port_lookup.v:496: Define or directive not defined: '`FAST_CLOCK_PERIOD'\n         if(ns_counter == (1_000_000_000/`FAST_CLOCK_PERIOD - 1'b1)) begin\n                                         ^~~~~~~~~~~~~~~~~~\n%Error: Exiting due to 18 error(s)\n"
module output_port_lookup
    #(parameter DATA_WIDTH = 64,
      parameter CTRL_WIDTH=DATA_WIDTH/8,
      parameter NUM_OUTPUT_QUEUES = 8,
      parameter OPENFLOW_ENTRY_WIDTH = 64,
      parameter OPENFLOW_WILDCARD_TABLE_SIZE = 16,
      parameter CURRENT_TABLE_ID = 0,
      parameter TABLE_NUM=2
   )

   (
    output     [DATA_WIDTH-1:0]        out_data,
    output     [CTRL_WIDTH-1:0]        out_ctrl,
    output                             out_wr,
    input                              out_rdy,

    input  [DATA_WIDTH-1:0]            in_data,
    input  [CTRL_WIDTH-1:0]            in_ctrl,
    input                              in_wr,
    output                             in_rdy,
    

    input [31:0]                       data_output_port_lookup_i,
    input [31:0]                       addr_output_port_lookup_i,
    input                              req_output_port_lookup_i,
    input                              rw_output_port_lookup_i,
    output                             ack_output_port_lookup_o,
    output [31:0]                      data_output_port_lookup_o,

    input                           config_sw_ok,

    input                              table_flush,


    input                              clk,
    input                              reset);

   `LOG2_FUNC
   `CEILDIV_FUNC


   localparam PKT_SIZE_WIDTH                 = 12;
   localparam OPENFLOW_WILDCARD_TABLE_DEPTH  = log2(OPENFLOW_WILDCARD_TABLE_SIZE);
   localparam OPENFLOW_ACTION_WIDTH          = `OPENFLOW_ACTION_WIDTH ;
   localparam OPENFLOW_ENTRY_SRC_PORT_WIDTH  = `OPENFLOW_ENTRY_SRC_PORT_WIDTH ;
   localparam PRIO_WIDTH                     = `PRIO_WIDTH ;
   localparam ACTION_WIDTH                   = `ACTION_WIDTH ;
   localparam OPENFLOW_ENTRY_WIDTH_ALL       = `OPENFLOW_ENTRY_WIDTH_ALL ;



   wire  [DATA_WIDTH-1:0]                             wildcard_out_data    ;
   wire  [CTRL_WIDTH-1:0]                             wildcard_out_ctrl    ;
   wire                                               wildcard_out_wr      ;
   wire                                               wildcard_out_rdy     ;
   
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  actions              ;
   wire                                               actions_en           ;
   
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  exact_data;
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  wildcard_data;       

   wire  [CTRL_WIDTH-1:0]                             in_fifo_ctrl         ;
   wire  [DATA_WIDTH-1:0]                             in_fifo_data         ;

   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                   flow_entry                 ;
   wire  [OPENFLOW_ENTRY_SRC_PORT_WIDTH-1:0]          flow_entry_src_port_parsed ;
   wire  [OPENFLOW_ENTRY_SRC_PORT_WIDTH-1:0]          flow_entry_src_port        ;
   wire  [PKT_SIZE_WIDTH-1:0]                         pkt_size                   ;

   reg   [31:0]                                       s_counter            ;
   reg   [27:0]                                       ns_counter           ;

   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  result_fifo_dout     ;

   wire  [NUM_OUTPUT_QUEUES-1:0]                      pkts_dropped         ;
   

   wire                                               wildcard_wins        ;
   
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          wildcard_address     ;
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          metadata_fifo_dout   ;
   
   wire                                               skip_lookup          ;

   wire                                               bram_cs              ;
   wire                                               bram_we              ;
   wire  [`PRIO_WIDTH-1:0]                             bram_addr            ;
   wire  [319:0]                                      lut_actions_in       ;
   wire  [319:0]                                      lut_actions_out      ;   
   
   wire  [`PRIO_WIDTH - 1:0]                           tcam_addr_out        ;
   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                             tcam_data_out        ;
   wire  [OPENFLOW_ENTRY_WIDTH-1:0]                              tcam_data_mask_out   ;
   wire                                               tcam_we              ;
   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                             tcam_data_in         ;
   wire  [OPENFLOW_ENTRY_WIDTH-1:0]                              tcam_data_mask_in    ;   
   
   wire  [7:0]                                        head_combine         ;
   
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          counter_addr_out     ;
   wire                                               counter_addr_rd      ;
   wire  [31:0]                                       pkt_counter_in       ;
   wire  [31:0]                                       byte_counter_in      ;  
   wire                                               wildcard_hit_dout    ;
   wire                                               actions_hit          ;
   wire  [3:0]                                        src_port             ;
   



    


    small_fifo 
    #(.WIDTH            (DATA_WIDTH+CTRL_WIDTH),
      .MAX_DEPTH_BITS   (5)
    )input_fifo
    (
      .din           ({in_ctrl, in_data}),
      .wr_en         (in_wr),
      .rd_en         (in_fifo_rd_en),
      .dout          ({in_fifo_ctrl, in_fifo_data}),
      .full          (),
      .prog_full     (),
      .nearly_full   (in_fifo_nearly_full),
      .empty         (in_fifo_empty),
      .reset         (reset),
      .clk           (clk)
    );


   header_parser
   #(.DATA_WIDTH                  (DATA_WIDTH),
     .CTRL_WIDTH                  (CTRL_WIDTH),
     .PKT_SIZE_WIDTH              (PKT_SIZE_WIDTH),
     .ADDITIONAL_WORD_SIZE        (`OPENFLOW_ENTRY_VLAN_ID_WIDTH),
     .ADDITIONAL_WORD_POS         (`OPENFLOW_ENTRY_VLAN_ID_POS),
     .ADDITIONAL_WORD_BITMASK     (16'hEFFF),
     .ADDITIONAL_WORD_CTRL        (`VLAN_CTRL_WORD),
     .ADDITIONAL_WORD_DEFAULT     (16'hFFFF),
     .FLOW_ENTRY_SIZE_ALL         (OPENFLOW_ENTRY_WIDTH_ALL),
     .OPENFLOW_ENTRY_WIDTH        (OPENFLOW_ENTRY_WIDTH+32),
     .CURRENT_TABLE_ID            (CURRENT_TABLE_ID)
   )
   header_parser
   (
      .in_data                   (in_data),
      .in_ctrl                   (in_ctrl),
      .in_wr                     (in_wr),
   

      .flow_entry                (flow_entry),

      .pkt_size                  (pkt_size),
      .flow_entry_vld            (flow_entry_vld),
      
      .skip_lookup                 (skip_lookup),
      
      .head_combine              (head_combine),

      .reset                     (reset),
      .clk                       (clk)             
   );

   wildcard_match
   #(.NUM_OUTPUT_QUEUES             (NUM_OUTPUT_QUEUES),
     .PKT_SIZE_WIDTH                (PKT_SIZE_WIDTH),
     .OPENFLOW_ENTRY_WIDTH          (OPENFLOW_ENTRY_WIDTH+32),
     .OPENFLOW_WILDCARD_TABLE_SIZE  (OPENFLOW_WILDCARD_TABLE_SIZE),
     .CURRENT_TABLE_ID              (CURRENT_TABLE_ID),
     .OPENFLOW_WILDCARD_TABLE_DEPTH (OPENFLOW_WILDCARD_TABLE_DEPTH),
     .CMP_WIDTH                     (OPENFLOW_ENTRY_WIDTH+32)

   ) wildcard_match
   (
      .flow_entry                           (flow_entry),
      .flow_entry_vld                       (flow_entry_vld),
      .wildcard_match_rdy                   (wildcard_match_rdy),
      .pkt_size                             (pkt_size),
 

      .wildcard_hit                          (wildcard_hit),
      .wildcard_data                         (wildcard_data[OPENFLOW_ACTION_WIDTH-1 : 0]),
      .wildcard_data_vld                     (wildcard_data_vld),
      
      .skip_lookup                           (skip_lookup),
      
      .openflow_timer                        (s_counter),
 


 
      .clk                                   (clk),
      .reset                                 (reset),
      .wildcard_address                      (wildcard_address),
    
      .bram_cs                               (bram_cs        ),
      .bram_we                               (bram_we        ),
      .bram_addr                             (bram_addr      ),
      .lut_actions_in                        (lut_actions_in ),
      .lut_actions_out                       (lut_actions_out),
      
      .tcam_addr                             (tcam_addr_out),
      .tcam_data_in                          (tcam_data_out),
      .tcam_data_mask_in                     (tcam_data_mask_out),
      .tcam_we                               (tcam_we      ),
      .tcam_data_out                         (tcam_data_in ),
      .tcam_data_mask_out                    (tcam_data_mask_in),
      
      .counter_addr_in                       (counter_addr_out),
      .counter_addr_rd                       (counter_addr_rd),
      .pkt_counter_out                       (pkt_counter_in),
      .byte_counter_out                      (byte_counter_in)
       
   );
   
   small_fifo
   #( .WIDTH                           (OPENFLOW_ACTION_WIDTH),
      .MAX_DEPTH_BITS                  (3)
    )result_fifo
    (
      .din           ({wildcard_data}),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (result_fifo_dout),
      .full          (),
      .nearly_full   (result_fifo_nearly_full),
      .prog_full     (),
      .empty         (result_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );
    
   small_fifo
   #( .WIDTH               (1),
      .MAX_DEPTH_BITS      (3)
   )wildcard_hit_fifo
   (
      .din           (wildcard_hit),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (wildcard_hit_dout),
      .full          (),
      .nearly_full   (result_fifo_nearly_full),
      .prog_full     (),
      .empty         (result_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );
                     
   small_fifo
   #(.WIDTH            (OPENFLOW_WILDCARD_TABLE_DEPTH),
     .MAX_DEPTH_BITS   (3)
    )metadata_fifo
   (
      .din           (wildcard_address),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (metadata_fifo_dout),
      .full          (),
      .nearly_full   (metadata_fifo_nearly_full),
      .prog_full     (),
      .empty         (metadata_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );


    wildcard_processor
    #(
      .TABLE_NUM        (TABLE_NUM),
      .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
    )wildcard_processor
    (
      .result_fifo_dout    (result_fifo_dout),
      .result_fifo_rd_en   (result_fifo_rd_en),
      .result_fifo_empty   (result_fifo_empty),
      

      .in_fifo_ctrl        (in_fifo_ctrl),
      .in_fifo_data        (in_fifo_data),
      .in_fifo_rd_en       (in_fifo_rd_en),
      .in_fifo_empty       (in_fifo_empty),
      

      .out_wr              (wildcard_out_wr),
      .out_rdy             (wildcard_out_rdy),
      .out_data            (wildcard_out_data),
      .out_ctrl            (wildcard_out_ctrl),
      
      .actions             (actions),
      .actions_en          (actions_en),
      .actions_hit         (actions_hit),
      .wildcard_hit_dout   (wildcard_hit_dout),
      .src_port            (src_port),
      
      .clk                 (clk),
      .reset               (reset),
      
      .skip_lookup         (skip_lookup)
   );
    
   action_processor 
   #(
       .TABLE_NUM        (TABLE_NUM),
       .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
   )action_processor
   (
       .actions_en       (actions_en),
       .actions_hit      (actions_hit),
       .actions          (actions),  
       .src_port         (src_port),
               
       .in_ctrl          (wildcard_out_ctrl),  
       .in_data          (wildcard_out_data),
       .in_rdy           (wildcard_out_rdy),   
       .in_wr            (wildcard_out_wr),
                    
       .out_data         (out_data),         
       .out_ctrl         (out_ctrl),
       .out_wr           (out_wr  ),
       .out_rdy          (out_rdy ),
       
       .config_sw_ok     (config_sw_ok),
                
       .clk              (clk),      
       .reset            (reset)
       
   );
     
   output_port_lookup_reg_master 
   #(
      .CMP_WIDTH  (OPENFLOW_ENTRY_WIDTH),
      .LUT_DEPTH(OPENFLOW_WILDCARD_TABLE_SIZE),
      .TABLE_NUM(TABLE_NUM-1),
      .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
   )
   output_port_lookup_reg_master
   (
   .data_output_port_lookup_i    (data_output_port_lookup_i),
   .addr_output_port_lookup_i    (addr_output_port_lookup_i),
   .req_output_port_lookup_i     (req_output_port_lookup_i ),
   .rw_output_port_lookup_i      (rw_output_port_lookup_i  ),
   .ack_output_port_lookup_o     (ack_output_port_lookup_o ),
   .data_output_port_lookup_o    (data_output_port_lookup_o  ),
   
   .bram_cs                      (bram_cs),
   .bram_we                      (bram_we),
   .bram_addr                    (bram_addr),
   .lut_actions_in               (lut_actions_in),
   .lut_actions_out              (lut_actions_out),
                
   .tcam_addr_out                (tcam_addr_out),
   .tcam_data_out                (tcam_data_out),
   .tcam_data_mask_out           (tcam_data_mask_out),
   .tcam_we                      (tcam_we),
   .tcam_data_in                 (tcam_data_in),
   .tcam_data_mask_in            (tcam_data_mask_in),
   
   .counter_addr_out             (counter_addr_out),
   .counter_addr_rd              (counter_addr_rd),
   .pkt_counter_in               (pkt_counter_in),
   .byte_counter_in              (byte_counter_in),
   
   .head_combine                 (head_combine),
      
   .clk                          (clk),
   .reset                        (reset)
   );


   assign in_rdy = !in_fifo_nearly_full && wildcard_match_rdy ;


   always @(posedge clk) begin
      if(reset) begin
         ns_counter <= 0;
         s_counter  <= 0;
      end
      else begin
         if(ns_counter == (1_000_000_000/`FAST_CLOCK_PERIOD - 1'b1)) begin
            s_counter  <= s_counter + 1'b1;
            ns_counter <= 0;
         end
         else begin
            ns_counter <= ns_counter + 1'b1;
         end
      end
   end


endmodule
module output_port_lookup
    #(parameter DATA_WIDTH = 64,
      parameter CTRL_WIDTH=DATA_WIDTH/8,
      parameter NUM_OUTPUT_QUEUES = 8,
      parameter OPENFLOW_ENTRY_WIDTH = 64,
      parameter OPENFLOW_WILDCARD_TABLE_SIZE = 16,
      parameter CURRENT_TABLE_ID = 0,
      parameter TABLE_NUM=2
   )

   (
    output     [DATA_WIDTH-1:0]        out_data,
    output     [CTRL_WIDTH-1:0]        out_ctrl,
    output                             out_wr,
    input                              out_rdy,

    input  [DATA_WIDTH-1:0]            in_data,
    input  [CTRL_WIDTH-1:0]            in_ctrl,
    input                              in_wr,
    output                             in_rdy,
    

    input [31:0]                       data_output_port_lookup_i,
    input [31:0]                       addr_output_port_lookup_i,
    input                              req_output_port_lookup_i,
    input                              rw_output_port_lookup_i,
    output                             ack_output_port_lookup_o,
    output [31:0]                      data_output_port_lookup_o,

    input                           config_sw_ok,

    input                              table_flush,


    input                              clk,
    input                              reset);


   `LOG2_FUNC
   `CEILDIV_FUNC


   localparam PKT_SIZE_WIDTH                 = 12;
   localparam OPENFLOW_WILDCARD_TABLE_DEPTH  = log2(OPENFLOW_WILDCARD_TABLE_SIZE);
   localparam OPENFLOW_ACTION_WIDTH          = `OPENFLOW_ACTION_WIDTH ;
   localparam OPENFLOW_ENTRY_SRC_PORT_WIDTH  = `OPENFLOW_ENTRY_SRC_PORT_WIDTH ;
   localparam PRIO_WIDTH                     = `PRIO_WIDTH ;
   localparam ACTION_WIDTH                   = `ACTION_WIDTH ;
   localparam OPENFLOW_ENTRY_WIDTH_ALL       = `OPENFLOW_ENTRY_WIDTH_ALL ;



   wire  [DATA_WIDTH-1:0]                             wildcard_out_data    ;
   wire  [CTRL_WIDTH-1:0]                             wildcard_out_ctrl    ;
   wire                                               wildcard_out_wr      ;
   wire                                               wildcard_out_rdy     ;
   
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  actions              ;
   wire                                               actions_en           ;
   
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  exact_data;
   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  wildcard_data;       

   wire  [CTRL_WIDTH-1:0]                             in_fifo_ctrl         ;
   wire  [DATA_WIDTH-1:0]                             in_fifo_data         ;

   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                   flow_entry                 ;
   wire  [OPENFLOW_ENTRY_SRC_PORT_WIDTH-1:0]          flow_entry_src_port_parsed ;
   wire  [OPENFLOW_ENTRY_SRC_PORT_WIDTH-1:0]          flow_entry_src_port        ;
   wire  [PKT_SIZE_WIDTH-1:0]                         pkt_size                   ;

   reg   [31:0]                                       s_counter            ;
   reg   [27:0]                                       ns_counter           ;

   wire  [OPENFLOW_ACTION_WIDTH-1:0]                  result_fifo_dout     ;

   wire  [NUM_OUTPUT_QUEUES-1:0]                      pkts_dropped         ;
   

   wire                                               wildcard_wins        ;
   
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          wildcard_address     ;
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          metadata_fifo_dout   ;
   
   wire                                               skip_lookup          ;

   wire                                               bram_cs              ;
   wire                                               bram_we              ;
   wire  [`PRIO_WIDTH-1:0]                             bram_addr            ;
   wire  [319:0]                                      lut_actions_in       ;
   wire  [319:0]                                      lut_actions_out      ;   
   
   wire  [`PRIO_WIDTH - 1:0]                           tcam_addr_out        ;
   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                             tcam_data_out        ;
   wire  [OPENFLOW_ENTRY_WIDTH-1:0]                              tcam_data_mask_out   ;
   wire                                               tcam_we              ;
   wire  [OPENFLOW_ENTRY_WIDTH+31:0]                             tcam_data_in         ;
   wire  [OPENFLOW_ENTRY_WIDTH-1:0]                              tcam_data_mask_in    ;   
   
   wire  [7:0]                                        head_combine         ;
   
   wire  [OPENFLOW_WILDCARD_TABLE_DEPTH-1:0]          counter_addr_out     ;
   wire                                               counter_addr_rd      ;
   wire  [31:0]                                       pkt_counter_in       ;
   wire  [31:0]                                       byte_counter_in      ;  
   wire                                               wildcard_hit_dout    ;
   wire                                               actions_hit          ;
   wire  [3:0]                                        src_port             ;
   



    


    small_fifo 
    #(.WIDTH            (DATA_WIDTH+CTRL_WIDTH),
      .MAX_DEPTH_BITS   (5)
    )input_fifo
    (
      .din           ({in_ctrl, in_data}),
      .wr_en         (in_wr),
      .rd_en         (in_fifo_rd_en),
      .dout          ({in_fifo_ctrl, in_fifo_data}),
      .full          (),
      .prog_full     (),
      .nearly_full   (in_fifo_nearly_full),
      .empty         (in_fifo_empty),
      .reset         (reset),
      .clk           (clk)
    );


   header_parser
   #(.DATA_WIDTH                  (DATA_WIDTH),
     .CTRL_WIDTH                  (CTRL_WIDTH),
     .PKT_SIZE_WIDTH              (PKT_SIZE_WIDTH),
     .ADDITIONAL_WORD_SIZE        (`OPENFLOW_ENTRY_VLAN_ID_WIDTH),
     .ADDITIONAL_WORD_POS         (`OPENFLOW_ENTRY_VLAN_ID_POS),
     .ADDITIONAL_WORD_BITMASK     (16'hEFFF),
     .ADDITIONAL_WORD_CTRL        (`VLAN_CTRL_WORD),
     .ADDITIONAL_WORD_DEFAULT     (16'hFFFF),
     .FLOW_ENTRY_SIZE_ALL         (OPENFLOW_ENTRY_WIDTH_ALL),
     .OPENFLOW_ENTRY_WIDTH        (OPENFLOW_ENTRY_WIDTH+32),
     .CURRENT_TABLE_ID            (CURRENT_TABLE_ID)
   )
   header_parser
   (
      .in_data                   (in_data),
      .in_ctrl                   (in_ctrl),
      .in_wr                     (in_wr),
   

      .flow_entry                (flow_entry),

      .pkt_size                  (pkt_size),
      .flow_entry_vld            (flow_entry_vld),
      
      .skip_lookup                 (skip_lookup),
      
      .head_combine              (head_combine),

      .reset                     (reset),
      .clk                       (clk)             
   );

   wildcard_match
   #(.NUM_OUTPUT_QUEUES             (NUM_OUTPUT_QUEUES),
     .PKT_SIZE_WIDTH                (PKT_SIZE_WIDTH),
     .OPENFLOW_ENTRY_WIDTH          (OPENFLOW_ENTRY_WIDTH+32),
     .OPENFLOW_WILDCARD_TABLE_SIZE  (OPENFLOW_WILDCARD_TABLE_SIZE),
     .CURRENT_TABLE_ID              (CURRENT_TABLE_ID),
     .OPENFLOW_WILDCARD_TABLE_DEPTH (OPENFLOW_WILDCARD_TABLE_DEPTH),
     .CMP_WIDTH                     (OPENFLOW_ENTRY_WIDTH+32)

   ) wildcard_match
   (
      .flow_entry                           (flow_entry),
      .flow_entry_vld                       (flow_entry_vld),
      .wildcard_match_rdy                   (wildcard_match_rdy),
      .pkt_size                             (pkt_size),
 

      .wildcard_hit                          (wildcard_hit),
      .wildcard_data                         (wildcard_data[OPENFLOW_ACTION_WIDTH-1 : 0]),
      .wildcard_data_vld                     (wildcard_data_vld),
      
      .skip_lookup                           (skip_lookup),
      
      .openflow_timer                        (s_counter),
 


 
      .clk                                   (clk),
      .reset                                 (reset),
      .wildcard_address                      (wildcard_address),
    
      .bram_cs                               (bram_cs        ),
      .bram_we                               (bram_we        ),
      .bram_addr                             (bram_addr      ),
      .lut_actions_in                        (lut_actions_in ),
      .lut_actions_out                       (lut_actions_out),
      
      .tcam_addr                             (tcam_addr_out),
      .tcam_data_in                          (tcam_data_out),
      .tcam_data_mask_in                     (tcam_data_mask_out),
      .tcam_we                               (tcam_we      ),
      .tcam_data_out                         (tcam_data_in ),
      .tcam_data_mask_out                    (tcam_data_mask_in),
      
      .counter_addr_in                       (counter_addr_out),
      .counter_addr_rd                       (counter_addr_rd),
      .pkt_counter_out                       (pkt_counter_in),
      .byte_counter_out                      (byte_counter_in)
       
   );
   
   small_fifo
   #( .WIDTH                           (OPENFLOW_ACTION_WIDTH),
      .MAX_DEPTH_BITS                  (3)
    )result_fifo
    (
      .din           ({wildcard_data}),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (result_fifo_dout),
      .full          (),
      .nearly_full   (result_fifo_nearly_full),
      .prog_full     (),
      .empty         (result_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );
    
   small_fifo
   #( .WIDTH               (1),
      .MAX_DEPTH_BITS      (3)
   )wildcard_hit_fifo
   (
      .din           (wildcard_hit),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (wildcard_hit_dout),
      .full          (),
      .nearly_full   (result_fifo_nearly_full),
      .prog_full     (),
      .empty         (result_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );
                     
   small_fifo
   #(.WIDTH            (OPENFLOW_WILDCARD_TABLE_DEPTH),
     .MAX_DEPTH_BITS   (3)
    )metadata_fifo
   (
      .din           (wildcard_address),
      .wr_en         (wildcard_data_vld),
      .rd_en         (result_fifo_rd_en),
      .dout          (metadata_fifo_dout),
      .full          (),
      .nearly_full   (metadata_fifo_nearly_full),
      .prog_full     (),
      .empty         (metadata_fifo_empty),
      .reset         (reset),
      .clk           (clk)
   );


    wildcard_processor
    #(
      .TABLE_NUM        (TABLE_NUM),
      .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
    )wildcard_processor
    (
      .result_fifo_dout    (result_fifo_dout),
      .result_fifo_rd_en   (result_fifo_rd_en),
      .result_fifo_empty   (result_fifo_empty),
      

      .in_fifo_ctrl        (in_fifo_ctrl),
      .in_fifo_data        (in_fifo_data),
      .in_fifo_rd_en       (in_fifo_rd_en),
      .in_fifo_empty       (in_fifo_empty),
      

      .out_wr              (wildcard_out_wr),
      .out_rdy             (wildcard_out_rdy),
      .out_data            (wildcard_out_data),
      .out_ctrl            (wildcard_out_ctrl),
      
      .actions             (actions),
      .actions_en          (actions_en),
      .actions_hit         (actions_hit),
      .wildcard_hit_dout   (wildcard_hit_dout),
      .src_port            (src_port),
      
      .clk                 (clk),
      .reset               (reset),
      
      .skip_lookup         (skip_lookup)
   );
    
   action_processor 
   #(
       .TABLE_NUM        (TABLE_NUM),
       .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
   )action_processor
   (
       .actions_en       (actions_en),
       .actions_hit      (actions_hit),
       .actions          (actions),  
       .src_port         (src_port),
               
       .in_ctrl          (wildcard_out_ctrl),  
       .in_data          (wildcard_out_data),
       .in_rdy           (wildcard_out_rdy),   
       .in_wr            (wildcard_out_wr),
                    
       .out_data         (out_data),         
       .out_ctrl         (out_ctrl),
       .out_wr           (out_wr  ),
       .out_rdy          (out_rdy ),
       
       .config_sw_ok     (config_sw_ok),
                
       .clk              (clk),      
       .reset            (reset)
       
   );
     
   output_port_lookup_reg_master 
   #(
      .CMP_WIDTH  (OPENFLOW_ENTRY_WIDTH),
      .LUT_DEPTH(OPENFLOW_WILDCARD_TABLE_SIZE),
      .TABLE_NUM(TABLE_NUM-1),
      .CURRENT_TABLE_ID (CURRENT_TABLE_ID)
   )
   output_port_lookup_reg_master
   (
   .data_output_port_lookup_i    (data_output_port_lookup_i),
   .addr_output_port_lookup_i    (addr_output_port_lookup_i),
   .req_output_port_lookup_i     (req_output_port_lookup_i ),
   .rw_output_port_lookup_i      (rw_output_port_lookup_i  ),
   .ack_output_port_lookup_o     (ack_output_port_lookup_o ),
   .data_output_port_lookup_o    (data_output_port_lookup_o  ),
   
   .bram_cs                      (bram_cs),
   .bram_we                      (bram_we),
   .bram_addr                    (bram_addr),
   .lut_actions_in               (lut_actions_in),
   .lut_actions_out              (lut_actions_out),
                
   .tcam_addr_out                (tcam_addr_out),
   .tcam_data_out                (tcam_data_out),
   .tcam_data_mask_out           (tcam_data_mask_out),
   .tcam_we                      (tcam_we),
   .tcam_data_in                 (tcam_data_in),
   .tcam_data_mask_in            (tcam_data_mask_in),
   
   .counter_addr_out             (counter_addr_out),
   .counter_addr_rd              (counter_addr_rd),
   .pkt_counter_in               (pkt_counter_in),
   .byte_counter_in              (byte_counter_in),
   
   .head_combine                 (head_combine),
      
   .clk                          (clk),
   .reset                        (reset)
   );


   assign in_rdy = !in_fifo_nearly_full && wildcard_match_rdy ;


   always @(posedge clk) begin
      if(reset) begin
         ns_counter <= 0;
         s_counter  <= 0;
      end
      else begin
         if(ns_counter == (1_000_000_000/`FAST_CLOCK_PERIOD - 1'b1)) begin
            s_counter  <= s_counter + 1'b1;
            ns_counter <= 0;
         end
         else begin
            ns_counter <= ns_counter + 1'b1;
         end
      end
   end


endmodule