[SOLVED] 'state is unconnected in block' verilog code error

Status
Not open for further replies.

arishsu

Member level 3
Joined
Sep 10, 2013
Messages
66
Helped
6
Reputation
12
Reaction score
6
Trophy points
8
Location
India
Visit site
Activity points
422
Hi
I wrote a code for pulse generator. But it shows the following warnings.
My code is given below
Code:
module pulse_generator(clk,reset,s,x,P,L);
input clk,reset,s,x;
output reg P,L;
localparam s0=00,
			 s1=01,
			 s2=10,
			 s3=11;
reg [1:0]state;
reg [1:0]next_state;
initial state<=s0;
always@(negedge clk)
begin
	state<=next_state;
end
always@(negedge clk or posedge reset)
 begin
	if(reset)
	 next_state<=s0;
	else
	begin
	 case(state)
	  s0: begin
				if(s==1)
					next_state<=s1;
				else if(s==0)
					next_state<=s0;
			end
	  s1: begin
			if(s==1)
				next_state<=s2;
			else if(s==0)
				next_state<=s0;
			end
	  s2: begin
			if((s==1)&&(x==0))
				next_state<=s3;
			else if((s==1)&&(x==1))
				next_state<=s1;
			else if(s==0)
				next_state<=s0;
			end
	  s3: begin
			if((s==1)&&(x==1))
				next_state<=s1;
			else if((s==1)&&(x==0))
				next_state<=s3;
	      else if(s==0)
				next_state<=s0;
			end
	 endcase
 end
 end
always@(state)
begin
	case(state)
	 s0:begin
			P=0;
			L=0;
		 end
	 s1:begin
			P=1;
			L=1;
		 end
	 s2:begin
			P=0;
			L=1;
		 end
	 s3:begin
			P=0;
			L=1;
		 end
	endcase
end
endmodule

Thanks&Regards
 

in verilog you should always determine size of your parameters otherwise verilog consider it 32 bit and most of time a lot of warning happens like this. in this case you should put s0=2'b00, s1=2'b01, s2=2'b10, s3=2'b11
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…