Altera_Forum
Honored Contributor
12 years agoif else statement in Verilog
I used to do a lot of C/C++ programming, and I do like to use for loop and if-else statement.
1. I tried to use if-else in Verilog. However, I always got an error which said that --- near text "if", expecting "endmodule". However, if I don't use if-else, everything is fine. The if-else format I used is: if (a<b) else; OR: if(a<b)begin statements; end else if (a == b) begin statements; end else begin statements; end 2. I couldn't assign a value to a variable twice (different values) in verilog. Does people still use loops when it is really needed? For example, to calculate a variable iteratively (say 16 loops) until it converges to its final stable value? Is there an efficient way that a loop is not used to solve problems like this? Thanks.