data/full_repos/permissive/137045072/exception_handler.v
1: b'%Error: data/full_repos/permissive/137045072/exception_handler.v:22: Cannot find include file: defines.v\n`include "defines.v" \n         ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/137045072,data/full_repos/permissive/137045072/defines.v\n             data/full_repos/permissive/137045072,data/full_repos/permissive/137045072/defines.v.v\n             data/full_repos/permissive/137045072,data/full_repos/permissive/137045072/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/137045072/exception_handler.v:28: Define or directive not defined: \'`DATA_BUS\'\n    input [`DATA_BUS] cp0_status,\n           ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:28: syntax error, unexpected \']\', expecting TYPE-IDENTIFIER\n    input [`DATA_BUS] cp0_status,\n                    ^\n%Error: data/full_repos/permissive/137045072/exception_handler.v:29: Define or directive not defined: \'`DATA_BUS\'\n    input [`DATA_BUS] cp0_cause,\n           ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:30: Define or directive not defined: \'`DATA_BUS\'\n    input [`DATA_BUS] cp0_epc,\n           ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:33: Define or directive not defined: \'`CP0_REG_BUS\'\n    input [`CP0_REG_BUS] wb_cp0_write_addr,\n           ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:34: Define or directive not defined: \'`DATA_BUS\'\n    input [`DATA_BUS] wb_cp0_write,\n           ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:36: Define or directive not defined: \'`EXCEPT_MASK_BUS\'\n    input [`EXCEPT_MASK_BUS] exception_mask,\n           ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:37: Define or directive not defined: \'`DATA_BUS\'\n    input [`DATA_BUS] pc,\n           ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:38: Define or directive not defined: \'`DATA_BUS\'\n    output reg [`DATA_BUS] exception,\n                ^~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:48: Define or directive not defined: \'`EXCEPT_NONE\'\n            exception <= `EXCEPT_NONE;\n                         ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:52: Define or directive not defined: \'`EXCEPT_NONE\'\n            exception <= `EXCEPT_NONE;\n                         ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:58: Define or directive not defined: \'`EXCEPT_INTERRUPT\'\n                    exception <= `EXCEPT_INTERRUPT;\n                                 ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:63: Define or directive not defined: \'`EXCEPT_SYSCALL\'\n                else if (exception_mask[`EXCEPT_SYSCALL])\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:65: Define or directive not defined: \'`EXCEPT_SYSCALL\'\n                    exception <= `EXCEPT_SYSCALL;\n                                 ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:70: Define or directive not defined: \'`EXCEPT_ILLEGAL\'\n                else if (exception_mask[`EXCEPT_ILLEGAL])\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:72: Define or directive not defined: \'`EXCEPT_ILLEGAL\'\n                    exception <= `EXCEPT_ILLEGAL;\n                                 ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:77: Define or directive not defined: \'`EXCEPT_TRAP\'\n                else if (exception_mask[`EXCEPT_TRAP])\n                                        ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:79: Define or directive not defined: \'`EXCEPT_TRAP\'\n                    exception <= `EXCEPT_TRAP;\n                                 ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:84: Define or directive not defined: \'`EXCEPT_OVERFLOW\'\n                else if (exception_mask[`EXCEPT_OVERFLOW])\n                                        ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:86: Define or directive not defined: \'`EXCEPT_OVERFLOW\'\n                    exception <= `EXCEPT_OVERFLOW;\n                                 ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:91: Define or directive not defined: \'`EXCEPT_ERET\'\n                else if (exception_mask[`EXCEPT_ERET])\n                                        ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:93: Define or directive not defined: \'`EXCEPT_ERET\'\n                    exception <= `EXCEPT_ERET;\n                                 ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:98: Define or directive not defined: \'`EXCEPT_ADDRL\'\n                else if (exception_mask[`EXCEPT_ADDRL])\n                                        ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:100: Define or directive not defined: \'`EXCEPT_ADDRL\'\n                    exception <= `EXCEPT_ADDRL;\n                                 ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:105: Define or directive not defined: \'`EXCEPT_ADDRS\'\n                else if (exception_mask[`EXCEPT_ADDRS])\n                                        ^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/137045072/exception_handler.v:107: Define or directive not defined: \'`EXCEPT_ADDRS\'\n                    exception <= `EXCEPT_ADDRS;\n                                 ^~~~~~~~~~~~~\n%Error: Exiting due to 27 error(s)\n'
module exception_handler#(parameter DATA_WIDTH = 32)(
    input clk,
    input rst_n,

    input [`DATA_BUS] cp0_status,
    input [`DATA_BUS] cp0_cause,
    input [`DATA_BUS] cp0_epc,

    input wb_wb_cp0,
    input [`CP0_REG_BUS] wb_cp0_write_addr,
    input [`DATA_BUS] wb_cp0_write,

    input [`EXCEPT_MASK_BUS] exception_mask,
    input [`DATA_BUS] pc,
    output reg [`DATA_BUS] exception,

    output force_disable_mem
);


    always @*
    begin
        if (!rst_n)
        begin
            exception <= `EXCEPT_NONE;
        end
        else
        begin
            exception <= `EXCEPT_NONE;
            if (pc != 0)
            begin
                if ((cp0_cause[15:8] & cp0_status[15:8]) != 0 &&
                    cp0_status[1] == 0 && cp0_status[0] == 1)
                begin
                    exception <= `EXCEPT_INTERRUPT;
`ifdef DEBUG_EXCEPT
                    $display("Exception interrupt");
