data/full_repos/permissive/463481430/RTL/core/ritter_top.v
1: b'%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:3: Cannot find include file: defines.v\n`include "defines.v" \n         ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/463481430/RTL/core,data/full_repos/permissive/463481430/defines.v\n             data/full_repos/permissive/463481430/RTL/core,data/full_repos/permissive/463481430/defines.v.v\n             data/full_repos/permissive/463481430/RTL/core,data/full_repos/permissive/463481430/defines.v.sv\n             defines.v\n             defines.v.v\n             defines.v.sv\n             obj_dir/defines.v\n             obj_dir/defines.v.v\n             obj_dir/defines.v.sv\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:4: Cannot find include file: config.v\n`include "config.v" \n         ^~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:34: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] ctrl2bpu_rs1idx;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:34: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] ctrl2bpu_rs1idx;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:36: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] ctrl2bpu_rs2idx;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:36: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] ctrl2bpu_rs2idx;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:39: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] ctrl2exu_rdidx0;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:39: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] ctrl2exu_rdidx0;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:42: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] ctrl2exu_rdidx1;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:42: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] ctrl2exu_rdidx1;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:44: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] ctrl2exu_rdidx2;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:44: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] ctrl2exu_rdidx2;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:137: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] wb_rdidx;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:137: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] wb_rdidx;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:138: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] wb_rdwdata;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:138: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] wb_rdwdata;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:143: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_exu_op1;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:143: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_exu_op1;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:144: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_exu_op2;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:144: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_exu_op2;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:145: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_rs2rdata;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:145: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_rs2rdata;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:146: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_imm;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:146: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_imm;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:148: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] bpu_rdidx;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:148: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] bpu_rdidx;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:151: Define or directive not defined: \'`csridxlen_def\'\n    wire[`csridxlen_def] bpu_csridx;\n         ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:151: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`csridxlen_def] bpu_csridx;\n                       ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:153: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_csr_zimm;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:153: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_csr_zimm;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:154: Define or directive not defined: \'`decinfo_grplen_def\'\n    wire[`decinfo_grplen_def] bpu_decinfo_grp;\n         ^~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:154: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`decinfo_grplen_def] bpu_decinfo_grp;\n                            ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:155: Define or directive not defined: \'`decinfolen_def\'\n    wire[`decinfolen_def] bpu_decinfo;\n         ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:155: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`decinfolen_def] bpu_decinfo;\n                        ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:156: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] bpu_iaddr;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:156: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] bpu_iaddr;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:159: Define or directive not defined: \'`rfidxlen_def\'\n    wire[`rfidxlen_def] exu_rdidx0;\n         ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:159: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`rfidxlen_def] exu_rdidx0;\n                      ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:160: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] exu_rdwdata0;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:160: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] exu_rdwdata0;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:209: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] csr_rdata;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:209: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] csr_rdata;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:212: Define or directive not defined: \'`csridxlen_def\'\n    wire[`csridxlen_def] wb_csridx;\n         ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:212: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`csridxlen_def] wb_csridx;\n                       ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:213: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] wb_csr_wdata;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:213: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] wb_csr_wdata;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:231: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] dis_exu_op1;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:231: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] dis_exu_op1;\n                  ^\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:232: Define or directive not defined: \'`xlen_def\'\n    wire[`xlen_def] dis_exu_op2;\n         ^~~~~~~~~\n%Error: data/full_repos/permissive/463481430/RTL/core/ritter_top.v:232: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    wire[`xlen_def] dis_exu_op2;\n                  ^\n%Error: Exiting due to too many errors encountered; --error-limit=50\n'
module RITTER_TOP (
    input wire i_clk,
    input wire i_rstn,
    

    output wire[31:0] o_ribm_addr0,
    output wire o_ribm_wrcs0,
    output wire[3:0] o_ribm_mask0,
    output wire[31:0] o_ribm_wdata0,
    input wire[31:0] i_ribm_rdata0,
    output wire o_ribm_req0,
    input wire i_ribm_gnt0,
    input wire i_ribm_rsp0,
    output wire o_ribm_rdy0,

    output wire[31:0] o_ribm_addr1,
    output wire o_ribm_wrcs1,
    output wire[3:0] o_ribm_mask1,
    output wire[31:0] o_ribm_wdata1,
    input wire[31:0] i_ribm_rdata1,
    output wire o_ribm_req1,
    input wire i_ribm_gnt1,
    input wire i_ribm_rsp1,
    output wire o_ribm_rdy1
);


    wire ctrl2bpu_rs1ren;
    wire[`rfidxlen_def] ctrl2bpu_rs1idx;
    wire ctrl2bpu_rs2ren;
    wire[`rfidxlen_def] ctrl2bpu_rs2idx;

    wire ctrl2exu_rdwen0;
    wire[`rfidxlen_def] ctrl2exu_rdidx0;

    wire ctrl2exu_rdwen1;
    wire[`rfidxlen_def] ctrl2exu_rdidx1;
    wire ctrl2exu_rdwen2;
    wire[`rfidxlen_def] ctrl2exu_rdidx2;

    wire ctrl2exu_resource_match;
    wire ctrl2wb_match;

    wire ctrl2ifu_wait;
    wire ctrl2bpu_wait;
    wire ctrl2dis_wait;
    wire ctrl2dis_flush;

    PIPE_CTRL u_PIPE_CTRL(
        .i_bpu_rs1ren         ( ctrl2bpu_rs1ren         ),
        .i_bpu_rs1idx         ( ctrl2bpu_rs1idx         ),
        .i_bpu_rs2ren         ( ctrl2bpu_rs2ren         ),
        .i_bpu_rs2idx         ( ctrl2bpu_rs2idx         ),

        .i_exu_rdwen0         ( ctrl2exu_rdwen0         ),
        .i_exu_rdidx0         ( ctrl2exu_rdidx0         ),
        .i_exu_rdwen1         ( ctrl2exu_rdwen1         ),
        .i_exu_rdidx1         ( ctrl2exu_rdidx1         ),
        .i_exu_rdwen2         ( ctrl2exu_rdwen2         ),
        .i_exu_rdidx2         ( ctrl2exu_rdidx2         ),

        .i_exu_resource_match ( ctrl2exu_resource_match ),
        .i_wb_match           ( ctrl2wb_match           ),

        .o_ifu_wait           ( ctrl2ifu_wait           ),
        .o_bpu_wait           ( ctrl2bpu_wait           ),
        .o_dis_wait           ( ctrl2dis_wait           ),
        .o_dis_flush          ( ctrl2dis_flush          )
    );



    wire bpu_taken_gen;
    wire[31:0] bpu_jaddr_gen;
    wire exu_taken_gen;
    wire[31:0] exu_jaddr_gen;
    wire ifu_data_vld;
    wire[31:0] ifu_iaddr;
    wire[31:0] ifu_data;

    wire bpu2ifu_vld;

    wire ifu_fetch_vld = bpu_taken_gen|exu_taken_gen ? 1 : (bpu2ifu_vld);
    IFU u_IFU(
        .i_clk        ( i_clk        ),
        .i_rstn       ( i_rstn       ),

        .i_fetch_vld  ( ifu_fetch_vld  ),

        .i_bpu_taken  ( bpu_taken_gen  ),
        .i_bpu_jaddr  ( bpu_jaddr_gen  ),
        .i_exu_taken  ( exu_taken_gen  ),
        .i_exu_jaddr  ( exu_jaddr_gen  ),

        .o_data_vld   ( ifu_data_vld   ),
        .o_iaddr      ( ifu_iaddr      ),
        .o_data       ( ifu_data       ),

        .o_ribm_addr  ( o_ribm_addr0  ),
        .o_ribm_wrcs  ( o_ribm_wrcs0  ),
        .o_ribm_mask  ( o_ribm_mask0  ),
        .o_ribm_wdata ( o_ribm_wdata0 ),
        .i_ribm_rdata ( i_ribm_rdata0 ),
        .o_ribm_req   ( o_ribm_req0   ),
        .i_ribm_gnt   ( i_ribm_gnt0   ),
        .i_ribm_rsp   ( i_ribm_rsp0   ),
        .o_ribm_rdy   ( o_ribm_rdy0   )
    );

    wire ifu2bpu_data_vld;
    wire[31:0] ifu2bpu_iaddr;
    wire[31:0] ifu2bpu_data;
    IFU2BPU u_IFU2BPU(
        .i_clk      ( i_clk      ),
        .i_rstn     ( i_rstn     ),

        .i_vld      ( ~ctrl2ifu_wait      ),
        .o_ifu_vld  ( bpu2ifu_vld ),
        .i_flush    ( bpu_taken_gen | exu_taken_gen    ),

        .i_data_vld ( ifu_data_vld ),
        .i_iaddr    ( ifu_iaddr    ),
        .i_data     ( ifu_data     ),

        .o_data_vld ( ifu2bpu_data_vld ),
        .o_iaddr    ( ifu2bpu_iaddr    ),
        .o_data     ( ifu2bpu_data     )
    );


    wire wb_rdwen;
    wire[`rfidxlen_def] wb_rdidx;
    wire[`xlen_def] wb_rdwdata;

    wire bpu_taken;
    wire[31:0] bpu_jaddr;
    wire bpu_inst_vld;
    wire[`xlen_def] bpu_exu_op1;
    wire[`xlen_def] bpu_exu_op2;
    wire[`xlen_def] bpu_rs2rdata;
    wire[`xlen_def] bpu_imm;
    wire bpu_rdwen;
    wire[`rfidxlen_def] bpu_rdidx;

    wire bpu_csrwren;
    wire[`csridxlen_def] bpu_csridx;

    wire[`xlen_def] bpu_csr_zimm;
    wire[`decinfo_grplen_def] bpu_decinfo_grp;
    wire[`decinfolen_def] bpu_decinfo;
    wire[`xlen_def] bpu_iaddr;

    wire exu_rdwen0;
    wire[`rfidxlen_def] exu_rdidx0;
    wire[`xlen_def] exu_rdwdata0;
    BPU u_BPU(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_stop        ( ctrl2bpu_wait      ),
        .i_flush       ( bpu_taken_gen | exu_taken_gen       ),

        .i_data_vld    ( ifu2bpu_data_vld    ),
        .i_iaddr       ( ifu2bpu_iaddr       ),
        .i_data        ( ifu2bpu_data        ),

        .o_bpu_rs1ren  ( ctrl2bpu_rs1ren  ),
        .o_bpu_rs1idx  ( ctrl2bpu_rs1idx  ),
        .o_bpu_rs2ren  ( ctrl2bpu_rs2ren  ),
        .o_bpu_rs2idx  ( ctrl2bpu_rs2idx  ),

        .i_rdwen       ( wb_rdwen       ),
        .i_rdidx       ( wb_rdidx       ),
        .i_rd_wdata    ( wb_rdwdata     ),


        .i_bypass_rdwen ( exu_rdwen0 ),
        .i_bypass_rdidx ( exu_rdidx0 ),
        .i_bypass_rd_wdata  ( exu_rdwdata0 ),



        .o_bpu_taken   ( bpu_taken   ),
        .o_bpu_jaddr   ( bpu_jaddr   ),

        .o_inst_vld    ( bpu_inst_vld    ),
        .o_exu_op1     ( bpu_exu_op1     ),
        .o_exu_op2     ( bpu_exu_op2     ),
        .o_rs2rdata    ( bpu_rs2rdata    ),
        .o_imm         ( bpu_imm         ),
        .o_rdwen       ( bpu_rdwen       ),
        .o_rdidx       ( bpu_rdidx       ),

        .o_csr_ren     ( bpu_csrwren     ),
        .o_csridx      ( bpu_csridx      ),
        .o_csr_zimm    ( bpu_csr_zimm    ),

        .o_decinfo_grp ( bpu_decinfo_grp ),
        .o_decinfo     ( bpu_decinfo     ),
        .o_iaddr       ( bpu_iaddr       )
    );


    wire[`xlen_def] csr_rdata;

    wire wb_csr_wen;
    wire[`csridxlen_def] wb_csridx;
    wire[`xlen_def] wb_csr_wdata;

    CSR_REGFILE u_CSR_REGFILE(
        .i_clk       ( i_clk       ),
        .i_rstn      ( i_rstn      ),

        .i_csr_ren   ( bpu_csrwren   ),
        .i_csr_ridx  ( bpu_csridx  ),
        .o_csr_rdata ( csr_rdata ),

        .i_csr_wen   ( wb_csr_wen   ),
        .i_csr_widx  ( wb_csridx  ),
        .i_csr_wdata  ( wb_csr_wdata  )
    );




    wire[`xlen_def] dis_exu_op1;
    wire[`xlen_def] dis_exu_op2;
    wire[`xlen_def] dis_rs2rdata;
    wire[`xlen_def] dis_imm;
    wire dis_rdwen;
    wire[`rfidxlen_def] dis_rdidx;

    wire[`csridxlen_def] dis_csridx;
    wire[`xlen_def] dis_csr_rdata;
    wire[`xlen_def] dis_csr_zimm;

    wire[`decinfo_grplen_def] dis_decinfo_grp;
    wire[`decinfolen_def] dis_decinfo;
    wire[`xlen_def] dis_iaddr;

    DISPATCH u_DISPATCH(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_dis_vld     ( (~ctrl2dis_wait)    ),

        .i_flush       ( (ctrl2dis_wait&(~ctrl2exu_resource_match) ? 0 :bpu_taken_gen)|exu_taken_gen|ctrl2dis_flush ),


        .i_bpu_taken   ( bpu_taken   ),
        .i_bpu_jaddr   ( bpu_jaddr   ),
        .o_bpu_taken   ( bpu_taken_gen   ),
        .o_bpu_jaddr   ( bpu_jaddr_gen   ),

        .i_inst_vld    ( bpu_inst_vld    ),
        .i_exu_op1     ( bpu_exu_op1     ),
        .i_exu_op2     ( bpu_exu_op2     ),
        .i_rs2rdata    ( bpu_rs2rdata    ),
        .i_imm         ( bpu_imm         ),
        .i_rdwen       ( bpu_rdwen       ),
        .i_rdidx       ( bpu_rdidx       ),

        .i_csridx      ( bpu_csridx      ),
        .i_csr_rdata   ( csr_rdata      ),
        .i_csr_zimm    ( bpu_csr_zimm    ),

        .i_decinfo_grp ( bpu_decinfo_grp ),
        .i_decinfo     ( bpu_decinfo     ),
        .i_iaddr       ( bpu_iaddr       ),

        .o_exu_op1     ( dis_exu_op1     ),
        .o_exu_op2     ( dis_exu_op2     ),
        .o_rs2rdata    ( dis_rs2rdata    ),
        .o_imm         ( dis_imm         ),
        .o_rdwen       ( dis_rdwen       ),
        .o_rdidx       ( dis_rdidx       ),

        .o_csridx      ( dis_csridx      ),
        .o_csr_rdata   ( dis_csr_rdata      ),
        .o_csr_zimm    ( dis_csr_zimm    ),

        .o_decinfo_grp ( dis_decinfo_grp ),
        .o_decinfo     ( dis_decinfo     ),
        .o_iaddr       ( dis_iaddr       )
    );


    
    wire exu_mdu_working;
    wire exu_rdwen1;
    wire[`rfidxlen_def] exu_rdidx1;
    wire[`xlen_def] exu_rdwdata1;   
    wire exu_lsu_working;
    wire exu_rdwen2;
    wire[`rfidxlen_def] exu_rdidx2;
    wire[`xlen_def] exu_rdwdata2;

    wire exu_taken;
    wire[`xlen_def] exu_jaddr;
    EXU u_EXU(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_vld       ( (~(exu_taken_gen | ctrl2dis_wait)) ),

        .i_exu_op1     ( dis_exu_op1     ),
        .i_exu_op2     ( dis_exu_op2     ),
        .i_rs2rdata    ( dis_rs2rdata    ),
        .i_imm         ( dis_imm         ),
        .i_rdwen       ( dis_rdwen       ),
        .i_rdidx       ( dis_rdidx       ),

        .i_csridx      ( dis_csridx      ),
        .i_csr_rdata   ( dis_csr_rdata      ),
        .i_csr_zimm    ( dis_csr_zimm    ),

        .i_decinfo_grp ( dis_decinfo_grp ),
        .i_decinfo     ( dis_decinfo     ),
        .i_iaddr       ( dis_iaddr       ),




        .o_exu_rdwen0           ( ctrl2exu_rdwen0 ),
        .o_exu_rdidx0           ( ctrl2exu_rdidx0 ),
        .o_exu_rdwen1           ( ctrl2exu_rdwen1 ),
        .o_exu_rdidx1           ( ctrl2exu_rdidx1 ),
        .o_exu_rdwen2           ( ctrl2exu_rdwen2 ),
        .o_exu_rdidx2           ( ctrl2exu_rdidx2 ),
        .o_exu_resource_match   ( ctrl2exu_resource_match ),

        .o_rdwen0      ( exu_rdwen0      ),
        .o_rdidx0      ( exu_rdidx0      ),
        .o_rdwdata0    ( exu_rdwdata0    ),
        .o_mdu_working ( exu_mdu_working ),
        .o_rdwen1      ( exu_rdwen1      ),
        .o_rdidx1      ( exu_rdidx1      ),
        .o_rdwdata1    ( exu_rdwdata1    ),
        .o_lsu_working ( exu_lsu_working ),
        .o_rdwen2      ( exu_rdwen2      ),
        .o_rdidx2      ( exu_rdidx2      ),
        .o_rdwdata2    ( exu_rdwdata2    ),

        .o_csr_wen     ( wb_csr_wen   ),
        .o_csridx      ( wb_csridx    ),
        .o_csr_wdata   ( wb_csr_wdata ),
        

        .o_exu_taken   ( exu_taken   ),
        .o_exu_jaddr   ( exu_jaddr   ),

        .o_ribm_addr  ( o_ribm_addr1  ),
        .o_ribm_wrcs  ( o_ribm_wrcs1  ),
        .o_ribm_mask  ( o_ribm_mask1  ),
        .o_ribm_wdata ( o_ribm_wdata1 ),
        .i_ribm_rdata ( i_ribm_rdata1 ),
        .o_ribm_req   ( o_ribm_req1   ),
        .i_ribm_gnt   ( i_ribm_gnt1   ),
        .i_ribm_rsp   ( i_ribm_rsp1   ),
        .o_ribm_rdy   ( o_ribm_rdy1   )

    );


    WB u_WB(
        .i_clk       ( i_clk       ),
        .i_rstn      ( i_rstn      ),



        .i_flush     ( ctrl2wb_match? 0 : exu_taken_gen   ),

        .i_rdwen0    ( exu_rdwen0    ),
        .i_rdidx0    ( exu_rdidx0    ),
        .i_rdwdata0  ( exu_rdwdata0  ),

        .i_mdu_working ( exu_mdu_working ),
        .i_rdwen1    ( exu_rdwen1    ),
        .i_rdidx1    ( exu_rdidx1    ),
        .i_rdwdata1  ( exu_rdwdata1  ),

        .i_lsu_working ( exu_lsu_working ),
        .i_rdwen2    ( exu_rdwen2    ),
        .i_rdidx2    ( exu_rdidx2    ),
        .i_rdwdata2  ( exu_rdwdata2  ),

        .i_exu_taken ( exu_taken     ),
        .i_exu_jaddr ( exu_jaddr     ),
        .o_exu_taken ( exu_taken_gen     ),
        .o_exu_jaddr ( exu_jaddr_gen     ),

        .o_wait      ( ctrl2wb_match     ),

        .o_wb_rdwen     ( wb_rdwen      ),
        .o_wb_rdidx     ( wb_rdidx      ),
        .o_wb_rdwdata   ( wb_rdwdata  )
    );





