data/full_repos/permissive/162924824/test2/comun/sprite.v
'utf-8' codec can't decode byte 0xf1 in position 1438: invalid continuation byte
1: b'%Warning-WIDTH: data/full_repos/permissive/162924824/test2/comun/sprite.v:44: Operator ASSIGNW expects 6 bits on the Assign RHS, but Assign RHS\'s SUB generates 11 bits.\n                                                                            : ... In instance sprite\n  wire [5:0] spr_x = hc - posx;  \n                   ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/162924824/test2/comun/sprite.v:45: Operator ASSIGNW expects 6 bits on the Assign RHS, but Assign RHS\'s SUB generates 11 bits.\n                                                                            : ... In instance sprite\n  wire [5:0] spr_y = vc - posy;  \n                   ^\n%Error: Exiting due to 2 warning(s)\n'
module sprite (
  input wire clk,
  input wire [10:0] hc,
  input wire [10:0] vc,
  input wire [10:0] posx,
  input wire [10:0] posy,
  input wire [7:0] rin,
  input wire [7:0] gin,
  input wire [7:0] bin,
  output reg [7:0] rout,
  output reg [7:0] gout,
  output reg [7:0] bout
  );

  localparam
    TRANSPARENTE = 24'h00FF00,
    TAM          = 11'd64;

  reg [23:0] spr[0:255];
  initial begin
    $readmemh ("datos_sprite.hex", spr);
  end
  
  wire [5:0] spr_x = hc - posx;
  wire [5:0] spr_y = vc - posy;
  
  reg [23:0] color;
  
  always @(posedge clk)
    color <= spr[{spr_y[5:2],spr_x[5:2]}];
    
  always @* begin
    if (hc >= posx && hc < (posx + TAM) && vc >= posy && vc < (posy + TAM) && color != TRANSPARENTE) begin
      rout = color[23:16];
      gout = color[15:8];
      bout = color[7:0];
    end
    else begin
      rout = rin;
      gout = gin;
      bout = bin;
    end  
  end
endmodule
module sprite (
  input wire clk,
  input wire [10:0] hc,
  input wire [10:0] vc,
  input wire [10:0] posx,
  input wire [10:0] posy,
  input wire [7:0] rin,
  input wire [7:0] gin,
  input wire [7:0] bin,
  output reg [7:0] rout,
  output reg [7:0] gout,
  output reg [7:0] bout
  );


  localparam
    TRANSPARENTE = 24'h00FF00,
    TAM          = 11'd64;

  reg [23:0] spr[0:255];
  initial begin
    $readmemh ("datos_sprite.hex", spr);
  end
  
  wire [5:0] spr_x = hc - posx;
  wire [5:0] spr_y = vc - posy;
  
  reg [23:0] color;
  
  always @(posedge clk)
    color <= spr[{spr_y[5:2],spr_x[5:2]}];
    
  always @* begin
    if (hc >= posx && hc < (posx + TAM) && vc >= posy && vc < (posy + TAM) && color != TRANSPARENTE) begin
      rout = color[23:16];
      gout = color[15:8];
      bout = color[7:0];
    end
    else begin
      rout = rin;
      gout = gin;
      bout = bin;
    end  
  end
endmodule