data/full_repos/permissive/51625123/src/vga.v
1: b'%Error: data/full_repos/permissive/51625123/src/vga.v:47: Unsupported: wand\nwand RED;\n^~~~\n%Error: data/full_repos/permissive/51625123/src/vga.v:48: Unsupported: wand\nwand GREEN;\n^~~~\n%Error: data/full_repos/permissive/51625123/src/vga.v:49: Unsupported: wand\nwand BLUE;\n^~~~\n%Error: Exiting due to 3 error(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module vga(clk, LED1, LED2, VSYNC, HSYNC, RED, GREEN, BLUE, MISO, MOSI, SCK, SCS, SOUND, BATON1, BATON2);
input clk;

output LED1;
output LED2;

output VSYNC;
output HSYNC;
output RED, GREEN, BLUE;

input MISO;
output MOSI;
output SCK;
output SCS;
output SOUND;

input BATON1;
input BATON2;

wand RED;
wand GREEN;
wand BLUE;

parameter SCREENWIDTH = 10'd640;
parameter SCREENHEIGHT = 10'd480;
parameter PADDLESIZE = 10'd64;
parameter BALLSIZE = 8;


wire paddle_scan;
wire ball_scan;

wire[9:0] paddleA_y;
wire[9:0] paddleB_y_manual;
wire[9:0] paddleB_y_robot;
reg [9:0] paddleB_y;
reg playerBswitch;




reg clkdiv8;					
reg [6:0] clkdiv8_cnt;
always @(posedge clk) begin
	if (clkdiv8_cnt == 0)
		clkdiv8 <= !clkdiv8;
	clkdiv8_cnt <= clkdiv8_cnt - 1'b1;
end




reg [7:0] paddle_cnt;				
reg [6:0] ball_cnt;
reg paddleAdvance;
reg ballAdvance;
always @(posedge clkdiv8) begin
	paddle_cnt <= paddle_cnt - 1'b1;
	ball_cnt <= ball_cnt - 1'b1;
	if (ball_cnt == 0) ball_cnt <= 7'b1100000;
end

always @(posedge clk) paddleAdvance = paddle_cnt == 0;
always @(posedge clk) ballAdvance = ball_cnt == 0;




wire resetpulse;
wire gamereset;
resetgen resetgen(clk, resetpulse, 1);	
button2 #(8192) gameresetter(clkdiv8, gamereset, BATON1);
button2 #(8192) button2(clkdiv8, playerBbutton, BATON2);


always @(posedge playerBbutton or posedge resetpulse) begin
	if (resetpulse) 
		playerBswitch <= 1;
	else 
		playerBswitch <= !playerBswitch;
end




assign LED2 = playerBswitch;


wire[9:0] realx;
wire[9:0] realy;
wire videoActive;
wire xscanstart, xscanend;
vgascan vgascan(clk, HSYNC, VSYNC, realx, realy, videoActive, xscanstart, xscanend);


analinput #(PADDLESIZE, SCREENHEIGHT) analinput(clkdiv8, paddleA_y, paddleB_y_manual, MISO, MOSI, SCS, SCK);

wire[9:0] ball_y;
robohand #(PADDLESIZE,SCREENHEIGHT) paddleB(resetpulse, paddleAdvance, ball_y, paddleB_y_robot);

always @(posedge clkdiv8) begin
	paddleB_y <= playerBswitch ? paddleB_y_manual : paddleB_y_robot;
end

tehgame teh(clk, clkdiv8, resetpulse, gamereset, HSYNC, realx, realy, paddleA_y, paddleB_y, ballAdvance, {ball_scan, paddle_scan, score_scan}, ball_y, SOUND, LED1);

wire border_scan;
borderscan #(640,480) borderscan(clk, xscanstart, xscanend, realy, border_scan);
	
reg [3:0] netcnt;
always @(posedge clk) begin
	if (realx == SCREENWIDTH/2 && realy[1])
		netcnt = 4;
	if (netcnt != 0) netcnt = netcnt - 1'b1;
end
wire net_scan = netcnt != 0;




wire bgr, bgg, bgb;
bgfill bgfill(clk, HSYNC, VSYNC, bgr, bgg, bgb);

reg red, green, blue;
always @(negedge clk) begin
	red 	<= videoActive & (bgr | paddle_scan | border_scan | ball_scan | score_scan);
	green 	<= videoActive & (bgg | paddle_scan | border_scan | ball_scan | net_scan | score_scan);
	blue 	<= videoActive & (bgb | paddle_scan | border_scan | ball_scan);
