always block in Verilog HDL is behavioural modeling and using this, we can describe combinational circuit, flip-flops, sequential circuits, and finite state machine. Using always block, we can write code in higher level like writing an algorithm and it is much easier to write Verilog code in always block.
1. If there is multi-line statement in always block, use begin and end statement and wire code inside begin and end
2. assigning inside always block must be reg type
always @ (senstivity list) is the syntax for using always block.
module gate(a,b,s,y);
input a,b,s;
output reg y;
always @ (*)begin
if(s)
y = a;
else
y = b;
end
endmodule
module gate(clk,reset,d,q);
input clk,reset,d;
output reg q;
always @ (posedge clk)begin
if(reset)
q <= 0;
else
q <= d;
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