Data Types
Data Types
A.G.Rao
IEEE Packages
IEEE defined a 9 valued logic system
IEEE developed two packages for this
system
STD_LOGIC_1164.VHD
Defines the basic value system and associated
functions
Used as is by vendors
NUMERIC_STD.VHD
Provides overloaded arithmetic and other operators
for synthesis
Vendors have developed their own versions of this
Synopsys Packages
Packages:
STD_LOGIC_1164.VHD
STD_LOGIC_ARITH.VHD
STD_LOGIC_SIGNED.VHD
STD_LOGIC_UNSIGNED.VHD
STD_LOGIC_MISC.VHD
STD_LOGIC_TEXTIO.VHD
Source location
$SYNOPSYS/packages/IEEE/src/*.vhd
STD_LOGIC_1164 - Logic Values
IEEE Standard
type STD_ULOGIC is ( ‘U’,-- Uninitialized
‘X’,-- Forcing Unknown
‘0’ ,-- Forcing 0
‘1’, -- Forcing 1
‘Z’,-- High Impedance
‘W’,-- Weak Unknown
‘L’,-- Weak 0
‘H’,-- Weak 1
‘-’,-- Don’t care
);
Strengths
Need to model bus contention
Logic values have strength
0 strong zero; 1 strong one
L weak zero; H weak one
Models the effect of source impedance
Suppose R is the resolution function, then strong
dominates weak, i.e.
0RH=HR0=0
1 RL= LR1=1
Unknown Values
X: value is 0 or 1 W: value is L or H
X and W are unknown values that arise from:
Bus contention, i.e. resolving opposite values of the
same strength yields unknowns of that strength
0 R 1 = 1 R 0 = X LR H = H R L= W
error conditions, e.g, a flip flop has an unknown state
Strength and weakness applied among values and
unknowns also, e.g.:
L R X = X, 1 R W = 1
Uninitialized Value (U)
Left most value of the type, thus the default
initialization value.
Used to model initialization of sequential
circuits:
Initial state of the circuit is U
Does the logic change this state to a 0 or a 1? If
not, the logic is not correctly designed
Z and ‘-’
Z represents high impedance, i.e., the output of
a tri-state buffer that is turned off.
- represents a don’t care
synthesis: represents a logic don’t care that can be
used for logic minimization
simulation: acts like an X, is converted to an X when
operated on.
Resolution
CONSTANT resolution_table : stdlogic_table := (
-- ---------------------------------------------------------
-- | U X 0 1 Z W L H - | |
-- ---------------------------------------------------------
( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |
( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |
( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ), -- | 0 |
( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ), -- | 1 |
( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |
( 'U', 'X', '0', '1', 'W', 'W', 'W','W', 'X' ), -- | W |
( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |
( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |
( 'U', 'X', 'X', 'X', 'X', 'X', 'X', ’ X', 'X' ) -- | - |
);
STD_LOGIC Definition
-------------------------------------------------------------------
-- *** industry standard logic type ***
-------------------------------------------------------------------
SUBTYPE std_logic IS resolved std_ulogic;
-------------------------------------------------------------------
-- unconstrained array of std_logic for use
in declaring signal arrays
-------------------------------------------------------------------
TYPE std_logic_vector IS
ARRAY ( NATURAL RANGE <>) OF std_logic;
Resolution Function - Resolved
FUNCTION resolved ( s : std_ulogic_vector )
RETURN std_ulogic IS
VARIABLE result : std_ulogic := 'Z'; -- weakest state default
BEGIN
-- the test for a single driver is essential otherwise the
-- loop would return 'X' for a single driver of '-' and that
-- would conflict with the value of a single driver unresolved
-- signal.
IF (s'LENGTH = 1) THEN RETURN s(s'LOW);
ELSE
FOR i IN s'RANGE LOOP
result := resolution_table(result, s(i));
END LOOP;
END IF;
RETURN result;
END resolved;
Common Subtypes