data/full_repos/permissive/449370139/verilog_code/vga_site.v
1: b'%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:72: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_h_cnt\' generates 10 bits.\n                                                                               : ... In instance vga_site\n             getx=R_h_cnt-h_startsite;\n                         ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:73: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_v_cnt\' generates 10 bits.\n                                                                               : ... In instance vga_site\n             gety=R_v_cnt-c_startsite;\n                         ^\n%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:152: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_h_cnt\' generates 10 bits.\n                                                                                : ... In instance vga_site\n            getx=R_h_cnt-h_startsite;\n                        ^\n%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:153: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_v_cnt\' generates 10 bits.\n                                                                                : ... In instance vga_site\n            gety=R_v_cnt-c_startsite;\n                        ^\n%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:182: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_h_cnt\' generates 10 bits.\n                                                                                : ... In instance vga_site\n            getx=R_h_cnt-h_startsite;\n                        ^\n%Warning-WIDTH: data/full_repos/permissive/449370139/verilog_code/vga_site.v:183: Operator SUB expects 32 or 16 bits on the LHS, but LHS\'s VARREF \'R_v_cnt\' generates 10 bits.\n                                                                                : ... In instance vga_site\n            gety=R_v_cnt-c_startsite;\n                        ^\n%Error: Exiting due to 6 warning(s)\n'
module vga_site (
    input          [4:0]     state,
    input          [1485:0]  broad,
    input    signed[15:0]    site_X,
    input    signed[15:0]    site_Y,
    input                    I_rst_n,
    input                    R_clk_25M,
    input                    W_active_flag,    
    input          [9:0]     R_h_cnt,
    input          [9:0]     R_v_cnt,     
    output   reg   [3:0]    O_red   ,
    output   reg   [3:0]    O_green ,
    output   reg   [3:0]    O_blue
);
parameter linerow = 20  ;
parameter linevolumn = 20 ;












parameter car_red = 4'b0000 ;
parameter car_green = 4'b0111 ;
parameter car_blue =  4'b0000 ;
parameter radius =15 ;

parameter h_startsite = 144 ;
parameter h_endsite = 784;
parameter c_startsite = 35;
parameter c_endsite = 515;
reg signed [15:0] getx;
reg signed [15:0] gety;