end

assign RED = red;
assign GREEN = green;
assign BLUE = blue;

endmodule
module vga(clk, LED1, LED2, VSYNC, HSYNC, RED, GREEN, BLUE, MISO, MOSI, SCK, SCS, SOUND, BATON1, BATON2);

input clk;

output LED1;
output LED2;

output VSYNC;
output HSYNC;
output RED, GREEN, BLUE;

input MISO;
output MOSI;
output SCK;
output SCS;
output SOUND;

input BATON1;
input BATON2;

wand RED;
wand GREEN;
wand BLUE;

parameter SCREENWIDTH = 10'd640;
parameter SCREENHEIGHT = 10'd480;
parameter PADDLESIZE = 10'd64;
parameter BALLSIZE = 8;


wire paddle_scan;
wire ball_scan;

wire[9:0] paddleA_y;
wire[9:0] paddleB_y_manual;
wire[9:0] paddleB_y_robot;
reg [9:0] paddleB_y;
reg playerBswitch;




reg clkdiv8;					
reg [6:0] clkdiv8_cnt;
always @(posedge clk) begin
	if (clkdiv8_cnt == 0)
		clkdiv8 <= !clkdiv8;
	clkdiv8_cnt <= clkdiv8_cnt - 1'b1;
end




reg [7:0] paddle_cnt;				
reg [6:0] ball_cnt;
reg paddleAdvance;
reg ballAdvance;
always @(posedge clkdiv8) begin
	paddle_cnt <= paddle_cnt - 1'b1;
	ball_cnt <= ball_cnt - 1'b1;
	if (ball_cnt == 0) ball_cnt <= 7'b1100000;
end

always @(posedge clk) paddleAdvance = paddle_cnt == 0;
always @(posedge clk) ballAdvance = ball_cnt == 0;




wire resetpulse;
wire gamereset;
resetgen resetgen(clk, resetpulse, 1);	
button2 #(8192) gameresetter(clkdiv8, gamereset, BATON1);
button2 #(8192) button2(clkdiv8, playerBbutton, BATON2);


always @(posedge playerBbutton or posedge resetpulse) begin
	if (resetpulse) 
		playerBswitch <= 1;
	else 
		playerBswitch <= !playerBswitch;
end




assign LED2 = playerBswitch;


wire[9:0] realx;
wire[9:0] realy;
wire videoActive;
wire xscanstart, xscanend;
vgascan vgascan(clk, HSYNC, VSYNC, realx, realy, videoActive, xscanstart, xscanend);


analinput #(PADDLESIZE, SCREENHEIGHT) analinput(clkdiv8, paddleA_y, paddleB_y_manual, MISO, MOSI, SCS, SCK);

wire[9:0] ball_y;
robohand #(PADDLESIZE,SCREENHEIGHT) paddleB(resetpulse, paddleAdvance, ball_y, paddleB_y_robot);

always @(posedge clkdiv8) begin
	paddleB_y <= playerBswitch ? paddleB_y_manual : paddleB_y_robot;
end

tehgame teh(clk, clkdiv8, resetpulse, gamereset, HSYNC, realx, realy, paddleA_y, paddleB_y, ballAdvance, {ball_scan, paddle_scan, score_scan}, ball_y, SOUND, LED1);

wire border_scan;
borderscan #(640,480) borderscan(clk, xscanstart, xscanend, realy, border_scan);
	
reg [3:0] netcnt;
always @(posedge clk) begin
	if (realx == SCREENWIDTH/2 && realy[1])
		netcnt = 4;
	if (netcnt != 0) netcnt = netcnt - 1'b1;
end
wire net_scan = netcnt != 0;




wire bgr, bgg, bgb;
bgfill bgfill(clk, HSYNC, VSYNC, bgr, bgg, bgb);

reg red, green, blue;
always @(negedge clk) begin
	red 	<= videoActive & (bgr | paddle_scan | border_scan | ball_scan | score_scan);
	green 	<= videoActive & (bgg | paddle_scan | border_scan | ball_scan | net_scan | score_scan);
	blue 	<= videoActive & (bgb | paddle_scan | border_scan | ball_scan);
end

assign RED = red;
assign GREEN = green;
assign BLUE = blue;

endmodule