--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-- --!! !!-- --!! V E R I L O G _ S T D V 1 . 0 !!-- --!! !!-- --!! The following package is provided with VDoc 454 to allow !!-- --!! for simulation of the output of this tool. It contains definitions !!-- --!! for the Verilog multi-value logic set, overloaded operators, and !!-- --!! resoulution functions. A group of utility routines are also !!-- --!! included to convert types and do other useful operations. !!-- --!! Definitions for the Verilog pre-defined gates are also provided !!-- --!! with this tool. This package specification, its associated body, !!-- --!! and the gate definitions are intended for use in verifying the !!-- --!! output of VDoc 454 and should not be used for any other purpose or !!-- --!! modified in any way. !!-- --!! !!-- --!! This program is the Confidential and Proprietary product of !!-- --!! Gateway Design Automation Corporation. Any unauthorized use, !!-- --!! reproduction, or transfer of this Program is strictly prohibited. !!-- --!! Copyright (c) 1989 by Gateway Design Automation Corporation. !!-- --!! All Rights Reserved. !!-- --!! !!-- --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-- package VERILOG_STD is --###########################################################################-- -- The following naming convention has been used for the MVL type definition:-- -- -- -- +----------- 'Basic' strength name (Sm, Me, We, La, Pu, St, Su, As, Fo) -- -- | -- -- | +--------- Indicates the logic value (0, 1, Z, X, L, H) -- -- | | -- -- | | +------- Intermediate strength values (a, b, c, d, e, and f), in -- -- v v v the increasing order. -- -- La1_a -- -- -- -- Exceptions to the above convention are made for these: -- -- -- -- 1. Default strengths, when -- -- St0 is represented as '0' -- -- St1 is represented as '1' -- -- StX is represented as 'X' -- -- Z is represented as 'Z' -- -- -- -- 2. Values representing the exact basic strengths -- -- For example Sm1, Su0 -- -- -- --###########################################################################-- type MVL is ( -- basic logic values -- 'Z', 'X', '0', '1', -- '0' values with different strengths -- Sm0, -- Small capacitor Me0, Me0_a, -- Medium capacitor We0, We0_a, We0_b, -- Weak drive La0, La0_a, La0_b, La0_c, -- Large capacitor Pu0, Pu0_a, Pu0_b, Pu0_c, Pu0_d, -- Pull drive St0_a, St0_b, St0_c, St0_d, St0_e, -- Strong drive Su0, Su0_a, Su0_b, Su0_c, Su0_d, Su0_e, Su0_f, -- Supply drive As0, Fo0, -- Assign/Force (Future) -- '1' values with different strengths -- Sm1, -- Small capacitor Me1, Me1_a, -- Medium capacitor We1, We1_a, We1_b, -- Weak drive La1, La1_a, La1_b, La1_c, -- Large capacitor Pu1, Pu1_a, Pu1_b, Pu1_c, Pu1_d, -- Pull drive St1_a, St1_b, St1_c, St1_d, St1_e, -- Strong drive Su1, Su1_a, Su1_b, Su1_c, Su1_d, Su1_e, Su1_f, -- Supply drive As1, Fo1, -- Assign/Force (Future) -- 'X' values with different strengths -- SmX, SmX_a, SmX_b, SmX_c, SmX_d, SmX_e, SmX_f, -- Small capacitor MeX_a, MeX, MeX_b, MeX_c, MeX_d, MeX_e, MeX_f, -- Medium capacitor WeX_a, WeX_b, WeX, WeX_c, WeX_d, WeX_e, WeX_f, -- Weak drive LaX_a, LaX_b, LaX_c, LaX, LaX_d, LaX_e, LaX_f, -- Large capacitor PuX_a, PuX_b, PuX_c, PuX_d, PuX, PuX_e, PuX_f, -- Pull drive StX_a, StX_b, StX_c, StX_d, StX_e, StX_f, -- Strong drive SuX_a, SuX_b, SuX_c, SuX_d, SuX_e, SuX_f, SuX, -- Supply drive AsX, FoX, -- Assign/Force (Future) -- 'L' values with different strengths -- SmL, MeL, WeL, LaL, PuL, StL, SuL, -- 'L' values -- 'H' values with different strengths -- SmH, MeH, WeH, LaH, PuH, StH, SuH, -- 'H' values -- 'Z' value -- HiZ, -- High Impedence AsZ, FoZ -- Assign/Force (Future) ); --########################################################################-- -- -- CONSTANTS AND ADDITIONAL TYPES/SUBTYPES: -- --########################################################################-- -- Types and subtypes: -- Unconstrained Vector of type MVL type MVL_VECTOR is array (INTEGER range <> ) of MVL ; -- Verilog INTEGER and TIME representations subtype VLINT is MVL_VECTOR(31 downto 0); -- Represents a Verilog Integer subtype VLTIME is MVL_VECTOR(63 downto 0); -- Return type of SYS_TIME -- Used to implement SYS_READMEMB type DATA_FILE is file of CHARACTER; -- Define type for unconnected ports -- type UNCONNECTED_PORT is (UNCONNECTED); -- Subtypes of MVL -- subtype MVL_XZ01 is MVL range 'Z' to '1';-- for logic values 'X' 'Z' '0' '1' subtype MVL_L is MVL range SmL to SuL; -- for 'L' values -- Type declaration for strength representation -- subtype STRENGTH is BIT_VECTOR (7 downto 0); -- Define type for input parameter to mvl_vector resolution functions. subtype MVL_VECTOR_CONSTRAINT is INTEGER range 1 to 16#FFFFFF#; subtype VECTOR_OF_MVL_VECTORS_ELEMENT is MVL_VECTOR(MVL_VECTOR_CONSTRAINT); type VECTOR_OF_MVL_VECTORS is array (INTEGER range <>) of VECTOR_OF_MVL_VECTORS_ELEMENT; -- Constants: -- Constant used for indicating the unspecified delay value, -- usually used in the 'gate' interface etc. constant NOT_SPECIFIED : INTEGER := -1; -- These constants describe the 8 levels of strengths used for coercion. constant SUPPLY : STRENGTH := "10000000"; constant STRONG : STRENGTH := "01000000"; constant PULL : STRENGTH := "00100000"; constant LARGE : STRENGTH := "00010000"; constant WEAK : STRENGTH := "00001000"; constant MEDIUM : STRENGTH := "00000100"; constant SMALL : STRENGTH := "00000010"; constant HIGHZ : STRENGTH := "00000000"; -- Used for conversion of MVL to CHARACTER type MVL_CHAR_TYPE is array (mvl_xz01) of CHARACTER; constant MVL_CHAR : MVL_CHAR_TYPE := ('Z','X','0','1'); -- Signals containing MVL '1', '0', 'X', and 'Z'. These -- will be used in the assignment of actuals in port lists. signal MVL_1 : MVL := '1'; signal MVL_0 : MVL := '0'; signal MVL_X : MVL := 'X'; signal MVL_Z : MVL := 'Z'; --########################################################################-- -- -- OVERLOADED OPERATORS: -- -- The following are the specifications for the functions that -- represent the operators for the type MVL and MVL_VECTOR. VHDL -- operators were overloaded where possible to increase -- the readability of the output of VDoc 454. -- --########################################################################-- -- ARITHMETIC OPERATORS -- function "+" (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function "+" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "+" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function "+" (op1, op2 : MVL) return MVL_VECTOR ; function "-" (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function "-" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "-" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function "-" (op1, op2 : MVL) return MVL_VECTOR ; function "*" (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function "*" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "*" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function "*" (op1, op2 : MVL) return MVL ; function "/" (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function "/" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "/" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function "/" (op1, op2 : MVL) return MVL ; function "mod" (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function "mod" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "mod" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function "mod" (op1, op2 : MVL) return MVL ; function minus (op1: MVL) return MVL_VECTOR; function minus (op1: MVL_VECTOR) return MVL_VECTOR; -- RELATIONAL OPERATORS -- function gt (op1, op2 : MVL_VECTOR) return MVL ; function gt (op1: MVL; op2 : MVL_VECTOR) return MVL ; function gt (op1: MVL_VECTOR; op2 : MVL) return MVL ; function gt (op1, op2 : MVL) return MVL ; function gte (op1, op2 : MVL_VECTOR) return MVL ; function gte (op1: MVL; op2 : MVL_VECTOR) return MVL ; function gte (op1: MVL_VECTOR; op2 : MVL) return MVL ; function gte (op1, op2 : MVL) return MVL ; function lt (op1, op2 : MVL_VECTOR) return MVL ; function lt (op1: MVL; op2 : MVL_VECTOR) return MVL ; function lt (op1: MVL_VECTOR; op2 : MVL) return MVL ; function lt (op1, op2 : MVL) return MVL ; function lte (op1, op2 : MVL_VECTOR) return MVL ; function lte (op1: MVL; op2 : MVL_VECTOR) return MVL ; function lte (op1: MVL_VECTOR; op2 : MVL) return MVL ; function lte (op1, op2 : MVL) return MVL ; function eq (op1, op2 : MVL_VECTOR) return MVL ; function eq (op1: MVL; op2 : MVL_VECTOR) return MVL ; function eq (op1: MVL_VECTOR; op2 : MVL) return MVL ; function eq (op1, op2 : MVL) return MVL ; function neq (op1, op2 : MVL_VECTOR) return MVL ; function neq (op1: MVL; op2 : MVL_VECTOR) return MVL ; function neq (op1: MVL_VECTOR; op2 : MVL) return MVL ; function neq (op1, op2 : MVL) return MVL ; -- LOGICAL OPERATORS -- function log_not (op1 : MVL_VECTOR) return MVL ; function log_not (op1 : MVL) return MVL; function "not" (op1 : MVL_VECTOR) return BOOLEAN ; function "not" (op1 : MVL) return BOOLEAN; function log_and (op1, op2 : MVL_VECTOR) return MVL ; function log_and (op1: MVL; op2 : MVL_VECTOR) return MVL ; function log_and (op1: MVL_VECTOR; op2 : MVL) return MVL ; function log_and (op1, op2 : MVL) return MVL ; function "and" (op1, op2 : MVL_VECTOR) return BOOLEAN ; function "and" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN ; function "and" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN ; function "and" (op1, op2 : MVL) return BOOLEAN ; function log_or (op1, op2 : MVL_VECTOR) return MVL ; function log_or (op1: MVL; op2 : MVL_VECTOR) return MVL ; function log_or (op1: MVL_VECTOR; op2 : MVL) return MVL ; function log_or (op1, op2 : MVL) return MVL ; function "or" (op1, op2 : MVL_VECTOR) return BOOLEAN ; function "or" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN ; function "or" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN ; function "or" (op1, op2 : MVL) return BOOLEAN ; -- EQUALITY OPERATORS -- function case_eq (op1, op2 : MVL_VECTOR) return MVL ; function case_eq (op1: MVL; op2 : MVL_VECTOR) return MVL ; function case_eq (op1: MVL_VECTOR; op2 : MVL) return MVL ; function case_eq (op1, op2 : MVL) return MVL ; function case_neq (op1, op2 : MVL_VECTOR) return MVL ; function case_neq (op1: MVL; op2 : MVL_VECTOR) return MVL ; function case_neq (op1: MVL_VECTOR; op2 : MVL) return MVL ; function case_neq (op1, op2 : MVL) return MVL ; -- BITWISE OPERATORS -- function bit_neg (op1 : MVL_VECTOR) return MVL_VECTOR ; function bit_neg (op1 : MVL) return MVL ; function bit_and (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_and (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_and (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function bit_and (op1, op2 : MVL) return MVL ; function bit_or (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_or (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_or (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function bit_or (op1, op2 : MVL) return MVL ; function bit_xor (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_xor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_xor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function bit_xor (op1, op2 : MVL) return MVL ; function bit_xnor (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_xnor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function bit_xnor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function bit_xnor (op1, op2 : MVL) return MVL ; -- REDUCTION OPERATORS (UNARY) -- function red_and (op1 : MVL_VECTOR) return MVL ; function red_and (op1 : MVL) return MVL ; function red_nand (op1 : MVL_VECTOR) return MVL ; function red_nand (op1 : MVL) return MVL ; function red_or (op1 : MVL_VECTOR) return MVL ; function red_or (op1 : MVL) return MVL ; function red_nor (op1 : MVL_VECTOR) return MVL ; function red_nor (op1 : MVL) return MVL ; function red_xor (op1 : MVL_VECTOR) return MVL ; function red_xor (op1 : MVL) return MVL ; function red_xnor (op1 : MVL_VECTOR) return MVL ; function red_xnor (op1 : MVL) return MVL ; -- SHIFT OPERATORS -- function sh_left (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function sh_left (op1, op2 : MVL) return MVL_VECTOR; function sh_left (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function sh_left (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; function sh_right (op1, op2 : MVL_VECTOR) return MVL_VECTOR ; function sh_right (op1, op2 : MVL) return MVL_VECTOR; function sh_right (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function sh_right (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; -- CONCATENATION OPERATORS -- function "&" (op1, op2 : MVL) return MVL_VECTOR; function "&" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR ; function "&" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR ; -- CONDITIONAL OPERATOR -- function cond_op (cond, left_val, right_val: MVL_VECTOR) return MVL_VECTOR; function cond_op (cond, left_val, right_val: MVL) return MVL; function cond_op (cond, left_val: MVL; right_val: MVL_VECTOR) return MVL_VECTOR ; function cond_op (cond: MVL; left_val, right_val: MVL_VECTOR) return MVL_VECTOR ; function cond_op (cond: MVL; left_val: MVL_VECTOR; right_val: MVL) return MVL_VECTOR ; function cond_op (cond: MVL_VECTOR; left_val, right_val: MVL) return MVL_VECTOR ; function cond_op (cond: MVL_VECTOR; left_val: MVL_VECTOR; right_val: MVL) return MVL_VECTOR ; function cond_op (cond: MVL_VECTOR; left_val: MVL; right_val: MVL_VECTOR) return MVL_VECTOR ; --############################################################################-- -- -- UTILITY ROUTINES: -- -- What follows are various routines that are called from the VHDL code created -- by VDoc 454. They are used for type conversion, perform necessary -- operations, and other useful operations. -- --############################################################################-- -- Functions used to make conversions. function SUM (B1, B2, B3 :BIT) return MVL; function CARRY (B1, B2, B3 :BIT) return BIT; function GET_0_STRENGTH (M1: MVL) return STRENGTH; function GET_1_STRENGTH (M1: MVL) return STRENGTH; function GET_MVL_0 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_MVL_1 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_MVL_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_MVL_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_X_MVL (M1,M2: MVL_L) return MVL; function GET_COERCED_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_COERCED_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL; function GET_TERN_VAL (M1: MVL) return MVL; function GET_01X_VAL (M1: MVL) return MVL; function BIT_TO_MVL (B1: BIT) return MVL; function MODIFY_MOS_STRENGTH (M1: MVL) return MVL; function REDUCE_MOS_STRENGTH (M1: MVL) return MVL; -- The following are conversion functions. -- Conversion from MVLV: procedure conv_mvlv_to_logv (oldv: IN MVL_VECTOR; newv: INOUT MVL_VECTOR; has_no_X : OUT BOOLEAN) ; procedure conv_mvlv_to_bitv (oldv: IN MVL_VECTOR; newv: INOUT BIT_VECTOR; has_no_X : OUT BOOLEAN) ; procedure conv_mvlv_to_int (oper: IN MVL_VECTOR; value: OUT INTEGER; has_no_X : OUT BOOLEAN) ; -- Conversion from MVL : function conv_mvl_to_bit (mvl_val: MVL) return BIT ; procedure conv_mvl_to_int (oper : IN MVL; value: OUT INTEGER ; has_no_X : OUT BOOLEAN); procedure conv_mvl_to_bitv (oldv: IN MVL; newv: INOUT BIT_VECTOR; has_no_X : OUT BOOLEAN); procedure conv_mvl_to_logv (oldv: IN MVL; newv: INOUT MVL_VECTOR; has_no_X : OUT BOOLEAN); -- Conversion to BOOLEAN: function bool (mvl_val: MVL_VECTOR) return BOOLEAN ; function bool (mvl_val: MVL) return BOOLEAN ; function bool (mvl_val: BOOLEAN) return BOOLEAN ; -- Conversion to INTEGER: function int (oper: MVL_VECTOR) return INTEGER; function int (oper: MVL) return INTEGER; function int (oper: INTEGER) return INTEGER; -- Conversion to MVL and MVL_VECTOR: function to_mvl (oper : BOOLEAN) return MVL; function to_mvlv (oper : MVL) return MVL_VECTOR; function to_mvlv (oper : BOOLEAN) return MVL_VECTOR; -- Conversion of MVL and MVL_VECTORs to STRING function MVL_STRING (INPUT_VECTOR : MVL_VECTOR) return STRING; function MVL_STRING (INPUT_CHAR : MVL) return STRING; -- Conversion to MVL and MVL VECTOR: function conv_strength_to_mvl (in_abits, in_bbits: STRENGTH) return MVL ; function conv_bitv_to_mvlv (bit_val: BIT_VECTOR) return MVL_VECTOR ; procedure conv_int_to_mvlv (op: IN INTEGER; result: OUT MVL_VECTOR) ; -- Routine to allow assignments of unaligned mvl_vectors function align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL_VECTOR; function align_size (in_val : MVL; size : INTEGER) return MVL_VECTOR; function align_size (in_val : MVL; size : INTEGER) return MVL; function align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL; -- Routines to pad out vectors. function fill_mvl_vector (value: MVL; size: INTEGER) return MVL_VECTOR ; function fill_msb_1 (abits: STRENGTH) return STRENGTH ; function fill_lsb_1 (abits: STRENGTH) return STRENGTH ; function get_mvl_X (abits, bbits: STRENGTH := "01111111") return MVL ; -- Routines used to assign values and strengths to gates function get_coerced_val (value: MVL; strength0, strength1: STRENGTH) return MVL; function assign_strength (in_vector: MVL_VECTOR; strength0, strength1: STRENGTH) return MVL_VECTOR; --Routines to assign delays to gates. function assign_delay (in_vector: MVL_VECTOR; delay1, delay2, delay3: INTEGER) return INTEGER; function assign_delay (in_vector: MVL_VECTOR; delay1, delay2: INTEGER) return INTEGER; function assign_delay (in_mvl: MVL; delay1, delay2, delay3: INTEGER) return INTEGER; function assign_delay (in_mvl: MVL; delay1, delay2: INTEGER) return INTEGER; -- Routines to determine delays to use. function get_delay2 (d1, d2: INTEGER; value: MVL) return INTEGER; function get_delay3 (d1, d2, d3: INTEGER; value: MVL) return INTEGER; -- System Subroutines procedure SYS_FINISH ; function SYS_TIME (time_unit : time) return VLTIME; function SYS_TIME (time_unit : time) return TIME; procedure SYS_READMEMB (variable FILE_NAME: in DATA_FILE; DATA : inout MVL_VECTOR); -- Other useful routines. function max_size (op1,op2 : INTEGER) return INTEGER; function max_pos (op1 : STRENGTH) return INTEGER; --###########################################################################-- -- -- RESOLUTION FUNCTIONS: -- -- VERILOG resolves the net conflicts as follows : ----------------+-------------------------------------------------------------- -- INPUTS | NET TYPE ----------------+-------------------------------------------------------------- -- | WIRE TRI WOR TRIOR WAND TRIAND TRI0 TRI1 SUPP0 SUPP1 -- | -- 0 1 X Z | X X 1 1 0 0 X X Su0 Su1 -- 0 Z Z Z | 0 0 0 0 0 0 0 0 Su0 Su1 -- 1 Z Z Z | 1 1 1 1 1 1 1 1 Su0 Su1 -- Z Z Z Z | Z Z Z Z Z Z Pu0 Pu1 Su0 Su1 -- NO DRIVER | Z Z Z Z Z Z Pu0 Pu1 Su0 Su1 -- FORCE | ----------------+-------------------------------------------------------------- -- --############################################################################-- -- DECLARATIONS FOR NET-RESOLUTION FUNCTIONS -- -- Resolution of MVL subtype function resolve_tri (sources: MVL_VECTOR) return MVL; -- WIRE function resolve_trior (sources: MVL_VECTOR) return MVL; -- WIRED OR function resolve_triand (sources: MVL_VECTOR) return MVL; -- WIRED AND function resolve_tri1 (sources: MVL_VECTOR) return MVL; -- PULLUP function resolve_tri0 (sources: MVL_VECTOR) return MVL; -- PULLDOWN function resolve_supply0 (sources: MVL_VECTOR) return MVL; -- SUPPLY0 function resolve_supply1 (sources: MVL_VECTOR) return MVL; -- SUPPLTY1 function trireg (curr_val : MVL; cap_size: STRENGTH := MEDIUM) return MVL; -- FOR TRIREG -- Resolution of MVL_VECTOR subtype function resolve_tri_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR; -- FOR TRI function resolve_trior_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- WIRED OR function resolve_triand_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- WIRED AND function resolve_tri1_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- PULLUP function resolve_tri0_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- PULLDOWN function resolve_supply0_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- SUPPLY0 function resolve_supply1_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_vector; -- SUPPLTY1 function trireg (curr_val : MVL_VECTOR; cap_size: STRENGTH := MEDIUM) return MVL_VECTOR; --###########################################################################-- -- -- DECLARATIONS FOR VERILOG NET TYPES: -- --###########################################################################-- -- Declarations for Verilog net types subtype WIRE is resolve_tri MVL ; -- WIRE subtype TRI is resolve_tri MVL ; subtype WOR is resolve_trior MVL ; -- WIRED OR subtype TRIOR is resolve_trior MVL ; subtype WAND is resolve_triand MVL ; -- WIRED AND subtype TRIAND is resolve_triand MVL ; subtype TRI1 is resolve_tri1 MVL ; -- PULLUP subtype TRI0 is resolve_tri0 MVL ; -- PULLDOWN subtype SUPPLY0 is resolve_supply0 MVL ; -- SUPPLY 0 subtype SUPPLY1 is resolve_supply1 MVL ; -- SUPPLY 1 -- Declarations for vectors of Verilog net types subtype WIRE_VECTOR is RESOLVE_TRI_VECTOR MVL_VECTOR ; subtype TRI_VECTOR is RESOLVE_TRI_VECTOR MVL_VECTOR; subtype WOR_VECTOR is RESOLVE_TRIOR_VECTOR MVL_VECTOR; subtype TRIOR_VECTOR is RESOLVE_TRIOR_VECTOR MVL_VECTOR; subtype WAND_VECTOR is RESOLVE_TRIAND_VECTOR MVL_VECTOR; subtype TRIAND_VECTOR is RESOLVE_TRIAND_VECTOR MVL_VECTOR; subtype TRI0_VECTOR is RESOLVE_TRI0_VECTOR MVL_VECTOR; subtype TRI1_VECTOR is RESOLVE_TRI1_VECTOR MVL_VECTOR; subtype SUPPLY0_VECTOR is RESOLVE_SUPPLY0_VECTOR MVL_VECTOR; subtype SUPPLY1_VECTOR is RESOLVE_SUPPLY1_VECTOR MVL_VECTOR; end VERILOG_STD; --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-- --!! !!-- --!! V E R I L O G _ S T D (B O D Y) V 1 . 0 !!-- --!! !!-- --!! The following is the package body for verilog_std. It defines the !!-- --!! the bodies for the subprograms defined in the specification as !!-- --!! well as types that are used internally to the body. !!-- --!! !!-- --!! This program is the Confidential and Proprietary product of !!-- --!! Gateway Design Automation Corporation. Any unauthorized use, !!-- --!! reproduction, or transfer of this Program is strictly prohibited. !!-- --!! Copyright (c) 1989 by Gateway Design Automation Corporation. !!-- --!! All Rights Reserved. !!-- --!! !!-- --!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-- use STD.TEXTIO.all; package body VERILOG_STD is --############################################################################-- -- -- The following are the types and constants that are needed internally to -- the package body. -- --############################################################################-- -- Type declarations defining various tables type MVL_TABLE3 is array (BIT, BIT, BIT) of MVL; type BIT_TABLE3 is array (BIT, BIT, BIT) of BIT; type MVL_TABLE8 is array (BIT, BIT, BIT, BIT, BIT, BIT, BIT, BIT) of MVL; type MVL_X_TABLE2 is array (MVL_L, MVL_L) of MVL; type STR_TABLE is array (MVL) of STRENGTH; type MVL_TO_MVL_TABLE is array (MVL) of MVL; type MVL_TO_BIT_TABLE is array (MVL) of BIT; type BIT_TO_MVL_TABLE is array (BIT) of MVL; -- Limits of the enumerated type positions, for the logic values of -- '0', '1', 'X', 'L', 'H', and 'Z' constant LIMIT_XZ01 : INTEGER := 3; -- pos limit of XZ01 value constant LIMIT_0 : INTEGER := LIMIT_XZ01 + 29; -- pos limit of '0' value constant LIMIT_1 : INTEGER := LIMIT_0 + 29; -- pos limit of '1' value constant LIMIT_X : INTEGER := LIMIT_1 + 50; -- pos limit of 'X' value constant LIMIT_L : INTEGER := LIMIT_X + 7; -- pos limit of 'L' value constant LIMIT_H : INTEGER := LIMIT_L + 7; -- pos limit of 'H' value constant LIMIT_Z : INTEGER := LIMIT_H + 3; -- pos limit of 'Z' value constant OFFSET_ASSIGN : INTEGER := 1; constant OFFSET_FORCE : INTEGER := 2; -- Maximum number of elements in the MVL type constant MAX_MVL : INTEGER := 129; -- These constants are used as MASKS by the resolution functions. constant MASK_0 : STRENGTH := "00000000"; constant MASK_1 : STRENGTH := "11111111"; constant MASK_CC: STRENGTH := "11111110"; -------------------------------------------------------------------------------- -- FUNCTION : -- FILL_BIT_VECTOR (VALUE: BIT; SIZE: INTEGER) return BIT_VECTOR -- INPUT : the value to be filled, and the size of vector required -- OUTPUT : A bit vector of the indicated size with the indicated value. -- -- This function creates a BIT vector of length SIZE and fills it with -- the VALUE. -- *NOTE: This function is used internal to the package. function fill_bit_vector (value: BIT; size: INTEGER) return BIT_VECTOR is variable mask: BIT_VECTOR(size-1 downto 0); begin mask := (size-1 downto 0 => value); return (mask); end fill_bit_vector; --############################################################################-- -- -- -- BODIES FOR ARITHMETIC OPERATORS -- -- -- --############################################################################-- -------------------------------------------------------------------------------- -- FUNCTION : -- "+" (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The sum of the two parameters. -- -- This function adds the two parameters and returns a MVL vector -- It uses table lookup to get sum and carry. function "+" (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable carry_bit: BIT := '0'; variable has_no_X: BOOLEAN := TRUE; variable LOOP_CNT : INTEGER := 0; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); LOOP_CNT := I; end loop; result (loop_cnt+1) := BIT_TO_MVL(carry_bit); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "+"; -------------------------------------------------------------------------------- -- FUNCTION : -- "+" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The sum of the two parameters. -- -- This function adds the two parameters and returns a MVL vector -- It uses table lookup to get sum and carry. function "+" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'length; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable carry_bit: BIT := '0'; variable has_no_X: BOOLEAN := TRUE; variable LOOP_CNT : INTEGER := 0; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); LOOP_CNT := I; end loop; result (loop_cnt+1) := BIT_TO_MVL(carry_bit); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "+"; -------------------------------------------------------------------------------- -- FUNCTION : -- "+" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The sum of the two parameters. -- -- This function adds the two parameters and returns a MVL vector -- It uses table lookup to get sum and carry. function "+" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable carry_bit: BIT := '0'; variable has_no_X: BOOLEAN := TRUE; variable LOOP_CNT : INTEGER := 0; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); LOOP_CNT := I; end loop; result (loop_cnt+1) := BIT_TO_MVL(carry_bit); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "+"; -------------------------------------------------------------------------------- -- FUNCTION : -- "+" (op1, op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The sum of the two parameters. -- -- This function adds the two parameters and returns a MVL vector -- It uses table lookup to get sum and carry. function "+" (op1, op2 : MVL) return MVL_VECTOR is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if strong_op1 /= strong_op2 then return ("01"); elsif strong_op2 = '1' and strong_op1 = '1' then return ("10"); elsif strong_op1 = '0' and strong_op2 = '0' then return ("00"); end if; else return ("XX"); end if; end "+"; --------------------------- -- Subtraction Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- "-" (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The difference of the two parameters. -- -- This function subtracts op2 from op1 and returns a MVL vector. -- It uses TWO's COMPLEMENT addition for subtraction and uses table lookup -- to get sum and carry. function "-" (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable has_no_X: BOOLEAN := TRUE; variable carry_bit: BIT := '1'; -- initialized to '1' to make 1's -- complement of oper2 as 2's complement variable LOOP_CNT : INTEGER := 0; -- Loop iteration counter begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands oper2 := not oper2; -- 1's complement of oper2 if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); loop_cnt := I; end loop; result (loop_cnt + 1) := SUM(carry_bit,'1','0'); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "-"; -------------------------------------------------------------------------------- -- FUNCTION : -- "-" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The difference of the two parameters. -- -- This function subtracts op2 from op1 and returns a MVL vector. -- It uses TWO's COMPLEMENT addition for subtraction and uses table lookup -- to get sum and carry. function "-" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable has_no_X: BOOLEAN := TRUE; variable carry_bit: BIT := '1'; -- initialized to '1' to make 1's -- complement of oper2 as 2's complement variable LOOP_CNT : INTEGER := 0; -- Loop iteration counter begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands oper2 := not oper2; -- 1's complement of oper2 if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); loop_cnt := I; end loop; result (loop_cnt + 1) := SUM(carry_bit,'1','0'); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "-"; -------------------------------------------------------------------------------- -- FUNCTION : -- "-" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The difference of the two parameters. -- -- This function subtracts op2 from op1 and returns a MVL vector. -- It uses TWO's COMPLEMENT addition for subtraction and uses table lookup -- to get sum and carry. function "-" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size(size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- size of result is size_op + 1 variable has_no_X: BOOLEAN := TRUE; variable carry_bit: BIT := '1'; -- initialized to '1' to make 1's -- complement of oper2 as 2's complement variable LOOP_CNT : INTEGER := 0; -- Loop iteration counter begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands oper2 := not oper2; -- 1's complement of oper2 if (has_no_X) then -- operands do not have 'X' for I in 0 to (size_op-1) loop -- do table lookup for SUM/CARRY result(I) := SUM(oper1(I), oper2(I), carry_bit); carry_bit := CARRY(oper1(I), oper2(I), carry_bit); loop_cnt := I; end loop; result (loop_cnt + 1) := SUM(carry_bit,'1','0'); -- final carry else result (size_op downto 0) := fill_mvl_vector('X', size_op+1); -- result is a vector end if; -- of X values end if; return (result); end "-"; -------------------------------------------------------------------------------- -- FUNCTION : -- "-" (op1, op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The difference of the two parameters. -- -- This function subtracts op2 from op1 and returns a MVL vector. -- It uses TWO's COMPLEMENT addition for subtraction and uses table lookup -- to get sum and carry. function "-" (op1, op2 : MVL) return MVL_VECTOR is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if strong_op1 = strong_op2 then return ("00"); elsif strong_op1 = '1' then return ("01"); elsif strong_op2 = '1' then return ("11"); end if; else return ("XX"); end if; end "-"; ----------------------------- -- Multiplication Operator -- -------------------------------------------------------------------------------- -- FUNCTION : -- "*" (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The product of the two parameters. -- -- This function multiplies the two parameters and returns a MVL vector -- It converts the parameters to integers and then multiplies. function "*" (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; variable multiplicand, multiplier : INTEGER; variable result : MVL_VECTOR (size1 + size2 -1 downto 0):= fill_mvl_vector('X', size1+size2); -- size of result is size1 + size2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, multiplicand, has_no_X);-- get the integer values if has_no_x then conv_mvlv_to_int (op2, multiplier, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' -- initialize result to '0's result (size1 + size2 -1 downto 0) := fill_mvl_vector('0', size1+size2); if (multiplier /= 0) then conv_int_to_mvlv((multiplicand * multiplier), result); else conv_int_to_mvlv ((0),result); end if; else result(size1+size2-1 downto 0) := fill_mvl_vector('X', size1+size2); -- result is a vector end if; -- of X values end if; return (result); end "*"; -------------------------------------------------------------------------------- -- FUNCTION : -- "*" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The product of the two parameters. -- -- This function multiplies the two parameters and returns a MVL vector -- It converts the parameters to integers and then multiplies. function "*" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; variable multiplicand, multiplier : INTEGER; variable result : MVL_VECTOR (size1 + size2 -1 downto 0):= fill_mvl_vector('X', size1+size2); -- size of result is size1 + size2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_int (op1, multiplicand, has_no_X); -- get the integer values if has_no_x then conv_mvlv_to_int (op2, multiplier, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' -- initialize result to '0's result (size1 + size2 -1 downto 0) := fill_mvl_vector('0', size1+size2); if (multiplier /= 0) then conv_int_to_mvlv((multiplicand * multiplier), result); else conv_int_to_mvlv ((0),result); end if; else result(size1+size2-1 downto 0) := fill_mvl_vector('X', size1+size2); -- result is a vector end if; -- of X values end if; return (result); end "*"; -------------------------------------------------------------------------------- -- FUNCTION : -- "*" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The product of the two parameters. -- -- This function multiplies the two parameters and returns a MVL vector -- It converts the parameters to integers and then multiplies. function "*" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; variable multiplicand, multiplier : INTEGER; variable result : MVL_VECTOR (size1 + size2 -1 downto 0):= fill_mvl_vector('X', size1+size2); -- size of result is size1 + size2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, multiplicand, has_no_X); --get the integer values if has_no_x then conv_mvl_to_int (op2, multiplier, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' -- initialize result to '0's result (size1 + size2 -1 downto 0) := fill_mvl_vector('0', size1+size2); if (multiplier /= 0) then conv_int_to_mvlv((multiplicand * multiplier), result); else conv_int_to_mvlv ((0),result); end if; else result(size1+size2-1 downto 0) := fill_mvl_vector('X', size1+size2); -- result is a vector end if; -- of X values end if; return (result); end "*"; ------------------------------------------------------------------------------- -- FUNCTION : -- "*" (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : The product of the two parameters. -- -- This function multiplies op2 by op1 and returns a MVL value. function "*" (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if strong_op1 = '0' or strong_op2 = '0' then return('0'); else return('1'); end if; else return ('X'); end if; end "*"; ------------------------ -- Division Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- "/" (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The quotient of the two parameters. -- -- This function divides op1 by op2 and returns a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "/" (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size1-1 downto 0):= fill_mvl_vector('X', size1); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvlv_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size1-1 downto 0) := fill_mvl_vector('0', size1); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend/divisor), result); else result(size1-1 downto 0) := fill_mvl_vector('X', size1); end if; else result(size1-1 downto 0) := fill_mvl_vector('X', size1); -- result is a vector end if; -- of X values end if; return (result); end "/"; -------------------------------------------------------------------------------- -- FUNCTION : -- "/" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The quotient of the two parameters. -- -- This function divides op1 by op2 and returns a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "/" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'length; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size2-1 downto 0):= fill_mvl_vector('X', size2); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvlv_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size2-1 downto 0) := fill_mvl_vector('0', size2); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend/divisor), result); else result(size2-1 downto 0) := fill_mvl_vector('X', size2); end if; else result(size2-1 downto 0) := fill_mvl_vector('X', size2); -- result is a vector end if; -- of X values end if; return (result); end "/"; -------------------------------------------------------------------------------- -- FUNCTION : -- "/" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The quotient of the two parameters. -- -- This function divides op1 by op2 and returns a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "/" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size1-1 downto 0):= fill_mvl_vector('X', size1); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvl_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size1-1 downto 0) := fill_mvl_vector('0', size1); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend/divisor), result); else result(size1-1 downto 0) := fill_mvl_vector('X', size1); end if; else result(size1-1 downto 0) := fill_mvl_vector('X', size1); -- result is a vector end if; -- of X values end if; return (result); end "/"; -------------------------------------------------------------------------------- -- FUNCTION : -- "/" (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : The quotient of the two parameters. -- -- This function divides op1 by op2 and returns a MVL value. function "/" (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if strong_op1 = '0' and strong_op2 /= '0' then return('0'); elsif strong_op2 = '0' then return ('X'); else return('1'); end if; else return ('X'); end if; end "/"; ------------------- -- Mod Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- "mod" (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The modulus of the two parameters. -- -- This function returns the modulus (op1 % op2), as a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "mod" (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size2-1 downto 0):= fill_mvl_vector('X', size2); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvlv_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size2-1 downto 0) := fill_mvl_vector('0', size2); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend mod divisor), result); else result(size2-1 downto 0) := fill_mvl_vector('X', size1); end if; else result(size2-1 downto 0) := fill_mvl_vector('X', size2); -- result is a vector end if; -- of X values end if; return (result); end "mod"; -------------------------------------------------------------------------------- -- FUNCTION : -- "mod" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The modulus of the two parameters. -- -- This function returns the modulus (op1 % op2), as a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "mod" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size2-1 downto 0):= fill_mvl_vector('X', size2); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvlv_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size2-1 downto 0) := fill_mvl_vector('0', size2); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend mod divisor), result); else result(size2-1 downto 0) := fill_mvl_vector('X', size2); end if; else result(size2-1 downto 0) := fill_mvl_vector('X', size2); -- result is a vector end if; -- of X values end if; return (result); end "mod"; -------------------------------------------------------------------------------- -- FUNCTION : -- "mod" (op1 : MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : The modulus of the two parameters. -- -- This function returns the modulus (op1 % op2), as a MVL vector. -- RESTRICTION : op1 and op2 must be less than 2**32 function "mod" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; variable dividend, divisor : INTEGER; variable result : MVL_VECTOR (size1-1 downto 0):= fill_mvl_vector('X', size1); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_int (op1, dividend, has_no_X); -- get the integer values if has_no_x then conv_mvl_to_int (op2, divisor, has_no_X); -- of the operands if (has_no_X) then -- operands do not have 'X' result (size1-1 downto 0) := fill_mvl_vector('0', size1); -- initialize result to '0's if (divisor /= 0) then conv_int_to_mvlv((dividend mod divisor), result); else result(size1-1 downto 0) := fill_mvl_vector('X', size1); end if; else result(size1-1 downto 0) := fill_mvl_vector('X', size1); -- result is a vector end if; -- of X values end if; return (result); end "mod"; ------------------------------------------------------------------------------- -- FUNCTION : -- "mod" (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : The modulus of the two parameters. -- -- This function returns the modulus (op1 % op2), as a MVL. function "mod" (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if strong_op2 = '0' then return('X'); elsif strong_op2 = op1 then return('0'); else return('1'); end if; else return ('X'); end if; end "mod"; -------------------------------------------------------------------------------- -- FUNCTION : -- minus (op1: MVL) return MVL_VECTOR -- INPUT : an MVL value -- OUTPUT : a 32 bit mvl_vector which is the two's compliment of op1 -- -- This function returns the twos compliment of the input parameter in -- a 32 bit MVL_VECTOR function minus (op1: MVL) return MVL_VECTOR is variable op1_32 : MVL_VECTOR (31 downto 0); begin op1_32 := align_size(op1,32); return (minus(op1_32)); end minus; -------------------------------------------------------------------------------- -- FUNCTION : -- minus (op1: MVL_VECTOR) return MVL_VECTOR -- INPUT : an MVL_VECTOR -- OUTPUT : a 32 bit mvl_vector which is the two's compliment of op1 -- -- This function returns the twos compliment of the input parameter in -- a 32 bit MVL_VECTOR function minus (op1: MVL_VECTOR) return MVL_VECTOR is variable oper1 : BIT_VECTOR (31 downto 0); variable result : MVL_VECTOR (31 downto 0); variable has_no_x : BOOLEAN := TRUE; variable carry_bit : BIT := '1'; variable LOOP_CNT : INTEGER := 0; begin assert op1'LENGTH <= 32 report "ERROR: Overflow has occured during execution of the minus function." severity WARNING; conv_mvlv_to_bitv (op1, oper1, has_no_x); if (has_no_X) then -- operands do not have 'X' oper1 := not oper1; for I in oper1'reverse_range loop result(I) := SUM(oper1(I), '0', carry_bit); carry_bit := CARRY(oper1(I), '0', carry_bit); LOOP_CNT := I; end loop; else result := fill_mvl_vector('X', 32); -- result is a vector end if; -- of X values return (result); end minus; --############################################################################-- -- -- -- RELATIONAL OPERATORS -- -- -- --############################################################################-- ---------------------------- -- Greater-Than Functions -- -------------------------------------------------------------------------------- -- FUNCTION : -- ">" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 > op2 -- FALSE if op1 <= op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function ">" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 > oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end ">"; -------------------------------------------------------------------------------- -- FUNCTION : -- ">" (op1 : MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 > op2 -- FALSE if op1 <= op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function ">" (op1 : MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 > oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end ">"; -------------------------------------------------------------------------------- -- FUNCTION : -- gt (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 > op2 -- '0' if op1 <= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gt (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 > oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gt; -------------------------------------------------------------------------------- -- FUNCTION : -- gt (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 > op2 -- '0' if op1 <= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gt (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 > oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gt; -------------------------------------------------------------------------------- -- FUNCTION : -- GT (op1 : MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 > op2 -- '0' if op1 <= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gt (op1 : MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 > oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gt; -------------------------------------------------------------------------------- -- FUNCTION : -- GT (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL bits and returns -- '1' if op1 > op2 -- '0' if op1 <= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gt (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (CONV_MVL_TO_BIT(strong_op1) > CONV_MVL_TO_BIT(strong_op2)) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; end gt; -------------------------------------- -- Greater Than or Equals Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- ">=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 >= op2 -- FALSE if op1 < op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function ">=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 >= oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end ">="; -------------------------------------------------------------------------------- -- FUNCTION : -- ">=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 >= op2 -- FALSE if op1 < op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function ">=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 >= oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end ">="; -------------------------------------------------------------------------------- -- FUNCTION : -- gte (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 >= op2 -- '0' if op1 < op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gte (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 >= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gte; -------------------------------------------------------------------------------- -- FUNCTION : -- gte (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 >= op2 -- '0' if op1 < op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gte (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 >= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gte; -------------------------------------------------------------------------------- -- FUNCTION : -- gte (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 >= op2 -- '0' if op1 < op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gte (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 >= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end gte; -------------------------------------------------------------------------------- -- FUNCTION : -- GTE (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL bits and returns -- '1' if op1 >= op2 -- '0' if op1 < op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function gte (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (CONV_MVL_TO_BIT(strong_op1) >= CONV_MVL_TO_BIT(strong_op2)) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; end gte; --------------- -- Less Than -- -------------------------------------------------------------------------------- -- FUNCTION : -- "<" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 < op2 -- FALSE if op1 >= op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function "<" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 < oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end "<"; -------------------------------------------------------------------------------- -- FUNCTION : -- "<" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 < op2 -- FALSE if op1 >= op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function "<" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 < oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end "<"; -------------------------------------------------------------------------------- -- FUNCTION : -- lt (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 < op2 -- '0' if op1 >= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lt (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 < oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end lt; ------------------------------------------------------------------------------- -- FUNCTION : -- LT (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 < op2 -- '0' if op1 >= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function LT (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 < oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end LT; -------------------------------------------------------------------------------- -- FUNCTION : -- LT (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 < op2 -- '0' if op1 >= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function LT (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_x then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 < oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end LT; -------------------------------------------------------------------------------- -- FUNCTION : -- lt (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL bits and returns -- '1' if op1 < op2 -- '0' if op1 >= op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lt (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (CONV_MVL_TO_BIT(strong_op1) < CONV_MVL_TO_BIT(strong_op2)) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; end lt; ------------------------- -- Less Than or Equals -- -------------------------------------------------------------------------------- -- FUNCTION : -- "<=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 <= op2 -- FALSE if op1 > op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function "<=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 <= oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end "<="; -------------------------------------------------------------------------------- -- FUNCTION : -- "<=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- TRUE if op1 <= op2 -- FALSE if op1 > op2 -- FALSE if either op1 or op2 has an 'X' as any of its elements function "<=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 <= oper2) then -- operands do not have 'X' return (TRUE); else return (FALSE); end if; else return (FALSE); -- operands have 'X' end if; else return (FALSE); end if; end "<="; -------------------------------------------------------------------------------- -- FUNCTION : -- lte (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 <= op2 -- '0' if op1 > op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lte (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 <= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end lte; -------------------------------------------------------------------------------- -- FUNCTION : -- lte (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 <= op2 -- '0' if op1 > op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lte (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvlv_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 <= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end lte; -------------------------------------------------------------------------------- -- FUNCTION : -- LTE (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns -- '1' if op1 <= op2 -- '0' if op1 > op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lte (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : BIT_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_bitv (op1, oper1, has_no_X); -- get the 0, 1, or X values if has_no_X then conv_mvl_to_bitv (op2, oper2, has_no_X); -- of the operands if (has_no_X) then if (oper1 <= oper2) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; else return ('X'); end if; end lte; -------------------------------------------------------------------------------- -- FUNCTION : -- lte (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL bits and returns -- '1' if op1 <= op2 -- '0' if op1 > op2 -- 'X' if either op1 or op2 has an 'X' as any of its elements function lte (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (CONV_MVL_TO_BIT(strong_op1) <= CONV_MVL_TO_BIT(strong_op2)) then -- operands do not have 'X' return ('1'); else return ('0'); end if; else return ('X'); -- operands have 'X' end if; end lte; --------------------- -- Equals Operator -- -------------------------------------------------------------------------------- -- FUNCTION : -- "=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : TRUE if op1 = op2 -- FALSE if not equal or ambiguous -- function "=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return (TRUE); else return (FALSE); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return (FALSE); end if; end loop; end if; return (FALSE); end "="; -------------------------------------------------------------------------------- -- FUNCTION : -- "=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : TRUE if op1 = op2 -- FALSE if op1 /= op2 or is ambiguous -- function "=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return (TRUE); else return (FALSE); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return (FALSE); end if; end loop; end if; return (FALSE); end "="; -------------------------------------------------------------------------------- -- FUNCTION : -- eq (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL equality), and -- returns a '1' if they are equal, a '0' if they are not equal, and a -- 'X' if it is ambiguous. function eq (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('1'); else return ('0'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('0'); end if; end loop; end if; return ('X'); end eq; -------------------------------------------------------------------------------- -- FUNCTION : -- eq (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL equality), and -- returns a '1' if they are equal, a '0' if they are not equal, and a -- 'X' if it is ambiguous. function eq (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('1'); else return ('0'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('0'); end if; end loop; end if; return ('X'); end eq; -------------------------------------------------------------------------------- -- FUNCTION : -- eq (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL equality), and -- returns a '1' if they are equal, a '0' if they are not equal, and a -- 'X' if it is ambiguous. function eq (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('1'); else return ('0'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('0'); end if; end loop; end if; return ('X'); end eq; -------------------------------------------------------------------------------- -- FUNCTION : -- eq (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands for (LOGICAL equality), and -- returns a '1' if they are equal, a '0' if they are not equal, and a -- 'X' if it is ambiguous. function eq (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = strong_op2) then return ('1'); else return ('0'); end if; else return ('X'); end if; end eq; ------------------------- -- Not Equals Operator -- -------------------------------------------------------------------------------- -- FUNCTION : -- "/=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : TRUE if op1 /= op2 -- FALSE if op1 = op2 or is ambiguous function "/=" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return (FALSE); else return (TRUE); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return (TRUE); end if; end loop; end if; return (FALSE); end "/="; -------------------------------------------------------------------------------- -- FUNCTION : -- "/=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : TRUE if op1 /= op2 -- FALSE if op1 = op2 or is ambiguous function "/=" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return (FALSE); else return (TRUE); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return (TRUE); end if; end loop; end if; return (FALSE); end "/="; -------------------------------------------------------------------------------- -- FUNCTION : -- neq (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL inequality), -- and returns a '0' if they are equal, a '1' if they are not equal, and -- a 'X' if it is ambiguous. function neq (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('0'); else return ('1'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('1'); end if; end loop; end if; return ('X'); end neq; -------------------------------------------------------------------------------- -- FUNCTION : -- neq (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL inequality), -- and returns a '0' if they are equal, a '1' if they are not equal, and -- a 'X' if it is ambiguous. function neq (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('0'); else return ('1'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('1'); end if; end loop; end if; return ('X'); end neq; -------------------------------------------------------------------------------- -- FUNCTION : -- neq (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands bit-by-bit for (LOGICAL inequality), -- and returns a '0' if they are equal, a '1' if they are not equal, and -- a 'X' if it is ambiguous. function neq (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if has_no_X then if (oper1 = oper2) then return ('0'); else return ('1'); end if; else for I in 0 to size_op-1 loop if ((oper1(I) /= oper2(I)) and (oper1(I) /= 'X') and (oper2(I) /= 'X')) then return ('1'); end if; end loop; end if; return ('X'); end neq; -------------------------------------------------------------------------------- -- FUNCTION : -- neq (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : '0' or '1' or 'X' of type MVL -- -- This function compares the operands for (LOGICAL inequality), -- and returns a '0' if they are equal, a '1' if they are not equal, and -- a 'X' if it is ambiguous. function neq (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = strong_op2) then return ('0'); else return ('1'); end if; else return ('X'); end if; end neq; --############################################################################-- -- -- -- LOGICAL OPERATORS -- -- -- --############################################################################-- --------------------------- -- Logical NOT Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- log_not (op : MVL_VECTOR) return MVL -- INPUT : op of type MVL_VECTOR -- -- This function computes the logical 'negation' of the value of op and it -- returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_not (op1 : MVL_VECTOR) return MVL is variable op_val: MVL; begin op_val := red_or(op1); case op_val is when '0' => return ('1'); when '1' => return ('0'); when others => return ('X'); end case; end log_not; -------------------------------------------------------------------------------- -- FUNCTION : -- log_not (op : MVL) return MVL -- INPUT : op of type MVL -- -- This function computes the logical 'negation' of the value of op and it -- returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_not (op1 : MVL) return MVL is variable strong_op1 : MVL; begin strong_op1 := GET_01X_VAL(op1); case strong_op1 is when '0' => return ('1'); when '1' => return ('0'); when others => return ('X'); end case; end log_not; -------------------------------------------------------------------------------- -- FUNCTION : -- "not" (op : MVL_VECTOR) return BOOLEAN -- INPUT : op of type MVL_VECTOR -- -- This function computes the logical 'negation' of the value of op and it -- returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "not" (op1 : MVL_VECTOR) return BOOLEAN is variable op_val: MVL; begin op_val := red_or(op1); case op_val is when '0' => return (TRUE); when '1' => return (FALSE); when others => return (FALSE); end case; end "not"; -------------------------------------------------------------------------------- -- FUNCTION : -- "not" (op : MVL) return BOOLEAN -- INPUT : op of type MVL -- -- This function computes the logical 'negation' of the value of op and it -- returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "not" (op1 : MVL) return BOOLEAN is variable strong_op1 : MVL; begin strong_op1 := GET_01X_VAL(op1); case strong_op1 is when '0' => return (TRUE); when '1' => return (FALSE); when others => return (FALSE); end case; end "not"; -------------------------- -- Logical AND Operator -- -------------------------------------------------------------------------------- -- FUNCTION : -- log_and (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_and (op1, op2 : MVL_VECTOR) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return ('1'); elsif (op1_val = '0' or op2_val = '0') then return ('0'); else return ('X'); end if; end log_and; -------------------------------------------------------------------------------- -- FUNCTION : -- log_and (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_and (op1: MVL; op2 : MVL_VECTOR) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return ('1'); elsif (op1_val = '0' or op2_val = '0') then return ('0'); else return ('X'); end if; end log_and; -------------------------------------------------------------------------------- -- FUNCTION : -- log_and (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_and (op1: MVL_VECTOR; op2 : MVL) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return ('1'); elsif (op1_val = '0' or op2_val = '0') then return ('0'); else return ('X'); end if; end log_and; -------------------------------------------------------------------------------- -- FUNCTION : -- log_and (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL's and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X' function log_and (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = '1' and strong_op2 = '1') then return ('1'); else return ('0'); end if; else if strong_op1 = '0' or strong_op2 = '0' then return ('0'); else return ('X'); end if; end if; end log_and; -------------------------------------------------------------------------------- -- FUNCTION : -- "and" (op1, op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "and" (op1, op2 : MVL_VECTOR) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return (TRUE); elsif (op1_val = '0' or op2_val = '0') then return (FALSE); else return (FALSE); end if; end "and"; -------------------------------------------------------------------------------- -- FUNCTION : -- "and" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "and" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return (TRUE); elsif (op1_val = '0' or op2_val = '0') then return (FALSE); else return (FALSE); end if; end "and"; -------------------------------------------------------------------------------- -- FUNCTION : -- "and" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "and" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' and op2_val = '1') then return (TRUE); elsif (op1_val = '0' or op2_val = '0') then return (FALSE); else return (FALSE); end if; end "and"; -------------------------------------------------------------------------------- -- FUNCTION : -- "and" (op1, op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL's and returns the logical 'and' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "and" (op1, op2 : MVL) return BOOLEAN is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = '1' and strong_op2 = '1') then return (TRUE); else return (FALSE); end if; else if strong_op1 = '0' or strong_op2 = '0' then return (FALSE); else return (FALSE); end if; end if; end "and"; ------------------------- -- Logical OR Operator -- -------------------------------------------------------------------------------- -- FUNCTION : -- log_or (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X' function log_or (op1, op2 : MVL_VECTOR) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return ('1'); elsif (op1_val = '0' and op2_val = '0') then return ('0'); else return ('X'); end if; end log_or; -------------------------------------------------------------------------------- -- FUNCTION : -- log_or (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X' function log_or (op1: MVL; op2 : MVL_VECTOR) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return ('1'); elsif (op1_val = '0' and op2_val = '0') then return ('0'); else return ('X'); end if; end log_or; -------------------------------------------------------------------------------- -- FUNCTION : -- log_or (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X' function log_or (op1: MVL_VECTOR; op2 : MVL) return MVL is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return ('1'); elsif (op1_val = '0' and op2_val = '0') then return ('0'); else return ('X'); end if; end log_or; -------------------------------------------------------------------------------- -- FUNCTION : -- log_or (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL values and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is 'X function log_or (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = '1' or strong_op2 = '1') then return ('1'); else return ('0'); end if; else if strong_op1 = '1' or strong_op2 = '1' then return ('1'); else return ('X'); end if; end if; end log_or; -------------------------------------------------------------------------------- -- FUNCTION : -- "or" (op1, op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "or" (op1, op2 : MVL_VECTOR) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return (TRUE); elsif (op1_val = '0' and op2_val = '0') then return (FALSE); else return (FALSE); end if; end "or"; -------------------------------------------------------------------------------- -- FUNCTION : -- "or" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "or" (op1: MVL; op2 : MVL_VECTOR) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return (TRUE); elsif (op1_val = '0' and op2_val = '0') then return (FALSE); else return (FALSE); end if; end "or"; -------------------------------------------------------------------------------- -- FUNCTION : -- "or" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function sees the two parameters and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "or" (op1: MVL_VECTOR; op2 : MVL) return BOOLEAN is variable op1_val, op2_val : MVL; variable result : BOOLEAN; begin op1_val := red_or(op1); -- see if op1 is TRUE op2_val := red_or(op2); -- see if op2 is TRUE if (op1_val = '1' or op2_val = '1') then return (TRUE); elsif (op1_val = '0' and op2_val = '0') then return (FALSE); else return (FALSE); end if; end "or"; -------------------------------------------------------------------------------- -- FUNCTION : -- "or" (op1, op2 : MVL) return BOOLEAN -- INPUT : op1 and op2 of type MVL -- -- This function sees the two MVL values and returns the logical 'or' -- value of op1 and op2. It returns either 0, 1 or X -- To compute the logical value of an operator: -- If value of operator = 0, it is FALSE -- If value of operator > 0, it is TRUE -- If value of operator = 'X' (may be 0 or > 0), it is FALSE function "or" (op1, op2 : MVL) return BOOLEAN is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if strong_op1 /= 'X' and strong_op2 /= 'X' then if (strong_op1 = '1' or strong_op2 = '1') then return (TRUE); else return (FALSE); end if; else if strong_op1 = '1' or strong_op2 = '1' then return (FALSE); else return (FALSE); end if; end if; end "or"; --############################################################################-- -- -- -- EQUALITY OPERATORS -- -- -- --############################################################################-- -------------------------------------------------------------------------------- -- FUNCTION : -- case_eq (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- -- OUTPUT : '0' or '1' of type MVL -- This function compares the operands bit-by-bit, and returns a '1', if -- they are equal, else it returns a '0' (CASE equality). function case_eq (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('1'); else return ('0'); end if; end case_eq; -------------------------------------------------------------------------------- -- FUNCTION : -- case_eq (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands bit-by-bit, and returns a '1', if -- they are equal, else it returns a '0' (CASE equality). function case_eq (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('1'); else return ('0'); end if; end case_eq; -------------------------------------------------------------------------------- -- FUNCTION : -- case_eq (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands bit-by-bit, and returns a '1', if -- they are equal, else it returns a '0' (CASE equality). function case_eq (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('1'); else return ('0'); end if; end case_eq; ------------------------------------------------------------------------------- -- FUNCTION : -- case_eq (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands and returns a '1', if -- they are equal, else it returns a '0' (CASE equality). function case_eq (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = strong_op2) then return ('1'); else return ('0'); end if; end case_eq; -------------------------------------------------------------------------------- -- FUNCTION : -- case_neq (op1, op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands bit-by-bit, and returns a '0', if -- they are equal, else it returns a '1' (CASE inequality). function case_neq (op1, op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('0'); else return ('1'); end if; end case_neq; -------------------------------------------------------------------------------- -- FUNCTION : -- case_neq (op1: MVL; op2 : MVL_VECTOR) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands bit-by-bit, and returns a '0', if -- they are equal, else it returns a '1' (CASE inequality). function case_neq (op1: MVL; op2 : MVL_VECTOR) return MVL is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('0'); else return ('1'); end if; end case_neq; -------------------------------------------------------------------------------- -- FUNCTION : -- case_neq (op1: MVL_VECTOR; op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL_VECTOR -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands bit-by-bit, and returns a '0', if -- they are equal, else it returns a '1' (CASE inequality). function case_neq (op1: MVL_VECTOR; op2 : MVL) return MVL is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands if (oper1 = oper2) then return ('0'); else return ('1'); end if; end case_neq; ------------------------------------------------------------------------------- -- FUNCTION : -- case_neq (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- OUTPUT : '0' or '1' of type MVL -- -- This function compares the operands and returns a '0', if -- they are equal, else it returns a '1' (CASE inequality). function case_neq (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = strong_op2) then return ('0'); else return ('1'); end if; end case_neq; --############################################################################-- -- -- -- BITWISE OPERATORS -- -- --############################################################################-- -------------------------------------------------------------------------------- -- FUNCTION : -- bit_neg (op1 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op of type MVL_VECTOR -- -- This function performs bit-wise 'negation' operation on each bit of op1 -- and returns a result of the same size. function bit_neg (op1 : MVL_VECTOR) return MVL_VECTOR is constant size_op: INTEGER := op1'LENGTH; variable oper, result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper, has_no_X); -- get the 0, 1, or X values -- of the operand for I in 0 to (size_op-1) loop case oper(I) is when '0' => result(I) := '1'; when '1' => result(I) := '0'; when others => result(I) := 'X'; end case; end loop; return (result); end bit_neg; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_neg (op1 : MVL) return MVL -- INPUT : op of type MVL -- -- This function performs bit 'negation' operation on the bit op1 -- and returns a result function bit_neg (op1 : MVL) return MVL is variable strong_op1 : MVL; begin strong_op1 := GET_01X_VAL(op1); case strong_op1 is when '0' => return '1'; when '1' => return '0'; when others => return 'X'; end case; end bit_neg; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_and (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'and' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_and (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '0' or oper2(I) = '0') then result(I) := '0'; -- at least one bit is '0' elsif (oper1(I) = '1' and oper2(I) = '1') then result(I) := '1'; -- both bits are '1' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_and; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_and (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'and' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_and (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '0' or oper2(I) = '0') then result(I) := '0'; -- at least one bit is '0' elsif (oper1(I) = '1' and oper2(I) = '1') then result(I) := '1'; -- both bits are '1' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_and; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_and (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'and' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_and (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '0' or oper2(I) = '0') then result(I) := '0'; -- at least one bit is '0' elsif (oper1(I) = '1' and oper2(I) = '1') then result(I) := '1'; -- both bits are '1' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_and; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_and (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function performs an 'and' operation on the bit op1 and -- op2 and returns a result 0, 1, or X. function bit_and (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = '0' or strong_op2 = '0') then return '0'; -- at least one bit is '0' elsif (strong_op1 = '1' and strong_op2 = '1') then return '1'; -- both bits are '1' else return 'X'; -- at least one bit is 'X' end if; end bit_and; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_or (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'or' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_or (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '1' or oper2(I) = '1') then result(I) := '1'; -- at least one bit is '1' elsif (oper1(I) = '0' and oper2(I) = '0') then result(I) := '0'; -- both bits are '0' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_or; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_or (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'or' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_or (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '1' or oper2(I) = '1') then result(I) := '1'; -- at least one bit is '1' elsif (oper1(I) = '0' and oper2(I) = '0') then result(I) := '0'; -- both bits are '0' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_or; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_or (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'or' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_or (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = '1' or oper2(I) = '1') then result(I) := '1'; -- at least one bit is '1' elsif (oper1(I) = '0' and oper2(I) = '0') then result(I) := '0'; -- both bits are '0' else result(I) := 'X'; -- at least one bit is 'X' end if; end loop; return (result); end bit_or; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_or (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function performs bit-wise 'or' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_or (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = '1' or strong_op2 = '1') then return '1'; -- at least one bit is '1' elsif (strong_op1 = '0' and strong_op2 = '0') then return '0'; -- both bits are '0' else return 'X'; -- at least one bit is 'X' end if; end bit_or; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_xor (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'xor' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_xor (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '0'; -- both bits are same (0 or 1) else result(I) := '1'; -- only one bit is '1' end if; end loop; return (result); end bit_xor; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_xor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'xor' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_xor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '0'; -- both bits are same (0 or 1) else result(I) := '1'; -- only one bit is '1' end if; end loop; return (result); end bit_xor; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_xor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'xor' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_xor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '0'; -- both bits are same (0 or 1) else result(I) := '1'; -- only one bit is '1' end if; end loop; return (result); end bit_xor; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_xor (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function performs bit-wise 'xor' operation on each bit of op1 and -- op2 and returns a result of the same size containing 0, 1, or X. function bit_xor (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = 'X' or strong_op2 = 'X') then return 'X'; -- at least one bit is 'X' elsif (strong_op1 = strong_op2) then return '0'; -- both bits are same (0 or 1) else return '1'; -- only one bit is '1' end if; end bit_xor; -------------------------------------------------------------------------------- -- FUNCTION : -- bit_xnor (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'equivalence' operation on each bit of -- op1 and op2 and returns a result of the same size containing 0, 1, or X. function bit_xnor (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '1'; -- both bits are same (0 or 1) else result(I) := '0'; -- bits are '1' and '0' end if; end loop; return (result); end bit_xnor; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_xnor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'equivalence' operation on each bit of -- op1 and op2 and returns a result of the same size containing 0, 1, or X. function bit_xnor (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is constant size1: INTEGER := 1; constant size2: INTEGER := op2'LENGTH; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvl_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvlv_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '1'; -- both bits are same (0 or 1) else result(I) := '0'; -- bits are '1' and '0' end if; end loop; return (result); end bit_xnor; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_xnor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function performs bit-wise 'equivalence' operation on each bit of -- op1 and op2 and returns a result of the same size containing 0, 1, or X. function bit_xnor (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size1: INTEGER := op1'LENGTH; constant size2: INTEGER := 1; constant size_op: INTEGER := max_size (size1, size2); -- size_op is the width of the larger operand variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result : MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; begin conv_mvlv_to_logv (op1, oper1, has_no_X); -- get the 0, 1, or X values conv_mvl_to_logv (op2, oper2, has_no_X); -- of the operands for I in 0 to (size_op-1) loop if (oper1(I) = 'X' or oper2(I) = 'X') then result(I) := 'X'; -- at least one bit is 'X' elsif (oper1(I) = oper2(I)) then result(I) := '1'; -- both bits are same (0 or 1) else result(I) := '0'; -- bits are '1' and '0' end if; end loop; return (result); end bit_xnor; ------------------------------------------------------------------------------- -- FUNCTION : -- bit_xnor (op1, op2 : MVL) return MVL -- INPUT : op1 and op2 of type MVL -- -- This function performs bit-wise 'equivalence' operation on each bit of -- op1 and op2 and returns a result of the same size containing 0, 1, or X. function bit_xnor (op1, op2 : MVL) return MVL is variable strong_op1 : MVL; variable strong_op2 : MVL; begin strong_op1 := GET_01X_VAL(op1); strong_op2 := GET_01X_VAL(op2); if (strong_op1 = 'X' or strong_op2 = 'X') then return 'X'; -- at least one bit is 'X' elsif (strong_op1 = strong_op2) then return '1'; -- both bits are same (0 or 1) else return '0'; -- bits are '1' and '0' end if; end bit_xnor; --############################################################################-- -- -- -- REDUCTION OPERATORS -- -- -- --############################################################################-- ------------------------------------------------------------------------------- -- FUNCTION : -- red_and (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'and' operation on the op1 and returns -- a MVL bit 0, 1 or X. function red_and (op1: MVL_VECTOR) return MVL is variable result: MVL; variable has_no_X: BOOLEAN := TRUE; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when '0' => return ('0'); -- result is '0' when '1' => null; when 'X' => has_no_X := FALSE; -- value is 'X', set flag to FALSE -- else value is '1', do nothing when others => null; end case; end loop; -- op1 has no '0's if (has_no_X) then return ('1'); -- result is '1' else return ('X'); -- result is 'X' end if; end red_and; -------------------------------------------------------------------------------- -- FUNCTION : -- red_and (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'and' operation on the op1 and returns -- a MVL bit 0, 1 or X. function red_and (op1: MVL) return MVL is begin return (GET_01X_VAL(op1)); end red_and; ------------------------------------------------------------------------------- -- FUNCTION : -- red_nand (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'nand' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_nand (op1: MVL_VECTOR) return MVL is variable result: MVL; variable has_no_X: BOOLEAN := TRUE; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when '0' => return ('1'); -- result is '1' when '1' => null; when 'X' => has_no_X := FALSE; -- value is 'X', set flag to FALSE -- else value is '1', do nothing when others => null; end case; end loop; -- op1 has no '0's if (has_no_X) then return ('0'); -- result is '0' else return ('X'); -- result is 'X' end if; end red_nand; -------------------------------------------------------------------------------- -- FUNCTION : -- red_nand (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'nand' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_nand (op1: MVL) return MVL is begin case (GET_01X_VAL(op1)) is when '1' => return '0'; when '0' => return '1'; when others => return 'X'; end case; end red_nand; ------------------------------------------------------------------------------- -- FUNCTION : -- red_or (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'or' operation on the op1 and returns -- a MVL bit 0, 1 or X. function red_or (op1: MVL_VECTOR) return MVL is variable result: MVL; variable has_no_X: BOOLEAN := TRUE; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when '0' => null; when '1' => return ('1'); -- result is '1' when 'X' => has_no_X := FALSE; -- value is 'X', set flag to FALSE -- else value is '1', do nothing when others => null; end case; end loop; -- op1 has no '1's if (has_no_X) then return ('0'); -- result is '0' else return ('X'); -- result is 'X' end if; end red_or; -------------------------------------------------------------------------------- -- FUNCTION : -- red_or (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'or' operation on the op1 and returns -- a MVL bit 0, 1 or X. function red_or (op1: MVL) return MVL is begin return (GET_01X_VAL(op1)); end red_or; ------------------------------------------------------------------------------- -- FUNCTION : -- red_nor (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'nor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_nor (op1: MVL_VECTOR) return MVL is variable result: MVL; variable has_no_X: BOOLEAN := TRUE; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when '0' => null; when '1' => return ('0'); -- result is '0' when 'X' => has_no_X := FALSE; -- value is 'X', set flag to FALSE -- else value is '1', do nothing when others => null; end case; end loop; -- op1 has no '1's if (has_no_X) then return ('1'); -- result is '1' else return ('X'); -- result is 'X' end if; end red_nor; -------------------------------------------------------------------------------- -- FUNCTION : -- red_nor (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'nor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_nor (op1: MVL) return MVL is begin case (GET_01X_VAL(op1)) is when '1' => return '0'; when '0' => return '1'; when others => return 'X'; end case; end red_nor; ------------------------------------------------------------------------------- -- FUNCTION : -- red_xor (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'xor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_xor (op1: MVL_VECTOR) return MVL is variable bit_result: BIT := '0'; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when 'X' => return ('X'); -- value is 'X', result is 'X' when '1' => bit_result := bit_result xor '1'; when '0' => bit_result := bit_result xor '0'; when others => null; end case; end loop; if (bit_result = '0') then -- invert result return ('0'); else return ('1'); end if; end red_xor; -------------------------------------------------------------------------------- -- FUNCTION : -- red_xor (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'xor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_xor (op1: MVL) return MVL is begin return (GET_01X_VAL(op1)); end red_xor; ------------------------------------------------------------------------------- -- FUNCTION : -- red_xnor (op1 : MVL_VECTOR) return MVL -- INPUT : op1 of type MVL_VECTOR -- -- This function performs a reduction 'xnor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_xnor (op1: MVL_VECTOR) return MVL is variable bit_result : BIT := '0'; begin for I in op1'RANGE loop case (GET_01X_VAL(op1(I))) is when 'X' => return ('X'); -- value is 'X', result is 'X' when '1' => bit_result := bit_result xor '1'; when '0' => bit_result := bit_result xor '0'; when others => null; end case; end loop; if (bit_result = '0') then -- invert result return ('1'); else return ('0'); end if; end red_xnor; -------------------------------------------------------------------------------- -- FUNCTION : -- red_xnor (op1 : MVL) return MVL -- INPUT : op1 of type MVL -- -- This function performs a reduction 'xnor' operation on the op1 and -- returns a MVL bit 0, 1 or X. function red_xnor (op1: MVL) return MVL is begin case (GET_01X_VAL(op1)) is when '1' => return '0'; when '0' => return '1'; when others => return 'X'; end case; end red_xnor; --############################################################################-- -- -- -- SHIFT OPERATORS -- -- --############################################################################-- -------------------------- -- Shift Left Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- sh_left (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function left-shifts the op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_left (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size_op: INTEGER := op1'LENGTH; constant left : INTEGER := op1'LEFT; constant right : INTEGER := op1'RIGHT; variable result: MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvlv_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= size_op) then -- if more than size_op bits are return (fill_mvl_vector('0', size_op)); -- to be shifted, the end if; -- result is all 0's if (left >= right) then -- op1 is of descending range result(size_op-1 downto shift) := op1((left - shift) downto right); result(shift-1 downto 0) := fill_mvl_vector('0', shift); else -- op1 is of ascending range result(size_op-1 downto shift) := op1((left + shift) to right); result(shift-1 downto 0) := fill_mvl_vector('0', shift); end if; return result; else return (fill_mvl_vector('X', size_op)); -- result is a vector of end if; -- X values end sh_left; -------------------------------------------------------------------------------- -- FUNCTION : -- sh_left (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function left-shifts the op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_left (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is variable result: MVL_VECTOR (0 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvlv_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= 1) then -- if more than size_op bits are result(0) := '0'; -- to be shifted, the else -- result is all 0's result(0) := op1; end if; else result (0) := 'X'; -- result is a vector of end if; -- X values return result; end sh_left; -------------------------------------------------------------------------------- -- FUNCTION : -- sh_left (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function left-shifts the op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_left (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size_op: INTEGER := op1'LENGTH; constant left : INTEGER := op1'LEFT; constant right : INTEGER := op1'RIGHT; variable result: MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvl_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= size_op) then -- if more than size_op bits are return (fill_mvl_vector('0', size_op)); -- to be shifted, the end if; -- result is all 0's if (left >= right) then -- op1 is of descending range result(size_op-1 downto shift) := op1((left - shift) downto right); result(shift-1 downto 0) := fill_mvl_vector('0', shift); else -- op1 is of ascending range result(size_op-1 downto shift) := op1((left + shift) to right); result(shift-1 downto 0) := fill_mvl_vector('0', shift); end if; return result; else return (fill_mvl_vector('X', size_op)); -- result is a vector of end if; -- X values end sh_left; ------------------------------------------------------------------------------- -- FUNCTION : -- sh_left (op1, op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL -- -- This function left-shifts the op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_left (op1, op2 : MVL) return MVL_VECTOR is variable strong_op2 : MVL ; begin strong_op2 := GET_01X_VAL(op2); case (strong_op2) is when ('0') => return (ALIGN_SIZE(op1,1)); when ('1') => return ("0"); when others => return ("X"); end case; end sh_left; --------------------------- -- Shift Right Operators -- -------------------------------------------------------------------------------- -- FUNCTION : -- sh_right (op1, op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function right-shifts op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_right (op1, op2 : MVL_VECTOR) return MVL_VECTOR is constant size_op: INTEGER := op1'LENGTH; constant left : INTEGER := op1'LEFT; constant right : INTEGER := op1'RIGHT; variable result: MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvlv_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= size_op) then -- if more than size_op bits are return (fill_mvl_vector('0', size_op)); -- to be shifted, the end if; -- result is all 0's if (left >= right) then -- op1 is of descending range result((size_op-1 - shift) downto 0) := op1(left downto (right + shift)); result((size_op - 1) downto (size_op - shift)) := fill_mvl_vector('0', shift); else -- op1 is of ascending range result((size_op - 1 - shift) downto 0) := op1(left to (right - shift)); result((size_op - 1) downto (size_op - shift)) := fill_mvl_vector('0', shift); end if; return result; else return (fill_mvl_vector('X', size_op)); -- result is a vector of end if; -- X values end sh_right; -------------------------------------------------------------------------------- -- FUNCTION : -- sh_right (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function right-shifts op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_right (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is variable result: MVL_VECTOR (0 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvlv_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= 1) then -- if more than size_op bits are result(0) := '0'; -- to be shifted, the else -- result is all 0's result(0) := op1; end if; else result(0) := 'X'; -- result is a vector of end if; -- X values return (result); end sh_right; -------------------------------------------------------------------------------- -- FUNCTION : -- sh_right (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL_VECTOR -- -- This function right-shifts op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_right (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is constant size_op: INTEGER := op1'LENGTH; constant left : INTEGER := op1'LEFT; constant right : INTEGER := op1'RIGHT; variable result: MVL_VECTOR (size_op-1 downto 0); variable has_no_X: BOOLEAN := TRUE; variable shift: INTEGER := 0; begin conv_mvl_to_int (op2, shift, has_no_X); -- get the number of bits to -- be shifted if (has_no_X) then if (shift >= size_op) then -- if more than size_op bits are return (fill_mvl_vector('0', size_op)); -- to be shifted, the end if; -- result is all 0's if (left >= right) then -- op1 is of descending range result((size_op-1 - shift) downto 0) := op1(left downto (right + shift)); result((size_op - 1) downto (size_op - shift)) := fill_mvl_vector('0', shift); else -- op1 is of ascending range result((size_op - 1 - shift) downto 0) := op1(left to (right - shift)); result((size_op - 1) downto (size_op - shift)) := fill_mvl_vector('0', shift); end if; return result; else return (fill_mvl_vector('X', size_op)); -- result is a vector of end if; -- X values end sh_right; -------------------------------------------------------------------------------- -- FUNCTION : -- sh_right (op1, op2 : MVL) return MVL_VECTOR -- INPUT : op1 and op2 of type MVL -- -- This function right-shifts op1, by the number of bits specified by op2 -- and returns the shifted result (of the same size as op1). function sh_right (op1, op2 : MVL) return MVL_VECTOR is variable strong_op2 : MVL ; begin strong_op2 := GET_01X_VAL(op2); case (strong_op2) is when ('0') => return (ALIGN_SIZE(op1,1)); when ('1') => return ("0"); when others => return ("X"); end case; end sh_right; -------------------------------------------------------------------------------- -- FUNCTION : -- "&" (op1, op2 : MVL) return MVL_VECTOR -- INPUT : Two MVL bits. -- OUTPUT : A two bit mvl bit with the two inputs concatenated together. -- function "&" (op1, op2 : MVL) return MVL_VECTOR is variable temp_op1 : MVL_VECTOR(0 to 0) := to_mvlv(op1); variable temp_op2 : MVL_VECTOR(0 to 0) := to_mvlv(op2); begin return (temp_op1 & temp_op2); end "&" ; -------------------------------------------------------------------------------- -- FUNCTION : -- "&" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR -- INPUT : An mvl and an mvl vector -- OUTPUT : A mvl vector with the two inputs concatenated together. -- function "&" (op1: MVL; op2 : MVL_VECTOR) return MVL_VECTOR is variable temp_op1 : MVL_VECTOR(0 to 0) := to_mvlv(op1); begin return (temp_op1 & op2); end "&" ; -------------------------------------------------------------------------------- -- FUNCTION : -- "&" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR -- INPUT : An mvl and an mvl vector -- OUTPUT : A mvl vector with the two inputs concatenated together. -- function "&" (op1: MVL_VECTOR; op2 : MVL) return MVL_VECTOR is variable temp_op2 : MVL_VECTOR(0 to 0) := to_mvlv(op2); begin return (op1 & temp_op2); end "&"; --############################################################################-- -- -- -- CONDITIONAL OPERATOR -- -- -- --############################################################################-- ------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond, left_val, right_val: MVL_VECTOR) return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond, left_val, right_val: MVL_VECTOR) return MVL_VECTOR is constant size_left: INTEGER := LEFT_VAL'LENGTH; constant size_right : INTEGER := RIGHT_VAL'LENGTH; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvlv_to_logv(left_val, oper1, has_no_x); conv_mvlv_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => return (right_val); when '1' => return (left_val); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; -------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond: MVL ; left_val, right_val: MVL) return MVL -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond, left_val, right_val: MVL) return MVL is variable strong_cond : MVL; begin strong_cond := GET_01X_VAL(cond); case strong_cond is when '0' => return (right_val); when '1' => return (left_val); when others => if left_val = right_val then return (left_val); else return ('X'); end if; end case; end cond_op; -------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond, left_val: MVL; right_val: MVL_VECTOR) return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond, left_val: MVL; right_val: MVL_VECTOR) return MVL_VECTOR is constant size_left: INTEGER := 1; constant size_right : INTEGER := RIGHT_VAL'LENGTH; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvl_to_logv(left_val, oper1, has_no_x); conv_mvlv_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => return (right_val); when '1' => result(0) := left_val; return (result); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; -------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond: MVL; left_val, right_val: MVL_VECTOR) return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond: MVL; left_val, right_val: MVL_VECTOR) return MVL_VECTOR is constant size_left: INTEGER := 1; constant size_right : INTEGER := RIGHT_VAL'LENGTH; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvlv_to_logv(left_val, oper1, has_no_x); conv_mvlv_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => return (right_val); when '1' => return (left_val); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; -------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond: MVL; left_val: MVL_VECTOR; right_val: MVL) -- return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond: MVL; left_val: MVL_VECTOR; right_val: MVL) return MVL_VECTOR is constant size_left: INTEGER := LEFT_VAL'LENGTH; constant size_right : INTEGER := 1; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvlv_to_logv(left_val, oper1, has_no_x); conv_mvl_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => result(0) := right_val; return (result); when '1' => return (left_val); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; ------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond: MVL_VECTOR; left_val, right_val: MVL) return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond: MVL_VECTOR; left_val, right_val: MVL) return MVL_VECTOR is constant size_left: INTEGER := 1; constant size_right : INTEGER := 1; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvl_to_logv(left_val, oper1, has_no_x); conv_mvl_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => result(0) := right_val; return (result); when '1' => result(0) := left_val; return (result); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; ------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond: MVL_VECTOR; left_val: MVL; right_val: MVL_VECTOR) -- return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond: MVL_VECTOR; left_val: MVL; right_val: MVL_VECTOR) return MVL_VECTOR is constant size_left: INTEGER := 1; constant size_right : INTEGER := RIGHT_VAL'LENGTH; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvl_to_logv(left_val, oper1, has_no_x); conv_mvlv_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => return (right_val); when '1' => result (0) := left_val; return (result); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; ------------------------------------------------------------------------------- -- FUNCTION : -- cond_op (cond, left_val : MVL_VECTOR; right_val: MVL) return MVL_VECTOR -- -- This function behaves like the conditional operator. -- If 'cond' has a logical value of -- '1' then left_val is returned, else -- '0' then right_val is returned, else -- 'X' is returned. function cond_op(cond: MVL_VECTOR; left_val : MVL_VECTOR; right_val: MVL) return MVL_VECTOR is constant size_left: INTEGER := left_val'LENGTH; constant size_right : INTEGER := 1; constant size_op: INTEGER := max_size(SIZE_left, SIZE_right); variable oper1, oper2 : MVL_VECTOR (size_op-1 downto 0); -- alligned operands are to be kept in oper1 and oper2 variable result: MVL_VECTOR (size_op-1 downto 0) := fill_mvl_vector('0', size_op); variable op_val: MVL; variable has_no_X: BOOLEAN := TRUE; begin op_val := red_or (cond); conv_mvlv_to_logv(left_val, oper1, has_no_x); conv_mvl_to_logv(right_val, oper2, has_no_x); case op_val is when '0' => result(0) := right_val; return (result); when '1' => return (left_val); when others => for I in result'RANGE loop if oper1(i) = oper2(i) then result (i) := oper1(i); else result (i) := 'X'; end if; end loop; return result; end case; end cond_op; --############################################################################-- -- -- BODIES FOR UTILITY ROUTINES: -- --############################################################################-- -------------------------------------------------------------------------------- -- FUNCTION : -- SUM (B1, B2, B3 :BIT) return MVL -- -- Function to get the SUM of three bits function SUM (B1, B2, B3 :BIT) return MVL is constant SUM_TAB: MVL_TABLE3 := -- SUM A B CIN ( (('0', -- 0 0 0 '1'), -- 0 0 1 ('1', -- 0 1 0 '0')), -- 0 1 1 (('1', -- 1 0 0 '0'), -- 1 0 1 ('0', -- 1 1 0 '1')) -- 1 1 1 ); begin return(SUM_TAB(B1,B2,B3)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- CARRY (B1, B2, B3 :BIT) return BIT -- -- Function to get the CARRY generated from three bits function CARRY (B1, B2, B3 :BIT) return BIT is constant CARRY_TAB: BIT_TABLE3 := -- CARRY A B CIN ( (('0', -- 0 0 0 '0'), -- 0 0 1 ('0', -- 0 1 0 '1')), -- 0 1 1 (('0', -- 1 0 0 '1'), -- 1 0 1 ('1', -- 1 1 0 '1')) -- 1 1 1 ); begin return(CARRY_TAB(B1,B2,B3)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_0_STRENGTH (M1: MVL) return STRENGTH -- -- Function to get the 0-strength byte values from the enumerated type element function GET_0_STRENGTH (M1: MVL) return STRENGTH is constant GET_0_STRENGTH_TAB: STR_TABLE := -- STRENGTH MVL value -- Su St Pu La We Me Sm HiZ ( -- basic logic values 'X', 'Z', '0', and '1' ('0','0','0','0','0','0','0','0'), -- 'Z' ('0','1','1','1','1','1','1','1'), -- 'X' ('0','1','0','0','0','0','0','0'), -- '0' ('0','0','0','0','0','0','0','0'), -- '1' -- '0' values with different strengths ('0','0','0','0','0','0','1','0'), -- Sm0 ('0','0','0','0','0','1','0','0'), -- Me0 ('0','0','0','0','0','1','1','0'), -- Me0_a ('0','0','0','0','1','0','0','0'), -- We0 ('0','0','0','0','1','1','0','0'), -- We0_a ('0','0','0','0','1','1','1','0'), -- We0_b ('0','0','0','1','0','0','0','0'), -- La0 ('0','0','0','1','1','0','0','0'), -- La0_a ('0','0','0','1','1','1','0','0'), -- La0_b ('0','0','0','1','1','1','1','0'), -- La0_c ('0','0','1','0','0','0','0','0'), -- Pu0 ('0','0','1','1','0','0','0','0'), -- Pu0_a ('0','0','1','1','1','0','0','0'), -- Pu0_b ('0','0','1','1','1','1','0','0'), -- Pu0_c ('0','0','1','1','1','1','1','0'), -- Pu0_d ('0','1','1','0','0','0','0','0'), -- St0_a ('0','1','1','1','0','0','0','0'), -- St0_b ('0','1','1','1','1','0','0','0'), -- St0_c ('0','1','1','1','1','1','0','0'), -- St0_d ('0','1','1','1','1','1','1','0'), -- St0_e ('1','0','0','0','0','0','0','0'), -- Su0 ('1','1','0','0','0','0','0','0'), -- Su0_a ('1','1','1','0','0','0','0','0'), -- Su0_b ('1','1','1','1','0','0','0','0'), -- Su0_c ('1','1','1','1','1','0','0','0'), -- Su0_d ('1','1','1','1','1','1','0','0'), -- Su0_e ('1','1','1','1','1','1','1','0'), -- Su0_f ('0','1','0','0','0','0','0','0'), -- As0 ('0','1','0','0','0','0','0','0'), -- Fo0 -- '1' values with different strengths ('0','0','0','0','0','0','0','0'), -- Sm1 ('0','0','0','0','0','0','0','0'), -- Me1 ('0','0','0','0','0','0','0','0'), -- Me1_a ('0','0','0','0','0','0','0','0'), -- We1 ('0','0','0','0','0','0','0','0'), -- We1_a ('0','0','0','0','0','0','0','0'), -- We1_b ('0','0','0','0','0','0','0','0'), -- La1 ('0','0','0','0','0','0','0','0'), -- La1_a ('0','0','0','0','0','0','0','0'), -- La1_b ('0','0','0','0','0','0','0','0'), -- La1_c ('0','0','0','0','0','0','0','0'), -- Pu1 ('0','0','0','0','0','0','0','0'), -- Pu1_a ('0','0','0','0','0','0','0','0'), -- Pu1_b ('0','0','0','0','0','0','0','0'), -- Pu1_c ('0','0','0','0','0','0','0','0'), -- Pu1_d ('0','0','0','0','0','0','0','0'), -- St1_a ('0','0','0','0','0','0','0','0'), -- St1_b ('0','0','0','0','0','0','0','0'), -- St1_c ('0','0','0','0','0','0','0','0'), -- St1_d ('0','0','0','0','0','0','0','0'), -- St1_e ('0','0','0','0','0','0','0','0'), -- Su1 ('0','0','0','0','0','0','0','0'), -- Su1_a ('0','0','0','0','0','0','0','0'), -- Su1_b ('0','0','0','0','0','0','0','0'), -- Su1_c ('0','0','0','0','0','0','0','0'), -- Su1_d ('0','0','0','0','0','0','0','0'), -- Su1_e ('0','0','0','0','0','0','0','0'), -- Su1_f ('0','0','0','0','0','0','0','0'), -- As1 ('0','0','0','0','0','0','0','0'), -- Fo1 -- 'X' values with different strengths ('0','0','0','0','0','0','1','1'), -- SmX ('0','0','0','0','0','0','1','1'), -- SmX_a ('0','0','0','0','0','0','1','1'), -- SmX_b ('0','0','0','0','0','0','1','1'), -- SmX_c ('0','0','0','0','0','0','1','1'), -- SmX_d ('0','0','0','0','0','0','1','1'), -- SmX_e ('0','0','0','0','0','0','1','1'), -- SmX_f ('0','0','0','0','0','1','1','1'), -- MeX_a ('0','0','0','0','0','1','1','1'), -- MeX ('0','0','0','0','0','1','1','1'), -- MeX_b ('0','0','0','0','0','1','1','1'), -- MeX_c ('0','0','0','0','0','1','1','1'), -- MeX_d ('0','0','0','0','0','1','1','1'), -- MeX_e ('0','0','0','0','0','1','1','1'), -- MeX_f ('0','0','0','0','1','1','1','1'), -- WeX_a ('0','0','0','0','1','1','1','1'), -- WeX_b ('0','0','0','0','1','1','1','1'), -- WeX ('0','0','0','0','1','1','1','1'), -- WeX_c ('0','0','0','0','1','1','1','1'), -- WeX_d ('0','0','0','0','1','1','1','1'), -- WeX_e ('0','0','0','0','1','1','1','1'), -- WeX_f ('0','0','0','1','1','1','1','1'), -- LaX_a ('0','0','0','1','1','1','1','1'), -- LaX_b ('0','0','0','1','1','1','1','1'), -- LaX_c ('0','0','0','1','1','1','1','1'), -- LaX ('0','0','0','1','1','1','1','1'), -- LaX_d ('0','0','0','1','1','1','1','1'), -- LaX_e ('0','0','0','1','1','1','1','1'), -- LaX_f ('0','0','1','1','1','1','1','1'), -- PuX_a ('0','0','1','1','1','1','1','1'), -- PuX_b ('0','0','1','1','1','1','1','1'), -- PuX_c ('0','0','1','1','1','1','1','1'), -- PuX_d ('0','0','1','1','1','1','1','1'), -- PuX ('0','0','1','1','1','1','1','1'), -- PuX_e ('0','0','1','1','1','1','1','1'), -- PuX_f ('0','1','1','1','1','1','1','1'), -- StX_a ('0','1','1','1','1','1','1','1'), -- StX_b ('0','1','1','1','1','1','1','1'), -- StX_c ('0','1','1','1','1','1','1','1'), -- StX_d ('0','1','1','1','1','1','1','1'), -- StX_e ('0','1','1','1','1','1','1','1'), -- StX_f ('1','1','1','1','1','1','1','1'), -- SuX ('1','1','1','1','1','1','1','1'), -- SuX_a ('1','1','1','1','1','1','1','1'), -- SuX_b ('1','1','1','1','1','1','1','1'), -- SuX_c ('1','1','1','1','1','1','1','1'), -- SuX_d ('1','1','1','1','1','1','1','1'), -- SuX_e ('1','1','1','1','1','1','1','1'), -- SuX_f ('0','1','1','1','1','1','1','1'), -- AsX ('0','1','1','1','1','1','1','1'), -- FoX -- 'L' values with different strengths ('0','0','0','0','0','0','1','1'), -- SmL ('0','0','0','0','0','1','1','1'), -- MeL ('0','0','0','0','1','1','1','1'), -- WeL ('0','0','0','1','1','1','1','1'), -- LaL ('0','0','1','1','1','1','1','1'), -- PuL ('0','1','1','1','1','1','1','1'), -- StL ('1','1','1','1','1','1','1','1'), -- SuL -- 'H' values with different strengths ('0','0','0','0','0','0','0','1'), -- SmH ('0','0','0','0','0','0','0','1'), -- MeH ('0','0','0','0','0','0','0','1'), -- WeH ('0','0','0','0','0','0','0','1'), -- LaH ('0','0','0','0','0','0','0','1'), -- PuH ('0','0','0','0','0','0','0','1'), -- StH ('0','0','0','0','0','0','0','1'), -- SuH -- 'Z' values with different strengths ('0','0','0','0','0','0','0','1'), -- HiZ ('0','0','0','0','0','0','0','0'), -- AsZ ('0','0','0','0','0','0','0','0') -- FoZ ); begin return(GET_0_STRENGTH_TAB(M1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_1_STRENGTH (M1: MVL) return STRENGTH -- -- Function to get the 1-strength byte values from the enumerated type element function GET_1_STRENGTH (M1: MVL) return STRENGTH is constant GET_1_STRENGTH_TAB: STR_TABLE := -- STRENGTH MVL value -- Su St Pu La We Me Sm HiZ ( -- basic logic values 'X', 'Z', '0', and '1' ('0','0','0','0','0','0','0','0'), -- 'Z' ('0','1','1','1','1','1','1','1'), -- 'X' ('0','0','0','0','0','0','0','0'), -- '0' ('0','1','0','0','0','0','0','0'), -- '1' -- '0' values with different strengths ('0','0','0','0','0','0','0','0'), -- Sm0 ('0','0','0','0','0','0','0','0'), -- Me0 ('0','0','0','0','0','0','0','0'), -- Me0_a ('0','0','0','0','0','0','0','0'), -- We0 ('0','0','0','0','0','0','0','0'), -- We0_a ('0','0','0','0','0','0','0','0'), -- We0_b ('0','0','0','0','0','0','0','0'), -- La0 ('0','0','0','0','0','0','0','0'), -- La0_a ('0','0','0','0','0','0','0','0'), -- La0_b ('0','0','0','0','0','0','0','0'), -- La0_c ('0','0','0','0','0','0','0','0'), -- Pu0 ('0','0','0','0','0','0','0','0'), -- Pu0_a ('0','0','0','0','0','0','0','0'), -- Pu0_b ('0','0','0','0','0','0','0','0'), -- Pu0_c ('0','0','0','0','0','0','0','0'), -- Pu0_d ('0','0','0','0','0','0','0','0'), -- St0_a ('0','0','0','0','0','0','0','0'), -- St0_b ('0','0','0','0','0','0','0','0'), -- St0_c ('0','0','0','0','0','0','0','0'), -- St0_d ('0','0','0','0','0','0','0','0'), -- St0_e ('0','0','0','0','0','0','0','0'), -- Su0 ('0','0','0','0','0','0','0','0'), -- Su0_a ('0','0','0','0','0','0','0','0'), -- Su0_b ('0','0','0','0','0','0','0','0'), -- Su0_c ('0','0','0','0','0','0','0','0'), -- Su0_d ('0','0','0','0','0','0','0','0'), -- Su0_e ('0','0','0','0','0','0','0','0'), -- Su0_f ('0','0','0','0','0','0','0','0'), -- As0 ('0','0','0','0','0','0','0','0'), -- Fo0 -- '1' values with different strengths ('0','0','0','0','0','0','1','0'), -- Sm1 ('0','0','0','0','0','1','0','0'), -- Me1 ('0','0','0','0','0','1','1','0'), -- Me1_a ('0','0','0','0','1','0','0','0'), -- We1 ('0','0','0','0','1','1','0','0'), -- We1_a ('0','0','0','0','1','1','1','0'), -- We1_b ('0','0','0','1','0','0','0','0'), -- La1 ('0','0','0','1','1','0','0','0'), -- La1_a ('0','0','0','1','1','1','0','0'), -- La1_b ('0','0','0','1','1','1','1','0'), -- La1_c ('0','0','1','0','0','0','0','0'), -- Pu1 ('0','0','1','1','0','0','0','0'), -- Pu1_a ('0','0','1','1','1','0','0','0'), -- Pu1_b ('0','0','1','1','1','1','0','0'), -- Pu1_c ('0','0','1','1','1','1','1','0'), -- Pu1_d ('0','1','1','0','0','0','0','0'), -- St1_a ('0','1','1','1','0','0','0','0'), -- St1_b ('0','1','1','1','1','0','0','0'), -- St1_c ('0','1','1','1','1','1','0','0'), -- St1_d ('0','1','1','1','1','1','1','0'), -- St1_e ('1','0','0','0','0','0','0','0'), -- Su1 ('1','1','0','0','0','0','0','0'), -- Su1_a ('1','1','1','0','0','0','0','0'), -- Su1_b ('1','1','1','1','0','0','0','0'), -- Su1_c ('1','1','1','1','1','0','0','0'), -- Su1_d ('1','1','1','1','1','1','0','0'), -- Su1_e ('1','1','1','1','1','1','1','0'), -- Su1_f ('0','1','0','0','0','0','0','0'), -- As1 ('0','1','0','0','0','0','0','0'), -- Fo1 -- 'X' values with different strengths ('0','0','0','0','0','0','1','1'), -- SmX ('0','0','0','0','0','1','1','1'), -- SmX_a ('0','0','0','0','1','1','1','1'), -- SmX_b ('0','0','0','1','1','1','1','1'), -- SmX_c ('0','0','1','1','1','1','1','1'), -- SmX_d ('0','1','1','1','1','1','1','1'), -- SmX_e ('1','1','1','1','1','1','1','1'), -- SmX_f ('0','0','0','0','0','0','1','1'), -- MeX_a ('0','0','0','0','0','1','1','1'), -- MeX ('0','0','0','0','1','1','1','1'), -- MeX_b ('0','0','0','1','1','1','1','1'), -- MeX_c ('0','0','1','1','1','1','1','1'), -- MeX_d ('0','1','1','1','1','1','1','1'), -- MeX_e ('1','1','1','1','1','1','1','1'), -- MeX_f ('0','0','0','0','0','0','1','1'), -- WeX_a ('0','0','0','0','0','1','1','1'), -- WeX_b ('0','0','0','0','1','1','1','1'), -- WeX ('0','0','0','1','1','1','1','1'), -- WeX_c ('0','0','1','1','1','1','1','1'), -- WeX_d ('0','1','1','1','1','1','1','1'), -- WeX_e ('1','1','1','1','1','1','1','1'), -- WeX_f ('0','0','0','0','0','0','1','1'), -- LaX_a ('0','0','0','0','0','1','1','1'), -- LaX_b ('0','0','0','0','1','1','1','1'), -- LaX_c ('0','0','0','1','1','1','1','1'), -- LaX ('0','0','1','1','1','1','1','1'), -- LaX_d ('0','1','1','1','1','1','1','1'), -- LaX_e ('1','1','1','1','1','1','1','1'), -- LaX_f ('0','0','0','0','0','0','1','1'), -- PuX_a ('0','0','0','0','0','1','1','1'), -- PuX_b ('0','0','0','0','1','1','1','1'), -- PuX_c ('0','0','0','1','1','1','1','1'), -- PuX_d ('0','0','1','1','1','1','1','1'), -- PuX ('0','1','1','1','1','1','1','1'), -- PuX_e ('1','1','1','1','1','1','1','1'), -- PuX_f ('0','0','0','0','0','0','1','1'), -- StX_a ('0','0','0','0','0','1','1','1'), -- StX_b ('0','0','0','0','1','1','1','1'), -- StX_c ('0','0','0','1','1','1','1','1'), -- StX_d ('0','0','1','1','1','1','1','1'), -- StX_e ('1','1','1','1','1','1','1','1'), -- StX_f ('0','0','0','0','0','0','1','1'), -- SuX ('0','0','0','0','0','1','1','1'), -- SuX_a ('0','0','0','0','1','1','1','1'), -- SuX_b ('0','0','0','1','1','1','1','1'), -- SuX_c ('0','0','1','1','1','1','1','1'), -- SuX_d ('0','1','1','1','1','1','1','1'), -- SuX_e ('1','1','1','1','1','1','1','1'), -- SuX_f ('0','1','1','1','1','1','1','1'), -- AsX ('0','1','1','1','1','1','1','1'), -- FoX -- 'L' values with different strengths ('0','0','0','0','0','0','0','1'), -- SmL ('0','0','0','0','0','0','0','1'), -- MeL ('0','0','0','0','0','0','0','1'), -- WeL ('0','0','0','0','0','0','0','1'), -- LaL ('0','0','0','0','0','0','0','1'), -- PuL ('0','0','0','0','0','0','0','1'), -- StL ('0','0','0','0','0','0','0','1'), -- SuL -- 'H' values with different strengths ('0','0','0','0','0','0','1','1'), -- SmH ('0','0','0','0','0','1','1','1'), -- MeH ('0','0','0','0','1','1','1','1'), -- WeH ('0','0','0','1','1','1','1','1'), -- HaH ('0','0','1','1','1','1','1','1'), -- PuH ('0','1','1','1','1','1','1','1'), -- StH ('1','1','1','1','1','1','1','1'), -- SuH -- 'Z' values with different strengths ('0','0','0','0','0','0','0','1'), -- HiZ ('0','0','0','0','0','0','0','0'), -- AsZ ('0','0','0','0','0','0','0','0') -- FoZ ); begin return(GET_1_STRENGTH_TAB(M1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_MVL_0 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the MVL value from a STRENGTH value, for '0' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_MVL_0 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_MVL_0_TAB: MVL_TABLE8 := ((((( (((HiZ, 'Z'), (Sm0, 'X')), ((Me0, 'X'), (Me0_a, 'X'))), (((We0, 'X'), ('X', 'X')), ((We0_a,'X'), (We0_b, 'X')))), ((((La0, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((La0_a,'X'), ('X', 'X')), ((La0_b,'X'), (La0_c,'X'))))), (( (((Pu0, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((Pu0_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((Pu0_b, 'X'), ('X', 'X')), ((Pu0_c, 'X'), (Pu0_d, 'X')))))), ((( ((('0', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( (((St0_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((St0_b, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((St0_c, 'X'), ('X', 'X')), ((St0_d, 'X'), (St0_e, 'X'))))))), (((( (((Su0, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), ((( (((Su0_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( (((Su0_b, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((Su0_c, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((Su0_d, 'X'), ('X', 'X')), ((Su0_e, 'X'), (Su0_f, 'X')))))))); begin return(GET_MVL_0_TAB(B1,B2,B3,B4,B5,B6,B7,B8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_MVL_1 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the MVL value from a STRENGTH value, for '1' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_MVL_1 (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_MVL_1_TAB: MVL_TABLE8 := ((((( (((HiZ, 'Z'), (Sm1, 'X')), ((Me1, 'X'), (Me1_a, 'X'))), (((We1, 'X'), ('X', 'X')), ((We1_a,'X'), (We1_b, 'X')))), ((((La1, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((La1_a,'X'), ('X', 'X')), ((La1_b,'X'), (La1_c,'X'))))), (( (((Pu1, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((Pu1_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((Pu1_b, 'X'), ('X', 'X')), ((Pu1_c, 'X'), (Pu1_d, 'X')))))), ((( ((('1', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( (((St1_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((St1_b, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((St1_c, 'X'), ('X', 'X')), ((St1_d, 'X'), (St1_e, 'X'))))))), (((( (((Su1, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), ((( (((Su1_a, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), (( (((Su1_b, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((Su1_c, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), (((Su1_d, 'X'), ('X', 'X')), ((Su1_e, 'X'), (Su1_f, 'X')))))))); begin return(GET_MVL_1_TAB(B1,B2,B3,B4,B5,B6,B7,B8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_MVL_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the MVL value from a STRENGTH value, for 'L' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_MVL_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_MVL_L_TAB: MVL_TABLE8 := ((((((( (HiZ, 'Z'), ('X', SmL)), (('X', 'X'), ('X', MeL))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', WeL)))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', LaL))))), ( (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', PuL)))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', StL))))))), ((( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', SuL)))))))); begin return(GET_MVL_L_TAB(B1,B2,B3,B4,B5,B6,B7,B8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_MVL_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the MVL value from a STRENGTH value, for 'H' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_MVL_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_MVL_H_TAB: MVL_TABLE8 := ((((((( (HiZ, 'Z'), ('X', SmH)), (('X', 'X'), ('X', MeH))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', WeH)))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', LaH))))), ( (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', PuH)))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', StH))))))), ((( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', SuH)))))))); begin return(GET_MVL_H_TAB(b1,b2,b3,b4,b5,b6,b7,b8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_X_MVL (M1,M2:MVL_L) return MVL -- -- Function to get the MVL value for 'X'. Its index are in terms of the type -- MVL_L. It is used as a second level table. function GET_X_MVL (M1,M2:MVL_L) return MVL is constant GET_X_MVL_TAB: MVL_X_TABLE2 := ( (SmX, SmX_a, SmX_b, SmX_c, SmX_d, SmX_e, SmX_f), (MeX_a, MeX, MeX_b, MeX_c, MeX_d, MeX_e, MeX_f), (WeX_a, WeX_b, WeX, WeX_c, WeX_d, WeX_e, WeX_f), (LaX_a, LaX_b, LaX_c, LaX, LaX_d, LaX_e, LaX_f), (PuX_a, PuX_b, PuX_c, PuX_d, PuX, PuX_e, PuX_f), (StX_a, StX_b, StX_c, StX_d, StX_e, 'X', StX_f), (SuX_a, SuX_b, SuX_c, SuX_d, SuX_e, SuX_f, SuX) ); begin return(GET_X_MVL_TAB(M1,M2)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_COERCED_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the COERCED MVL value from a STRENGTH value, for 'L' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_COERCED_L (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_COERCED_L_TAB: MVL_TABLE8 := ((((((( (HiZ, 'Z'), (SmL, 'X')), ((MeL, 'X'), ('X', 'X'))), (((WeL, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((LaL, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( ((((PuL,'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( ((((StL, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))))), ((( ((((SuL, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))))); begin return(GET_COERCED_L_TAB(B1,B2,B3,B4,B5,B6,B7,B8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_COERCED_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL -- -- Function to get the COERCED MVL value from a STRENGTH value, for 'H' values -- For invalid strength inputs, an MVL 'X' is returned. function GET_COERCED_H (B1, B2, B3, B4, B5, B6, B7, B8: BIT) return MVL is constant GET_COERCED_H_TAB: MVL_TABLE8 := ((((((( (HiZ, 'Z'), (SmH, 'X')), ((MeH, 'X'), ('X', 'X'))), (((WeH, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), ((((LaH, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( ((((PuH,'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X','X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( ((((StH, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))))), ((( ((((SuH, 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))), (( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))))), ( (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))), (((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X'))), ((('X', 'X'), ('X', 'X')), (('X', 'X'), ('X', 'X')))))))); begin return(GET_COERCED_H_TAB(B1,B2,B3,B4,B5,B6,B7,B8)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_TERN_VAL (M1: MVL) return MVL -- -- Function to get a ternary value from '0', '1', 'X', 'L', 'H' or 'Z' -- from the 129 MVL values function GET_TERN_VAL (M1: MVL) return MVL is constant GET_TERN_VAL_TAB : MVL_TO_MVL_TABLE := ( 'Z', 'X', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', StL, StL, StL, StL, StL, StL, StL, StH, StH, StH, StH, StH, StH, StH, 'Z', 'Z', 'Z' ); begin return(GET_TERN_VAL_TAB(M1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_01X_VAL (M1: MVL) return MVL -- -- Function to get a logic value of '0', '1' or 'X' from the 129 MVL values function GET_01X_VAL (M1: MVL) return MVL is constant GET_01X_VAL_TAB : MVL_TO_MVL_TABLE := ( 'X', 'X', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ); begin return(GET_01X_VAL_TAB(M1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- BIT_TO_MVL (B1: BIT) return MVL -- -- Function to convert a BIT value to an MVL value function BIT_TO_MVL (B1: BIT) return MVL is constant BIT_TO_MVL_TAB: BIT_TO_MVL_TABLE := ( '0', '1' ); begin return(BIT_TO_MVL_TAB(B1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- MODIFY_MOS_STRENGTH (M1: MVL) return MVL -- -- Function to get the strengths of MVL values after they pass through a -- pmos or nmos.Here, the SUPPLY strength is changed to STRONG. function MODIFY_MOS_STRENGTH (M1: MVL) return MVL is constant MODIFY_MOS_STRENGTH_TAB: MVL_TO_MVL_TABLE := ( -- basic logic values 'X', 'Z', '0', and '1' 'Z', 'X', '0', '1', -- '0' values with different strengths Sm0, Me0, Me0_a, We0, We0_a, We0_b, La0, La0_a, La0_b, La0_c, Pu0, Pu0_a, Pu0_b, Pu0_c, Pu0_d, St0_a, St0_b, St0_c, St0_d, St0_e, '0', '0', St0_a, St0_b, St0_c, St0_d, St0_e, '0', '0', -- '1' values with different strengths Sm1, Me1, Me1_a, We1, We1_a, We1_b, La1, La1_a, La1_b, La1_c, Pu1, Pu1_a, Pu1_b, Pu1_c, Pu1_d, St1_a, St1_b, St1_c, St1_d, St1_e, '1', '1', St1_a, St1_b, St1_c, St1_d, St1_e, '1', '1', -- 'X' values with different strengths SmX, SmX_a, SmX_b, SmX_c, SmX_d, SmX_e, SmX_e, MeX_a, MeX, MeX_b, MeX_c, MeX_d, MeX_e, MeX_e, WeX_a, WeX_b, WeX, WeX_c, WeX_d, WeX_e, WeX_e, LaX_a, LaX_b, LaX_c, LaX, LaX_d, LaX_e, LaX_e, PuX_a, PuX_b, PuX_c, PuX_d, PuX, PuX_e, PuX_e, StX_a, StX_b, StX_c, StX_d, StX_e, 'X', StX_a, StX_b, StX_c, StX_d, StX_e, 'X', 'X', 'X', 'X', -- 'L' values SmL, MeL, WeL, LaL, PuL, StL, StL, -- 'H' values SmH, MeH, WeH, LaH, PuH, StH, StH, -- 'Z' value 'Z', 'Z', 'Z' ); begin return(MODIFY_MOS_STRENGTH_TAB(M1)); end; -------------------------------------------------------------------------------- -- FUNCTION : -- REDUCE_MOS_STRENGTH (M1: MVL) return MVL -- -- Function to get the REDUCED strengths of MVL values after they pass -- through a rpmos or rnmos. function REDUCE_MOS_STRENGTH (M1: MVL) return MVL is constant REDUCE_MOS_STRENGTH_TAB: MVL_TO_MVL_TABLE := ( -- basic logic values 'X', 'Z', '0', and '1' 'Z', PuX, Pu0, Pu1, -- '0' values with different strengths Sm0, Sm0, Sm0, Me0, Me0_a, Me0_a, Me0, Me0 , Me0_a, Me0_a, We0, We0_a, We0_a, We0_b, We0_b, Pu0_b, Pu0_c, Pu0_c, Pu0_d, Pu0_d, Pu0, Pu0 , Pu0_b, Pu0_c, Pu0_c, Pu0_d, Pu0_d, Pu0, Pu0, -- '1' values with different strengths Sm1, Sm1, Sm1, Me1, Me1_a, Me1_a, Me1, Me1 , Me1_a, Me1_a, We1, We1_a, We1_a, We1_b, We1_b, Pu1_b, Pu1_c, Pu1_c, Pu1_d, Pu1_d, Pu1, Pu1 , Pu1_b, Pu1_c, Pu1_c, Pu1_d, Pu1_d, Pu1, Pu1, -- 'X' values with different strengths SmX , SmX , SmX_a, SmX_a, SmX_b, SmX_d, SmX_d, SmX , SmX , SmX_a, SmX_a, SmX_b, SmX_d, SmX_d, MeX_a, MeX_a, MeX , MeX , MeX_b, MeX_d, MeX_d, MeX_a, MeX_a, MeX , MeX , MeX_b, MeX_d, MeX_d, WeX_a, WeX_a, WeX_b, WeX_b, WeX , WeX_d, WeX_d, PuX_a, PuX_a, PuX_b, PuX_b, PuX_c, PuX , PuX_a, PuX_a, PuX_b, PuX_b, PuX_c, PuX , PuX , PuX , PuX , -- 'L' values SmL, SmL, MeL, MeL, WeL, PuL, PuL, -- 'H' values SmH, SmH, MeH, MeH, WeH, PuH, PuH, -- 'Z' value 'Z', 'Z', 'Z' ); begin return(REDUCE_MOS_STRENGTH_TAB(M1)); end; ---------------------------------------------------------------------------------- PROCEDURE : -- SHIFT_AND_ADD (OPER1: IN BIT_VECTOR; SHIFT: IN INTEGER; -- RESULT: INOUT MVL_VECTOR) -- -- This procedure shifts the OPER1 by SHIFT positions to the left -- and adds it to the RESULT. The left-shift is done implicitly by -- adjusting the index of RESULT. -- It is used for multiplication. procedure shift_and_add (oper1: IN BIT_VECTOR; shift: IN INTEGER; result: INOUT MVL_VECTOR) is variable carry_bit: BIT := '0'; variable LOOP_CNT : INTEGER := 0; begin for I in oper1'REVERSE_RANGE loop -- (0 to size1-1) result(shift+I) := SUM (oper1(I), conv_mvl_to_bit(result(shift+I)), carry_bit); carry_bit := CARRY (oper1(I), conv_mvl_to_bit(result(shift+I)), carry_bit); LOOP_CNT := I; end loop; result(shift+LOOP_CNT+1) := BIT_TO_MVL (carry_bit); -- final carry end shift_and_add; -------------------------------------------------------------------------------- -- -- CONVERSION ROUTINES -- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- PROCEDURE : -- CONV_MVLV_TO_LOGV (oldv: IN MVL_VECTOR ; newv: INOUT MVL_VECTOR; -- has_no_X : OUT BOOLEAN) -- INPUT : oldv vector (each element could be any of 128 MVL) -- OUTPUT : newv vector (Each element is either 0, 1, or X). -- -- This procedure converts the oldv vector values to logical values -- 0, 1 or X. -- It also fills in 0's in the MSB of newv, if the size of newv is more -- than that of oldv. -- If in oldv, there is any element of value 'X', then the flag -- has_no_X is set to FALSE. -- It also ensures that the indices for newv are in descending order -- (i.e MSB downto LSB) e.g., 31 downto 0. -- Will be used for bit-wise operators. procedure conv_mvlv_to_logv (oldv: IN MVL_VECTOR; newv: INOUT MVL_VECTOR; has_no_X : OUT BOOLEAN) is constant size_old : INTEGER := oldv'LENGTH; constant size_new : INTEGER := newv'LENGTH; variable index : INTEGER := 0; -- used as an index for newv variable temp_oldv : MVL_VECTOR (oldv'LENGTH - 1 downto 0) := oldv; begin newv := fill_mvl_vector('0', size_new); has_no_x := true; for I in temp_oldv'REVERSE_RANGE loop -- loop from oldv's right to left newv(I) := GET_01X_VAL(temp_oldv(I)); if (newv(I) = 'X') then has_no_X := FALSE; -- set flag to FALSE end if; index := index + 1; exit when I + 1 = size_new; end loop; -- if (size_old < size_new) then -- fill 0's in MSB of newv -- newv := ((size_new-1) downto (index)=> '0'); -- end if; end conv_mvlv_to_logv; -------------------------------------------------------------------------------- -- PROCEDURE : -- CONV_MVLV_TO_BITV (oldv: IN MVL_VECTOR ; newv: INOUT BIT_VECTOR; -- has_no_X : OUT BOOLEAN) -- INPUT : oldv vector (each element could be any of 128 MVL) -- OUTPUT : newv vector (Each element is either BIT '0' or '1'). -- -- This procedure converts the oldv vector values to BIT values -- '0' or '1' -- It also fills in 0's in the MSB of newv, if the size of newv is more -- than that of oldv. -- If in oldv, there is any element of value 'X', then the flag -- has_no_X is set to FALSE and in that case, the value stored in newv -- is invalid. -- It also ensures that the indices for newv are in descending order -- (i.e MSB downto LSB) e.g., 31 downto 0. -- Will be used for arithmetic operators. procedure conv_mvlv_to_bitv (oldv: IN MVL_VECTOR; newv: INOUT BIT_VECTOR; has_no_X : OUT BOOLEAN) is constant size_old : INTEGER := oldv'LENGTH; constant size_new : INTEGER := newv'LENGTH; variable index : INTEGER := newv'right ; -- used as an index for newv variable temp_oldv : MVL_VECTOR (oldv'LENGTH -1 downto 0) := oldv; begin has_no_x := true; newv := fill_bit_vector('0', size_new); for I in temp_oldv'reverse_range loop case (GET_01X_VAL(temp_oldv(I))) is when '0' => newv(I) := '0'; -- value is '0' when '1' => newv(I) := '1'; -- value is '1' when others => -- value is 'X' has_no_X := FALSE; -- set flag to FALSE return; -- and return end case; index := index + 1; exit when I +1 = size_new; end loop; -- if (size_old < size_new) then -- fill 0's in MSB of newv -- newv := ((size_new-1) downto (index)=> '0'); -- end if; end conv_mvlv_to_bitv; ---------------------------------------------------------------------------------- PROCEDURE : -- CONV_MVLV_TO_INT (oper: IN MVL_VECTOR; value: OUT INTEGER; -- has_no_X : OUT BOOLEAN := TRUE) -- INPUT : a mvl vector -- OUTPUT: an INTEGER value of the oper. -- -- This function returns the integer value of the oper. -- If in oper, there is any element of value 'X', then the flag -- has_no_X is set to FALSE and in that case, the value stored in newv -- is invalid. -- If oper is a 32 bit vector and the msb is set, two's compliment -- is performed and the result is multiplied by minus one. -- WARNING : If the converted integer value is greater than -- 2 ** 32, overflow error may occur. This is flagged as an error. procedure conv_mvlv_to_int (oper : IN MVL_VECTOR; value: OUT INTEGER; has_no_X : OUT BOOLEAN ) is variable INDEX : INTEGER := 0; variable NEG_FLAG : BOOLEAN := FALSE; variable temp_value : INTEGER := 0; variable temp_oper : MVL_VECTOR(oper'range) := oper; begin has_no_x := true; if oper'length > 32 then assert FALSE report "ERROR: OVERFLOW DETECTED DURING INTEGER CONVERSION." severity FAILURE; else if oper'LENGTH = 32 and oper(oper'HIGH) = '1' then temp_oper := minus(temp_oper); neg_flag := TRUE; end if; for I in oper'reverse_range loop case (GET_01X_VAL(temp_oper(I))) is when '0' => null; when '1' => temp_value := temp_value + (2 ** INDEX); when others => has_no_X := FALSE; -- set flag to FALSE -- return; -- and return end case; INDEX := INDEX + 1; end loop; if neg_flag then value := temp_value * (-1); else value := temp_value; end if; end if; end conv_mvlv_to_int; -------------------------------------------------------------------------------- -- FUNCTION : -- CONV_MVL_TO_BIT (MVL_VAL: MVL) return BIT -- INPUT : a MVL value, '0' or '1' -- OUTPUT: an equivalent BIT '0' or '1' -- -- This function converts a MVL value to a BIT value. function conv_mvl_to_bit (mvl_val: MVL) return BIT is begin case (GET_01X_VAL(MVL_VAL)) is when '0' => return ('0'); when '1' => return ('1'); when others => assert FALSE report "ERROR: Illegal value detected in the conversion of bit to integer. Data Corrupted." severity WARNING; return ('1'); end case; end conv_mvl_to_bit; ---------------------------------------------------------------------------------- PROCEDURE : -- CONV_MVL_TO_INT (oldv: IN MVL ; newv: INOUT INTEGER; -- has_no_X : INOUT BOOLEAN) is -- INPUT : An MVL value -- OUTPUT : The Integer equivalent (0 or 1); procedure conv_mvl_to_int (oper : IN MVL; value: OUT INTEGER ; has_no_X : OUT BOOLEAN) is begin has_no_x := true; value := 0; case (GET_01X_VAL(oper)) is when '0' => null; when '1' => value := 1; when others => has_no_X := FALSE; -- set flag to FALSE end case; end conv_mvl_to_int; ---------------------------------------------------------------------------------- PROCEDURE : -- CONV_MVL_TO_BITV (oldv: IN MVL_VECTOR ; newv: INOUT BIT_VECTOR; -- has_no_X : OUT BOOLEAN) is -- INPUT : an MVL value -- OUTPUT : A bit vector representing the MVL value procedure conv_mvl_to_bitv (oldv: IN MVL; newv: INOUT BIT_VECTOR; has_no_X : OUT BOOLEAN) is constant size_old : INTEGER := 1; constant size_new : INTEGER := newv'LENGTH; constant right : INTEGER := newv'right ; -- used as an index for newv variable offset : INTEGER := 0; begin newv := (newv'range => '0'); --intialize to all zeros case (GET_01X_VAL(oldv)) is when '0' => newv(right) := '0'; -- value is '0' when '1' => newv(right) := '1'; -- value is '1' when others => -- value is 'X' has_no_X := FALSE; -- set flag to FALSE end case; end conv_mvl_to_bitv; ---------------------------------------------------------------------------------- PROCEDURE : -- CONV_MVL_TO_LOGV (oldv: IN MVL_VECTOR ; newv: INOUT MVL_VECTOR; -- has_no_X : OUT BOOLEAN) is -- INPUT : An MVL value. -- OUTPUT : A logical vector representing the MVL value. procedure conv_mvl_to_logv (oldv: IN MVL; newv: INOUT MVL_VECTOR; has_no_X : OUT BOOLEAN) is constant size_old : INTEGER := 1; constant size_new : INTEGER := newv'LENGTH; variable right : INTEGER := newv'right; -- used as an index for newv begin newv := (newv'range => '0'); -- initalize to all zeros newv(right) := GET_01X_VAL(oldv); if (newv(right) = 'X') then has_no_X := FALSE; -- set flag to FALSE end if; end conv_mvl_to_logv; -------------------------------------------------------------------------------- -- FUNCTION : -- BOOL (MVL_VAL: MVL_VECTOR) return BOOLEAN -- INPUT : a MVL VECTOR containing only '0', '1', 'X' or 'Z' -- OUTPUT: a BOOLEAN value TRUE or FALSE -- -- This function creturns a TRUE if any element of the MVL_VAL is a '1', -- otherwise it returns a FALSE. -- '0' -> FALSE -- 'X' -> FALSE -- 'Z' -> FALSE -- '1' -> TRUE -- To be used in conditional statements, where BOOLEAN value is needed. function bool(mvl_val: MVL_VECTOR) return BOOLEAN is begin for I in mvl_val'RANGE loop if (mvl_val(I) = '1') then return (TRUE); end if; end loop; return (FALSE); end bool; -------------------------------------------------------------------------------- -- FUNCTION : -- BOOL (MVL_VAL: MVL) return BOOLEAN -- INPUT : a MVL VECTOR containing only '0', '1', 'X' or 'Z' -- OUTPUT: a BOOLEAN value TRUE or FALSE -- -- This function creturns a TRUE if any element of the MVL_VAL is a '1', -- otherwise it returns a FALSE. -- '0' -> FALSE -- 'X' -> FALSE -- 'Z' -> FALSE -- '1' -> TRUE function bool(mvl_val: MVL) return BOOLEAN is begin if (mvl_val = '1') then return (TRUE); end if; return (FALSE); end bool; -------------------------------------------------------------------------------- -- FUNCTION : -- BOOL (MVL_VAL: BOOLEAN) return BOOLEAN -- INPUT : boolean value -- OUTPUT: the input boolean value -- -- This function returns the boolean value that it is passed. -- This function exists to make translation easier. function bool(mvl_val: BOOLEAN) return BOOLEAN is begin return (MVL_VAL); end bool; -------------------------------------------------------------------------------- -- FUNCTION : -- INT (oper: MVL_VECTOR) return INTEGER; -- INPUT : an mvl vector -- OUTPUT: an INTEGER value of the oper. -- -- This function returns the integer value of the oper. -- WARNING : The converted integer value should not be greater than -- 2 ** 32, else overflow error will occur. function int (oper : MVL_VECTOR) return INTEGER is variable value, INDEX : INTEGER := 0; variable temp_oper : MVL_VECTOR(oper'RANGE) := oper; variable neg_flag : BOOLEAN := FALSE; begin if oper'LENGTH > 32 then assert FALSE report "ERROR: AN OVERFLOW ERROR HAS OCCURED DURING CONVERSION OF MVL_VECTOR TO INTEGER. SIMULATION TERMINATED." severity FAILURE; else value := 0; if oper'LENGTH = 32 and oper(oper'HIGH) = '1' then temp_oper := minus(temp_oper); neg_flag := TRUE; end if; for I in oper'reverse_range loop case (GET_01X_VAL(oper(I))) is when '0' => null; when '1' => value := value + (2 ** INDEX); when others => assert FALSE report "ERROR: Illegal value detected during conversion from MVL_VECTOR to INTEGER. Data Corrupted." severity WARNING; return (-1); -- and return end case; INDEX := INDEX + 1; end loop; if neg_flag then return VALUE * (-1); else return VALUE; end if; end if; end int; -------------------------------------------------------------------------------- -- FUNCTION : -- INT (oper: MVL) return INTEGER; -- INPUT : a mvl vector -- OUTPUT: an INTEGER value of the oper. -- -- This function returns the integer value of the oper. It is overloaded -- in this way to make translation easier. function int (oper : MVL) return INTEGER is begin case (GET_01X_VAL(oper)) is when '0' => return(0); when '1' => return(1); when others => assert FALSE report "ERROR: Illegal value detected during conversion from MVL to INTEGER. Data corrupted." severity WARNING; return (-1); -- and return end case; end int; -------------------------------------------------------------------------------- -- FUNCTION : -- INT (oper: INTEGER) return INTEGER; -- INPUT : an INTEGER -- OUTPUT: the input parameter. -- -- This function is used to simplify translation. function int (oper : INTEGER) return INTEGER is begin return (oper); end int; -------------------------------------------------------------------------------- -- FUNCTION : -- to_mvl (oper : BOOLEAN) return MVL; -- INPUT : a boolean value -- OUTPUT: The mvl equivalent to that value -- -- This routine converts a boolean value to its equivalent mvl value. -- An X is interpreted as FALSE. function to_mvl (oper : BOOLEAN) return MVL is begin case oper is when TRUE => return ('1'); when FALSE => return ('0'); end case; end to_mvl; -------------------------------------------------------------------------------- -- FUNCTION : -- to_mvlv (oper : BOOLEAN) return MVL_VECTOR; -- INPUT : A boolean value -- OUPUT : A one bit mvl_vector representing that boolean value. -- -- This is the same as the TO_MVL that returns the mvl value -- except that this function returns a one bit MVL_VECTOR. This -- is called when an MVL_VECTOR is called for in an expression. function to_mvlv (oper : BOOLEAN) return MVL_VECTOR is variable RETURN_VECTOR : MVL_VECTOR (0 to 0); begin case oper is when TRUE => RETURN_VECTOR(0) := '1'; when FALSE => RETURN_VECTOR(0) := '0'; end case; return(RETURN_VECTOR); end to_mvlv; -------------------------------------------------------------------------------- -- FUNCTION : -- to_mvlv (oper : MVL) return MVL_VECTOR; -- INPUT : an MVL value -- OUTPUT: A vector containing that value -- -- This function stuffs an MVL value into an MVL_VECTOR function to_mvlv (oper : MVL) return MVL_VECTOR is variable RETURN_VECTOR : MVL_VECTOR (0 to 0); begin RETURN_VECTOR(0) := OPER; return(RETURN_VECTOR); end to_mvlv; -------------------------------------------------------------------------------- -- FUNCTION : -- TO_MVLV (oper : INTEGER) return MVL_VECTOR -- INPUT : An integer value -- OUTPUT: An MVL_VECTOR representing that integer value. -- -- This function will convert an integer value into its equivalent -- mvl_vector. This is an overloaded function that will accept MVL, -- and MVL_VECTOR as well. function TO_MVLV (oper : INTEGER) return MVL_VECTOR is -- This function will find the number of bits needed to represent -- the integer. It is used to size the array of the return value. function FIND_LENGTH (VAL : INTEGER) return INTEGER is variable TEMP : INTEGER := VAL; variable INDEX : INTEGER := 0; begin if TEMP = 0 then INDEX := 1; else while (TEMP /= 0) loop TEMP := TEMP / 2; INDEX := INDEX + 1; end loop; end if; return (INDEX); end FIND_LENGTH; variable RETURN_VECTOR : MVL_VECTOR (FIND_LENGTH(OPER) - 1 downto 0); begin conv_int_to_mvlv (oper, return_vector); return (return_vector); end TO_MVLV; -------------------------------------------------------------------------------- -- FUNCTION : -- CONV_STRENGTH_TO_MVL (ABITS, BBITS : STRENGTH) return MVL -- -- This function converts the strength representation in terms of -- 0-strength byte and 1-strength byte, into a MVL value. -- Before converting, it fills-in the missing bits, for unknown values -- and adjusts bits for 'L' or 'H' values. function conv_strength_to_mvl (in_abits, in_bbits : STRENGTH) return MVL is variable result: MVL; variable abits, bbits: STRENGTH; begin abits := in_abits; bbits := in_bbits; -- fill in missing bits, if an unknown value if ((abits /= MASK_0) and (bbits /= MASK_0)) then abits := fill_lsb_1(abits); bbits := fill_lsb_1(bbits); end if; -- test and adjust for 'L' and 'H' values if (bbits(0) = '1') then abits(0) := '1'; end if; if (abits(0) = '1') then bbits(0) := '1'; end if; -- get MVL values from abits, bbits. if ((abits /= MASK_0) and (abits(0) /= '1') and (bbits = MASK_0)) then result := GET_MVL_0 (abits(7),abits(6),abits(5),abits(4), abits(3),abits(2),abits(1),abits(0)); -- logic value is '0' elsif ((bbits /= MASK_0) and (bbits(0) /= '1') and (abits = MASK_0)) then result := GET_MVL_1(bbits(7),bbits(6),bbits(5),bbits(4), bbits(3),bbits(2),bbits(1),bbits(0)); elsif ((abits(1) and bbits(1) and '1') /= '0') then result := get_mvl_X(abits, bbits); -- logic value is 'X' elsif (abits(1) /= '0') then result := GET_MVL_L(abits(7),abits(6),abits(5),abits(4),abits(3), abits(2),abits(1),abits(0)); elsif (bbits(1) /= '0') then result := GET_MVL_H(bbits(7),bbits(6),bbits(5),bbits(4),bbits(3), bbits(2),bbits(1),bbits(0)); else result := 'Z'; -- logic value is 'Z' end if; return (result); end conv_strength_to_mvl; -------------------------------------------------------------------------------- -- FUNCTION : -- CONV_BITV_TO_MVLV (BIT_VAL: BIT_VECTOR) return MVL_VECTOR -- INPUT : a BIT VECTOR -- OUTPUT: an equivalent MVL VECTOR -- -- This function converts a BIT vector to a MVL vector. function conv_bitv_to_mvlv (bit_val: BIT_VECTOR) return MVL_VECTOR is variable mvl_val : MVL_VECTOR (BIT_VAL'LENGTH-1 downto 0); begin for I in bit_val'REVERSE_RANGE loop mvl_val(I) := BIT_TO_MVL(bit_val(I)); end loop; return mvl_val; end conv_bitv_to_mvlv; -------------------------------------------------------------------------------- -- PROCEDURE : -- CONV_INT_TO_MVLV (OP: IN INTEGER; RESULT: INOUT MVL_VECTOR) -- INPUT : -- OUTPUT: -- -- This function takes an Integer number and converts it to a MVL VECTOR -- containing '0' and '1's. procedure conv_int_to_mvlv (op: IN INTEGER; result: OUT MVL_VECTOR) is variable temp : INTEGER := op; variable index: INTEGER := result'LOW; -- index for the result variable neg_flag : BOOLEAN := FALSE; variable temp_result : MVL_VECTOR (result'RANGE) := FILL_MVL_VECTOR('0', RESULT'LENGTH); begin if temp < 0 then temp := temp * (-1); neg_flag := true; end if; while (temp /= 0) loop if TEMP mod 2 = 1 then temp_result(index) := '1'; else temp_result(index) := '0'; end if; temp := temp / 2; index := index + 1; end loop; if neg_flag then result := minus(temp_result); else result := temp_result; end if; end conv_int_to_mvlv; -------------------------------------------------------------------------------- -- FUNCTION : -- MVL_STRING (INPUT_VECTOR : MVL_VECTOR) return STRING -- INPUT : An MVL_VECTOR -- OUTPUT: a string representing that MVL_VECTOR. -- -- This function is called in order to use the predefined subprogram -- WRITE to display mvl values. function MVL_STRING (INPUT_VECTOR : MVL_VECTOR) return STRING is type MVL_CHAR_TYPE is array (MVL_XZ01) of CHARACTER; constant MVL_CHAR : MVL_CHAR_TYPE := ('Z','X','0','1'); variable OUT_STRING : STRING (INPUT_VECTOR'LENGTH downto 1); constant GET_01XZ_TAB : MVL_TO_MVL_TABLE := ( 'Z', 'X', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'Z', 'Z', 'Z'); begin if INPUT_VECTOR'LEFT > INPUT_VECTOR'RIGHT then for I in OUT_STRING'RANGE loop OUT_STRING (I) := MVL_CHAR(GET_01XZ_TAB(INPUT_VECTOR(INPUT_VECTOR'LOW + I -1))); end loop; else for I in OUT_STRING'REVERSE_RANGE loop OUT_STRING (I) := MVL_CHAR(GET_01XZ_TAB(INPUT_VECTOR(INPUT_VECTOR'LOW + I -1))); end loop; end if; return OUT_STRING; end MVL_STRING; -------------------------------------------------------------------------------- -- FUNCTION : -- MVL_STRING (INPUT_CHAR : MVL) return STRING -- INPUT : An MVL value -- OUTPUT: a string representing that MVL. -- -- This function is called in order to use the predefined subprogram -- WRITE to display mvl values. function MVL_STRING (INPUT_CHAR : MVL) return STRING is type MVL_CHAR_TYPE is array (MVL_XZ01) of CHARACTER; constant MVL_CHAR : MVL_CHAR_TYPE := ('Z','X','0','1'); variable OUT_STRING : STRING (1 to 1); constant GET_01XZ_TAB : MVL_TO_MVL_TABLE := ( 'Z', 'X', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'Z', 'Z', 'Z'); begin OUT_STRING (1) := MVL_CHAR(GET_01XZ_TAB(INPUT_CHAR)); return OUT_STRING; end MVL_STRING; -------------------------------------------------------------------------------- -- FUNCTION : -- align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL_VECTOR -- INPUT : a vector to be aligned and the designated size of the result -- OUTPUT: a vector of the specified size with the input value -- truncated or aligned and padded as needed. -- MVL_VECTOR is function align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL_VECTOR is variable out_mvlv : MVL_VECTOR(size -1 downto 0); variable temp_in_val : MVL_VECTOR(in_val'LENGTH -1 downto 0) := in_val; begin -- Truncate left, right justify, pad with zeros if in_val'length > size then -- Truncate left out_mvlv := temp_in_val(size -1 downto 0); else out_mvlv := fill_mvl_vector ('0', size); -- Right justify, pad with zeros out_mvlv(in_val'LENGTH - 1 downto 0) := in_val ; end if; return (out_mvlv); end align_size; -------------------------------------------------------------------------------- -- FUNCTION : -- align_size (in_val : MVL; size : INTEGER) return MVL_VECTOR -- INPUT : a mvl value to be place in a vector and the designated -- size of the result -- OUTPUT: a vector of the specified size with the input value -- truncated or aligned and padded as needed. -- function align_size (in_val : MVL; size : INTEGER) return MVL_VECTOR is variable out_mvlv : MVL_VECTOR(size-1 downto 0) := fill_mvl_vector ('0', size); begin out_mvlv(out_mvlv'LOW) := in_val; return (out_mvlv); end align_size; -------------------------------------------------------------------------------- -- FUNCTION : -- align_size (in_val : MVL; size : INTEGER) return MVL -- INPUT : An mvl value -- OUTPUT: The input value -- function align_size (in_val : MVL; size : INTEGER) return MVL is begin return (in_val); end align_size; -------------------------------------------------------------------------------- -- FUNCTION : -- align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL -- INPUT : An mvl vector. -- OUTPUT: The least significant bit of the input vector -- function align_size (in_val : MVL_VECTOR; size : INTEGER) return MVL is variable out_mvlv : MVL_VECTOR(size-1 downto 0); begin return (in_val(in_val'LOW)); end align_size; -------------------------------------------------------------------------------- -- FUNCTION : -- FILL_MVL_VECTOR (VALUE: MVL; SIZE: INTEGER) return MVL_VECTOR -- INPUT : the value to be filled, and the size of vector required -- OUTPUT: A vector of the specified size filled with the value. -- -- This function creates a MVL vector of length SIZE and fills it with -- the VALUE. function fill_mvl_vector (value: MVL; size: INTEGER) return MVL_VECTOR is variable mask: MVL_VECTOR(size-1 downto 0); begin mask := (size-1 downto 0 => value); return (mask); end fill_mvl_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- FILL_MSB_1 (ABITS: STRENGTH) return STRENGTH -- INPUT : An eight bit mvl_vector representing a strength -- OUTPUT: An eight bit mvl_vector representing a strength -- -- This function fills '1' in the positions between the MSB and -- the rightmost bit which is set to '1' e.g., 00010110 is returned -- as 11111110. function fill_msb_1 (abits: STRENGTH) return STRENGTH is variable result: STRENGTH := MASK_1; begin for I in abits'reverse_range loop if (abits(I) = '1') then return (result); -- result is ready else result(I) := '0'; -- update result end if; end loop; return (result); end fill_msb_1; -------------------------------------------------------------------------------- -- FUNCTION : -- FILL_LSB_1 (ABITS: STRENGTH) return STRENGTH -- INPUT : An eight bit mvl_vector representing a strength -- OUTPUT: An eight bit mvl_vector representing a strength -- -- This function fills '1' in the positions between the LSB and -- the rightmost bit which is set to '1' e.g., 00010100 is returned -- as 00010111 function fill_lsb_1 (abits: STRENGTH) return STRENGTH is variable result: STRENGTH; begin result := abits; -- initialize result if result = MASK_0 then return result; end if; for I in abits'REVERSE_RANGE loop if (abits(I) = '1') then return (result); -- result is ready else result(I) := '1'; -- update result end if; end loop; return (result); end fill_lsb_1; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_MVL_X (ABITS, BBITS : STRENGTH) return MVL is -- INPUT : -- OUTPUT: -- -- This function returns the MVL type corresponding to the 'X' value which -- is specified by abits and bbits. function get_mvl_X (abits, bbits : STRENGTH := "01111111") return MVL is variable index_0, index_1 : MVL_L; begin index_0 := MVL'VAL(LIMIT_X + max_pos(abits)); index_1 := MVL'VAL(LIMIT_X + max_pos(bbits)); return(GET_X_MVL(index_0, index_1)); -- second level table lookup end get_mvl_X; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_COERCED_VAL (VALUE: MVL; STRENGTH0, STRENGTH1 : STRENGTH); -- INPUT : -- OUTPUT: -- -- This procedure gets the coerced MVL value on the gate, depending on -- the value specified by the VALUE. function get_coerced_val (value: MVL; strength0, strength1: STRENGTH) return MVL is begin case (value) is when '0' => return (GET_MVL_0 (strength0(7),strength0(6),strength0(5), strength0(4),strength0(3),strength0(2), strength0(1),strength0(0))); when '1' => return (GET_MVL_1 (strength1(7),strength1(6),strength1(5), strength1(4),strength1(3),strength1(2), strength1(1),strength1(0))); when others => return (conv_strength_to_mvl(fill_lsb_1(strength0), fill_lsb_1(strength1))); end case; end get_coerced_val; -------------------------------------------------------------------------------- -- FUNCTION : -- ASSIGN_STRENGTH (IN_VECTOR: MVL_VECTOR; STRENGTH0, STRENGTH1: STRENGTH) -- INPUT : -- OUTPUT: -- -- This function is used in changing the strengths of each bit of the -- input vector to that specified by the strength0 and strength1 values. -- function assign_strength (in_vector: MVL_VECTOR; strength0, strength1: STRENGTH) return MVL_VECTOR is variable out_vector: MVL_VECTOR(in_vector'RANGE); begin for I in in_vector'RANGE loop out_vector(I) := get_coerced_val(in_vector(I), strength0, strength1); end loop; return (out_vector); end assign_strength; -------------------------------------------------------------------------------- -- FUNCTION : -- ASSIGN_DELAY (IN_VECTOR: MVL_VECTOR; D1, D2, D3: INTEGER) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function is used in selecting the delay value in a assign stat. -- Currently, the delay is picked depending on the value of the -- lsb of the in_vector. -- function assign_delay (in_vector: MVL_VECTOR; delay1, delay2, delay3: INTEGER) return INTEGER is variable val: MVL := 'X'; variable result: INTEGER := 0; begin val := GET_TERN_VAL(in_vector(in_vector'RIGHT)); result := get_delay3(delay1, delay2, delay3, val); return(result); end assign_delay; -------------------------------------------------------------------------------- -- FUNCTION : -- ASSIGN_DELAY (IN_VECTOR: MVL_VECTOR; D1, D2: INTEGER) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function is used in selecting the delay value in a assign stat. -- Currently, the delay is picked depending on the value of the -- lsb of the in_vector. (OVERLOADED) -- function assign_delay (in_vector: MVL_VECTOR; delay1, delay2: INTEGER) return INTEGER is variable val: MVL := 'X'; variable result: INTEGER := 0; begin val := GET_TERN_VAL(in_vector(in_vector'RIGHT)); result := get_delay2(delay1, delay2, val); return(result); end assign_delay; -------------------------------------------------------------------------------- -- FUNCTION : -- ASSIGN_DELAY (IN_MVL: MVL; D1, D2, D3: INTEGER) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function is used in selecting the delay value in a assign stat. -- Currently, the delay is picked depending on the value of the -- lsb of the in_vector. (OVERLOADED) -- function assign_delay (in_mvl: MVL; delay1, delay2, delay3: INTEGER) return INTEGER is variable val: MVL := 'X'; variable result: INTEGER := 0; begin val := GET_TERN_VAL(in_mvl); result := get_delay3(delay1, delay2, delay3, val); return(result); end assign_delay; -------------------------------------------------------------------------------- -- FUNCTION : -- ASSIGN_DELAY (IN_MVL: MVL; D1, D2: INTEGER) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function is used in selecting the delay value in a assign stat. -- (OVERLOADED) function assign_delay (in_mvl: MVL; delay1, delay2: INTEGER) return INTEGER is variable val: MVL := 'X'; variable result: INTEGER := 0; begin val := GET_TERN_VAL(in_mvl); result := get_delay2(delay1, delay2, val); return(result); end assign_delay; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_DELAY2 (D1, D2: INTEGER; VALUE: MVL) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function returns the appropriate delay value depending on -- the MVL VALUE. It works for 2 delays. -- RESTRICTION : It is not possible for D2 to be specified and D1 -- to remain unspecified. function get_delay2 (d1, d2: INTEGER; value: MVL) return INTEGER is begin if (d1 /= NOT_SPECIFIED) then if (d2 = NOT_SPECIFIED) then return (d1); -- use d1 for all transitions else -- both d1 and d2 are specified case (value) is when '0' => return (d2); -- fall delay when '1' => return (d1); -- rise delay when others => -- X/Z transition delay if (d1 < d2) then return (d1); else return (d2); end if; end case; end if; else -- d1 (and d2) are not specified, assume delays to be 0 return 0; end if; end get_delay2; -------------------------------------------------------------------------------- -- FUNCTION : -- GET_DELAY3 (D1, D2, D3: INTEGER; VALUE: MVL) RETURN INTEGER -- INPUT : -- OUTPUT: -- -- This function returns the appropriate delay value depending on -- the MVL VALUE. It works for 3 delays. -- RESTRICTION : Only the following combinations of delays can be specified -- (D1), (D1 and D2), (D1, D2, D3) function get_delay3 (d1, d2, d3: INTEGER; value: MVL) return INTEGER is variable temp_result: INTEGER; begin if (d1 /= NOT_SPECIFIED) then if (d2 = NOT_SPECIFIED) then return (d1); -- use d1 for all transitions else -- both d1 and d2 are specified case (value) is when '0' => return (d2); -- fall delay when '1' => return (d1); -- rise delay when 'Z' => -- 'Z' transition delay if (d3 /= NOT_SPECIFIED) then return (d3); else -- min (d1, d2) if (d1 < d2) then return (d1); else return (d2); end if; end if; when others => -- 'X' transition delay if (d1 < d2) then temp_result := d1; else temp_result := d2; end if; if (d3 /= NOT_SPECIFIED) then if (d3 < temp_result) then temp_result := d3; -- min (d1, d2, d3) end if; end if; return (temp_result); end case; end if; else -- d1 (d2 and d3) not specified, assume delays to be 0 return 0; end if; end get_delay3; -------------------------------------------------------------------------------- -- PROCEDURE : -- SYS_FINISH; -- INPUTS : none -- OUPUTS : none -- -- This procedure is used to halt simulation. It executes an assert with -- a severity failure which will stop simulation. It reports that simulation -- has been stopped by a call to $FINISH. procedure SYS_FINISH is begin assert FALSE report "Simulation Terminated By $FINISH." severity FAILURE; end SYS_FINISH; -------------------------------------------------------------------------------- -- FUNCTION : -- SYS_TIME (time_unit : time) return VLTIME -- INPUT : the desired time unit the output value will be in. -- OUTPUT: An MVL_VECTOR representing the current simulation time. -- -- This function will call the predfined function NOW to get the current -- simulation time and return a mvl_vector representing that value in -- the desired time units. function SYS_TIME (time_unit : time) return VLTIME is variable return_val : vltime; begin return_val := align_size(TO_MVLV(NOW/time_unit),64); return (return_val); end SYS_TIME; -------------------------------------------------------------------------------- -- FUNCTION : -- SYS_TIME (time_unit : time) return TIME -- INPUT : the desired time unit the output value will be in. -- OUTPUT: the current system time. -- -- This function will call the predfined function NOW to get the current -- simulation time and return a mvl_vector representing that value in -- the desired time units. function SYS_TIME (time_unit : time) return TIME is begin return (NOW); end SYS_TIME; -------------------------------------------------------------------------------- -- PROCEDURE : -- SYS_READMEMB (variable FILE_NAME: in DATA_FILE; -- DATA : inout MVL_VECTOR) -- INPUT : file to be read from -- OUTPUT : A one dimensional array of MVL that will be stored as -- one row of the memory by the calling process. -- (not to be confused with one row of the file). procedure SYS_READMEMB (variable FILE_NAME : in DATA_FILE; DATA : inout MVL_VECTOR) is variable TEMP_CHAR : MVL; procedure GET_CHAR (variable F: in DATA_FILE; RETURN_VAL : out MVL) is variable VALID_CHAR : BOOLEAN := FALSE; variable TEMP_CHAR, LAST_CHAR : CHARACTER := '~'; procedure SKIP_TO_EOL (variable F :in DATA_FILE) is variable TEMP_CHAR : CHARACTER := '~'; begin while TEMP_CHAR /= LF and not ENDFILE(FILE_NAME) loop READ (F, TEMP_CHAR); end loop; end SKIP_TO_EOL; procedure SKIP_COMMENT (variable F :in DATA_FILE) is variable TEMP_CHAR, LAST_CHAR : CHARACTER := '~'; begin while not ENDFILE(FILE_NAME) loop READ (F, TEMP_CHAR); if TEMP_CHAR = '/' and LAST_CHAR = '*' then exit; end if; LAST_CHAR := TEMP_CHAR; end loop; end SKIP_COMMENT; begin while not VALID_CHAR and not ENDFILE (FILE_NAME) loop READ (FILE_NAME, TEMP_CHAR); case TEMP_CHAR is when '0' => return_val := '0'; VALID_CHAR := TRUE; when '1' => return_val := '1'; VALID_CHAR := TRUE; when 'X' => return_val := 'X'; VALID_CHAR := TRUE; when 'Z' => return_val := 'Z'; VALID_CHAR := TRUE; when '/' => if LAST_CHAR = '/' then SKIP_TO_EOL (FILE_NAME); end if; when '*' => if LAST_CHAR = '/' then SKIP_COMMENT (FILE_NAME); end if; when others => null; end case; LAST_CHAR := TEMP_CHAR; end loop; end GET_CHAR; begin DATA := FILL_MVL_VECTOR('X',DATA'LENGTH); for I in DATA'RANGE loop GET_CHAR (FILE_NAME, TEMP_CHAR); exit when (ENDFILE (FILE_NAME)); DATA(I) := TEMP_CHAR; end loop; end SYS_READMEMB; -------------------------------------------------------------------------------- -- FUNCTION : -- max_size (op1, op2 : INTEGER) return INTEGER -- INPUT : Two integers representing the size of an array. -- OUTPUT: The greater of the two input values. -- -- Function which returns the maximum size of a two input -- parameters. It is used to constrain output arrays if -- the input arrays to a given function are of different sizes. function max_size (op1, op2 : INTEGER) return INTEGER is begin if op1 > op2 then return op1; else return op2; end if; end max_size; -------------------------------------------------------------------------------- -- FUNCTION : -- MAX_POS (OP1 : STRENGTH) return INTEGER -- INPUT : An mvl_vector representing a strength -- OUTPUT: An integer representing position of the leftmost bit of op1 -- which is set to '1' (result is between 7 and 0 ). -- function max_pos (op1 : STRENGTH) return INTEGER is variable result : INTEGER := 7; begin for I in op1'RANGE loop if op1(I) = '1' then return (result); else result := result - 1; end if; end loop; return (result); end max_pos; --############################################################################-- -- -- BODIES FOR NET RESOLUTION FUNCTIONS : -- --############################################################################-- -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog TRI (WIRE) net-type. function resolve_tri (sources: MVL_VECTOR) return MVL is variable result: MVL := 'Z'; -- default value is 'Z' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin for I in sources'RANGE loop -- if default strengths '0','1','X' or 'Z' case sources(I) is when '0' => if (result /= '0' and result /= 'Z') then result := 'X'; else result := '0'; end if; when '1' => if (result /= '1' and result /= 'Z') then result := 'X'; else result := '1'; end if; when 'X' => result := 'X'; when 'Z' => null; when others => -- the strengths have been specified, so the strength_given := TRUE; -- current result is invalid end case; end loop; if (strength_given) then -- use strength values for resolving for I in sources'RANGE loop in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); end if; return result; end resolve_tri; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRIOR (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog TRIOR (WOR) net-type. function resolve_trior (sources: MVL_VECTOR) return MVL is subtype TMP_STRENGTH_TYPE is BIT_VECTOR (6 downto 0); constant TMP_MASK_0 : TMP_STRENGTH_TYPE := "0000000"; variable TMP_STRENGTH_1, TMP_STRENGTH_2, TMP_STRENGTH_3 : tmp_strength_type := tmp_mask_0; variable result: MVL := 'Z'; -- default value is 'Z' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask, wormask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin for I in sources'RANGE loop -- if default strengths '0','1','X' or 'Z' case sources(I) is when '0' => if (result = 'Z' and result /= '1') then result := '0'; end if; when '1' => result := '1'; when 'X' => if (result /= '1') then result := 'X'; end if; when 'Z' => null; when others => -- the strengths have been specified, so the strength_given := TRUE; -- current result is invalid end case; end loop; if (strength_given) then -- use strength values for resolving for I in sources'RANGE loop in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; wormask := wormask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; wormask(0) := '0'; -- shift-left inmask once, and TMP_STRENGTH_1 := wormask(7 downto 1); TMP_STRENGTH_2 := in_mask(6 downto 0); TMP_STRENGTH_3 := TMP_STRENGTH_1 and TMP_STRENGTH_2; wormask(7 downto 1) := TMP_STRENGTH_3; end if; end loop; -- clear non-effective weak bits abits := abits and wormask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); end if; return result; end resolve_trior; -- FUNCTION : -- RESOLVE_TRIAND (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog TRIAND (WAND) net-type. function resolve_triand (sources: MVL_VECTOR) return MVL is subtype TMP_STRENGTH_TYPE is BIT_VECTOR (6 downto 0); constant TMP_MASK_0 : TMP_STRENGTH_TYPE := "0000000"; variable TMP_STRENGTH_1, TMP_STRENGTH_2, TMP_STRENGTH_3 : TMP_strength_TYPE := TMP_mask_0; variable result: MVL := 'Z'; -- default value is 'Z' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask, wandmask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin for I in sources'RANGE loop -- if default strengths '0','1','X' or 'Z' case sources(I) is when '0' => result := '0'; when '1' => if (result = 'Z' and result /= '0') then result := '1'; end if; when 'X' => if (result /= '0') then result := 'X'; end if; when 'Z' => null; when others => -- the strengths have been specified, so the strength_given := TRUE; -- current result is invalid end case; end loop; if (strength_given) then -- use strength values for resolving for I in sources'RANGE loop in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; wandmask(0) := '0'; -- shift-left inmask once, and TMP_STRENGTH_1 := wandmask(7 downto 1); TMP_STRENGTH_2 := in_mask(6 downto 0); TMP_STRENGTH_3 := TMP_STRENGTH_1 and TMP_STRENGTH_2; wandmask(7 downto 1) := TMP_STRENGTH_3(6 downto 0); end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; wandmask := wandmask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and wandmask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); end if; return result; end resolve_triand; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI0 (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog TRI0 net-type. function resolve_tri0 (sources: MVL_VECTOR) return MVL is variable result: MVL := 'Z'; -- default value is 'Z' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin for I in sources'RANGE loop -- if default strengths '0','1','X' or 'Z' case sources(I) is when '0' => if (result /= '0' and result /= 'Z') then result := 'X'; else result := '0'; end if; when '1' => if (result /= '1' and result /= 'Z') then result := 'X'; else result := '1'; end if; when 'X' => result := 'X'; when 'Z' => null; when others => -- the strengths have been specified, so the strength_given := TRUE; -- current result is invalid end case; end loop; if ((strength_given = FALSE) and (result = 'Z')) then return Pu0; end if; if (strength_given) then -- use strength values for resolving abits := PULL; -- initializations for tri0 mask := fill_msb_1(abits); for I in sources'RANGE loop in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); end if; return result; end resolve_tri0; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI1 (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog TRI1 net-type. function resolve_tri1 (sources: MVL_VECTOR) return MVL is variable result: MVL := 'Z'; -- default value is 'Z' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin for I in sources'RANGE loop -- if default strengths '0','1','X' or 'Z' case sources(I) is when '0' => if (result /= '0' and result /= 'Z') then result := 'X'; else result := '0'; end if; when '1' => if (result /= '1' and result /= 'Z') then result := 'X'; else result := '1'; end if; when 'X' => result := 'X'; when 'Z' => null; when others => -- the strengths have been specified, so the strength_given := TRUE; -- current result is invalid end case; end loop; if ((strength_given = FALSE) and (result = 'Z')) then return Pu1; end if; if (strength_given) then -- use strength values for resolving bbits := PULL; -- initializations for tri1 mask := fill_msb_1(bbits); for I in sources'RANGE loop in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); end if; return result; end resolve_tri1; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_SUPPLY0 (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog SUPPLY0 net-type. function resolve_supply0 (sources: MVL_VECTOR) return MVL is variable result: MVL := Su0; -- default value is 'Su0' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin abits := SUPPLY; -- initializations for supply0 mask := fill_msb_1(abits); for I in sources'RANGE loop -- normal resolution in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); return result; end resolve_supply0; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_SUPPLY1 (SOURCES: MVL_VECTOR) return MVL -- This function resolves as verilog SUPPLY1 net-type. function resolve_supply1 (sources: MVL_VECTOR) return MVL is variable result: MVL := Su1; -- default value is 'Su1' variable in_aval, in_bval: STRENGTH; variable abits, bbits: STRENGTH := MASK_0; variable mask, in_mask: STRENGTH := MASK_1; variable strength_given: BOOLEAN := FALSE; -- indicates if strengths -- are given explicitly (not default) begin bbits := SUPPLY; -- initializations for supply1 mask := fill_msb_1(bbits); for I in sources'RANGE loop -- normal resolution in_aval := GET_0_STRENGTH(sources(I)); in_bval := GET_1_STRENGTH(sources(I)); if (in_aval /= MASK_0) then in_mask := fill_msb_1(in_aval); mask := mask and in_mask; abits := abits or in_aval; end if; if (in_bval /= MASK_0) then in_mask := fill_msb_1(in_bval); mask := mask and in_mask; bbits := bbits or in_bval; end if; end loop; -- clear non-effective weak bits abits := abits and mask; bbits := bbits and mask; -- convert abits/bbits to MVL value result := conv_strength_to_mvl(abits, bbits); return result; end resolve_supply1; ------------------------------------------------------------------------------- -- FUNCTION : -- TRIREG (CURR_VAL : MVL; CAP_SIZE: STRENGTH) return MVL -- This function resolves the verilog TRIREG net-type. -- IT IS NOT A RESOLUTION FUNCTION. -- The CURR_VAL will be evaluated by RESOLVE_TRI function. -- The CAP_SIZE gives the charge storage strength. function trireg (curr_val : MVL; cap_size: STRENGTH := MEDIUM) return MVL is variable result: MVL := 'Z'; -- default value is 'Z' begin case (GET_TERN_VAL(curr_val)) is when '0' => case (cap_size) is when LARGE => result := La0; return(result); when SMALL => result := Sm0; return(result); when others => result := Me0; return(result); end case; when '1' => case (cap_size) is when LARGE => result := La1; return(result); when SMALL => result := Sm1; return(result); when others => result := Me1; return(result); end case; when 'Z' => return ('Z'); when others => case (cap_size) is when LARGE => result := LaX; return(result); when SMALL => result := SmX; return(result); when others => result := MeX; return(result); end case; end case; end trireg; -------------------------------------------------------------------------------- -- FUNCTION : -- TRIREG (CURR_VAL : MVL_VECTOR; CAP_SIZE: STRENGTH) return MVL_VECTOR -- This function resolves the verilog TRIREG net-type. -- IT IS NOT A RESOLUTION FUNCTION. -- The CURR_VAL will be evaluated by RESOLVE_TRI function. -- The CAP_SIZE gives the charge storage strength. function trireg (curr_val : MVL_VECTOR; cap_size: STRENGTH := MEDIUM) return MVL_VECTOR is variable result: MVL_VECTOR(curr_val'RANGE); -- set default values to 'Z's begin for I in curr_val'RANGE loop case (GET_TERN_VAL(curr_val(I))) is when '0' => case (cap_size) is when LARGE => result(I) := La0; when SMALL => result(I) := Sm0; when others => result(I) := Me0; end case; when '1' => case (cap_size) is when LARGE => result(I) := La1; when SMALL => result(I) := Sm1; when others => result(I) := Me1; end case; when 'Z' => result(I) := 'Z'; when others => case (cap_size) is when LARGE => result(I) := LaX; when SMALL => result(I) := SmX; when others => result(I) := MeX; end case; end case; end loop; return(result); end trireg; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_tri_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_tri (column); end loop; return result; end resolve_tri_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRIOR_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_trior_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_trior (column); end loop; return result; end resolve_trior_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRIAND_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_triand_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_triand (column); end loop; return result; end resolve_triand_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI1_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_tri1_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_tri1 (column); end loop; return result; end resolve_tri1_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_TRI0_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_tri0_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_tri0 (column); end loop; return result; end resolve_tri0_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_SUPPLY0_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_supply0_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_supply0 (column); end loop; return result; end resolve_supply0_vector; -------------------------------------------------------------------------------- -- FUNCTION : -- RESOLVE_SUPPLY1_VECTOR (SOURCES: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR function resolve_supply1_vector (sources: VECTOR_OF_MVL_VECTORS) return MVL_VECTOR is variable result: MVL_VECTOR(MVL_VECTOR_CONSTRAINT); variable temp_mvl_vector, subelement : MVL_VECTOR(MVL_VECTOR_CONSTRAINT) := sources(sources'LEFT); variable column : MVL_VECTOR(sources'RANGE); begin for I in subelement'RANGE loop for J in sources'RANGE loop temp_mvl_vector := sources(J); column(J) := temp_mvl_vector(I); end loop; result(I) := resolve_supply1(column); end loop; return result; end resolve_supply1_vector; end VERILOG_STD;