always @(posedge R_clk_25M or negedge I_rst_n)
begin
    if(!I_rst_n)begin
            O_red   <=  4'b0000    ;
            O_green <=  4'b0000    ;
            O_blue  <=  4'b0000    ; 
    end
    else if(W_active_flag)begin

        if(state[0])begin
             getx=R_h_cnt-h_startsite;
             gety=R_v_cnt-c_startsite;
             if(((getx-200)*(getx-200)+(gety-180)*(gety-180))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-400)*(getx-400)+(gety-180)*(gety-180))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-300)*(getx-300)+(gety-300)*(gety-300))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-300)*(getx-300)+(gety-400)*(gety-400))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(gety<=40)begin
                 O_red   <=  4'b0101   ; 
                 O_green <=  4'b0111   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(gety<=80)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b0010    ;
                 O_blue  <=  4'b0101    ;
             end
             else if(gety<=120)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0111    ;
             end
             else if(gety<=160)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b1000    ;
                 O_blue  <=  4'b0110    ;
             end
             else if(gety<=200)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0100    ;
             end
             else if(gety<=240)begin
                 O_red   <=  4'b0011    ; 
                 O_green <=  4'b0110    ;
                 O_blue  <=  4'b0010    ;
             end
             else if(gety<=280)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b1100    ;
                 O_blue  <=  4'b0110    ;
             end
             else if(gety<=320)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b0000    ;
                 O_blue  <=  4'b0000    ;
             end
             else if(gety<=360)begin
                 O_red   <=  4'b1111    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0011    ;
             end
             else if(gety<=400)begin
                 O_red   <=  4'b0000    ; 
                 O_green <=  4'b0110    ;
                 O_blue  <=  4'b1000    ;
             end
             else begin
                 O_red   <=  4'b0000    ; 
                 O_green <=  4'b1000    ;
                 O_blue  <=  4'b0010    ;
             end
        end

        else if(state[1]||state[2]||state[4])begin
            getx=R_h_cnt-h_startsite;
            gety=R_v_cnt-c_startsite;

            if((getx <= linerow || getx >= (h_endsite - linerow - h_startsite )) ||
                (gety <= linevolumn || gety >= (c_endsite - linevolumn - c_startsite)))begin
                O_red   <=  4'b0101    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b0000    ;
            end

            else if(((getx-site_X)*(getx-site_X)+(gety-site_Y)*(gety-site_Y))<=radius*radius)begin
                O_red   <=  car_red     ; 
                O_green <=  car_green   ;
                O_blue  <=  car_blue    ;
            end

            else if(broad[getx/13+gety/13*45])begin
                O_red   <=  4'b1010    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b1111    ;
            end

            else begin
                O_red   <=  4'b0000   ;
                O_green <=  4'b0000   ;
                O_blue  <=  4'b0000   ; 
            end
        end

        else if(state[3])begin
            getx=R_h_cnt-h_startsite;
            gety=R_v_cnt-c_startsite;

            if((getx <= linerow|| getx >= (h_endsite - linerow-h_startsite)) ||
                (gety <= linevolumn || gety >= (c_endsite - linevolumn-c_startsite)))begin
                O_red   <=  4'b0101    ; 
                O_green <=  4'b1000    ;
                O_blue  <=  4'b0000    ;
             end



            else if(((getx-site_X)*(getx-site_X)+(gety-site_Y)*(gety-site_Y))<=radius*radius)begin
                O_red   <=  car_red     ; 
                O_green <=  car_green   ;
                O_blue  <=  car_blue    ;
            end

            else if(broad[getx/13+gety/13*45])begin
                O_red   <=  4'b1010    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b1111    ;
            end

            else begin
                O_red   <=  4'b0000   ;
                O_green <=  4'b0000   ;
                O_blue  <=  4'b0000   ; 
            end

        end
    end
    else begin
        O_red   <=  4'b0000    ;
        O_green <=  4'b0000    ;
        O_blue  <=  4'b0000    ; 
    end           
end
    
endmodule
module vga_site (
    input          [4:0]     state,
    input          [1485:0]  broad,
    input    signed[15:0]    site_X,
    input    signed[15:0]    site_Y,
    input                    I_rst_n,
    input                    R_clk_25M,
    input                    W_active_flag,    
    input          [9:0]     R_h_cnt,
    input          [9:0]     R_v_cnt,     
    output   reg   [3:0]    O_red   ,
    output   reg   [3:0]    O_green ,
    output   reg   [3:0]    O_blue
);

parameter linerow = 20  ;
parameter linevolumn = 20 ;












parameter car_red = 4'b0000 ;
parameter car_green = 4'b0111 ;
parameter car_blue =  4'b0000 ;
parameter radius =15 ;

parameter h_startsite = 144 ;
parameter h_endsite = 784;
parameter c_startsite = 35;
parameter c_endsite = 515;
reg signed [15:0] getx;
reg signed [15:0] gety;

