data/full_repos/permissive/158606829/sys/video_mixer.sv
 line:75: before: "*"
1: b'%Warning-IMPLICIT: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Signal definition not found, creating implicitly: \'r\'\n                                                                              : ... Suggested alternative: \'rt\'\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                   ^\n                   ... Use "/* verilator lint_off IMPLICIT */" and lint_on around source to disable this message.\n%Warning-IMPLICIT: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Signal definition not found, creating implicitly: \'g\'\n                                                                              : ... Suggested alternative: \'gt\'\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                   ^\n%Warning-IMPLICIT: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Signal definition not found, creating implicitly: \'b\'\n                                                                              : ... Suggested alternative: \'bt\'\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                   ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:73: Cannot find file containing module: \'scandoubler\'\nscandoubler #(.LENGTH(LINE_LENGTH), .HALF_DEPTH(HALF_DEPTH)) sd\n^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/158606829/sys,data/full_repos/permissive/158606829/scandoubler\n             data/full_repos/permissive/158606829/sys,data/full_repos/permissive/158606829/scandoubler.v\n             data/full_repos/permissive/158606829/sys,data/full_repos/permissive/158606829/scandoubler.sv\n             scandoubler\n             scandoubler.v\n             scandoubler.sv\n             obj_dir/scandoubler\n             obj_dir/scandoubler.v\n             obj_dir/scandoubler.sv\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                                      ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:135: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]} + {2\'b00, r[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                                      ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:136: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]} + {2\'b00, g[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                                      ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:137: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]} + {2\'b00, b[7:2]};\n                                      ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:141: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:141: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:141: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_R <= {1\'b0, r[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:142: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:142: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:142: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_G <= {1\'b0, g[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:143: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:143: Extracting 7 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]};\n                    ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:143: Selection index out of range: 7:1 outside 6:0\n                                                                              : ... In instance video_mixer\n   VGA_B <= {1\'b0, b[7:1]};\n                    ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:147: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_R <= {2\'b00, r[7:2]};\n                     ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:147: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_R <= {2\'b00, r[7:2]};\n                     ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:147: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_R <= {2\'b00, r[7:2]};\n                     ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:148: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_G <= {2\'b00, g[7:2]};\n                     ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:148: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_G <= {2\'b00, g[7:2]};\n                     ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:148: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_G <= {2\'b00, g[7:2]};\n                     ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:149: Illegal bit or array select; type does not have a bit range, or bad dimension: data type is \'logic\'\n                                                                   : ... In instance video_mixer\n   VGA_B <= {2\'b00, b[7:2]};\n                     ^\n%Error: data/full_repos/permissive/158606829/sys/video_mixer.sv:149: Extracting 6 bits from only 1 bit number\n                                                                   : ... In instance video_mixer\n   VGA_B <= {2\'b00, b[7:2]};\n                     ^\n%Warning-SELRANGE: data/full_repos/permissive/158606829/sys/video_mixer.sv:149: Selection index out of range: 7:2 outside 5:0\n                                                                              : ... In instance video_mixer\n   VGA_B <= {2\'b00, b[7:2]};\n                     ^\n%Warning-WIDTH: data/full_repos/permissive/158606829/sys/video_mixer.sv:153: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'r\' generates 1 bits.\n                                                                           : ... In instance video_mixer\n   VGA_R <= r;\n         ^~\n%Warning-WIDTH: data/full_repos/permissive/158606829/sys/video_mixer.sv:154: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'g\' generates 1 bits.\n                                                                           : ... In instance video_mixer\n   VGA_G <= g;\n         ^~\n%Warning-WIDTH: data/full_repos/permissive/158606829/sys/video_mixer.sv:155: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s VARREF \'b\' generates 1 bits.\n                                                                           : ... In instance video_mixer\n   VGA_B <= b;\n         ^~\n%Error: Exiting due to 25 error(s), 18 warning(s)\n'
module video_mixer
#(
	parameter LINE_LENGTH  = 768,
	parameter HALF_DEPTH   = 0
)
(


	input            clk_sys,
	

	input            ce_pix,
	output           ce_pix_out,

	input            scandoubler,


	input      [1:0] scanlines,


	input            hq2x,


	input [DWIDTH:0] R,
	input [DWIDTH:0] G,
	input [DWIDTH:0] B,


	input            mono,


	input            HSync,
	input            VSync,
	input            HBlank,
	input            VBlank,


	output reg [7:0] VGA_R,
	output reg [7:0] VGA_G,
	output reg [7:0] VGA_B,
	output reg       VGA_VS,
	output reg       VGA_HS,
	output reg       VGA_DE
);

