data/full_repos/permissive/207111076/my_osd.v
 line:25: before: "="
1: b'%Warning-PINMISSING: data/full_repos/permissive/207111076/my_osd.v:578: Cell has missing pin: \'load_late\'\nspi8 spi0\n     ^~~~\n                     ... Use "/* verilator lint_off PINMISSING */" and lint_on around source to disable this message.\n%Warning-IMPLICIT: data/full_repos/permissive/207111076/my_osd.v:210: Signal definition not found, creating implicitly: \'COLDRESET_N\'\nassign COLDRESET_N = int_mask[7];\n       ^~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/207111076/my_osd.v:541: Signal definition not found, creating implicitly: \'audio_fifo_reset\'\nassign audio_fifo_reset = (rx && cmd && spicmd==4\'b1010);\n       ^~~~~~~~~~~~~~~~\n%Warning-IMPLICIT: data/full_repos/permissive/207111076/my_osd.v:542: Signal definition not found, creating implicitly: \'audio_wrreq\'\nassign audio_wrreq = (rx && ~cmd && spicmd==4\'b1010);\n       ^~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:259: Operator ASSIGNW expects 12 bits on the Assign RHS, but Assign RHS\'s SEL generates 10 bits.\n                                                                 : ... In instance my_osd\nwire [11:0] frame_x_scroll = frame_x[11:2] ;\n                           ^\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:260: Operator ASSIGNW expects 12 bits on the Assign RHS, but Assign RHS\'s SEL generates 10 bits.\n                                                                 : ... In instance my_osd\nwire [11:0] frame_y_scroll = frame_y[11:2] ;\n                           ^\n%Error: data/full_repos/permissive/207111076/my_osd.v:272: Cannot find file containing module: \'scroll_buf\'\nscroll_buf scroll_buf_a (\n^~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/207111076,data/full_repos/permissive/207111076/scroll_buf\n             data/full_repos/permissive/207111076,data/full_repos/permissive/207111076/scroll_buf.v\n             data/full_repos/permissive/207111076,data/full_repos/permissive/207111076/scroll_buf.sv\n             scroll_buf\n             scroll_buf.v\n             scroll_buf.sv\n             obj_dir/scroll_buf\n             obj_dir/scroll_buf.v\n             obj_dir/scroll_buf.sv\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:326: Operator ASSIGNW expects 14 bits on the Assign RHS, but Assign RHS\'s REPLICATE generates 17 bits.\n                                                                 : ... In instance my_osd\nwire [13:0] patt_addr = { frame_y_scroll[8:0], frame_x_scroll[5:1],3\'b000 };\n                      ^\n%Error: data/full_repos/permissive/207111076/my_osd.v:340: Cannot find file containing module: \'osdbuf\'\nosdbuf osdbuf_inst (\n^~~~~~\n%Error: data/full_repos/permissive/207111076/my_osd.v:351: Cannot find file containing module: \'att_buf\'\natt_buf att_buf_inst (\n^~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:430: Operator COND expects 32 bits on the Conditional False, but Conditional False\'s VARREF \'rgb_in\' generates 24 bits.\n                                                                 : ... In instance my_osd\nalways @(*) rgb_out = (osdframe | scrollframe) ? pal_pixel : rgb_in;\n                                               ^\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:430: Operator ASSIGN expects 24 bits on the Assign RHS, but Assign RHS\'s COND generates 32 bits.\n                                                                 : ... In instance my_osd\nalways @(*) rgb_out = (osdframe | scrollframe) ? pal_pixel : rgb_in;\n                    ^\n%Warning-WIDTH: data/full_repos/permissive/207111076/my_osd.v:497: Operator ADD expects 8 bits on the RHS, but RHS\'s CONST \'4\'h1\' generates 4 bits.\n                                                                 : ... In instance my_osd\n  paladdr <= paladdr + 4\'d1;\n                     ^\n%Error: Exiting due to 3 error(s), 10 warning(s)\n'
module my_osd
(
	input	reset_n,
	
	input	pix_clk,
	
	input sys_clk,
	
	input	hsync,
	input	vsync,
	
	input	[7:0] osd_ctrl,
	
	input	_scs,
	inout sdo,
	input	sdi,
	input	sck,
	
	input wire [11:0] horbeam,
	input wire [11:0] verbeam,
	
	output	wire osdframe,
	
	output 	reg cont_disable = 0,
	output	reg osd_enable = 0,
		
	output	reg [1:0] cable_type = 3,

	
	output	reg [3:0] scanline_mode = 0,
	
	output	reg [1:0] lr_filter = 0,
	output	reg [1:0] hr_filter = 0,
	
	input wire [23:0] rgb_in,
	output reg [23:0] rgb_out
);



wire	[7:0] wrdat;
reg 	[13:0] wraddr;
wire	osd_wren;

