data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v
 line:526: before: "signed"
1: b'%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:33: Cannot find include file: common_defines.v\n`include "common_defines.v" \n         ^~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source,data/full_repos/permissive/114714167/common_defines.v\n             data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source,data/full_repos/permissive/114714167/common_defines.v.v\n             data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source,data/full_repos/permissive/114714167/common_defines.v.sv\n             common_defines.v\n             common_defines.v.v\n             common_defines.v.sv\n             obj_dir/common_defines.v\n             obj_dir/common_defines.v.v\n             obj_dir/common_defines.v.sv\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:34: Cannot find include file: pid_parameters.v\n`include "pid_parameters.v" \n         ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:37: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] throttle_rate_out,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:38: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] yaw_rate_out,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:39: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] pitch_rate_out,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:40: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] roll_rate_out,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:41: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] yaw_angle_error,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:42: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] pitch_angle_error,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:43: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    output reg  signed [`RATE_BIT_WIDTH-1:0] roll_angle_error,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:46: Define or directive not defined: \'`REC_VAL_BIT_WIDTH\'\n    input  wire [`REC_VAL_BIT_WIDTH-1:0] throttle_target,\n                 ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:47: Define or directive not defined: \'`REC_VAL_BIT_WIDTH\'\n    input  wire [`REC_VAL_BIT_WIDTH-1:0] pitch_target,\n                 ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:48: Define or directive not defined: \'`REC_VAL_BIT_WIDTH\'\n    input  wire [`REC_VAL_BIT_WIDTH-1:0] roll_target,\n                 ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:50: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    input  wire signed [`RATE_BIT_WIDTH-1:0] yaw_angle_target,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:51: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    input  wire signed [`RATE_BIT_WIDTH-1:0] yaw_angle_error_in,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:52: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    input  wire signed [`RATE_BIT_WIDTH-1:0] pitch_actual,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:53: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    input  wire signed [`RATE_BIT_WIDTH-1:0] roll_actual,\n                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:61: Define or directive not defined: \'`OPS_BIT_WIDTH\'\n    localparam signed [`OPS_BIT_WIDTH-1:0]\n                       ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:62: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        THROTTLE_MAX    =  250 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:62: syntax error, unexpected \',\', expecting TYPE-IDENTIFIER\n        THROTTLE_MAX    =  250 << `FIXED_POINT_SHIFT,\n                                                    ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:63: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        YAW_MAX         =  200 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:64: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        YAW_MIN         = -200 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:65: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        PITCH_MAX       =  200 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:66: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        PITCH_MIN       = -200 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:67: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        ROLL_MAX        =  200 << `FIXED_POINT_SHIFT,\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:68: Define or directive not defined: \'`FIXED_POINT_SHIFT\'\n        ROLL_MIN        = -200 << `FIXED_POINT_SHIFT;\n                                  ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:72: Define or directive not defined: \'`OPS_BIT_WIDTH\'\n    localparam signed [`OPS_BIT_WIDTH-1:0]\n                       ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:83: Define or directive not defined: \'`OPS_BIT_WIDTH\'\n    reg signed [`OPS_BIT_WIDTH-1:0]     mapped_throttle, mapped_yaw, mapped_roll, mapped_pitch;\n                ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:84: Define or directive not defined: \'`OPS_BIT_WIDTH\'\n    reg signed [`OPS_BIT_WIDTH-1:0]     scaled_throttle, scaled_yaw, scaled_roll, scaled_pitch;\n                ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:85: Define or directive not defined: \'`REC_VAL_BIT_WIDTH\'\n    reg signed [`REC_VAL_BIT_WIDTH-1:0] latched_throttle, latched_pitch, latched_roll;\n                ^~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:86: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    reg signed [`RATE_BIT_WIDTH-1:0]    latched_yaw_angle_target;\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:87: Define or directive not defined: \'`RATE_BIT_WIDTH\'\n    reg signed [`RATE_BIT_WIDTH-1:0]    latched_yaw_angle_error;\n                ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:88: Define or directive not defined: \'`OPS_BIT_WIDTH\'\n    reg [`OPS_BIT_WIDTH-1:0]            multiplier;\n         ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:101: Define or directive not defined: \'`FALSE\'\n    reg start_flag = `FALSE;\n                     ^~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:101: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n    reg start_flag = `FALSE;\n                           ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:106: Define or directive not defined: \'`FALSE\'\n            start_flag     <= `FALSE;\n                              ^~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:106: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            start_flag     <= `FALSE;\n                                    ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:108: Define or directive not defined: \'`TRUE\'\n            start_flag     <= `TRUE;\n                              ^~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:108: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            start_flag     <= `TRUE;\n                                   ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:111: Define or directive not defined: \'`FALSE\'\n                start_flag <= `FALSE;\n                              ^~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:111: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n                start_flag <= `FALSE;\n                                    ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:121: Define or directive not defined: \'`ALL_ZERO_2BYTE\'\n            latched_throttle         <= `ALL_ZERO_2BYTE;\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:121: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            latched_throttle         <= `ALL_ZERO_2BYTE;\n                                                       ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:122: Define or directive not defined: \'`ALL_ZERO_2BYTE\'\n            latched_yaw_angle_error  <= `ALL_ZERO_2BYTE;\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:122: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            latched_yaw_angle_error  <= `ALL_ZERO_2BYTE;\n                                                       ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:123: Define or directive not defined: \'`ALL_ZERO_2BYTE\'\n            latched_pitch            <= `ALL_ZERO_2BYTE;\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:123: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            latched_pitch            <= `ALL_ZERO_2BYTE;\n                                                       ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:124: Define or directive not defined: \'`ALL_ZERO_2BYTE\'\n            latched_roll             <= `ALL_ZERO_2BYTE;\n                                        ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:124: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            latched_roll             <= `ALL_ZERO_2BYTE;\n                                                       ^\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:167: Define or directive not defined: \'`ALL_ZERO_2BYTE\'\n            yaw_rate_out   <= `ALL_ZERO_2BYTE;\n                              ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/114714167/Source-Code/Drone2/impl1/source/angle_controller.v:167: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n            yaw_rate_out   <= `ALL_ZERO_2BYTE;\n                                             ^\n%Error: Exiting due to too many errors encountered; --error-limit=50\n'
function automatic signed [`RATE_BIT_WIDTH-1:0] scale_val;
    input reg signed [`RATE_BIT_WIDTH-1:0]        val;
    input reg signed [`OPS_BIT_WIDTH-1:0]          k_mult;
    input reg signed [`SHIFT_OP_BIT_WIDTH-1:0]    k_shift;

    reg signed [31:0]
        val_32,
        scaled;

    localparam
        SHIFT_BACK = 7'd16,
        ZERO_PAD   = 16'd0;

    localparam signed [31:0]
        OVERFLOW_PROTECTION_MIN = 32'shFFFF8000,
        OVERFLOW_PROTECTION_MAX = 32'sh00007FFF;

    begin

        val_32 = $signed({val, ZERO_PAD}) >>> SHIFT_BACK;

        scaled = (val_32 * k_mult) >>> k_shift;


        if (scaled <= OVERFLOW_PROTECTION_MIN)
            scale_val = OVERFLOW_PROTECTION_MIN;
        else if (scaled >= OVERFLOW_PROTECTION_MAX)
            scale_val = OVERFLOW_PROTECTION_MAX;
        else
            scale_val = $signed(scaled[`RATE_BIT_WIDTH-1:0]);
    end
endfunction
function automatic signed [`RATE_BIT_WIDTH-1:0] scale_val;

    input reg signed [`RATE_BIT_WIDTH-1:0]        val;
    input reg signed [`OPS_BIT_WIDTH-1:0]          k_mult;
    input reg signed [`SHIFT_OP_BIT_WIDTH-1:0]    k_shift;

    reg signed [31:0]
        val_32,
        scaled;

    localparam
        SHIFT_BACK = 7'd16,
        ZERO_PAD   = 16'd0;

    localparam signed [31:0]
        OVERFLOW_PROTECTION_MIN = 32'shFFFF8000,
        OVERFLOW_PROTECTION_MAX = 32'sh00007FFF;

    begin

        val_32 = $signed({val, ZERO_PAD}) >>> SHIFT_BACK;

        scaled = (val_32 * k_mult) >>> k_shift;


        if (scaled <= OVERFLOW_PROTECTION_MIN)
            scale_val = OVERFLOW_PROTECTION_MIN;
        else if (scaled >= OVERFLOW_PROTECTION_MAX)
            scale_val = OVERFLOW_PROTECTION_MAX;
        else
            scale_val = $signed(scaled[`RATE_BIT_WIDTH-1:0]);
    end
endfunction