localparam DWIDTH = HALF_DEPTH ? 3 : 7;

wire [DWIDTH:0] R_sd;
wire [DWIDTH:0] G_sd;
wire [DWIDTH:0] B_sd;
wire hs_sd, vs_sd, hb_sd, vb_sd, ce_pix_sd;

scandoubler #(.LENGTH(LINE_LENGTH), .HALF_DEPTH(HALF_DEPTH)) sd
(
	.*,
	.hs_in(HSync),
	.vs_in(VSync),
	.hb_in(HBlank),
	.vb_in(VBlank),
	.r_in(R),
	.g_in(G),
	.b_in(B),

	.ce_pix_out(ce_pix_sd),
	.hs_out(hs_sd),
	.vs_out(vs_sd),
	.hb_out(hb_sd),
	.vb_out(vb_sd),
	.r_out(R_sd),
	.g_out(G_sd),
	.b_out(B_sd)
);

wire [DWIDTH:0] rt  = (scandoubler ? R_sd : R);
wire [DWIDTH:0] gt  = (scandoubler ? G_sd : G);
wire [DWIDTH:0] bt  = (scandoubler ? B_sd : B);

generate
	if(HALF_DEPTH) begin
		wire [7:0] r  = mono ? {gt,rt} : {rt,rt};
		wire [7:0] g  = mono ? {gt,rt} : {gt,gt};
		wire [7:0] b  = mono ? {gt,rt} : {bt,bt};
	end else begin
		wire [7:0] r  = rt;
		wire [7:0] g  = gt;
		wire [7:0] b  = bt;
	end
endgenerate

wire hs = (scandoubler ? hs_sd : HSync);
wire vs = (scandoubler ? vs_sd : VSync);

assign ce_pix_out = scandoubler ? ce_pix_sd : ce_pix;


reg scanline = 0;
always @(posedge clk_sys) begin
	reg old_hs, old_vs;
	
	old_hs <= hs;
	old_vs <= vs;
	
	if(old_hs && ~hs) scanline <= ~scanline;
	if(old_vs && ~vs) scanline <= 0;
end

wire hde = scandoubler ? ~hb_sd : ~HBlank;
wire vde = scandoubler ? ~vb_sd : ~VBlank;

always @(posedge clk_sys) begin
	reg old_hde;

	case(scanlines & {scanline, scanline})
		1: begin
			VGA_R <= {1'b0, r[7:1]} + {2'b00, r[7:2]};
			VGA_G <= {1'b0, g[7:1]} + {2'b00, g[7:2]};
			VGA_B <= {1'b0, b[7:1]} + {2'b00, b[7:2]};
		end

		2: begin
			VGA_R <= {1'b0, r[7:1]};
			VGA_G <= {1'b0, g[7:1]};
			VGA_B <= {1'b0, b[7:1]};
		end

		3: begin
			VGA_R <= {2'b00, r[7:2]};
			VGA_G <= {2'b00, g[7:2]};
			VGA_B <= {2'b00, b[7:2]};
		end

		default: begin
			VGA_R <= r;
			VGA_G <= g;
			VGA_B <= b;
		end
	endcase

	VGA_VS <= vs;
	VGA_HS <= hs;

	old_hde <= hde;
	if(~old_hde && hde) VGA_DE <= vde;
	if(old_hde && ~hde) VGA_DE <= 0;
end

endmodule
module video_mixer
#(
	parameter LINE_LENGTH  = 768,
	parameter HALF_DEPTH   = 0
)
(


	input            clk_sys,
	

	input            ce_pix,
	output           ce_pix_out,

	input            scandoubler,


	input      [1:0] scanlines,


	input            hq2x,


	input [DWIDTH:0] R,
	input [DWIDTH:0] G,
	input [DWIDTH:0] B,


	input            mono,


	input            HSync,
	input            VSync,
	input            HBlank,
	input            VBlank,


	output reg [7:0] VGA_R,
	output reg [7:0] VGA_G,
	output reg [7:0] VGA_B,
	output reg       VGA_VS,
	output reg       VGA_HS,
	output reg       VGA_DE
);


localparam DWIDTH = HALF_DEPTH ? 3 : 7;

wire [DWIDTH:0] R_sd;
wire [DWIDTH:0] G_sd;
wire [DWIDTH:0] B_sd;
wire hs_sd, vs_sd, hb_sd, vb_sd, ce_pix_sd;

scandoubler #(.LENGTH(LINE_LENGTH), .HALF_DEPTH(HALF_DEPTH)) sd
(
	.*,
	.hs_in(HSync),
	.vs_in(VSync),
	.hb_in(HBlank),
	.vb_in(VBlank),
	.r_in(R),
	.g_in(G),
	.b_in(B),

	.ce_pix_out(ce_pix_sd),
	.hs_out(hs_sd),
	.vs_out(vs_sd),
	.hb_out(hb_sd),
	.vb_out(vb_sd),
	.r_out(R_sd),
	.g_out(G_sd),
	.b_out(B_sd)
);

wire [DWIDTH:0] rt  = (scandoubler ? R_sd : R);
wire [DWIDTH:0] gt  = (scandoubler ? G_sd : G);
wire [DWIDTH:0] bt  = (scandoubler ? B_sd : B);

generate
	if(HALF_DEPTH) begin
		wire [7:0] r  = mono ? {gt,rt} : {rt,rt};
		wire [7:0] g  = mono ? {gt,rt} : {gt,gt};
		wire [7:0] b  = mono ? {gt,rt} : {bt,bt};
	end else begin
		wire [7:0] r  = rt;
		wire [7:0] g  = gt;
		wire [7:0] b  = bt;
	end
endgenerate

wire hs = (scandoubler ? hs_sd : HSync);
wire vs = (scandoubler ? vs_sd : VSync);

assign ce_pix_out = scandoubler ? ce_pix_sd : ce_pix;


reg scanline = 0;
always @(posedge clk_sys) begin
	reg old_hs, old_vs;
	
	old_hs <= hs;
	old_vs <= vs;
	
	if(old_hs && ~hs) scanline <= ~scanline;
	if(old_vs && ~vs) scanline <= 0;
end

wire hde = scandoubler ? ~hb_sd : ~HBlank;
wire vde = scandoubler ? ~vb_sd : ~VBlank;

always @(posedge clk_sys) begin
	reg old_hde;

	case(scanlines & {scanline, scanline})
		1: begin
			VGA_R <= {1'b0, r[7:1]} + {2'b00, r[7:2]};
			VGA_G <= {1'b0, g[7:1]} + {2'b00, g[7:2]};
			VGA_B <= {1'b0, b[7:1]} + {2'b00, b[7:2]};
		end

		2: begin
			VGA_R <= {1'b0, r[7:1]};
			VGA_G <= {1'b0, g[7:1]};
			VGA_B <= {1'b0, b[7:1]};
		end

		3: begin
			VGA_R <= {2'b00, r[7:2]};
			VGA_G <= {2'b00, g[7:2]};
			VGA_B <= {2'b00, b[7:2]};
		end

		default: begin
			VGA_R <= r;
			VGA_G <= g;
			VGA_B <= b;
		end
	endcase

	VGA_VS <= vs;
	VGA_HS <= hs;

	old_hde <= hde;
	if(~old_hde && hde) VGA_DE <= vde;
	if(old_hde && ~hde) VGA_DE <= 0;
end

endmodule