โณ Continuous vs Procedural Assignment
Understanding the difference between continuous and procedural assignment is essential for designing reliable, audit-ready hardware systems. This note breaks down both styles with annotated clarity.
๐ Continuous Assignment
Definition: A declarative connection between a wire and a logic expression that is always active.
wire y;
assign y = a & b;Syntax
wirerefers to literal wiring- Paired with
assignwhich is only used for continuous assignment
โ Characteristics
- Always active: updates instantly when inputs change.
- Stateless: does not store values.
- Used for: simple combinational logic, wiring, gates.
๐ Notes
- Only works with
wiretypes. - Cannot include
if,case, or multi-step logic. - Ideal for clean, declarative connections.
๐ Procedural Assignment
Definition: Imperative logic inside an always block that executes when triggered by a sensitivity list.
reg y;
always @(*) begin
y = a & b;
endSyntax
regstands for register which points to storing values
โ Characteristics
- Triggered: runs when inputs in sensitivity list change.
- Can store state: especially in clocked blocks.
- Used for: FSMs, conditional logic, multi-step computation.
๐ Notes
- Requires
regtype for assigned variables - Can include
if,case, loops, and intermediate variables. - Enables modeling of both combinational and sequential logic.
๐งช Comparison Table
| Feature | Continuous (assign) | Procedural (always) |
|---|---|---|
| Syntax | assign y = ... | always @(*) y = ... |
| Target type | wire | reg |
| Timing | Always active | Event-driven |
| State retention | โ No | โ Yes (if clocked) |
| Control flow | โ Limited | โ
Full (if, case) |
| Use case | Simple logic | FSMs, counters, branching |
๐งญ When to Use Each
Use assign when:
- Logic is simple and stateless.
- You want direct wiring between signals.
Use always when:
- Logic involves conditions, branching, or multi-step computation.
- You need to store state or react to clock edges.
๐งฐ Vault Notes
Rule of Thumb
If you’re modeling wires, use assign.
If you’re modeling behavior, use always.
โน๏ธ
FSM State Update
reg [1:0] state;
always @(posedge clk) begin
if (rst)
state <= IDLE;
else
state <= next_state;
endโ ๏ธ
Common Mistake
Donโt use
assign to drive a reg, and donโt assign to a wire inside an always block.Last updated on