J
jjlindula@hotmail.com
Guest
Hello, I'm excited to be learning Verilog and have a few books to get
me started but I do have one question that I hope someone can answer.
I'll give a little code:
module(input Y, output Z)
reg X;
reg A, B;
always @(posedge clk_in)
if(reset)begin
A = 0;
B = 0;
X = 0;
end
else
case(my_stateMachine_reg)
1: if(Y)
X = 1;
else
X = 0;
2: A = 1;
3: B =0;
endcase
My question is, in states 2 and 3 do I need to have X = 0?
Should my code look like:
module(input Y, output Z)
reg X;
reg A, B;
always @(posedge clk_in)
if(reset)begin
A = 0;
B = 0;
X = 0;
else
case(my_stateMachine_reg)
1: begin
A = 0;
B = 0;
if(Y)begin
X = 1;
else
X = 0;
end
2: A = 1;
B = 0;
X = 0;
3: B =0;
A = 0;
X = 0;
endcase
Do I really need to include each reg variable in each state and give
it a value?
thanks,
joe
me started but I do have one question that I hope someone can answer.
I'll give a little code:
module(input Y, output Z)
reg X;
reg A, B;
always @(posedge clk_in)
if(reset)begin
A = 0;
B = 0;
X = 0;
end
else
case(my_stateMachine_reg)
1: if(Y)
X = 1;
else
X = 0;
2: A = 1;
3: B =0;
endcase
My question is, in states 2 and 3 do I need to have X = 0?
Should my code look like:
module(input Y, output Z)
reg X;
reg A, B;
always @(posedge clk_in)
if(reset)begin
A = 0;
B = 0;
X = 0;
else
case(my_stateMachine_reg)
1: begin
A = 0;
B = 0;
if(Y)begin
X = 1;
else
X = 0;
end
2: A = 1;
B = 0;
X = 0;
3: B =0;
A = 0;
X = 0;
endcase
Do I really need to include each reg variable in each state and give
it a value?
thanks,
joe