reg 	[7:0] paladdr;
wire	pal_wren;

reg	invert;

reg	[31:0] palette [63:0];

reg	[8:0] attrib_wraddr;

reg	[2:0] pos_wraddr;
wire 	pos_wren;

reg	[11:0] frame_x;
reg	[11:0] frame_y;

reg	double_size = 0;

wire  osd_vsync = (verbeam==osd_vpos && hframe);

reg scroll_enable = 1;












	













wire [13:0] patt_addr = { frame_y_scroll[8:0], frame_x_scroll[5:1],3'b000 };








wire [3:0] pal_entry = (!frame_x_scroll[0]) ? osdbuf_data_out[7:4] : osdbuf_data_out[3:0];



wire [7:0] osdbuf_data_out;
osdbuf	osdbuf_inst (
	.clock ( pix_clk ),
	.data ( wrdat ),
	.rdaddress ( patt_addr ),
	.wraddress ( wraddr ),
	.wren ( osd_wren ),
	.q ( osdbuf_data_out )
);


wire [7:0] attrib_data_out;
att_buf	att_buf_inst (
	.clock ( pix_clk ),
	.data ( wrdat ),
	.rdaddress ( patt_addr[13:5] ),
	.wraddress ( attrib_wraddr ),
	.wren ( attrib_wren ),
	.q ( attrib_data_out )
);




wire [31:0] pal_pixel = (pal_entry==0)  ? 32'h00_44_44_44 :
								(pal_entry==1)  ? 32'h00_FF_DD_99 :
								(pal_entry==2)  ? 32'h00_FF_BB_88 :
								(pal_entry==3)  ? 32'h00_EE_99_77 :
								(pal_entry==4)  ? 32'h00_CC_88_66 :
								(pal_entry==5)  ? 32'h00_99_66_55 :
								(pal_entry==6)  ? 32'h00_66_44_33 :
								(pal_entry==7)  ? 32'h00_BB_00_00 :
								(pal_entry==8)  ? 32'h00_FF_FF_FF :
								(pal_entry==9)  ? 32'h00_EE_EE_CC :
								(pal_entry==10) ? 32'h00_DD_CC_AA :
								(pal_entry==11) ? 32'h00_BB_AA_88 :
								(pal_entry==12) ? 32'h00_AA_88_77 :
								(pal_entry==13) ? 32'h00_88_66_CC :
								(pal_entry==14) ? 32'h00_77_66_55 :
														32'h00_00_11_FF;
						
wire [7:0] r_in = rgb_in[23:16];
wire [7:0] g_in = rgb_in[15:8];
wire [7:0] b_in = rgb_in[7:0];

wire [7:0] alpha = pal_pixel[31:24];
wire [7:0] r_pal = pal_pixel[23:16];
wire [7:0] g_pal = pal_pixel[15:8];
wire [7:0] b_pal = pal_pixel[7:0];





















always @(*) rgb_out = (osdframe | scrollframe) ? pal_pixel : rgb_in;


























always @(posedge sys_clk or negedge reset_n)
if (!reset_n) begin

end
else begin


	if (rx && cmd) spicmd <= wrdat[7:4];







	if (rx && cmd && wrdat[7:4]==4'b0001) attrib_wraddr <= {wrdat[3:0],5'b00000};
	else if (rx && ~cmd && spicmd == 4'b0001) attrib_wraddr <= attrib_wraddr + 9'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b0010) wraddr <= {wrdat[3:0],10'b0000000000};
	else if (rx && ~cmd && spicmd == 4'b0010) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b1101) wraddr <= 0;
	else if (rx && ~cmd && spicmd == 4'b1101) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b1110) wraddr <= 0;
	else if (rx && ~cmd && spicmd == 4'b1110) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b0011) paladdr <= {wrdat[1:0],6'b0000_00};
	else if (pal_wren) begin
		case (paladdr[1:0])
			0: palette[ paladdr[7:2] ][31:24] <= wrdat;
			1: palette[ paladdr[7:2] ][23:16] <= wrdat;
			2: palette[ paladdr[7:2] ][15:8]  <= wrdat;
			3: palette[ paladdr[7:2] ][7:0]	 <= wrdat;
			default:;
		endcase
		paladdr <= paladdr + 4'd1;
	end
	

	if (rx && cmd && wrdat[7:4]==4'b0100) {scroll_enable, double_size, cont_disable, osd_enable} <= wrdat[3:0];


	if (rx && cmd && wrdat[7:4]==4'b0101) cable_type <= wrdat[1:0];
	

	if (rx && cmd && wrdat[7:4]==4'b0110) scanline_mode <= wrdat[3:0];


	if (rx && cmd && wrdat[7:4]==4'b0111) {hr_filter,lr_filter} <= wrdat[3:0];
	

	if (rx && cmd && wrdat[7:4]==4'b1000) pos_wraddr <= 3'b000;
	else if (pos_wren) begin
		case (pos_wraddr)
			0: osd_hpos[11:8] <= wrdat[3:0];
			1: osd_hpos[7:0]  <= wrdat;
			2: osd_vpos[11:8] <= wrdat[3:0];
			3: osd_vpos[7:0]  <= wrdat;
			4: scroll_x[11:8] <= wrdat[3:0];
			5: scroll_x[7:0] 	<= wrdat;
			6: scroll_y[11:8] <= wrdat[3:0];
			7: scroll_y[7:0] 	<= wrdat;
			default:;
		endcase
		pos_wraddr <= pos_wraddr + 3'd1;
	end
	
end


wire attrib_wren 	= (rx && ~cmd && spicmd==4'b0001);
assign osd_wren   = (rx && ~cmd && spicmd==4'b0010);
assign pal_wren   = (rx && ~cmd && spicmd==4'b0011);

wire scroll_a_wren = (rx && ~cmd && spicmd==4'b1101 && wraddr[0]);
wire scroll_b_wren = (rx && ~cmd && spicmd==4'b1110 && wraddr[0]);

assign pos_wren   	= (rx && ~cmd && spicmd==4'b1000);

assign audio_fifo_reset = (rx && cmd && spicmd==4'b1010);
assign audio_wrreq = (rx && ~cmd && spicmd==4'b1010);




wire [7:0] spi_in_mux = status;





wire	rx;
wire	cmd;
reg 	[3:0] spicmd;

reg load_late = 0;


spi8 spi0
(
	.clk( sys_clk ),
	._scs( _scs ),
	.sdi( sdi ),
	.sdo( sdo ),
	.sck( sck ),
	.in( spi_in_mux ),
	.out( wrdat[7:0] ),
	.rx( rx ),
	.cmd( cmd )
);

endmodule
module my_osd
(
	input	reset_n,
	
	input	pix_clk,
	
	input sys_clk,
	
	input	hsync,
	input	vsync,
	
	input	[7:0] osd_ctrl,
	
	input	_scs,
	inout sdo,
	input	sdi,
	input	sck,
	
	input wire [11:0] horbeam,
	input wire [11:0] verbeam,
	
	output	wire osdframe,
	
	output 	reg cont_disable = 0,
	output	reg osd_enable = 0,
		
	output	reg [1:0] cable_type = 3,

	
	output	reg [3:0] scanline_mode = 0,
	
	output	reg [1:0] lr_filter = 0,
	output	reg [1:0] hr_filter = 0,
	
	input wire [23:0] rgb_in,
	output reg [23:0] rgb_out
);




wire	[7:0] wrdat;
reg 	[13:0] wraddr;
wire	osd_wren;

reg 	[7:0] paladdr;
wire	pal_wren;

reg	invert;

reg	[31:0] palette [63:0];

reg	[8:0] attrib_wraddr;

reg	[2:0] pos_wraddr;
wire 	pos_wren;

reg	[11:0] frame_x;
reg	[11:0] frame_y;

reg	double_size = 0;

wire  osd_vsync = (verbeam==osd_vpos && hframe);

reg scroll_enable = 1;












	













wire [13:0] patt_addr = { frame_y_scroll[8:0], frame_x_scroll[5:1],3'b000 };








wire [3:0] pal_entry = (!frame_x_scroll[0]) ? osdbuf_data_out[7:4] : osdbuf_data_out[3:0];



wire [7:0] osdbuf_data_out;
osdbuf	osdbuf_inst (
	.clock ( pix_clk ),
	.data ( wrdat ),
	.rdaddress ( patt_addr ),
	.wraddress ( wraddr ),
	.wren ( osd_wren ),
	.q ( osdbuf_data_out )
);


wire [7:0] attrib_data_out;
att_buf	att_buf_inst (
	.clock ( pix_clk ),
	.data ( wrdat ),
	.rdaddress ( patt_addr[13:5] ),
	.wraddress ( attrib_wraddr ),
	.wren ( attrib_wren ),
	.q ( attrib_data_out )
);




wire [31:0] pal_pixel = (pal_entry==0)  ? 32'h00_44_44_44 :
								(pal_entry==1)  ? 32'h00_FF_DD_99 :
								(pal_entry==2)  ? 32'h00_FF_BB_88 :
								(pal_entry==3)  ? 32'h00_EE_99_77 :
								(pal_entry==4)  ? 32'h00_CC_88_66 :
								(pal_entry==5)  ? 32'h00_99_66_55 :
								(pal_entry==6)  ? 32'h00_66_44_33 :
								(pal_entry==7)  ? 32'h00_BB_00_00 :
								(pal_entry==8)  ? 32'h00_FF_FF_FF :
								(pal_entry==9)  ? 32'h00_EE_EE_CC :
								(pal_entry==10) ? 32'h00_DD_CC_AA :
								(pal_entry==11) ? 32'h00_BB_AA_88 :
								(pal_entry==12) ? 32'h00_AA_88_77 :
								(pal_entry==13) ? 32'h00_88_66_CC :
								(pal_entry==14) ? 32'h00_77_66_55 :
														32'h00_00_11_FF;
						
wire [7:0] r_in = rgb_in[23:16];
wire [7:0] g_in = rgb_in[15:8];
wire [7:0] b_in = rgb_in[7:0];

wire [7:0] alpha = pal_pixel[31:24];
wire [7:0] r_pal = pal_pixel[23:16];
wire [7:0] g_pal = pal_pixel[15:8];
wire [7:0] b_pal = pal_pixel[7:0];





















always @(*) rgb_out = (osdframe | scrollframe) ? pal_pixel : rgb_in;


























always @(posedge sys_clk or negedge reset_n)
if (!reset_n) begin

end
else begin


	if (rx && cmd) spicmd <= wrdat[7:4];







	if (rx && cmd && wrdat[7:4]==4'b0001) attrib_wraddr <= {wrdat[3:0],5'b00000};
	else if (rx && ~cmd && spicmd == 4'b0001) attrib_wraddr <= attrib_wraddr + 9'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b0010) wraddr <= {wrdat[3:0],10'b0000000000};
	else if (rx && ~cmd && spicmd == 4'b0010) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b1101) wraddr <= 0;
	else if (rx && ~cmd && spicmd == 4'b1101) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b1110) wraddr <= 0;
	else if (rx && ~cmd && spicmd == 4'b1110) wraddr <= wraddr + 14'd1;
	

	if (rx && cmd && wrdat[7:4]==4'b0011) paladdr <= {wrdat[1:0],6'b0000_00};
	else if (pal_wren) begin
		case (paladdr[1:0])
			0: palette[ paladdr[7:2] ][31:24] <= wrdat;
			1: palette[ paladdr[7:2] ][23:16] <= wrdat;
			2: palette[ paladdr[7:2] ][15:8]  <= wrdat;
			3: palette[ paladdr[7:2] ][7:0]	 <= wrdat;
			default:;
		endcase
		paladdr <= paladdr + 4'd1;
	end
	

	if (rx && cmd && wrdat[7:4]==4'b0100) {scroll_enable, double_size, cont_disable, osd_enable} <= wrdat[3:0];


	if (rx && cmd && wrdat[7:4]==4'b0101) cable_type <= wrdat[1:0];
	

	if (rx && cmd && wrdat[7:4]==4'b0110) scanline_mode <= wrdat[3:0];


	if (rx && cmd && wrdat[7:4]==4'b0111) {hr_filter,lr_filter} <= wrdat[3:0];
	

	if (rx && cmd && wrdat[7:4]==4'b1000) pos_wraddr <= 3'b000;
	else if (pos_wren) begin
		case (pos_wraddr)
			0: osd_hpos[11:8] <= wrdat[3:0];
			1: osd_hpos[7:0]  <= wrdat;
			2: osd_vpos[11:8] <= wrdat[3:0];
			3: osd_vpos[7:0]  <= wrdat;
			4: scroll_x[11:8] <= wrdat[3:0];
			5: scroll_x[7:0] 	<= wrdat;
			6: scroll_y[11:8] <= wrdat[3:0];
			7: scroll_y[7:0] 	<= wrdat;
			default:;
		endcase
		pos_wraddr <= pos_wraddr + 3'd1;
	end
	
end


wire attrib_wren 	= (rx && ~cmd && spicmd==4'b0001);
assign osd_wren   = (rx && ~cmd && spicmd==4'b0010);
assign pal_wren   = (rx && ~cmd && spicmd==4'b0011);

wire scroll_a_wren = (rx && ~cmd && spicmd==4'b1101 && wraddr[0]);
wire scroll_b_wren = (rx && ~cmd && spicmd==4'b1110 && wraddr[0]);

assign pos_wren   	= (rx && ~cmd && spicmd==4'b1000);

assign audio_fifo_reset = (rx && cmd && spicmd==4'b1010);
assign audio_wrreq = (rx && ~cmd && spicmd==4'b1010);




wire [7:0] spi_in_mux = status;





wire	rx;
wire	cmd;
reg 	[3:0] spicmd;

reg load_late = 0;


spi8 spi0
(
	.clk( sys_clk ),
	._scs( _scs ),
	.sdi( sdi ),
	.sdo( sdo ),
	.sck( sck ),
	.in( spi_in_mux ),
	.out( wrdat[7:0] ),
	.rx( rx ),
	.cmd( cmd )
);

endmodule