data/full_repos/permissive/211634836/controller.v
1: b'%Warning-MULTITOP: data/full_repos/permissive/211634836/controller.v:117: Multiple top level modules\n                                                                        : ... Suggest see manual; fix the duplicates, or use --top-module to select top.\n                   ... Use "/* verilator lint_off MULTITOP */" and lint_on around source to disable this message.\n                                                                        : ... Top module \'animationclock\'\nmodule animationclock (input clk, output [7:0] animationcounter, output [7:0] stepclock);\n       ^~~~~~~~~~~~~~\n                                                                        : ... Top module \'ledcontroller\'\nmodule ledcontroller (\n       ^~~~~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:60: Operator SUB expects 32 or 16 bits on the RHS, but RHS\'s VARREF \'normalisedledindex\' generates 8 bits.\n                                                                    : ... In instance ledcontroller.thecolourcalculator\n    { colmuxr, throwaway } <= usera * normalisedledindex + userb * (255-normalisedledindex);\n                                                                       ^\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:64: Operator SUB expects 32 or 16 bits on the RHS, but RHS\'s VARREF \'normalisedledindex\' generates 8 bits.\n                                                                    : ... In instance ledcontroller.thecolourcalculator\n    { colmuxr, throwaway } <= usera * normalisedledindex + userb * (255-normalisedledindex);\n                                                                       ^\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:229: Operator LT expects 11 bits on the RHS, but RHS\'s VARREF \'glittervolume\' generates 8 bits.\n                                                                     : ... In instance ledcontroller\n      glitterpos[glitteri] <= (lfsrout<glittervolume);\n                                      ^\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:244: Operator ADD expects 8 bits on the LHS, but LHS\'s SEL generates 2 bits.\n                                                                     : ... In instance ledcontroller\n    colindex[1:0] <= stepclock[1:0] + ledindex;\n                                    ^\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:244: Operator ASSIGNDLY expects 2 bits on the Assign RHS, but Assign RHS\'s ADD generates 8 bits.\n                                                                     : ... In instance ledcontroller\n    colindex[1:0] <= stepclock[1:0] + ledindex;\n                  ^~\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:286: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s SUB generates 32 or 16 bits.\n                                                                     : ... In instance ledcontroller\n      proximity <= 256-(proxa/4);\n                ^~\n%Warning-WIDTH: data/full_repos/permissive/211634836/controller.v:309: Operator ASSIGNDLY expects 8 bits on the Assign RHS, but Assign RHS\'s SEL generates 9 bits.\n                                                                     : ... In instance ledcontroller\n    rainbowpos_mux <= rainbowlookup[normalisedledindex][16:8];\n                   ^~\n%Error: Exiting due to 8 warning(s)\n'
module ledcontroller (
	input clk, 
	input [7:0] mode, 
	input [7:0] colmode, 
	input [7:0] blocksize,
	input [7:0] usera_red,
	input [7:0] usera_green,
	input [7:0] usera_blue,
	input [7:0] userb_red,
	input [7:0] userb_green,
	input [7:0] userb_blue,
	input [7:0] masterfader,
	input [7:0] ledindex, 
	input [7:0] animationcounter, 
	input [7:0] stepclock,
	input [7:0] glitterrate,
	input [7:0] glittervolume,
	output reg [7:0] red, 
	output reg [7:0] green, 
	output reg [7:0] blue);

	wire [15:0] fadeout;

	reg [7:0] usera_mux;
	reg [7:0] userb_mux;

	reg [4:0] phase;

	reg [1:0] colindex;

	reg [7:0] colmux_mux;

	reg [7:0] normalisedledindex;

	reg [15:0] fractionalposition;
	reg [15:0] proxa;
	reg [7:0] proximity;

	reg [7:0] rainbowpos_mux;

	reg [7:0] steppedcol_red;
	reg [7:0] steppedcol_green;
	reg [7:0] steppedcol_blue;
	reg [7:0] steppedcol_mux;

	reg [7:0] predimmed_mux;

	reg [24:0] rainbowlookup [0:255];

	reg [255:0] glitterpos;
	reg [7:0] glitterclock;
	reg glittercalculating;
	reg [7:0] glitteri;
	reg [4:0] glitterdivider;

	reg [10:0] lfsrout;

	initial begin
		$readmemh("rainbow.hex", rainbowlookup, 0, 255);
	end

	colourchannelcalculator thecolourcalculator
	(
		.clk(clk),
		.colmode(colmode),
		.usera(usera_mux), 
		.userb(userb_mux), 
		.normalisedledindex(normalisedledindex),
		.fractionalposition(fractionalposition),
		.steppedcol(steppedcol_mux),
		.rainbowpos(rainbowpos_mux),
		.colmux(colmux_mux)
	);

	outputmultiplexer theoutputmux
	(
		.clk(clk),
		.mode(mode),
		.proximity(proximity),
		.colmux(colmux_mux),
		.predimmed(predimmed_mux)
	);

	lfsr thelfrs
	(
		.clk(clk),
		.out(lfsrout)
	);

	assign fadeout = predimmed_mux * masterfader;

	always @(posedge clk) begin
		phase <= phase + 1;
		case (phase)





			0: begin

				if ((colmode==3)||(colmode==6)) begin
					normalisedledindex <= (ledindex*blocksize)+animationcounter;
				end else begin
					normalisedledindex <= ledindex*blocksize + ledindex;
				end

				fractionalposition <= animationcounter*55;

				glitterdivider <= glitterdivider +1;
				if (glitterdivider==0) begin
					if (glitterclock<=glitterrate) begin
						glitterpos[glitteri] <= (lfsrout<glittervolume);
						glitteri <= glitteri + 1;
						glitterclock <= 255;
					end	else begin
						glitterclock <= glitterclock-1;
					end
				end
			end





			1: begin

				colindex[1:0] <= stepclock[1:0] + ledindex;
				case (colindex)
					0: begin
						steppedcol_red[7:0] <= (8'hFF);
						steppedcol_green[7:0] <= (8'h00);
						steppedcol_blue[7:0] <= (8'h00);
					end
					1: begin
						steppedcol_red[7:0] <= (8'h00);
						steppedcol_green[7:0] <= (8'hFF);
						steppedcol_blue[7:0] <= (8'h00);
					end
					2: begin
						steppedcol_red[7:0] <= (8'h00);
						steppedcol_green[7:0] <= (8'h00);
						steppedcol_blue[7:0] <= (8'hFF);
					end
					3: begin
						steppedcol_red[7:0] <= (8'hFF);
						steppedcol_green[7:0] <= (8'hFF);
						steppedcol_blue[7:0] <= (8'h00);
					end
				endcase		



				if (fractionalposition>{ ledindex, 8'h00}) begin
					proxa[15:0] <= fractionalposition-{ ledindex, 8'h00};
				end else begin
					proxa[15:0] <= { ledindex, 8'h00}-fractionalposition;
				end
			end



			2: begin
				if (proxa>=1024) begin
					proximity <= 0;
				end else begin
					if (proxa<=8) begin
						proximity <= 255;
					end else begin
						proximity <= 256-(proxa/4);
					end
				end			
			end

			3: begin
				usera_mux <= usera_red;
				userb_mux <= userb_red;
				steppedcol_mux <= steppedcol_red;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][24:17];
			end

			5: begin
				if (glitterpos[normalisedledindex]) begin
					red <= 255;
				end else begin
					red <= fadeout[15:8];
				end
			end
			6: begin
				usera_mux <= usera_green;
				userb_mux <= userb_green;
				steppedcol_mux <= steppedcol_green;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][16:8];
			end

			8: begin
				if (glitterpos[normalisedledindex]) begin
					green <= 255;
				end else begin
					green <= fadeout[15:8];
				end
			end
			9: begin
				usera_mux <= usera_blue;
				userb_mux <= userb_blue;
				steppedcol_mux <= steppedcol_blue;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][7:0];
			end

			11: begin
				if (glitterpos[normalisedledindex]) begin
					blue <= 255;
				end else begin
					blue <= fadeout[15:8];
				end
			end
		endcase
	end	

endmodule
module ledcontroller (
	input clk, 
	input [7:0] mode, 
	input [7:0] colmode, 
	input [7:0] blocksize,
	input [7:0] usera_red,
	input [7:0] usera_green,
	input [7:0] usera_blue,
	input [7:0] userb_red,
	input [7:0] userb_green,
	input [7:0] userb_blue,
	input [7:0] masterfader,
	input [7:0] ledindex, 
	input [7:0] animationcounter, 
	input [7:0] stepclock,
	input [7:0] glitterrate,
	input [7:0] glittervolume,
	output reg [7:0] red, 
	output reg [7:0] green, 
	output reg [7:0] blue);


	wire [15:0] fadeout;

	reg [7:0] usera_mux;
	reg [7:0] userb_mux;

	reg [4:0] phase;

	reg [1:0] colindex;

	reg [7:0] colmux_mux;

	reg [7:0] normalisedledindex;

	reg [15:0] fractionalposition;
	reg [15:0] proxa;
	reg [7:0] proximity;

	reg [7:0] rainbowpos_mux;

	reg [7:0] steppedcol_red;
	reg [7:0] steppedcol_green;
	reg [7:0] steppedcol_blue;
	reg [7:0] steppedcol_mux;

	reg [7:0] predimmed_mux;

	reg [24:0] rainbowlookup [0:255];

	reg [255:0] glitterpos;
	reg [7:0] glitterclock;
	reg glittercalculating;
	reg [7:0] glitteri;
	reg [4:0] glitterdivider;

	reg [10:0] lfsrout;

	initial begin
		$readmemh("rainbow.hex", rainbowlookup, 0, 255);
	end

	colourchannelcalculator thecolourcalculator
	(
		.clk(clk),
		.colmode(colmode),
		.usera(usera_mux), 
		.userb(userb_mux), 
		.normalisedledindex(normalisedledindex),
		.fractionalposition(fractionalposition),
		.steppedcol(steppedcol_mux),
		.rainbowpos(rainbowpos_mux),
		.colmux(colmux_mux)
	);

	outputmultiplexer theoutputmux
	(
		.clk(clk),
		.mode(mode),
		.proximity(proximity),
		.colmux(colmux_mux),
		.predimmed(predimmed_mux)
	);

	lfsr thelfrs
	(
		.clk(clk),
		.out(lfsrout)
	);

	assign fadeout = predimmed_mux * masterfader;

	always @(posedge clk) begin
		phase <= phase + 1;
		case (phase)





			0: begin

				if ((colmode==3)||(colmode==6)) begin
					normalisedledindex <= (ledindex*blocksize)+animationcounter;
				end else begin
					normalisedledindex <= ledindex*blocksize + ledindex;
				end

				fractionalposition <= animationcounter*55;

				glitterdivider <= glitterdivider +1;
				if (glitterdivider==0) begin
					if (glitterclock<=glitterrate) begin
						glitterpos[glitteri] <= (lfsrout<glittervolume);
						glitteri <= glitteri + 1;
						glitterclock <= 255;
					end	else begin
						glitterclock <= glitterclock-1;
					end
				end
			end





			1: begin

				colindex[1:0] <= stepclock[1:0] + ledindex;
				case (colindex)
					0: begin
						steppedcol_red[7:0] <= (8'hFF);
						steppedcol_green[7:0] <= (8'h00);
						steppedcol_blue[7:0] <= (8'h00);
					end
					1: begin
						steppedcol_red[7:0] <= (8'h00);
						steppedcol_green[7:0] <= (8'hFF);
						steppedcol_blue[7:0] <= (8'h00);
					end
					2: begin
						steppedcol_red[7:0] <= (8'h00);
						steppedcol_green[7:0] <= (8'h00);
						steppedcol_blue[7:0] <= (8'hFF);
					end
					3: begin
						steppedcol_red[7:0] <= (8'hFF);
						steppedcol_green[7:0] <= (8'hFF);
						steppedcol_blue[7:0] <= (8'h00);
					end
				endcase		



				if (fractionalposition>{ ledindex, 8'h00}) begin
					proxa[15:0] <= fractionalposition-{ ledindex, 8'h00};
				end else begin
					proxa[15:0] <= { ledindex, 8'h00}-fractionalposition;
				end
			end



			2: begin
				if (proxa>=1024) begin
					proximity <= 0;
				end else begin
					if (proxa<=8) begin
						proximity <= 255;
					end else begin
						proximity <= 256-(proxa/4);
					end
				end			
			end

			3: begin
				usera_mux <= usera_red;
				userb_mux <= userb_red;
				steppedcol_mux <= steppedcol_red;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][24:17];
			end

			5: begin
				if (glitterpos[normalisedledindex]) begin
					red <= 255;
				end else begin
					red <= fadeout[15:8];
				end
			end
			6: begin
				usera_mux <= usera_green;
				userb_mux <= userb_green;
				steppedcol_mux <= steppedcol_green;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][16:8];
			end

			8: begin
				if (glitterpos[normalisedledindex]) begin
					green <= 255;
				end else begin
					green <= fadeout[15:8];
				end
			end
			9: begin
				usera_mux <= usera_blue;
				userb_mux <= userb_blue;
				steppedcol_mux <= steppedcol_blue;
				rainbowpos_mux <= rainbowlookup[normalisedledindex][7:0];
			end

			11: begin
				if (glitterpos[normalisedledindex]) begin
					blue <= 255;
				end else begin
					blue <= fadeout[15:8];
				end
			end
		endcase
	end	

endmodule