---------------------------------------------------------------------------- -- -- (c) COPYRIGHT 1989 ZYCAD CORPORATION. -- This source file may be used and distributed without restriction -- provided that the copyright is not removed and that the code is -- not used or distributed for profit. -- -- Package name: types.vhd -- -- Purpose: This package defines the types, logic functions, -- truth tables, definitions for wired signals, -- and conversion functions for the Zycad Standard Logic library. -- -- Author: JT, PH, GWH -- ---------------------------------------------------------------------------- package TYPES is --------------------------------------------------------------------- -- -- Definitions for Standard Logic types -- --------------------------------------------------------------------- -- multi-valued logic 4 states: type MVL4 is ('X', '0', '1', 'Z'); -- (unknown,low,high,high impedance) -- vector of MVL4 type MVL4_VECTOR is array (Natural range <>) of MVL4; -- internal type for table look up type MVL4_TAB1D is array (MVL4) of MVL4; -- one dimensional type MVL4_TABLE is array (MVL4, MVL4) of MVL4; -- two dimensional type MVL4_TAB3D is array (MVL4, MVL4, MVL4) of MVL4; --three dimensional ----------------------------------------------------------------------- -- -- Truth tables for logical operations -- ---------------------------------------------------------------------- -- truth table for "and" function constant table_AND: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', '0', 'X', 'X'), -- | X | ('0', '0', '0', '0'), -- | 0 | ('X', '0', '1', 'X'), -- | 1 | ('X', '0', 'X', 'X')); -- | Z | -- truth table for "nand" function constant table_NAND: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', '1', 'X', 'X'), -- | X | ('1', '1', '1', '1'), -- | 0 | ('X', '1', '0', 'X'), -- | 1 | ('X', '1', 'X', 'X')); -- | Z | -- truth table for "or" function constant table_OR: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', '1', 'X'), -- | X | ('X', '0', '1', 'X'), -- | 0 | ('1', '1', '1', '1'), -- | 1 | ('X', 'X', '1', 'X')); -- | Z | -- truth table for "nor" function constant table_NOR: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', '0', 'X'), -- | X | ('X', '1', '0', 'X'), -- | 0 | ('0', '0', '0', '0'), -- | 1 | ('X', 'X', '0', 'X')); -- | Z | -- truth table for "xor" function constant table_XOR: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('X', '0', '1', 'X'), -- | 0 | ('X', '1', '0', 'X'), -- | 1 | ('X', 'X', 'X', 'X')); -- | Z | -- truth table for "nxor" function constant table_NXOR: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('X', '1', '0', 'X'), -- | 0 | ('X', '0', '1', 'X'), -- | 1 | ('X', 'X', 'X', 'X')); -- | Z | -- truth table for "not" function constant table_NOT: MVL4_TAB1D := -- ---------------------- -- | X 0 1 Z | -- ---------------------- ('X', '1', '0', 'X'); -- truth table for "buf" function constant table_BUF: MVL4_TAB1D := -- ---------------------- -- | X 0 1 Z | -- ---------------------- ('X', '0', '1', 'X'); -- truth table for tristate "not" function constant table_NOT3S: MVL4_TABLE := -- ---------------------------------- -- | X 0 1 Z | Enable | -- ---------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('Z', 'Z', 'Z', 'Z'), -- | 0 | ('X', '1', '0', 'X'), -- | 1 | ('X', 'X', 'X', 'X')); -- | Z | -- truth table for tristate "buf" function constant table_BUF3S: MVL4_TABLE := -- ---------------------------------- -- | X 0 1 Z | Enable | -- ---------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('Z', 'Z', 'Z', 'Z'), -- | 0 | ('X', '0', '1', 'X'), -- | 1 | ('X', 'X', 'X', 'X')); -- | Z | -- truth table for "=" function -- this table is identical to NXOR table constant table_EQUAL: MVL4_TABLE := table_NXOR; -- truth table for "/=" function -- this table is identical to XOR table constant table_UNEQUAL: MVL4_TABLE := table_XOR; -- truth table for "MAJORITY" function constant table_MJR: MVL4_TAB3D := --------------------------------------------- --| In3 |'X' '0' '1' 'Z' | In2 In1 | --------------------------------------------- ((('X', 'X', 'X', 'X'), --| 'X' 'X' | ('X', '0', 'X', 'X'), --| '0' 'X' | ('X', 'X', '1', 'X'), --| '1' 'X' | ('X', 'X', 'X', 'X')), --| 'Z' 'X' | (('X', '0', 'X', 'X'), --| 'X' '0' | ('0', '0', '0', '0'), --| '0' '0' | ('X', '0', '1', 'X'), --| '1' '0' | ('X', '0', 'X', 'X')), --| 'Z' '0' | (('X', 'X', '1', 'X'), --| 'X' '1' | ('X', '0', '1', 'X'), --| '0' '1' | ('1', '1', '1', '1'), --| '1' '1' | ('X', 'X', '1', 'X')), --| 'Z' '1' | (('X', 'X', 'X', 'X'), --| 'X' 'Z' | ('X', '0', 'X', 'X'), --| '0' 'Z' | ('X', 'X', '1', 'X'), --| '1' 'Z' | ('X', 'X', 'X', 'X')));--| 'Z' 'Z' | -- truth table for "MUX2x1" function constant table_MUX2x1: MVL4_TAB3D := ---------------------------------------------- --| In0 |'X' '0' '1' 'Z' | Sel In1 | ---------------------------------------------- ((('X', 'X', 'X', 'X'), --| 'X' 'X' | ('X', '0', '1', 'X'), --| '0' 'X' | ('X', 'X', 'X', 'X'), --| '1' 'X' | ('X', 'X', 'X', 'X')), --| 'Z' 'X' | (('X', '0', 'X', 'X'), --| 'X' '0' | ('X', '0', '1', 'X'), --| '0' '0' | ('0', '0', '0', '0'), --| '1' '0' | ('X', '0', 'X', 'X')), --| 'Z' '0' | (('X', 'X', '1', 'X'), --| 'X' '1' | ('X', '0', '1', 'X'), --| '0' '1' | ('1', '1', '1', '1'), --| '1' '1' | ('X', 'X', '1', 'X')), --| 'Z' '1' | (('X', 'X', 'X', 'X'), --| 'X' 'Z' | ('X', '0', '1', 'X'), --| '0' 'Z' | ('X', 'X', 'X', 'X'), --| '1' 'Z' | ('X', 'X', 'X', 'X')));--| 'Z' 'Z' | ---------------------------------------------------------------------- -- -- Truth tables for resolution functions -- ---------------------------------------------------------------------- -- truth table for "WiredPullUp" function constant table_WIREDPULLUP: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', '0', 'X', 'X'), -- | X | ('0', '0', '0', '0'), -- | 0 | ('X', '0', '1', '1'), -- | 1 | ('X', '0', '1', '1')); -- | Z | -- truth table for "WiredPullDown" function constant table_WIREDPULLDOWN: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', '1', 'X'), -- | X | ('X', '0', '1', '0'), -- | 0 | ('1', '1', '1', '1'), -- | 1 | ('X', '0', '1', '0')); -- | Z | -- truth table for "WiredX" function constant table_WIREDX: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('X', '0', 'X', '0'), -- | 0 | ('X', 'X', '1', '1'), -- | 1 | ('X', '0', '1', 'Z')); -- | Z | -- truth table for "WiredSingle" function -- this truth table allows only one driver to be active constant table_WIREDSINGLE: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', 'X', 'X'), -- | X | ('X', 'X', 'X', '0'), -- | 0 | ('X', 'X', 'X', '1'), -- | 1 | ('X', '0', '1', 'Z')); -- | Z | -- truth table for "WiredAnd" function constant table_WIREDAND: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', '0', 'X', 'X'), -- | X | ('0', '0', '0', '0'), -- | 0 | ('X', '0', '1', '1'), -- | 1 | ('X', '0', '1', 'Z')); -- | Z | -- truth table for "WiredOr" function constant table_WIREDOR: MVL4_TABLE := -- -------------------------------- -- | X 0 1 Z | | -- -------------------------------- (('X', 'X', '1', 'X'), -- | X | ('X', '0', '1', '0'), -- | 0 | ('1', '1', '1', '1'), -- | 1 | ('X', '0', '1', 'Z')); -- | Z | ----------------------------------------------------------------------- -- -- logical functions for scalar type of MVL4 -- ----------------------------------------------------------------------- function "and" (L, R: MVL4) return MVL4; function "nand" (L, R: MVL4) return MVL4; function "or" (L, R: MVL4) return MVL4; function "nor" (L, R: MVL4) return MVL4; function "xor" (L, R: MVL4) return MVL4; function nxor (L, R: MVL4) return MVL4; function "not" (R: MVL4) return MVL4; function buf (R: MVL4) return MVL4; ----------------------------------------------------------------------- -- -- logical functions for composite type of MVL4_VECTOR -- ----------------------------------------------------------------------- function "and" (L, R: MVL4_VECTOR) return MVL4_VECTOR; function "nand" (L, R: MVL4_VECTOR) return MVL4_VECTOR; function "or" (L, R: MVL4_VECTOR) return MVL4_VECTOR; function "nor" (L, R: MVL4_VECTOR) return MVL4_VECTOR; function "xor" (L, R: MVL4_VECTOR) return MVL4_VECTOR; function nxor (L, R: MVL4_VECTOR) return MVL4_VECTOR; function "not" (R: MVL4_VECTOR) return MVL4_VECTOR; function buf (R: MVL4_VECTOR) return MVL4_VECTOR; ----------------------------------------------------------------------- -- -- comparison functions for scalar type of MVL4 -- (equivalent to nxor and xor) -- ----------------------------------------------------------------------- function "=" (L, R: MVL4) return MVL4; function "/=" (L, R: MVL4) return MVL4; ----------------------------------------------------------------------- -- -- comparison operations for composite type of MVL4_VECTOR -- (equivalent to nxor and xor) -- ----------------------------------------------------------------------- function "=" (L, R: MVL4_VECTOR) return MVL4; function "/=" (L, R: MVL4_VECTOR) return MVL4; ----------------------------------------------------------------------- -- -- resolution functions for wired signals -- ----------------------------------------------------------------------- function WiredPullUp (V: MVL4_VECTOR) return MVL4; function WiredPullDown (V: MVL4_VECTOR) return MVL4; function WiredX (V: MVL4_VECTOR) return MVL4; function WiredSingle (V: MVL4_VECTOR) return MVL4; function WiredAnd (V: MVL4_VECTOR) return MVL4; function WiredOr (V: MVL4_VECTOR) return MVL4; ----------------------------------------------------------------------- -- -- Definitions for wired signals (scalars and vectors) -- ----------------------------------------------------------------------- subtype DotPullUp is WiredPullUp MVL4; subtype DotPullDown is WiredPullDown MVL4; subtype DotX is WiredX MVL4; subtype DotSingle is WiredSingle MVL4; subtype DotAnd is WiredAnd MVL4; subtype DotOr is WiredOr MVL4; type BusPullUp is array (Natural range <>) of DotPullUp; type BusPullDown is array (Natural range <>) of DotPullDown; type BusX is array (Natural range <>) of DotX; type BusSingle is array (Natural range <>) of DotSingle; type BusAnd is array (Natural range <>) of DotAnd; type BusOr is array (Natural range <>) of DotOr; ----------------------------------------------------------------------- -- -- conversion functions for driving various types -- ----------------------------------------------------------------------- function Drive (V: MVL4) return MVL4; function Drive (V: MVL4_VECTOR) return MVL4_VECTOR; function Drive (V: MVL4_VECTOR) return BusPullUp; function Drive (V: MVL4_VECTOR) return BusPullDown; function Drive (V: MVL4_VECTOR) return BusX; function Drive (V: MVL4_VECTOR) return BusSingle; function Drive (V: MVL4_VECTOR) return BusAnd; function Drive (V: MVL4_VECTOR) return BusOr; function Drive (V: BusPullUp) return MVL4_VECTOR; function Drive (V: BusPullDown) return MVL4_VECTOR; function Drive (V: BusX) return MVL4_VECTOR; function Drive (V: BusSingle) return MVL4_VECTOR; function Drive (V: BusAnd) return MVL4_VECTOR; function Drive (V: BusOr) return MVL4_VECTOR; ----------------------------------------------------------------------- -- -- conversion functions for sensing various types -- (the second argument allows the user to specify the value to -- be returned when the network is undriven) -- ----------------------------------------------------------------------- function Sense (V: MVL4; vZ: MVL4) return MVL4; function Sense (V: MVL4_VECTOR; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusPullUp; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusPullDown; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusX; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusSingle; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusAnd; vZ: MVL4) return MVL4_VECTOR; function Sense (V: BusOr; vZ: MVL4) return MVL4_VECTOR; ----------------------------------------------------------------------- -- -- Function: BVtoMVL4V -- -- Purpose: Conversion function from BIT_VECTOR to MVL4_VECTOR -- -- Mapping: 0 --> 0 -- 1 --> 1 -- ----------------------------------------------------------------------- function BVtoMVL4V (V: BIT_VECTOR) return MVL4_VECTOR; ----------------------------------------------------------------------- -- -- Function: MVL4VtoBV -- -- Purpose: Conversion function from MVL4_VECTOR to BIT_VECTOR -- -- Mapping: 0 --> 0 -- 1 --> 1 -- X --> vX if Xflag is TRUE -- X --> 0 if Xflag is FALSE -- Z --> vZ if Zflag is TRUE -- Z --> 0 if Zflag is FALSE -- ----------------------------------------------------------------------- function MVL4VtoBV (V: MVL4_VECTOR; vX, vZ: BIT := '0'; Xflag, Zflag: BOOLEAN := FALSE) return BIT_VECTOR; ----------------------------------------------------------------------- -- -- Function: BITtoMVL4 -- -- Purpose: Conversion function from BIT to MVL4 -- -- Mapping: 0 --> 0 -- 1 --> 1 -- ----------------------------------------------------------------------- function BITtoMVL4 (V: BIT) return MVL4; ----------------------------------------------------------------------- -- -- Function: MVL4toBIT -- -- Purpose: Conversion function from MVL4 to BIT -- -- Mapping: 0 --> 0 -- 1 --> 1 -- X --> vX if Xflag is TRUE -- X --> 0 if Xflag is FALSE -- Z --> vZ if Zflag is TRUE -- Z --> 0 if Zflag is FALSE -- ----------------------------------------------------------------------- function MVL4toBIT (V: MVL4; vX, vZ: BIT := '0'; Xflag, Zflag: BOOLEAN := FALSE) return BIT; end TYPES; package body TYPES is ----------------------------------------------------------------------- -- -- logical functions for scalar type of MVL4 -- ----------------------------------------------------------------------- function "and" (L, R: MVL4) return MVL4 is begin return table_AND(L, R); end "and"; function "nand" (L, R: MVL4) return MVL4 is begin return table_NAND(L, R); end "nand"; function "or" (L, R: MVL4) return MVL4 is begin return table_OR(L, R); end "or"; function "nor" (L, R: MVL4) return MVL4 is begin return table_NOR(L, R); end "nor"; function "xor" (L, R: MVL4) return MVL4 is begin return table_XOR(L, R); end "xor"; function nxor (L, R: MVL4) return MVL4 is begin return table_NXOR(L, R); end nxor; function "not" (R: MVL4) return MVL4 is begin return table_NOT(R); end "not"; function buf (R: MVL4) return MVL4 is begin return table_BUF(R); end buf; ----------------------------------------------------------------------- -- -- logical functions for composite type of MVL4_VECTOR -- ----------------------------------------------------------------------- function "and" (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result (i) := table_AND(LV (i), RV (i)); end loop; return result; end "and"; function "nand" (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result (i) := table_NAND(LV (i), RV (i)); end loop; return result; end "nand"; function "or" (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result (i) := table_OR(LV (i), RV (i)); end loop; return result; end "or"; function "nor" (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result (i) := table_NOR( LV (i), RV (i)); end loop; return result; end "nor"; function "xor" (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result (i) := table_XOR(LV (i), RV (i)); end loop; return result; end "xor"; function nxor (L, R: MVL4_VECTOR) return MVL4_VECTOR is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (L'length-1 downto 0); begin assert L'length = R'length; for i in result'range loop result(i) := table_NXOR(LV(i), RV(i)); end loop; return result; end nxor; function "not" (R: MVL4_VECTOR) return MVL4_VECTOR is alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (R'length-1 downto 0); begin for i in result'range loop result (i) := table_NOT( RV(i) ); end loop; return result; end "not"; function buf (R: MVL4_VECTOR) return MVL4_VECTOR is alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4_VECTOR (R'length-1 downto 0); begin for i in result'range loop result(i) := table_BUF( RV(i) ); end loop; return result; end buf; ----------------------------------------------------------------------- -- -- comparison functions for scalar type of MVL4 -- ----------------------------------------------------------------------- function "=" (L, R: MVL4) return MVL4 is begin return table_EQUAL(L, R); end "="; function "/=" (L, R: MVL4) return MVL4 is begin return table_UNEQUAL(L, R); end "/="; ----------------------------------------------------------------------- -- -- comparison functions for composite type of MVL4_VECTOR -- ----------------------------------------------------------------------- function "=" (L, R: MVL4_VECTOR) return MVL4 is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4; variable Xresult: MVL4:= '1'; begin assert L'length = R'length; for i in LV'range loop result := table_EQUAL( LV (i), RV (i)); next when result = '1'; if (result = '0') then return '0'; end if; Xresult := 'X'; end loop; return (Xresult); end "="; function "/=" (L, R: MVL4_VECTOR) return MVL4 is alias LV: MVL4_VECTOR (L'length-1 downto 0) is L; alias RV: MVL4_VECTOR (R'length-1 downto 0) is R; variable result: MVL4; variable Xresult: MVL4:= '0'; begin assert L'length = R'length; for i in LV'range loop result := table_UNEQUAL(LV (i), RV (i)); next when result = '0'; if (result = '1') then return '1'; end if; Xresult := 'X'; end loop; return (Xresult); end "/="; ----------------------------------------------------------------------- -- -- resolution functions for wired signals -- ----------------------------------------------------------------------- function WiredPullUp (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; begin for i in V'range loop result := table_WIREDPULLUP(result, V(i)); exit when result = '0'; end loop; return result; end WiredPullUp; function WiredPullDown (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; begin for i in V'range loop result := table_WIREDPULLDOWN(result, V(i)); exit when result = '1'; end loop; return result; end WiredPullDown; function WiredX (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; begin for i in V'range loop result := table_WIREDX(result, V(i)); exit when result = 'X'; end loop; return result; end WiredX; function WiredSingle (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; variable got_one: BOOLEAN := FALSE; begin for i in V'range loop next when V(i) = 'Z'; if got_one then assert false report "Multiple contributors to WiredSingle node." severity WARNING; result := 'X'; return result; end if; got_one := TRUE; result := V(i); end loop; return result; end WiredSingle; function WiredAnd (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; begin for i in V'range loop result := table_WIREDAND(result, V(i)); exit when result = '0'; end loop; return result; end WiredAnd; function WiredOr (V: MVL4_VECTOR) return MVL4 is variable result: MVL4 := 'Z'; begin for i in V'range loop result := table_WIREDOR(result, V(i)); exit when result = '1'; end loop; return result; end WiredOr; ----------------------------------------------------------------------- -- -- conversion functions for driving various types -- ----------------------------------------------------------------------- function Drive (V: MVL4) return MVL4 is begin return V; end Drive; function Drive (V: MVL4_VECTOR) return MVL4_VECTOR is begin return V; end Drive; function Drive (V: BusPullUp) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: BusPullDown) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: BusX) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: BusSingle) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: BusAnd) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: BusOr) return MVL4_VECTOR is begin return MVL4_VECTOR(V); end Drive; function Drive (V: MVL4_VECTOR) return BusPullUp is begin return BusPullUp(V); end Drive; function Drive (V: MVL4_VECTOR) return BusPullDown is begin return BusPullDown(V); end Drive; function Drive (V: MVL4_VECTOR) return BusX is begin return BusX(V); end Drive; function Drive (V: MVL4_VECTOR) return BusSingle is begin return BusSingle(V); end Drive; function Drive (V: MVL4_VECTOR) return BusAnd is begin return BusAnd(V); end Drive; function Drive (V: MVL4_VECTOR) return BusOr is begin return BusOr(V); end Drive; ----------------------------------------------------------------------- -- -- conversion functions for sensing various types -- -- (the second argument allows the user to specify the value to -- be returned when the network is undriven) -- ----------------------------------------------------------------------- function Sense (V: MVL4; vZ: MVL4) return MVL4 is begin if V = 'Z' then return vZ; else return V; end if; end Sense; function Sense (V: MVL4_VECTOR; vZ: MVL4) return MVL4_VECTOR is alias Value: MVL4_VECTOR (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusPullUp; vZ: MVL4) return MVL4_VECTOR is alias Value: BusPullUp (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusPullDown; vZ: MVL4) return MVL4_VECTOR is alias Value: BusPullDown (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusX; vZ: MVL4) return MVL4_VECTOR is alias Value: BusX (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusSingle; vZ: MVL4) return MVL4_VECTOR is alias Value: BusSingle (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusAnd; vZ: MVL4) return MVL4_VECTOR is alias Value: BusAnd (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; function Sense (V: BusOr; vZ: MVL4) return MVL4_VECTOR is alias Value: BusOr (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = 'Z' ) then Result(i) := vZ; else Result(i) := Value(i); end if; end loop; return Result; end Sense; ----------------------------------------------------------------------- -- -- Function: BVtoMVL4V -- -- Purpose: Conversion function from BIT_VECTOR to MVL4_VECTOR -- -- Mapping: 0 --> 0 -- 1 --> 1 -- ----------------------------------------------------------------------- function BVtoMVL4V (V: BIT_VECTOR) return MVL4_VECTOR is alias Value: BIT_VECTOR (V'length-1 downto 0) is V; variable Result: MVL4_VECTOR (V'length-1 downto 0); begin for i in Value'range loop if ( Value(i) = '0' ) then Result(i) := '0'; else Result(i) := '1'; end if; end loop; return Result; end BVtoMVL4V; ----------------------------------------------------------------------- -- -- Function: MVL4VtoBV -- -- Purpose: Conversion function from MVL4_VECTOR to BIT_VECTOR -- -- Mapping: 0 --> 0 -- 1 --> 1 -- X --> vX if Xflag is TRUE -- X --> 0 if Xflag is FALSE -- Z --> vZ if Zflag is TRUE -- Z --> 0 if Zflag is FALSE -- ----------------------------------------------------------------------- function MVL4VtoBV (V: MVL4_VECTOR; vX, vZ: BIT := '0'; Xflag, Zflag: BOOLEAN := FALSE) return BIT_VECTOR is alias Value: MVL4_VECTOR (V'length-1 downto 0) is V; variable Result: BIT_VECTOR (V'length-1 downto 0); begin for i in Value'range loop case Value(i) is when '0' => Result(i) := '0'; when '1' => Result(i) := '1'; when 'X' => if ( Xflag ) then Result(i) := vX; else Result(i) := '0'; assert FALSE report "MVL4VtoBV: X --> 0" severity WARNING; end if; when others => if ( Zflag ) then Result(i) := vZ; else Result(i) := '0'; assert FALSE report "MVL4VtoBV: Z --> 0" severity WARNING; end if; end case; end loop; return Result; end MVL4VtoBV; ----------------------------------------------------------------------- -- -- Function: BITtoMVL4 -- -- Purpose: Conversion function from BIT to MVL4 -- -- Mapping: 0 --> 0 -- 1 --> 1 -- ----------------------------------------------------------------------- function BITtoMVL4 (V: BIT) return MVL4 is variable Result: MVL4; begin if ( V = '0' ) then Result := '0'; else Result := '1'; end if; return Result; end BITtoMVL4; ----------------------------------------------------------------------- -- -- Function: MVL4toBIT -- -- Purpose: Conversion function from MVL4 to BIT -- -- Mapping: 0 --> 0 -- 1 --> 1 -- X --> vX if Xflag is TRUE -- X --> 0 if Xflag is FALSE -- Z --> vZ if Zflag is TRUE -- Z --> 0 if Zflag is FALSE -- ----------------------------------------------------------------------- function MVL4toBIT (V: MVL4; vX, vZ: BIT := '0'; Xflag, Zflag: BOOLEAN := FALSE) return BIT is variable Result: BIT; begin case V is when '0' => Result := '0'; when '1' => Result := '1'; when 'X' => if ( Xflag ) then Result := vX; else Result := '0'; assert FALSE report "MVL4toBIT: X --> 0" severity WARNING; end if; when others => if ( Zflag ) then Result := vZ; else Result := '0'; assert FALSE report "MVL4toBIT: Z --> 0" severity WARNING; end if; end case; return Result; end MVL4toBIT; end TYPES;