Verilog Basic Concepts
Questions on Verilog Data Types, Reg vs Wire, and basic syntax.
Beginner Level
wire: Represents a physical connection. Driven by continuous assignment (`assign`) or output of a module. Cannot store a value.
reg: Represents a storage element (variable). Assigned inside procedural blocks (`always`, `initial`). May or may not synthesize to a flip-flop.
Used for tri-state logic (0, 1, Z). If multiple drivers drive it, it supports the High-Z state effectively, often used in bidirectional pads.
Intermediate Level
Verilog uses 2's Complement format. A signed 4-bit number ranges from -8 to +7. You can declare signals as `signed` (e.g. `reg signed [3:0] a;`).
reg: `x` (Unknown).
wire: `z` (High Impedance).
Advanced Level (Tricky)
`4'b1001` (9) + `4'b0111` (7) = 16. In 4-bit arithmetic, this overflows to `0000`. The carry is lost unless stored in a 5-bit result.