always @(posedge R_clk_25M or negedge I_rst_n)
begin
    if(!I_rst_n)begin
            O_red   <=  4'b0000    ;
            O_green <=  4'b0000    ;
            O_blue  <=  4'b0000    ; 
    end
    else if(W_active_flag)begin

        if(state[0])begin
             getx=R_h_cnt-h_startsite;
             gety=R_v_cnt-c_startsite;
             if(((getx-200)*(getx-200)+(gety-180)*(gety-180))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-400)*(getx-400)+(gety-180)*(gety-180))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-300)*(getx-300)+(gety-300)*(gety-300))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(((getx-300)*(getx-300)+(gety-400)*(gety-400))<=25*25)begin
                 O_red   <=  4'b0000   ; 
                 O_green <=  4'b0000   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(gety<=40)begin
                 O_red   <=  4'b0101   ; 
                 O_green <=  4'b0111   ;
                 O_blue  <=  4'b0000   ;
             end
             else if(gety<=80)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b0010    ;
                 O_blue  <=  4'b0101    ;
             end
             else if(gety<=120)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0111    ;
             end
             else if(gety<=160)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b1000    ;
                 O_blue  <=  4'b0110    ;
             end
             else if(gety<=200)begin
                 O_red   <=  4'b0001    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0100    ;
             end
             else if(gety<=240)begin
                 O_red   <=  4'b0011    ; 
                 O_green <=  4'b0110    ;
                 O_blue  <=  4'b0010    ;
             end
             else if(gety<=280)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b1100    ;
                 O_blue  <=  4'b0110    ;
             end
             else if(gety<=320)begin
                 O_red   <=  4'b0101    ; 
                 O_green <=  4'b0000    ;
                 O_blue  <=  4'b0000    ;
             end
             else if(gety<=360)begin
                 O_red   <=  4'b1111    ; 
                 O_green <=  4'b0100    ;
                 O_blue  <=  4'b0011    ;
             end
             else if(gety<=400)begin
                 O_red   <=  4'b0000    ; 
                 O_green <=  4'b0110    ;
                 O_blue  <=  4'b1000    ;
             end
             else begin
                 O_red   <=  4'b0000    ; 
                 O_green <=  4'b1000    ;
                 O_blue  <=  4'b0010    ;
             end
        end

        else if(state[1]||state[2]||state[4])begin
            getx=R_h_cnt-h_startsite;
            gety=R_v_cnt-c_startsite;

            if((getx <= linerow || getx >= (h_endsite - linerow - h_startsite )) ||
                (gety <= linevolumn || gety >= (c_endsite - linevolumn - c_startsite)))begin
                O_red   <=  4'b0101    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b0000    ;
            end

            else if(((getx-site_X)*(getx-site_X)+(gety-site_Y)*(gety-site_Y))<=radius*radius)begin
                O_red   <=  car_red     ; 
                O_green <=  car_green   ;
                O_blue  <=  car_blue    ;
            end

            else if(broad[getx/13+gety/13*45])begin
                O_red   <=  4'b1010    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b1111    ;
            end

            else begin
                O_red   <=  4'b0000   ;
                O_green <=  4'b0000   ;
                O_blue  <=  4'b0000   ; 
            end
        end

        else if(state[3])begin
            getx=R_h_cnt-h_startsite;
            gety=R_v_cnt-c_startsite;

            if((getx <= linerow|| getx >= (h_endsite - linerow-h_startsite)) ||
                (gety <= linevolumn || gety >= (c_endsite - linevolumn-c_startsite)))begin
                O_red   <=  4'b0101    ; 
                O_green <=  4'b1000    ;
                O_blue  <=  4'b0000    ;
             end



            else if(((getx-site_X)*(getx-site_X)+(gety-site_Y)*(gety-site_Y))<=radius*radius)begin
                O_red   <=  car_red     ; 
                O_green <=  car_green   ;
                O_blue  <=  car_blue    ;
            end

            else if(broad[getx/13+gety/13*45])begin
                O_red   <=  4'b1010    ; 
                O_green <=  4'b0000    ;
                O_blue  <=  4'b1111    ;
            end

            else begin
                O_red   <=  4'b0000   ;
                O_green <=  4'b0000   ;
                O_blue  <=  4'b0000   ; 
            end

        end
    end
    else begin
        O_red   <=  4'b0000    ;
        O_green <=  4'b0000    ;
        O_blue  <=  4'b0000    ; 
    end           
end
    
endmodule