Even though the type indicator may be hexadecimal or decimal, the size indicator is always measured in bits.
8'h81
Since 81
is an 8-bit number in binary (1000 0001
), it requires 8 bits. This is why the size is 8, even though the number is expressed in hex.
Also, size may be the bus size that the signal is driving (or part of it), even though the value itself may require fewer bits.
This is shown here:
16'd5
The decimal 5
only needs 3 bits (101
), however, this value may be desgnated for a 16 bit bus:
wire [15:0] test;
assign test = 16'd5;
While verilog does pad smaller sizes, sometimes if you're concatenating, you want to specify each length:
wire [31:0] test;
assign test = {16'd5,16'd5};
In the last case:
32'h8f_32_ab_f7
32 bits are required to store the hexadecimal number, which is 1000 1111 0011 0010 1010 1011 1111 0111
in binary.
The hexadecimal is just the short way of writing the number, but the size is still 32 bits.
What is the motivation in using hardware description languages (HDL) such as Verilog and VHDL over programming languages like C or some Assembly?
C and assembly are good languages for telling a CPU what to do. They describe actions to be done sequentially by a single state machine.
HDLs are good languages for describing or defining an arbitrary collection of digital circuits. They can express operations done in parallel in ways that programming languages can't. They can also describe timing limitations for the interfaces between blocks in ways that programming languages can't.
I was surprised to see discussions expressing doubts whether to write firmware in C or Assembly (how is Assembly appropriate if you don't necessarily have a CPU?)
In that question, what's asked is, "If you are writing code for a microcontroller is there a real difference if you write in assembly or C or some other high level language?".
Since he's specifically asking about systems with a microcontroller (a CPU with peripherals), C or assembly are both reasonable choices for firwmare development, and HDL's are not.
A firmware really can be written either in HDL or in a software programming language, or it's just another way to perform the same mission?
It depends what kind of hardware you have. If you have a CPU, use a programming language. If you have an FPGA or you're designing an ASIC, use an HDL. If you are designing a very large amount of digital logic, you can look to one of the in-between languages like SystemVerilog.
I've read that the firmware mostly burned on ROM or flash. How it is represented in there? In bits, like software? If so, what's the profound difference? Is it the availability of adapted circuits in the case of firmware?
I think you are getting hung up on the term "firmware". This word originally meant code to be run on an embedded system, that wasn't accessible for the end user to change. If you sold somebody a PC, there's a very high chance that the user would change what software is run on it. If you sold them an oscilloscope, you wouldn't want them to change the code that's run on the internal microprocessor, so you called it firmware.
FPGA users appropriated the word "firmware" for the output of their designs, because it is more changeable than hardware (stuff that's soldered together). But really the "firmware" that configures an FPGA is different from the "firmware" that runs on a uC. uC firmware directs the uC through a series of states to perform it's function. FPGA firmware defines a set of interconnections between logic elements, and values to be stored in look-up tables.
In either case, the firmware is typically stored as bits on an eeprom (or on disk on a host machine that will donwload it whenever the embedded system is re-started). But that doesn't make them similar to each other.
Best Answer
1'b0 is Verilog syntax for a constant value that is a one bit number expressed in binary format with a value of zero.
A bit value of one would be expressed as 1'b1.
Similarly a four bit value in binary that is equivalent magnitude to a decimal value of 11 could be written as 4'b1011.
You could also express this same value in a hexadecimal notation as 4'hB.