endmodule
module RITTER_TOP (
    input wire i_clk,
    input wire i_rstn,
    

    output wire[31:0] o_ribm_addr0,
    output wire o_ribm_wrcs0,
    output wire[3:0] o_ribm_mask0,
    output wire[31:0] o_ribm_wdata0,
    input wire[31:0] i_ribm_rdata0,
    output wire o_ribm_req0,
    input wire i_ribm_gnt0,
    input wire i_ribm_rsp0,
    output wire o_ribm_rdy0,

    output wire[31:0] o_ribm_addr1,
    output wire o_ribm_wrcs1,
    output wire[3:0] o_ribm_mask1,
    output wire[31:0] o_ribm_wdata1,
    input wire[31:0] i_ribm_rdata1,
    output wire o_ribm_req1,
    input wire i_ribm_gnt1,
    input wire i_ribm_rsp1,
    output wire o_ribm_rdy1
);



    wire ctrl2bpu_rs1ren;
    wire[`rfidxlen_def] ctrl2bpu_rs1idx;
    wire ctrl2bpu_rs2ren;
    wire[`rfidxlen_def] ctrl2bpu_rs2idx;

    wire ctrl2exu_rdwen0;
    wire[`rfidxlen_def] ctrl2exu_rdidx0;

    wire ctrl2exu_rdwen1;
    wire[`rfidxlen_def] ctrl2exu_rdidx1;
    wire ctrl2exu_rdwen2;
    wire[`rfidxlen_def] ctrl2exu_rdidx2;

    wire ctrl2exu_resource_match;
    wire ctrl2wb_match;

    wire ctrl2ifu_wait;
    wire ctrl2bpu_wait;
    wire ctrl2dis_wait;
    wire ctrl2dis_flush;

    PIPE_CTRL u_PIPE_CTRL(
        .i_bpu_rs1ren         ( ctrl2bpu_rs1ren         ),
        .i_bpu_rs1idx         ( ctrl2bpu_rs1idx         ),
        .i_bpu_rs2ren         ( ctrl2bpu_rs2ren         ),
        .i_bpu_rs2idx         ( ctrl2bpu_rs2idx         ),

        .i_exu_rdwen0         ( ctrl2exu_rdwen0         ),
        .i_exu_rdidx0         ( ctrl2exu_rdidx0         ),
        .i_exu_rdwen1         ( ctrl2exu_rdwen1         ),
        .i_exu_rdidx1         ( ctrl2exu_rdidx1         ),
        .i_exu_rdwen2         ( ctrl2exu_rdwen2         ),
        .i_exu_rdidx2         ( ctrl2exu_rdidx2         ),

        .i_exu_resource_match ( ctrl2exu_resource_match ),
        .i_wb_match           ( ctrl2wb_match           ),

        .o_ifu_wait           ( ctrl2ifu_wait           ),
        .o_bpu_wait           ( ctrl2bpu_wait           ),
        .o_dis_wait           ( ctrl2dis_wait           ),
        .o_dis_flush          ( ctrl2dis_flush          )
    );



    wire bpu_taken_gen;
    wire[31:0] bpu_jaddr_gen;
    wire exu_taken_gen;
    wire[31:0] exu_jaddr_gen;
    wire ifu_data_vld;
    wire[31:0] ifu_iaddr;
    wire[31:0] ifu_data;

    wire bpu2ifu_vld;

    wire ifu_fetch_vld = bpu_taken_gen|exu_taken_gen ? 1 : (bpu2ifu_vld);
    IFU u_IFU(
        .i_clk        ( i_clk        ),
        .i_rstn       ( i_rstn       ),

        .i_fetch_vld  ( ifu_fetch_vld  ),

        .i_bpu_taken  ( bpu_taken_gen  ),
        .i_bpu_jaddr  ( bpu_jaddr_gen  ),
        .i_exu_taken  ( exu_taken_gen  ),
        .i_exu_jaddr  ( exu_jaddr_gen  ),

        .o_data_vld   ( ifu_data_vld   ),
        .o_iaddr      ( ifu_iaddr      ),
        .o_data       ( ifu_data       ),

        .o_ribm_addr  ( o_ribm_addr0  ),
        .o_ribm_wrcs  ( o_ribm_wrcs0  ),
        .o_ribm_mask  ( o_ribm_mask0  ),
        .o_ribm_wdata ( o_ribm_wdata0 ),
        .i_ribm_rdata ( i_ribm_rdata0 ),
        .o_ribm_req   ( o_ribm_req0   ),
        .i_ribm_gnt   ( i_ribm_gnt0   ),
        .i_ribm_rsp   ( i_ribm_rsp0   ),
        .o_ribm_rdy   ( o_ribm_rdy0   )
    );

    wire ifu2bpu_data_vld;
    wire[31:0] ifu2bpu_iaddr;
    wire[31:0] ifu2bpu_data;
    IFU2BPU u_IFU2BPU(
        .i_clk      ( i_clk      ),
        .i_rstn     ( i_rstn     ),

        .i_vld      ( ~ctrl2ifu_wait      ),
        .o_ifu_vld  ( bpu2ifu_vld ),
        .i_flush    ( bpu_taken_gen | exu_taken_gen    ),

        .i_data_vld ( ifu_data_vld ),
        .i_iaddr    ( ifu_iaddr    ),
        .i_data     ( ifu_data     ),

        .o_data_vld ( ifu2bpu_data_vld ),
        .o_iaddr    ( ifu2bpu_iaddr    ),
        .o_data     ( ifu2bpu_data     )
    );


    wire wb_rdwen;
    wire[`rfidxlen_def] wb_rdidx;
    wire[`xlen_def] wb_rdwdata;

    wire bpu_taken;
    wire[31:0] bpu_jaddr;
    wire bpu_inst_vld;
    wire[`xlen_def] bpu_exu_op1;
    wire[`xlen_def] bpu_exu_op2;
    wire[`xlen_def] bpu_rs2rdata;
    wire[`xlen_def] bpu_imm;
    wire bpu_rdwen;
    wire[`rfidxlen_def] bpu_rdidx;

    wire bpu_csrwren;
    wire[`csridxlen_def] bpu_csridx;

    wire[`xlen_def] bpu_csr_zimm;
    wire[`decinfo_grplen_def] bpu_decinfo_grp;
    wire[`decinfolen_def] bpu_decinfo;
    wire[`xlen_def] bpu_iaddr;

    wire exu_rdwen0;
    wire[`rfidxlen_def] exu_rdidx0;
    wire[`xlen_def] exu_rdwdata0;
    BPU u_BPU(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_stop        ( ctrl2bpu_wait      ),
        .i_flush       ( bpu_taken_gen | exu_taken_gen       ),

        .i_data_vld    ( ifu2bpu_data_vld    ),
        .i_iaddr       ( ifu2bpu_iaddr       ),
        .i_data        ( ifu2bpu_data        ),

        .o_bpu_rs1ren  ( ctrl2bpu_rs1ren  ),
        .o_bpu_rs1idx  ( ctrl2bpu_rs1idx  ),
        .o_bpu_rs2ren  ( ctrl2bpu_rs2ren  ),
        .o_bpu_rs2idx  ( ctrl2bpu_rs2idx  ),

        .i_rdwen       ( wb_rdwen       ),
        .i_rdidx       ( wb_rdidx       ),
        .i_rd_wdata    ( wb_rdwdata     ),


        .i_bypass_rdwen ( exu_rdwen0 ),
        .i_bypass_rdidx ( exu_rdidx0 ),
        .i_bypass_rd_wdata  ( exu_rdwdata0 ),



        .o_bpu_taken   ( bpu_taken   ),
        .o_bpu_jaddr   ( bpu_jaddr   ),

        .o_inst_vld    ( bpu_inst_vld    ),
        .o_exu_op1     ( bpu_exu_op1     ),
        .o_exu_op2     ( bpu_exu_op2     ),
        .o_rs2rdata    ( bpu_rs2rdata    ),
        .o_imm         ( bpu_imm         ),
        .o_rdwen       ( bpu_rdwen       ),
        .o_rdidx       ( bpu_rdidx       ),

        .o_csr_ren     ( bpu_csrwren     ),
        .o_csridx      ( bpu_csridx      ),
        .o_csr_zimm    ( bpu_csr_zimm    ),

        .o_decinfo_grp ( bpu_decinfo_grp ),
        .o_decinfo     ( bpu_decinfo     ),
        .o_iaddr       ( bpu_iaddr       )
    );


    wire[`xlen_def] csr_rdata;

    wire wb_csr_wen;
    wire[`csridxlen_def] wb_csridx;
    wire[`xlen_def] wb_csr_wdata;

    CSR_REGFILE u_CSR_REGFILE(
        .i_clk       ( i_clk       ),
        .i_rstn      ( i_rstn      ),

        .i_csr_ren   ( bpu_csrwren   ),
        .i_csr_ridx  ( bpu_csridx  ),
        .o_csr_rdata ( csr_rdata ),

        .i_csr_wen   ( wb_csr_wen   ),
        .i_csr_widx  ( wb_csridx  ),
        .i_csr_wdata  ( wb_csr_wdata  )
    );




    wire[`xlen_def] dis_exu_op1;
    wire[`xlen_def] dis_exu_op2;
    wire[`xlen_def] dis_rs2rdata;
    wire[`xlen_def] dis_imm;
    wire dis_rdwen;
    wire[`rfidxlen_def] dis_rdidx;

    wire[`csridxlen_def] dis_csridx;
    wire[`xlen_def] dis_csr_rdata;
    wire[`xlen_def] dis_csr_zimm;

    wire[`decinfo_grplen_def] dis_decinfo_grp;
    wire[`decinfolen_def] dis_decinfo;
    wire[`xlen_def] dis_iaddr;

    DISPATCH u_DISPATCH(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_dis_vld     ( (~ctrl2dis_wait)    ),

        .i_flush       ( (ctrl2dis_wait&(~ctrl2exu_resource_match) ? 0 :bpu_taken_gen)|exu_taken_gen|ctrl2dis_flush ),


        .i_bpu_taken   ( bpu_taken   ),
        .i_bpu_jaddr   ( bpu_jaddr   ),
        .o_bpu_taken   ( bpu_taken_gen   ),
        .o_bpu_jaddr   ( bpu_jaddr_gen   ),

        .i_inst_vld    ( bpu_inst_vld    ),
        .i_exu_op1     ( bpu_exu_op1     ),
        .i_exu_op2     ( bpu_exu_op2     ),
        .i_rs2rdata    ( bpu_rs2rdata    ),
        .i_imm         ( bpu_imm         ),
        .i_rdwen       ( bpu_rdwen       ),
        .i_rdidx       ( bpu_rdidx       ),

        .i_csridx      ( bpu_csridx      ),
        .i_csr_rdata   ( csr_rdata      ),
        .i_csr_zimm    ( bpu_csr_zimm    ),

        .i_decinfo_grp ( bpu_decinfo_grp ),
        .i_decinfo     ( bpu_decinfo     ),
        .i_iaddr       ( bpu_iaddr       ),

        .o_exu_op1     ( dis_exu_op1     ),
        .o_exu_op2     ( dis_exu_op2     ),
        .o_rs2rdata    ( dis_rs2rdata    ),
        .o_imm         ( dis_imm         ),
        .o_rdwen       ( dis_rdwen       ),
        .o_rdidx       ( dis_rdidx       ),

        .o_csridx      ( dis_csridx      ),
        .o_csr_rdata   ( dis_csr_rdata      ),
        .o_csr_zimm    ( dis_csr_zimm    ),

        .o_decinfo_grp ( dis_decinfo_grp ),
        .o_decinfo     ( dis_decinfo     ),
        .o_iaddr       ( dis_iaddr       )
    );


    
    wire exu_mdu_working;
    wire exu_rdwen1;
    wire[`rfidxlen_def] exu_rdidx1;
    wire[`xlen_def] exu_rdwdata1;   
    wire exu_lsu_working;
    wire exu_rdwen2;
    wire[`rfidxlen_def] exu_rdidx2;
    wire[`xlen_def] exu_rdwdata2;

    wire exu_taken;
    wire[`xlen_def] exu_jaddr;
    EXU u_EXU(
        .i_clk         ( i_clk         ),
        .i_rstn        ( i_rstn        ),

        .i_vld       ( (~(exu_taken_gen | ctrl2dis_wait)) ),

        .i_exu_op1     ( dis_exu_op1     ),
        .i_exu_op2     ( dis_exu_op2     ),
        .i_rs2rdata    ( dis_rs2rdata    ),
        .i_imm         ( dis_imm         ),
        .i_rdwen       ( dis_rdwen       ),
        .i_rdidx       ( dis_rdidx       ),

        .i_csridx      ( dis_csridx      ),
        .i_csr_rdata   ( dis_csr_rdata      ),
        .i_csr_zimm    ( dis_csr_zimm    ),

        .i_decinfo_grp ( dis_decinfo_grp ),
        .i_decinfo     ( dis_decinfo     ),
        .i_iaddr       ( dis_iaddr       ),




        .o_exu_rdwen0           ( ctrl2exu_rdwen0 ),
        .o_exu_rdidx0           ( ctrl2exu_rdidx0 ),
        .o_exu_rdwen1           ( ctrl2exu_rdwen1 ),
        .o_exu_rdidx1           ( ctrl2exu_rdidx1 ),
        .o_exu_rdwen2           ( ctrl2exu_rdwen2 ),
        .o_exu_rdidx2           ( ctrl2exu_rdidx2 ),
        .o_exu_resource_match   ( ctrl2exu_resource_match ),

        .o_rdwen0      ( exu_rdwen0      ),
        .o_rdidx0      ( exu_rdidx0      ),
        .o_rdwdata0    ( exu_rdwdata0    ),
        .o_mdu_working ( exu_mdu_working ),
        .o_rdwen1      ( exu_rdwen1      ),
        .o_rdidx1      ( exu_rdidx1      ),
        .o_rdwdata1    ( exu_rdwdata1    ),
        .o_lsu_working ( exu_lsu_working ),
        .o_rdwen2      ( exu_rdwen2      ),
        .o_rdidx2      ( exu_rdidx2      ),
        .o_rdwdata2    ( exu_rdwdata2    ),

        .o_csr_wen     ( wb_csr_wen   ),
        .o_csridx      ( wb_csridx    ),
        .o_csr_wdata   ( wb_csr_wdata ),
        

        .o_exu_taken   ( exu_taken   ),
        .o_exu_jaddr   ( exu_jaddr   ),

        .o_ribm_addr  ( o_ribm_addr1  ),
        .o_ribm_wrcs  ( o_ribm_wrcs1  ),
        .o_ribm_mask  ( o_ribm_mask1  ),
        .o_ribm_wdata ( o_ribm_wdata1 ),
        .i_ribm_rdata ( i_ribm_rdata1 ),
        .o_ribm_req   ( o_ribm_req1   ),
        .i_ribm_gnt   ( i_ribm_gnt1   ),
        .i_ribm_rsp   ( i_ribm_rsp1   ),
        .o_ribm_rdy   ( o_ribm_rdy1   )

    );


    WB u_WB(
        .i_clk       ( i_clk       ),
        .i_rstn      ( i_rstn      ),



        .i_flush     ( ctrl2wb_match? 0 : exu_taken_gen   ),

        .i_rdwen0    ( exu_rdwen0    ),
        .i_rdidx0    ( exu_rdidx0    ),
        .i_rdwdata0  ( exu_rdwdata0  ),

        .i_mdu_working ( exu_mdu_working ),
        .i_rdwen1    ( exu_rdwen1    ),
        .i_rdidx1    ( exu_rdidx1    ),
        .i_rdwdata1  ( exu_rdwdata1  ),

        .i_lsu_working ( exu_lsu_working ),
        .i_rdwen2    ( exu_rdwen2    ),
        .i_rdidx2    ( exu_rdidx2    ),
        .i_rdwdata2  ( exu_rdwdata2  ),

        .i_exu_taken ( exu_taken     ),
        .i_exu_jaddr ( exu_jaddr     ),
        .o_exu_taken ( exu_taken_gen     ),
        .o_exu_jaddr ( exu_jaddr_gen     ),

        .o_wait      ( ctrl2wb_match     ),

        .o_wb_rdwen     ( wb_rdwen      ),
        .o_wb_rdidx     ( wb_rdidx      ),
        .o_wb_rdwdata   ( wb_rdwdata  )
    );





endmodule