data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v
1: b'%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:171: Operator ADD expects 8 bits on the LHS, but LHS\'s VARREF \'cnt2\' generates 4 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s1_1 <= cnt2+cnt0;\n                       ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:171: Operator ADD expects 8 bits on the RHS, but RHS\'s VARREF \'cnt0\' generates 3 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s1_1 <= cnt2+cnt0;\n                       ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:172: Operator ADD expects 8 bits on the LHS, but LHS\'s VARREF \'cnt3\' generates 4 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s1_2 <= cnt3+cnt1;\n                       ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:172: Operator ADD expects 8 bits on the RHS, but RHS\'s VARREF \'cnt1\' generates 3 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s1_2 <= cnt3+cnt1;\n                       ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:173: Operator ADD expects 8 bits on the LHS, but LHS\'s REPLICATE generates 5 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s2_1 <= {f3_raddr_s1_2[3:0],1\'b0} + f3_raddr_s1_1;\n                                             ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:174: Operator ADD expects 8 bits on the RHS, but RHS\'s REPLICATE generates 6 bits.\n                                                                              : ... In instance conv2_ctrl\n  f3_raddr_s2_2 <= {f3_raddr_s1_2[3:0],3\'b0}+{f3_raddr_s1_2[3:0],2\'b0};\n                                            ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:177: Operator ADD expects 5 bits on the LHS, but LHS\'s VARREF \'cnt0\' generates 3 bits.\n                                                                              : ... In instance conv2_ctrl\n  w3_raddr_s1_1 <= cnt0+cnt1;\n                       ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:177: Operator ADD expects 5 bits on the RHS, but RHS\'s VARREF \'cnt1\' generates 3 bits.\n                                                                              : ... In instance conv2_ctrl\n  w3_raddr_s1_1 <= cnt0+cnt1;\n                       ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:193: Operator ADD expects 7 bits on the RHS, but RHS\'s REPLICATE generates 5 bits.\n                                                                              : ... In instance conv2_ctrl\n  f4_waddr_s1_1 <= {cnt3[3:0],3\'b0}+{cnt3[3:0],1\'b0};\n                                   ^\n%Warning-WIDTH: data/full_repos/permissive/124846744/src/conv/conv2_ctrl.v:194: Operator ASSIGNDLY expects 7 bits on the Assign RHS, but Assign RHS\'s VARREF \'cnt2\' generates 4 bits.\n                                                                              : ... In instance conv2_ctrl\n  f4_waddr_s1_2 <= cnt2;\n                ^~\n%Error: Exiting due to 10 warning(s)\n'
module conv2_ctrl(

			w3_raddr,
			f3_raddr,
			f4_waddr,
			f4_wr_en,
			conv2_done,
			conv2_clr,

			clk,
			rst_n,
			conv2_start);
	input  clk;
	input  rst_n;



	output  [4:0] w3_raddr;
	output  [7:0] f3_raddr;


	output  [6:0] f4_waddr;
	output        f4_wr_en;


	input         conv2_start;
	output        conv2_clr;
	output        conv2_done;

	localparam	IDLE=3'b001;
	localparam  RUN =3'b010;
	localparam  DONE=3'b100;
	reg[2:0] current_state;
	reg[2:0] next_state;

	reg[2:0] cnt0,cnt1;
	reg[3:0] cnt2,cnt3;
	wire add_cnt0,end_cnt0,add_cnt1,add_cnt2,end_cnt2,end_cnt1,add_cnt3,end_cnt3;

	wire IDLE2RUN_start,RUN2DONE_start;

	always@(posedge clk or negedge rst_n)begin
		if(!rst_n)
			current_state <= IDLE;
		else
			current_state <= next_state;
	end

	always@(*) begin
		case(current_state)
			IDLE:begin
				if(IDLE2RUN_start)
					next_state = RUN;
				else
					next_state = IDLE;
			end
			RUN:begin
				if(RUN2DONE_start)
					next_state = DONE;
				else begin
					next_state = current_state;
				end
			end
			DONE:begin
				next_state = IDLE;
			end
			default: next_state = IDLE;	
		endcase
	end

	assign IDLE2RUN_start = current_state==IDLE && conv2_start == 1'b1;
	assign RUN2DONE_start = current_state==RUN  && end_cnt3;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt0 <= 0;	
		end
		else if (add_cnt0) begin
			if(end_cnt0)
				cnt0 <= 0;
			else begin
				cnt0 <= cnt0 + 1'b1;
			end
		end
	end

	assign add_cnt0 = current_state==RUN;
	assign end_cnt0 = add_cnt0 && cnt0 == 5-1;	


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt1 <= 0;	
		end
		else if (add_cnt1) begin
			if(end_cnt1)
				cnt1 <= 0;
			else begin
				cnt1 <= cnt1 + 1'b1;
			end
		end
	end

	assign add_cnt1 = end_cnt0;
	assign end_cnt1 = add_cnt1 && cnt1 == 5-1;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt2 <= 0;	
		end
		else if (add_cnt2) begin
			if(end_cnt2)
				cnt2 <= 0;
			else begin
				cnt2 <= cnt2 + 1'b1;
			end
		end

	end

	assign add_cnt2 = end_cnt1;
	assign end_cnt2 = add_cnt2 && cnt2 == 10-1;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt3 <= 0;	
		end
		else if (add_cnt3) begin
			if(end_cnt3)
				cnt3 <= 0;
			else begin
				cnt3 <= cnt3 + 1'b1;
			end
		end

	end

	assign add_cnt3 = end_cnt2;
	assign end_cnt3 = add_cnt3 && cnt3 == 10-1;





	reg [7:0]  f3_raddr_s1_1,f3_raddr_s1_2,f3_raddr_s2_1,f3_raddr_s2_2,f3_raddr_s3;        
	reg [4:0]  w3_raddr_s1_1,w3_raddr_s1_2,w3_raddr_s2,w3_raddr_s3;


	always@(posedge clk)begin
		f3_raddr_s1_1 <= cnt2+cnt0;
		f3_raddr_s1_2 <= cnt3+cnt1;
		f3_raddr_s2_1 <= {f3_raddr_s1_2[3:0],1'b0} + f3_raddr_s1_1;
		f3_raddr_s2_2 <= {f3_raddr_s1_2[3:0],3'b0}+{f3_raddr_s1_2[3:0],2'b0};
		f3_raddr_s3   <= f3_raddr_s2_1 + f3_raddr_s2_2;

		w3_raddr_s1_1 <= cnt0+cnt1;
		w3_raddr_s1_2 <= {cnt1[2:0],2'b0};
		w3_raddr_s2   <= w3_raddr_s1_1+w3_raddr_s1_2;
		w3_raddr_s3   <= w3_raddr_s2; 
	end

	assign f3_raddr = f3_raddr_s3;
	assign w3_raddr = w3_raddr_s3;

	


	wire[6:0] f4_waddr_temp;
	reg[6:0] f4_waddr_s1_1,f4_waddr_s1_2,f4_waddr_s2,f4_waddr_s3;

	always@(posedge clk)begin
		f4_waddr_s1_1 <= {cnt3[3:0],3'b0}+{cnt3[3:0],1'b0};
		f4_waddr_s1_2 <= cnt2;
		f4_waddr_s2   <= f4_waddr_s1_2 + f4_waddr_s1_1;
		f4_waddr_s3   <= f4_waddr_s2;
  	end
  	assign f4_waddr_temp = f4_waddr_s3;




	wire 	  conv2_clr_temp;
	wire      f4_wr_en_temp;
	wire      conv2_done_temp;

	assign f4_wr_en_temp = end_cnt1? 1'b1:1'b0;
	assign conv2_done_temp = current_state==DONE? 1'b1:1'b0;
	assign conv2_clr_temp = cnt0==0 && cnt1==0;








	reg [6:0]   f4_waddr_reg[10:0];
	reg  		f4_wr_en_reg[13:0];
	reg  	    conv2_done_reg[13:0];
	reg  		conv2_clr_reg[6:0];
	always@*begin
		 f4_waddr_reg[0] = f4_waddr_temp;
		 f4_wr_en_reg[0] = f4_wr_en_temp;
		 conv2_clr_reg[0] = conv2_clr_temp;
		 conv2_done_reg[0] = conv2_done_temp;
	end
	generate
		genvar i,j,k;
		for (i = 0; i < 10; i = i + 1)
		begin:reg_gen1





			always@(posedge clk)begin
				f4_waddr_reg[i+1] <= f4_waddr_reg[i];
			end
		end
		for (j = 0; j < 13; j = j + 1)
		begin:reg_gen2






			always@(posedge clk)begin
				f4_wr_en_reg[j+1] <= f4_wr_en_reg[j];
				conv2_done_reg[j+1] <= conv2_done_reg[j];
			end
		end
		for (k = 0; k < 6; k = k + 1)
		begin:reg_gen3

			always@(posedge clk)begin
				conv2_clr_reg[k+1] <= conv2_clr_reg[k];
			end
		end		
	endgenerate
	



	assign f4_waddr 	= f4_waddr_reg[10];
	assign f4_wr_en  = f4_wr_en_reg[13];
	assign conv2_done   = conv2_done_reg[13];
	assign conv2_clr    = conv2_clr_reg[6];
	
endmodule
module conv2_ctrl(

			w3_raddr,
			f3_raddr,
			f4_waddr,
			f4_wr_en,
			conv2_done,
			conv2_clr,

			clk,
			rst_n,
			conv2_start);

	input  clk;
	input  rst_n;



	output  [4:0] w3_raddr;
	output  [7:0] f3_raddr;


	output  [6:0] f4_waddr;
	output        f4_wr_en;


	input         conv2_start;
	output        conv2_clr;
	output        conv2_done;

	localparam	IDLE=3'b001;
	localparam  RUN =3'b010;
	localparam  DONE=3'b100;
	reg[2:0] current_state;
	reg[2:0] next_state;

	reg[2:0] cnt0,cnt1;
	reg[3:0] cnt2,cnt3;
	wire add_cnt0,end_cnt0,add_cnt1,add_cnt2,end_cnt2,end_cnt1,add_cnt3,end_cnt3;

	wire IDLE2RUN_start,RUN2DONE_start;

	always@(posedge clk or negedge rst_n)begin
		if(!rst_n)
			current_state <= IDLE;
		else
			current_state <= next_state;
	end

	always@(*) begin
		case(current_state)
			IDLE:begin
				if(IDLE2RUN_start)
					next_state = RUN;
				else
					next_state = IDLE;
			end
			RUN:begin
				if(RUN2DONE_start)
					next_state = DONE;
				else begin
					next_state = current_state;
				end
			end
			DONE:begin
				next_state = IDLE;
			end
			default: next_state = IDLE;	
		endcase
	end

	assign IDLE2RUN_start = current_state==IDLE && conv2_start == 1'b1;
	assign RUN2DONE_start = current_state==RUN  && end_cnt3;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt0 <= 0;	
		end
		else if (add_cnt0) begin
			if(end_cnt0)
				cnt0 <= 0;
			else begin
				cnt0 <= cnt0 + 1'b1;
			end
		end
	end

	assign add_cnt0 = current_state==RUN;
	assign end_cnt0 = add_cnt0 && cnt0 == 5-1;	


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt1 <= 0;	
		end
		else if (add_cnt1) begin
			if(end_cnt1)
				cnt1 <= 0;
			else begin
				cnt1 <= cnt1 + 1'b1;
			end
		end
	end

	assign add_cnt1 = end_cnt0;
	assign end_cnt1 = add_cnt1 && cnt1 == 5-1;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt2 <= 0;	
		end
		else if (add_cnt2) begin
			if(end_cnt2)
				cnt2 <= 0;
			else begin
				cnt2 <= cnt2 + 1'b1;
			end
		end

	end

	assign add_cnt2 = end_cnt1;
	assign end_cnt2 = add_cnt2 && cnt2 == 10-1;


	always @(posedge clk or negedge rst_n) begin
		if (!rst_n) begin

			cnt3 <= 0;	
		end
		else if (add_cnt3) begin
			if(end_cnt3)
				cnt3 <= 0;
			else begin
				cnt3 <= cnt3 + 1'b1;
			end
		end

	end

	assign add_cnt3 = end_cnt2;
	assign end_cnt3 = add_cnt3 && cnt3 == 10-1;





	reg [7:0]  f3_raddr_s1_1,f3_raddr_s1_2,f3_raddr_s2_1,f3_raddr_s2_2,f3_raddr_s3;        
	reg [4:0]  w3_raddr_s1_1,w3_raddr_s1_2,w3_raddr_s2,w3_raddr_s3;


	always@(posedge clk)begin
		f3_raddr_s1_1 <= cnt2+cnt0;
		f3_raddr_s1_2 <= cnt3+cnt1;
		f3_raddr_s2_1 <= {f3_raddr_s1_2[3:0],1'b0} + f3_raddr_s1_1;
		f3_raddr_s2_2 <= {f3_raddr_s1_2[3:0],3'b0}+{f3_raddr_s1_2[3:0],2'b0};
		f3_raddr_s3   <= f3_raddr_s2_1 + f3_raddr_s2_2;

		w3_raddr_s1_1 <= cnt0+cnt1;
		w3_raddr_s1_2 <= {cnt1[2:0],2'b0};
		w3_raddr_s2   <= w3_raddr_s1_1+w3_raddr_s1_2;
		w3_raddr_s3   <= w3_raddr_s2; 
	end

	assign f3_raddr = f3_raddr_s3;
	assign w3_raddr = w3_raddr_s3;

	


	wire[6:0] f4_waddr_temp;
	reg[6:0] f4_waddr_s1_1,f4_waddr_s1_2,f4_waddr_s2,f4_waddr_s3;

	always@(posedge clk)begin
		f4_waddr_s1_1 <= {cnt3[3:0],3'b0}+{cnt3[3:0],1'b0};
		f4_waddr_s1_2 <= cnt2;
		f4_waddr_s2   <= f4_waddr_s1_2 + f4_waddr_s1_1;
		f4_waddr_s3   <= f4_waddr_s2;
  	end
  	assign f4_waddr_temp = f4_waddr_s3;




	wire 	  conv2_clr_temp;
	wire      f4_wr_en_temp;
	wire      conv2_done_temp;

	assign f4_wr_en_temp = end_cnt1? 1'b1:1'b0;
	assign conv2_done_temp = current_state==DONE? 1'b1:1'b0;
	assign conv2_clr_temp = cnt0==0 && cnt1==0;








	reg [6:0]   f4_waddr_reg[10:0];
	reg  		f4_wr_en_reg[13:0];
	reg  	    conv2_done_reg[13:0];
	reg  		conv2_clr_reg[6:0];
	always@*begin
		 f4_waddr_reg[0] = f4_waddr_temp;
		 f4_wr_en_reg[0] = f4_wr_en_temp;
		 conv2_clr_reg[0] = conv2_clr_temp;
		 conv2_done_reg[0] = conv2_done_temp;
	end
	generate
		genvar i,j,k;
		for (i = 0; i < 10; i = i + 1)
		begin:reg_gen1





			always@(posedge clk)begin
				f4_waddr_reg[i+1] <= f4_waddr_reg[i];
			end
		end
		for (j = 0; j < 13; j = j + 1)
		begin:reg_gen2






			always@(posedge clk)begin
				f4_wr_en_reg[j+1] <= f4_wr_en_reg[j];
				conv2_done_reg[j+1] <= conv2_done_reg[j];
			end
		end
		for (k = 0; k < 6; k = k + 1)
		begin:reg_gen3

			always@(posedge clk)begin
				conv2_clr_reg[k+1] <= conv2_clr_reg[k];
			end
		end		
	endgenerate
	



	assign f4_waddr 	= f4_waddr_reg[10];
	assign f4_wr_en  = f4_wr_en_reg[13];
	assign conv2_done   = conv2_done_reg[13];
	assign conv2_clr    = conv2_clr_reg[6];
	
endmodule