The assign statement continuously drives a wire with an expression:
Assign Statement Examples
module logic_gates (
input wire a, b, c,
output wire and_out,
output wire or_out,
output wire xor_out,
output wire mux_out
);
// Simple logic gates
assign and_out = a & b;
assign or_out = a | b;
assign xor_out = a ^ b;
// Ternary operator for mux
assign mux_out = c ? a : b; // if c=1, output a; else b
endmodule
Key characteristics of continuous assignment:
- LHS must be a
wire(or other net type) - Executes continuously – output updates whenever inputs change
- Models combinational logic only