data/full_repos/permissive/181665138/verilog/capitolo_vii/Controllore_Interruzioni.v
 line:122: before: "=="
1: b"%Error: data/full_repos/permissive/181665138/verilog/capitolo_vii/Controllore_Interruzioni.v:122: syntax error, unexpected ==, expecting ')' or ',' or or\n    always @(reset_ == 0) #1 begin\n                    ^~\n%Error: data/full_repos/permissive/181665138/verilog/capitolo_vii/Controllore_Interruzioni.v:154: syntax error, unexpected casex\n        casex(ipr15_ipr0)\n        ^~~~~\n%Error: data/full_repos/permissive/181665138/verilog/capitolo_vii/Controllore_Interruzioni.v:177: syntax error, unexpected casex\n        casex(index)\n        ^~~~~\n%Error: Cannot continue\n"
module Controllore_Interruzioni(intr, inta, ipr15_ipr0, index, remove_req,
                                clock, reset);
    input   clock, reset_;
    input           inta;
    output          intr;
    input   [15:0]  ipr15_ipr0;
    output  [3:0]   index;
    output  [15:0]  remove_req;
    
    reg             INTR;
    assign intr = INTR;
    
    reg     [3:0]   INDEX;
    assign index = INDEX;

    reg     [15:0]  REMOVE_REQ;
    assign remove_req = REMOVE_REQ;
    
    reg     [1:0]   STAR;
    parameter S0 = 0, S1 = 1, S2 = 2, WS = 3;

    always @(reset_ == 0) #1 begin
        INTR <= 0;
        REMOVE_REQ <= 'HFFFF;
        STAR <= WS;
    end

    always @(posedge clock) if (reset_ == 1) #3
        casex(STAR)
            WS: begin
                STAR <= S0;
            end
            S0: begin
                REMOVE_REQ <= 'H0000;
                INTR <= (ipr15_ipr0 == 'H0000)? 0:1;


                INDEX <= priority(ipr15_ipr0);
                STAR <= (inta == 0)? S0:S1;
            end
            S1: begin
                INTR <= 0;
                REMOVE_REQ <= decode(INDEX);
                STAR <= S2;
            end
            S2: begin
                REMOVE_REQ <= 'H0000;
                STAR <= (inta == 1)? S2:S0;
            end
        endcase
    
    function [3:0] priority;
        input [15:0] ipr15_ipr0;
        casex(ipr15_ipr0)
            'B???????????????1 : priority = 'B0000;
            'B??????????????10 : priority = 'B0001;
            'B?????????????100 : priority = 'B0010;
            'B????????????1000 : priority = 'B0011;
            'B???????????10000 : priority = 'B0100;
            'B??????????100000 : priority = 'B0101;
            'B?????????1000000 : priority = 'B0110;
            'B????????10000000 : priority = 'B0111;
            'B???????100000000 : priority = 'B1000;
            'B??????1000000000 : priority = 'B1001;
            'B?????10000000000 : priority = 'B1010;
            'B????100000000000 : priority = 'B1011;
            'B???1000000000000 : priority = 'B1100;
            'B??10000000000000 : priority = 'B1101;
            'B?100000000000000 : priority = 'B1110;
            'B1000000000000000 : priority = 'B1111;
            'B0000000000000000 : priority = 'BXXXX;
        endcase
    endfunction

    function [15:0] decode;
        input [3:0] index;
        casex(index)
            'B0000 : decode = 'B0000000000000001;
            'B0001 : decode = 'B0000000000000010;
            'B0010 : decode = 'B0000000000000100;
            'B0011 : decode = 'B0000000000001000;
            'B0100 : decode = 'B0000000000010000;
            'B0101 : decode = 'B0000000000100000;
            'B0110 : decode = 'B0000000001000000;
            'B0111 : decode = 'B0000000010000000;
            'B1000 : decode = 'B0000000100000000;
            'B1001 : decode = 'B0000001000000000;
            'B1010 : decode = 'B0000010000000000;
            'B1011 : decode = 'B0000100000000000;
            'B1100 : decode = 'B0001000000000000;
            'B1101 : decode = 'B0010000000000000;
            'B1110 : decode = 'B0100000000000000;
            'B1111 : decode = 'B1000000000000000;
        endcase
    endfunction
endmodule
module Controllore_Interruzioni(intr, inta, ipr15_ipr0, index, remove_req,
                                clock, reset);

    input   clock, reset_;
    input           inta;
    output          intr;
    input   [15:0]  ipr15_ipr0;
    output  [3:0]   index;
    output  [15:0]  remove_req;
    
    reg             INTR;
    assign intr = INTR;
    
    reg     [3:0]   INDEX;
    assign index = INDEX;

    reg     [15:0]  REMOVE_REQ;
    assign remove_req = REMOVE_REQ;
    
    reg     [1:0]   STAR;
    parameter S0 = 0, S1 = 1, S2 = 2, WS = 3;

    always @(reset_ == 0) #1 begin
        INTR <= 0;
        REMOVE_REQ <= 'HFFFF;
        STAR <= WS;
    end

    always @(posedge clock) if (reset_ == 1) #3
        casex(STAR)
            WS: begin
                STAR <= S0;
            end
            S0: begin
                REMOVE_REQ <= 'H0000;
                INTR <= (ipr15_ipr0 == 'H0000)? 0:1;


                INDEX <= priority(ipr15_ipr0);
                STAR <= (inta == 0)? S0:S1;
            end
            S1: begin
                INTR <= 0;
                REMOVE_REQ <= decode(INDEX);
                STAR <= S2;
            end
            S2: begin
                REMOVE_REQ <= 'H0000;
                STAR <= (inta == 1)? S2:S0;
            end
        endcase
    
    function [3:0] priority;
        input [15:0] ipr15_ipr0;
        casex(ipr15_ipr0)
            'B???????????????1 : priority = 'B0000;
            'B??????????????10 : priority = 'B0001;
            'B?????????????100 : priority = 'B0010;
            'B????????????1000 : priority = 'B0011;
            'B???????????10000 : priority = 'B0100;
            'B??????????100000 : priority = 'B0101;
            'B?????????1000000 : priority = 'B0110;
            'B????????10000000 : priority = 'B0111;
            'B???????100000000 : priority = 'B1000;
            'B??????1000000000 : priority = 'B1001;
            'B?????10000000000 : priority = 'B1010;
            'B????100000000000 : priority = 'B1011;
            'B???1000000000000 : priority = 'B1100;
            'B??10000000000000 : priority = 'B1101;
            'B?100000000000000 : priority = 'B1110;
            'B1000000000000000 : priority = 'B1111;
            'B0000000000000000 : priority = 'BXXXX;
        endcase
    endfunction

    function [15:0] decode;
        input [3:0] index;
        casex(index)
            'B0000 : decode = 'B0000000000000001;
            'B0001 : decode = 'B0000000000000010;
            'B0010 : decode = 'B0000000000000100;
            'B0011 : decode = 'B0000000000001000;
            'B0100 : decode = 'B0000000000010000;
            'B0101 : decode = 'B0000000000100000;
            'B0110 : decode = 'B0000000001000000;
            'B0111 : decode = 'B0000000010000000;
            'B1000 : decode = 'B0000000100000000;
            'B1001 : decode = 'B0000001000000000;
            'B1010 : decode = 'B0000010000000000;
            'B1011 : decode = 'B0000100000000000;
            'B1100 : decode = 'B0001000000000000;
            'B1101 : decode = 'B0010000000000000;
            'B1110 : decode = 'B0100000000000000;
            'B1111 : decode = 'B1000000000000000;
        endcase
    endfunction
endmodule