π Procedural vs Continuous Assignments in Verilog #
Verilog supports two main types of assignments, each used in different contexts for modeling hardware accurately.
βοΈ Continuous Assignment #
- Uses the
assign
keyword - Automatically updates the output whenever any input changes
- Describes combinational logic
- Signal must be a
wire
type
β Example: #
assign y = a & b;
Key Points:
- Declared outside any
always
orinitial
block - Suitable for simple logic and dataflow connections
- Behaves like a real physical wire
π Procedural Assignment #
- Defined inside
initial
oralways
blocks - Describes sequential or controlled logic
- Signal must be a
reg
,integer
, orreal
β Example: #
always @(posedge clk) begin
count <= count + 1;
end
Key Points:
- Supports conditional logic (
if
,case
,for
) - Must use
=
(blocking) or<=
(non-blocking) - Used for FSMs, registers, clocked logic
π§ Summary Table #
Feature | Continuous Assignment | Procedural Assignment |
---|---|---|
Keyword | assign |
always , initial |
Signal type | wire |
reg , integer , etc. |
Location | Outside blocks | Inside procedural blocks |
Update timing | Continuous | On triggered events |
Control structures | β Not supported | β Supported |
Synthesis use | β Yes | β Yes |
π Tip: Common Error #
reg y;
assign y = a & b; // β Error! Cannot drive reg from assign
β‘οΈ Use wire
with assign
, or move logic into an always
block.
π‘ Understanding these two assignment types is essential for writing valid, synthesizable Verilog code.