Conditional Statements: (same as C)
Multiway Branching :
Case statement syntax :
case (expression)
Alternative 1 : statement 1;
Alternative 2 : statement 2;
Alternative 3 : statement 3;
default : default_statement;
endcase
casez :- treats all z values in the case alternatives or the case expression as don’t cares. All bit positions with z can also represented by ? in that position.
casex :- treats all x and z values in the case item or the case expression as don’t cares.
Loops :
while loop (same as C)
for loop (same as C)
repeat loop :
Keyword : repeat
->executes the loop fixed number of times.
forever loop :
Keyword : forever
->executes forever until the $finish task is encountered
->equivalent to while(1)
->can be exited by the ‘disable’ statement
Eg : //clock generation
reg clock;
initial
begin
Clock=1’b0;
forever #10 clock=~clock; //clock with period of 20 units
end
No comments:
Post a Comment
Your Comments... (comments are moderated)