--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-- --!! !!-- --!! 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)