initial block is much similar to always block but initial block only executes once in entire program and it is non synthesizable Veilog.
1. If there is multi-line statement in initial block, use begin and end statement and wire code inside begin and end
2. assigning inside initial block must be reg type
Initial block is used to initialise the value of register, or flip-flop in testbench. You can initialise clock register so that you can generate clock. you can generate testcases for test module inside initial block
module testb;
reg clk;
initial begin
clk = 0; //initialise clock to 0
end
always #10 clk = ~ clk; //generates clock
endmodule
module testb;
reg a,b;
wire y;
andgate uut(a,b,y);
initial begin
a = 0; b = 0; //test cases
#10
a = 0; b = 1;
#10
a = 1; b = 0;
#10
a = 1; b = 1;
#10
$finish();
end
endmodule
Click like if you found this useful
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments