Home / Learn Verilog / Number Literals in Detail
Number Literals in Detail
Sized, unsized, signed and underscores.
Quick summarySized, unsized, signed and underscores.
How to think about this
Definition
Format: size, apostrophe, base, digits. 4'b1010, 8'hFF, 12'd300, 'o17.
Why you need this
Wrong sizes cause silent truncation or extension.
How it works
Always size constants that go into a bus.
Where you'll see this
- Everyday RTL design
- FPGA and ASIC projects
- Testbenches and debugging
Try it
Truncation and extensionVerilog: edit and run
Extra high bits are dropped; missing high bits are 0.
Test what you just read
1. 12'd300 has how many bits?
The size is before the apostrophe.