`endif
                end
                else if (exception_mask[`EXCEPT_SYSCALL])
                begin
                    exception <= `EXCEPT_SYSCALL;
`ifdef DEBUG_EXCEPT
                    $display("Exception syscall");
`endif
                end
                else if (exception_mask[`EXCEPT_ILLEGAL])
                begin
                    exception <= `EXCEPT_ILLEGAL;
`ifdef DEBUG_EXCEPT
                    $display("Exception illegal");
`endif
                end
                else if (exception_mask[`EXCEPT_TRAP])
                begin
                    exception <= `EXCEPT_TRAP;
`ifdef DEBUG_EXCEPT
                    $display("Exception trap");
`endif
                end
                else if (exception_mask[`EXCEPT_OVERFLOW])
                begin
                    exception <= `EXCEPT_OVERFLOW;
`ifdef DEBUG_EXCEPT
                    $display("Exception overflow");
`endif
                end
                else if (exception_mask[`EXCEPT_ERET])
                begin
                    exception <= `EXCEPT_ERET;
`ifdef DEBUG_EXCEPT
                    $display("Exception eret");
`endif
                end
                else if (exception_mask[`EXCEPT_ADDRL])
                begin
                    exception <= `EXCEPT_ADDRL;
`ifdef DEBUG_EXCEPT
                    $display("Exception addrl");
`endif
                end
                else if (exception_mask[`EXCEPT_ADDRS])
                begin
                    exception <= `EXCEPT_ADDRS;
`ifdef DEBUG_EXCEPT
                    $display("Exception addrs");
`endif
                end
            end
        end
    end


    assign force_disable_mem = exception_mask != 0;

endmodule
module exception_handler#(parameter DATA_WIDTH = 32)(
    input clk,
    input rst_n,

    input [`DATA_BUS] cp0_status,
    input [`DATA_BUS] cp0_cause,
    input [`DATA_BUS] cp0_epc,

    input wb_wb_cp0,
    input [`CP0_REG_BUS] wb_cp0_write_addr,
    input [`DATA_BUS] wb_cp0_write,

    input [`EXCEPT_MASK_BUS] exception_mask,
    input [`DATA_BUS] pc,
    output reg [`DATA_BUS] exception,

    output force_disable_mem
);



    always @*
    begin
        if (!rst_n)
        begin
            exception <= `EXCEPT_NONE;
        end
        else
        begin
            exception <= `EXCEPT_NONE;
            if (pc != 0)
            begin
                if ((cp0_cause[15:8] & cp0_status[15:8]) != 0 &&
                    cp0_status[1] == 0 && cp0_status[0] == 1)
                begin
                    exception <= `EXCEPT_INTERRUPT;
`ifdef DEBUG_EXCEPT
                    $display("Exception interrupt");
`endif
                end
                else if (exception_mask[`EXCEPT_SYSCALL])
                begin
                    exception <= `EXCEPT_SYSCALL;
`ifdef DEBUG_EXCEPT
                    $display("Exception syscall");
`endif
                end
                else if (exception_mask[`EXCEPT_ILLEGAL])
                begin
                    exception <= `EXCEPT_ILLEGAL;
`ifdef DEBUG_EXCEPT
                    $display("Exception illegal");
`endif
                end
                else if (exception_mask[`EXCEPT_TRAP])
                begin
                    exception <= `EXCEPT_TRAP;
`ifdef DEBUG_EXCEPT
                    $display("Exception trap");
`endif
                end
                else if (exception_mask[`EXCEPT_OVERFLOW])
                begin
                    exception <= `EXCEPT_OVERFLOW;
`ifdef DEBUG_EXCEPT
                    $display("Exception overflow");
`endif
                end
                else if (exception_mask[`EXCEPT_ERET])
                begin
                    exception <= `EXCEPT_ERET;
`ifdef DEBUG_EXCEPT
                    $display("Exception eret");
`endif
                end
                else if (exception_mask[`EXCEPT_ADDRL])
                begin
                    exception <= `EXCEPT_ADDRL;
`ifdef DEBUG_EXCEPT
                    $display("Exception addrl");
`endif
                end
                else if (exception_mask[`EXCEPT_ADDRS])
                begin
                    exception <= `EXCEPT_ADDRS;
`ifdef DEBUG_EXCEPT
                    $display("Exception addrs");
`endif
                end
            end
        end
    end


    assign force_disable_mem = exception_mask != 0;

endmodule