Computer Organization & Embedded System โ Hardware Description Language and IC Technology, NEC licence examination syllabus (Nepal Engineering Council).
Choosing the right data type is half the battle in VHDL.
bit / std_logicA single binary value. std_logic also allows 'Z', 'U', 'X' for tri-state/unknown โ much closer to real hardware behaviour than plain bit.
std_logic_vectorAn array of std_logic bits (like a bus).
integerWhole numbers, useful for counters/indices.
signed / unsigned(from numeric_std) Let you do proper arithmetic with two's complement semantics.
When adding two signed numbers, overflow is checked exactly like in hardware: compare the sign of the operands to the sign of the result (same reasoning as in the Computer Arithmetic topic).
Adding two 4-bit numbers can produce a 5-bit result, and VHDL will not silently widen the vector to fit.
Widen the targetDeclare SUM as 5 bits and resize the operands: SUM <= resize(A,5) + resize(B,5); โ no information is lost.
Capture the carryKeep SUM at 4 bits and take the fifth bit as a separate carry-out signal, which is what a hardware adder does.
numeric_std's signed and unsigned types exist rather than doing arithmetic directly on std_logic_vector. A raw vector is just a bundle of bits with no arithmetic meaning at all โ the type is what tells the tools how to interpret it, and therefore which adder to build.
bit holds only '0' and '1'. std_logic holds nine values, and the extra ones model things real hardware genuinely does.
'Z'High impedance โ the output is disconnected, which is how several devices share one bus without fighting.
'U'Uninitialised โ a signal that has never been assigned. Seeing 'U' in simulation usually means a missing reset.
'X'Unknown or conflicting โ two drivers pulling the same wire in opposite directions.
bit would hide. A design that reads an uninitialised register shows 'U' propagating through the results instead of a plausible-looking 0 โ the error is visible rather than silently wrong, which is the whole argument for the richer type.Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Loadingโฆ