aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/synopsys
diff options
context:
space:
mode:
authorgingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7>2005-09-24 05:10:24 +0000
committergingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7>2005-09-24 05:10:24 +0000
commit977ff5e02c6d2f9bfdabcf8b4e98b81e2d83e849 (patch)
tree7bcf8e7aff40a8b54d4af83e90cccd73568e77bb /libraries/synopsys
downloadghdl-977ff5e02c6d2f9bfdabcf8b4e98b81e2d83e849.tar.gz
ghdl-977ff5e02c6d2f9bfdabcf8b4e98b81e2d83e849.tar.bz2
ghdl-977ff5e02c6d2f9bfdabcf8b4e98b81e2d83e849.zip
First import from sources
Diffstat (limited to 'libraries/synopsys')
-rw-r--r--libraries/synopsys/std_logic_arith.vhdl2391
-rw-r--r--libraries/synopsys/std_logic_misc-body.vhdl811
-rw-r--r--libraries/synopsys/std_logic_misc.vhdl170
-rw-r--r--libraries/synopsys/std_logic_signed.vhdl343
-rw-r--r--libraries/synopsys/std_logic_textio.vhdl634
-rw-r--r--libraries/synopsys/std_logic_unsigned.vhdl329
6 files changed, 4678 insertions, 0 deletions
diff --git a/libraries/synopsys/std_logic_arith.vhdl b/libraries/synopsys/std_logic_arith.vhdl
new file mode 100644
index 000000000..685b64732
--- /dev/null
+++ b/libraries/synopsys/std_logic_arith.vhdl
@@ -0,0 +1,2391 @@
+--------------------------------------------------------------------------
+-- --
+-- Copyright (c) 1990,1991,1992 by Synopsys, Inc. All rights reserved. --
+-- --
+-- This source file may be used and distributed without restriction --
+-- provided that this copyright statement is not removed from the file --
+-- and that any derivative work contains this copyright notice. --
+-- --
+-- Package name: STD_LOGIC_ARITH --
+-- --
+-- Purpose: --
+-- A set of arithemtic, conversion, and comparison functions --
+-- for SIGNED, UNSIGNED, SMALL_INT, INTEGER, --
+-- STD_ULOGIC, STD_LOGIC, and STD_LOGIC_VECTOR. --
+-- --
+--------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+
+package std_logic_arith is
+
+ type UNSIGNED is array (NATURAL range <>) of STD_LOGIC;
+ type SIGNED is array (NATURAL range <>) of STD_LOGIC;
+ subtype SMALL_INT is INTEGER range 0 to 1;
+
+ function "+"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED;
+ function "+"(L: SIGNED; R: SIGNED) return SIGNED;
+ function "+"(L: UNSIGNED; R: SIGNED) return SIGNED;
+ function "+"(L: SIGNED; R: UNSIGNED) return SIGNED;
+ function "+"(L: UNSIGNED; R: INTEGER) return UNSIGNED;
+ function "+"(L: INTEGER; R: UNSIGNED) return UNSIGNED;
+ function "+"(L: SIGNED; R: INTEGER) return SIGNED;
+ function "+"(L: INTEGER; R: SIGNED) return SIGNED;
+ function "+"(L: UNSIGNED; R: STD_ULOGIC) return UNSIGNED;
+ function "+"(L: STD_ULOGIC; R: UNSIGNED) return UNSIGNED;
+ function "+"(L: SIGNED; R: STD_ULOGIC) return SIGNED;
+ function "+"(L: STD_ULOGIC; R: SIGNED) return SIGNED;
+
+ function "+"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: UNSIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "+"(L: INTEGER; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: SIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "+"(L: INTEGER; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: UNSIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_ULOGIC; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: SIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_ULOGIC; R: SIGNED) return STD_LOGIC_VECTOR;
+
+ function "-"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED;
+ function "-"(L: SIGNED; R: SIGNED) return SIGNED;
+ function "-"(L: UNSIGNED; R: SIGNED) return SIGNED;
+ function "-"(L: SIGNED; R: UNSIGNED) return SIGNED;
+ function "-"(L: UNSIGNED; R: INTEGER) return UNSIGNED;
+ function "-"(L: INTEGER; R: UNSIGNED) return UNSIGNED;
+ function "-"(L: SIGNED; R: INTEGER) return SIGNED;
+ function "-"(L: INTEGER; R: SIGNED) return SIGNED;
+ function "-"(L: UNSIGNED; R: STD_ULOGIC) return UNSIGNED;
+ function "-"(L: STD_ULOGIC; R: UNSIGNED) return UNSIGNED;
+ function "-"(L: SIGNED; R: STD_ULOGIC) return SIGNED;
+ function "-"(L: STD_ULOGIC; R: SIGNED) return SIGNED;
+
+ function "-"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: UNSIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "-"(L: INTEGER; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: SIGNED; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "-"(L: INTEGER; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: UNSIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_ULOGIC; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: SIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_ULOGIC; R: SIGNED) return STD_LOGIC_VECTOR;
+
+ function "+"(L: UNSIGNED) return UNSIGNED;
+ function "+"(L: SIGNED) return SIGNED;
+ function "-"(L: SIGNED) return SIGNED;
+ function "ABS"(L: SIGNED) return SIGNED;
+
+ function "+"(L: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "+"(L: SIGNED) return STD_LOGIC_VECTOR;
+ function "-"(L: SIGNED) return STD_LOGIC_VECTOR;
+ function "ABS"(L: SIGNED) return STD_LOGIC_VECTOR;
+
+ function "*"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED;
+ function "*"(L: SIGNED; R: SIGNED) return SIGNED;
+ function "*"(L: SIGNED; R: UNSIGNED) return SIGNED;
+ function "*"(L: UNSIGNED; R: SIGNED) return SIGNED;
+
+ function "*"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "*"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+ function "*"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR;
+ function "*"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR;
+
+ function "<"(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function "<"(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function "<"(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function "<"(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function "<"(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function "<"(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function "<"(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function "<"(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function "<="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function "<="(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function "<="(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function "<="(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function "<="(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function "<="(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function "<="(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function "<="(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function ">"(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function ">"(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function ">"(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function ">"(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function ">"(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function ">"(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function ">"(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function ">"(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function ">="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function ">="(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function ">="(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function ">="(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function ">="(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function ">="(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function ">="(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function ">="(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function "="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function "="(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function "="(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function "="(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function "="(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function "="(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function "="(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function "="(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function "/="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN;
+ function "/="(L: SIGNED; R: SIGNED) return BOOLEAN;
+ function "/="(L: UNSIGNED; R: SIGNED) return BOOLEAN;
+ function "/="(L: SIGNED; R: UNSIGNED) return BOOLEAN;
+ function "/="(L: UNSIGNED; R: INTEGER) return BOOLEAN;
+ function "/="(L: INTEGER; R: UNSIGNED) return BOOLEAN;
+ function "/="(L: SIGNED; R: INTEGER) return BOOLEAN;
+ function "/="(L: INTEGER; R: SIGNED) return BOOLEAN;
+
+ function SHL(ARG: UNSIGNED; COUNT: UNSIGNED) return UNSIGNED;
+ function SHL(ARG: SIGNED; COUNT: UNSIGNED) return SIGNED;
+ function SHR(ARG: UNSIGNED; COUNT: UNSIGNED) return UNSIGNED;
+ function SHR(ARG: SIGNED; COUNT: UNSIGNED) return SIGNED;
+
+ function CONV_INTEGER(ARG: INTEGER) return INTEGER;
+ function CONV_INTEGER(ARG: UNSIGNED) return INTEGER;
+ function CONV_INTEGER(ARG: SIGNED) return INTEGER;
+ function CONV_INTEGER(ARG: STD_ULOGIC) return SMALL_INT;
+
+ function CONV_UNSIGNED(ARG: INTEGER; SIZE: INTEGER) return UNSIGNED;
+ function CONV_UNSIGNED(ARG: UNSIGNED; SIZE: INTEGER) return UNSIGNED;
+ function CONV_UNSIGNED(ARG: SIGNED; SIZE: INTEGER) return UNSIGNED;
+ function CONV_UNSIGNED(ARG: STD_ULOGIC; SIZE: INTEGER) return UNSIGNED;
+
+ function CONV_SIGNED(ARG: INTEGER; SIZE: INTEGER) return SIGNED;
+ function CONV_SIGNED(ARG: UNSIGNED; SIZE: INTEGER) return SIGNED;
+ function CONV_SIGNED(ARG: SIGNED; SIZE: INTEGER) return SIGNED;
+ function CONV_SIGNED(ARG: STD_ULOGIC; SIZE: INTEGER) return SIGNED;
+
+ function CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER)
+ return STD_LOGIC_VECTOR;
+ function CONV_STD_LOGIC_VECTOR(ARG: UNSIGNED; SIZE: INTEGER)
+ return STD_LOGIC_VECTOR;
+ function CONV_STD_LOGIC_VECTOR(ARG: SIGNED; SIZE: INTEGER)
+ return STD_LOGIC_VECTOR;
+ function CONV_STD_LOGIC_VECTOR(ARG: STD_ULOGIC; SIZE: INTEGER)
+ return STD_LOGIC_VECTOR;
+ -- zero extend STD_LOGIC_VECTOR (ARG) to SIZE,
+ -- SIZE < 0 is same as SIZE = 0
+ -- returns STD_LOGIC_VECTOR(SIZE-1 downto 0)
+ function EXT(ARG: STD_LOGIC_VECTOR; SIZE: INTEGER) return STD_LOGIC_VECTOR;
+
+ -- sign extend STD_LOGIC_VECTOR (ARG) to SIZE,
+ -- SIZE < 0 is same as SIZE = 0
+ -- return STD_LOGIC_VECTOR(SIZE-1 downto 0)
+ function SXT(ARG: STD_LOGIC_VECTOR; SIZE: INTEGER) return STD_LOGIC_VECTOR;
+
+end Std_logic_arith;
+
+
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+
+package body std_logic_arith is
+
+ function max(L, R: INTEGER) return INTEGER is
+ begin
+ if L > R then
+ return L;
+ else
+ return R;
+ end if;
+ end;
+
+
+ function min(L, R: INTEGER) return INTEGER is
+ begin
+ if L < R then
+ return L;
+ else
+ return R;
+ end if;
+ end;
+
+ -- synopsys synthesis_off
+ type tbl_type is array (STD_ULOGIC) of STD_ULOGIC;
+ constant tbl_BINARY : tbl_type :=
+ ('X', 'X', '0', '1', 'X', 'X', '0', '1', 'X');
+ -- synopsys synthesis_on
+
+ -- synopsys synthesis_off
+ type tbl_mvl9_boolean is array (STD_ULOGIC) of boolean;
+ constant IS_X : tbl_mvl9_boolean :=
+ (true, true, false, false, true, true, false, false, true);
+ -- synopsys synthesis_on
+
+
+
+ function MAKE_BINARY(A : STD_ULOGIC) return STD_ULOGIC is
+ -- synopsys built_in SYN_FEED_THRU
+ begin
+ -- synopsys synthesis_off
+ if (IS_X(A)) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ return ('X');
+ end if;
+ return tbl_BINARY(A);
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : UNSIGNED) return UNSIGNED is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : UNSIGNED (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : UNSIGNED) return SIGNED is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : SIGNED (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : SIGNED) return UNSIGNED is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : UNSIGNED (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : SIGNED) return SIGNED is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : SIGNED (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : STD_LOGIC_VECTOR (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : UNSIGNED) return STD_LOGIC_VECTOR is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : STD_LOGIC_VECTOR (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function MAKE_BINARY(A : SIGNED) return STD_LOGIC_VECTOR is
+ -- synopsys built_in SYN_FEED_THRU
+ variable one_bit : STD_ULOGIC;
+ variable result : STD_LOGIC_VECTOR (A'range);
+ begin
+ -- synopsys synthesis_off
+ for i in A'range loop
+ if (IS_X(A(i))) then
+ assert false
+ report "There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es)."
+ severity warning;
+ result := (others => 'X');
+ return result;
+ end if;
+ result(i) := tbl_BINARY(A(i));
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+
+ -- Type propagation function which returns a signed type with the
+ -- size of the left arg.
+ function LEFT_SIGNED_ARG(A,B: SIGNED) return SIGNED is
+ variable Z: SIGNED (A'left downto 0);
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+ -- Type propagation function which returns an unsigned type with the
+ -- size of the left arg.
+ function LEFT_UNSIGNED_ARG(A,B: UNSIGNED) return UNSIGNED is
+ variable Z: UNSIGNED (A'left downto 0);
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+ -- Type propagation function which returns a signed type with the
+ -- size of the result of a signed multiplication
+ function MULT_SIGNED_ARG(A,B: SIGNED) return SIGNED is
+ variable Z: SIGNED ((A'length+B'length-1) downto 0);
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+ -- Type propagation function which returns an unsigned type with the
+ -- size of the result of a unsigned multiplication
+ function MULT_UNSIGNED_ARG(A,B: UNSIGNED) return UNSIGNED is
+ variable Z: UNSIGNED ((A'length+B'length-1) downto 0);
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+
+
+ function mult(A,B: SIGNED) return SIGNED is
+
+ variable BA: SIGNED((A'length+B'length-1) downto 0);
+ variable PA: SIGNED((A'length+B'length-1) downto 0);
+ variable AA: SIGNED(A'length downto 0);
+ variable neg: STD_ULOGIC;
+ constant one : UNSIGNED(1 downto 0) := "01";
+
+ -- pragma map_to_operator MULT_TC_OP
+ -- pragma type_function MULT_SIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ PA := (others => 'X');
+ return(PA);
+ end if;
+ PA := (others => '0');
+ neg := B(B'left) xor A(A'left);
+ BA := CONV_SIGNED(('0' & ABS(B)),(A'length+B'length));
+ AA := '0' & ABS(A);
+ for i in integer range 0 to A'length-1 loop
+ if AA(i) = '1' then
+ PA := PA+BA;
+ end if;
+ BA := SHL(BA,one);
+ end loop;
+ if (neg= '1') then
+ return(-PA);
+ else
+ return(PA);
+ end if;
+ end;
+
+ function mult(A,B: UNSIGNED) return UNSIGNED is
+
+ variable BA: UNSIGNED((A'length+B'length-1) downto 0);
+ variable PA: UNSIGNED((A'length+B'length-1) downto 0);
+ constant one : UNSIGNED(1 downto 0) := "01";
+
+ -- pragma map_to_operator MULT_UNS_OP
+ -- pragma type_function MULT_UNSIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ PA := (others => 'X');
+ return(PA);
+ end if;
+ PA := (others => '0');
+ BA := CONV_UNSIGNED(B,(A'length+B'length));
+ for i in integer range 0 to A'length-1 loop
+ if A(i) = '1' then
+ PA := PA+BA;
+ end if;
+ BA := SHL(BA,one);
+ end loop;
+ return(PA);
+ end;
+
+ -- subtract two signed numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function minus(A, B: SIGNED) return SIGNED is
+ variable carry: STD_ULOGIC;
+ variable BV: STD_ULOGIC_VECTOR (A'left downto 0);
+ variable sum: SIGNED (A'left downto 0);
+
+ -- pragma map_to_operator SUB_TC_OP
+
+ -- pragma type_function LEFT_SIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ sum := (others => 'X');
+ return(sum);
+ end if;
+ carry := '1';
+ BV := not STD_ULOGIC_VECTOR(B);
+
+ for i in 0 to A'left loop
+ sum(i) := A(i) xor BV(i) xor carry;
+ carry := (A(i) and BV(i)) or
+ (A(i) and carry) or
+ (carry and BV(i));
+ end loop;
+ return sum;
+ end;
+
+ -- add two signed numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function plus(A, B: SIGNED) return SIGNED is
+ variable carry: STD_ULOGIC;
+ variable BV, sum: SIGNED (A'left downto 0);
+
+ -- pragma map_to_operator ADD_TC_OP
+ -- pragma type_function LEFT_SIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ sum := (others => 'X');
+ return(sum);
+ end if;
+ carry := '0';
+ BV := B;
+
+ for i in 0 to A'left loop
+ sum(i) := A(i) xor BV(i) xor carry;
+ carry := (A(i) and BV(i)) or
+ (A(i) and carry) or
+ (carry and BV(i));
+ end loop;
+ return sum;
+ end;
+
+
+ -- subtract two unsigned numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function unsigned_minus(A, B: UNSIGNED) return UNSIGNED is
+ variable carry: STD_ULOGIC;
+ variable BV: STD_ULOGIC_VECTOR (A'left downto 0);
+ variable sum: UNSIGNED (A'left downto 0);
+
+ -- pragma map_to_operator SUB_UNS_OP
+ -- pragma type_function LEFT_UNSIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ sum := (others => 'X');
+ return(sum);
+ end if;
+ carry := '1';
+ BV := not STD_ULOGIC_VECTOR(B);
+
+ for i in 0 to A'left loop
+ sum(i) := A(i) xor BV(i) xor carry;
+ carry := (A(i) and BV(i)) or
+ (A(i) and carry) or
+ (carry and BV(i));
+ end loop;
+ return sum;
+ end;
+
+ -- add two unsigned numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function unsigned_plus(A, B: UNSIGNED) return UNSIGNED is
+ variable carry: STD_ULOGIC;
+ variable BV, sum: UNSIGNED (A'left downto 0);
+
+ -- pragma map_to_operator ADD_UNS_OP
+ -- pragma type_function LEFT_UNSIGNED_ARG
+ -- pragma return_port_name Z
+
+ begin
+ if (A(A'left) = 'X' or B(B'left) = 'X') then
+ sum := (others => 'X');
+ return(sum);
+ end if;
+ carry := '0';
+ BV := B;
+
+ for i in 0 to A'left loop
+ sum(i) := A(i) xor BV(i) xor carry;
+ carry := (A(i) and BV(i)) or
+ (A(i) and carry) or
+ (carry and BV(i));
+ end loop;
+ return sum;
+ end;
+
+
+
+ function "*"(L: SIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 296
+ begin
+ return mult(CONV_SIGNED(L, L'length),
+ CONV_SIGNED(R, R'length)); -- pragma label mult
+ end;
+
+ function "*"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 295
+ begin
+ return mult(CONV_UNSIGNED(L, L'length),
+ CONV_UNSIGNED(R, R'length)); -- pragma label mult
+ end;
+
+ function "*"(L: UNSIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 297
+ begin
+ return mult(CONV_SIGNED(L, L'length+1),
+ CONV_SIGNED(R, R'length)); -- pragma label mult
+ end;
+
+ function "*"(L: SIGNED; R: UNSIGNED) return SIGNED is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 298
+ begin
+ return mult(CONV_SIGNED(L, L'length),
+ CONV_SIGNED(R, R'length+1)); -- pragma label mult
+ end;
+
+
+ function "*"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 301
+ begin
+ return STD_LOGIC_VECTOR (
+ mult(-- pragma label mult
+ CONV_SIGNED(L, L'length), CONV_SIGNED(R, R'length)));
+ end;
+
+ function "*"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 300
+ begin
+ return STD_LOGIC_VECTOR (
+ mult(-- pragma label mult
+ CONV_UNSIGNED(L, L'length), CONV_UNSIGNED(R, R'length)));
+ end;
+
+ function "*"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 302
+ begin
+ return STD_LOGIC_VECTOR (
+ mult(-- pragma label mult
+ CONV_SIGNED(L, L'length+1), CONV_SIGNED(R, R'length)));
+ end;
+
+ function "*"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ -- synopsys subpgm_id 303
+ begin
+ return STD_LOGIC_VECTOR (
+ mult(-- pragma label mult
+ CONV_SIGNED(L, L'length), CONV_SIGNED(R, R'length+1)));
+ end;
+
+
+ function "+"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 236
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_plus(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: SIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 237
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: UNSIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 238
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: SIGNED; R: UNSIGNED) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 239
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: UNSIGNED; R: INTEGER) return UNSIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 240
+ constant length: INTEGER := L'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ plus( -- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "+"(L: INTEGER; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 241
+ constant length: INTEGER := R'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ plus( -- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "+"(L: SIGNED; R: INTEGER) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 242
+ constant length: INTEGER := L'length;
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: INTEGER; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 243
+ constant length: INTEGER := R'length;
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: UNSIGNED; R: STD_ULOGIC) return UNSIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 244
+ constant length: INTEGER := L'length;
+ begin
+ return unsigned_plus(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)) ; -- pragma label plus
+ end;
+
+
+ function "+"(L: STD_ULOGIC; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 245
+ constant length: INTEGER := R'length;
+ begin
+ return unsigned_plus(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: SIGNED; R: STD_ULOGIC) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 246
+ constant length: INTEGER := L'length;
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+ function "+"(L: STD_ULOGIC; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 247
+ constant length: INTEGER := R'length;
+ begin
+ return plus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label plus
+ end;
+
+
+
+ function "+"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 260
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ unsigned_plus(-- pragma label plus
+ CONV_UNSIGNED(L, length), CONV_UNSIGNED(R, length)));
+ end;
+
+
+ function "+"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 261
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 262
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 263
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: UNSIGNED; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 264
+ constant length: INTEGER := L'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ plus( -- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "+"(L: INTEGER; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 265
+ constant length: INTEGER := R'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ plus( -- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "+"(L: SIGNED; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 266
+ constant length: INTEGER := L'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: INTEGER; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 267
+ constant length: INTEGER := R'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: UNSIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 268
+ constant length: INTEGER := L'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ unsigned_plus(-- pragma label plus
+ CONV_UNSIGNED(L, length), CONV_UNSIGNED(R, length))) ;
+ end;
+
+
+ function "+"(L: STD_ULOGIC; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 269
+ constant length: INTEGER := R'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ unsigned_plus(-- pragma label plus
+ CONV_UNSIGNED(L, length), CONV_UNSIGNED(R, length)));
+ end;
+
+
+ function "+"(L: SIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 270
+ constant length: INTEGER := L'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "+"(L: STD_ULOGIC; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ -- synopsys subpgm_id 271
+ constant length: INTEGER := R'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ plus(-- pragma label plus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+
+ function "-"(L: UNSIGNED; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 248
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_minus(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: SIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 249
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: UNSIGNED; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 250
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: SIGNED; R: UNSIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 251
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: UNSIGNED; R: INTEGER) return UNSIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 252
+ constant length: INTEGER := L'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "-"(L: INTEGER; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 253
+ constant length: INTEGER := R'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "-"(L: SIGNED; R: INTEGER) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 254
+ constant length: INTEGER := L'length;
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: INTEGER; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 255
+ constant length: INTEGER := R'length;
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: UNSIGNED; R: STD_ULOGIC) return UNSIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 256
+ constant length: INTEGER := L'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "-"(L: STD_ULOGIC; R: UNSIGNED) return UNSIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 257
+ constant length: INTEGER := R'length + 1;
+ begin
+ return CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1);
+ end;
+
+
+ function "-"(L: SIGNED; R: STD_ULOGIC) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 258
+ constant length: INTEGER := L'length;
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+ function "-"(L: STD_ULOGIC; R: SIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 259
+ constant length: INTEGER := R'length;
+ begin
+ return minus(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label minus
+ end;
+
+
+
+
+ function "-"(L: UNSIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 272
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ unsigned_minus(-- pragma label minus
+ CONV_UNSIGNED(L, length), CONV_UNSIGNED(R, length)));
+ end;
+
+
+ function "-"(L: SIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 273
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: UNSIGNED; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 274
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: SIGNED; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 275
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: UNSIGNED; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 276
+ constant length: INTEGER := L'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "-"(L: INTEGER; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 277
+ constant length: INTEGER := R'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "-"(L: SIGNED; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 278
+ constant length: INTEGER := L'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: INTEGER; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 279
+ constant length: INTEGER := R'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: UNSIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 280
+ constant length: INTEGER := L'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "-"(L: STD_ULOGIC; R: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 281
+ constant length: INTEGER := R'length + 1;
+ begin
+ return STD_LOGIC_VECTOR (CONV_UNSIGNED(
+ minus( -- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)), length-1));
+ end;
+
+
+ function "-"(L: SIGNED; R: STD_ULOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 282
+ constant length: INTEGER := L'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+ function "-"(L: STD_ULOGIC; R: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 283
+ constant length: INTEGER := R'length;
+ begin
+ return STD_LOGIC_VECTOR (
+ minus(-- pragma label minus
+ CONV_SIGNED(L, length), CONV_SIGNED(R, length)));
+ end;
+
+
+
+
+ function "+"(L: UNSIGNED) return UNSIGNED is
+ -- synopsys subpgm_id 284
+ begin
+ return L;
+ end;
+
+
+ function "+"(L: SIGNED) return SIGNED is
+ -- synopsys subpgm_id 285
+ begin
+ return L;
+ end;
+
+
+ function "-"(L: SIGNED) return SIGNED is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 286
+ begin
+ return 0 - L; -- pragma label minus
+ end;
+
+
+ function "ABS"(L: SIGNED) return SIGNED is
+ -- synopsys subpgm_id 287
+ begin
+ if (L(L'left) = '0' or L(L'left) = 'L') then
+ return L;
+ else
+ return 0 - L;
+ end if;
+ end;
+
+
+ function "+"(L: UNSIGNED) return STD_LOGIC_VECTOR is
+ -- synopsys subpgm_id 289
+ begin
+ return STD_LOGIC_VECTOR (L);
+ end;
+
+
+ function "+"(L: SIGNED) return STD_LOGIC_VECTOR is
+ -- synopsys subpgm_id 290
+ begin
+ return STD_LOGIC_VECTOR (L);
+ end;
+
+
+ function "-"(L: SIGNED) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ -- synopsys subpgm_id 292
+ variable tmp: SIGNED(L'length-1 downto 0);
+ begin
+ tmp := 0 - L; -- pragma label minus
+ return STD_LOGIC_VECTOR (tmp);
+ end;
+
+
+ function "ABS"(L: SIGNED) return STD_LOGIC_VECTOR is
+ -- synopsys subpgm_id 294
+ variable tmp: SIGNED(L'length-1 downto 0);
+ begin
+ if (L(L'left) = '0' or L(L'left) = 'L') then
+ return STD_LOGIC_VECTOR (L);
+ else
+ tmp := 0 - L;
+ return STD_LOGIC_VECTOR (tmp);
+ end if;
+ end;
+
+
+ -- Type propagation function which returns the type BOOLEAN
+ function UNSIGNED_RETURN_BOOLEAN(A,B: UNSIGNED) return BOOLEAN is
+ variable Z: BOOLEAN;
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+ -- Type propagation function which returns the type BOOLEAN
+ function SIGNED_RETURN_BOOLEAN(A,B: SIGNED) return BOOLEAN is
+ variable Z: BOOLEAN;
+ -- pragma return_port_name Z
+ begin
+ return(Z);
+ end;
+
+
+ -- compare two signed numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function is_less(A, B: SIGNED) return BOOLEAN is
+ constant sign: INTEGER := A'left;
+ variable a_is_0, b_is_1, result : boolean;
+
+ -- pragma map_to_operator LT_TC_OP
+ -- pragma type_function SIGNED_RETURN_BOOLEAN
+ -- pragma return_port_name Z
+
+ begin
+ if A(sign) /= B(sign) then
+ result := A(sign) = '1';
+ else
+ result := FALSE;
+ for i in 0 to sign-1 loop
+ a_is_0 := A(i) = '0';
+ b_is_1 := B(i) = '1';
+ result := (a_is_0 and b_is_1) or
+ (a_is_0 and result) or
+ (b_is_1 and result);
+ end loop;
+ end if;
+ return result;
+ end;
+
+
+ -- compare two signed numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function is_less_or_equal(A, B: SIGNED) return BOOLEAN is
+ constant sign: INTEGER := A'left;
+ variable a_is_0, b_is_1, result : boolean;
+
+ -- pragma map_to_operator LEQ_TC_OP
+ -- pragma type_function SIGNED_RETURN_BOOLEAN
+ -- pragma return_port_name Z
+
+ begin
+ if A(sign) /= B(sign) then
+ result := A(sign) = '1';
+ else
+ result := TRUE;
+ for i in 0 to sign-1 loop
+ a_is_0 := A(i) = '0';
+ b_is_1 := B(i) = '1';
+ result := (a_is_0 and b_is_1) or
+ (a_is_0 and result) or
+ (b_is_1 and result);
+ end loop;
+ end if;
+ return result;
+ end;
+
+
+
+ -- compare two unsigned numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function unsigned_is_less(A, B: UNSIGNED) return BOOLEAN is
+ constant sign: INTEGER := A'left;
+ variable a_is_0, b_is_1, result : boolean;
+
+ -- pragma map_to_operator LT_UNS_OP
+ -- pragma type_function UNSIGNED_RETURN_BOOLEAN
+ -- pragma return_port_name Z
+
+ begin
+ result := FALSE;
+ for i in 0 to sign loop
+ a_is_0 := A(i) = '0';
+ b_is_1 := B(i) = '1';
+ result := (a_is_0 and b_is_1) or
+ (a_is_0 and result) or
+ (b_is_1 and result);
+ end loop;
+ return result;
+ end;
+
+
+ -- compare two unsigned numbers of the same length
+ -- both arrays must have range (msb downto 0)
+ function unsigned_is_less_or_equal(A, B: UNSIGNED) return BOOLEAN is
+ constant sign: INTEGER := A'left;
+ variable a_is_0, b_is_1, result : boolean;
+
+ -- pragma map_to_operator LEQ_UNS_OP
+ -- pragma type_function UNSIGNED_RETURN_BOOLEAN
+ -- pragma return_port_name Z
+
+ begin
+ result := TRUE;
+ for i in 0 to sign loop
+ a_is_0 := A(i) = '0';
+ b_is_1 := B(i) = '1';
+ result := (a_is_0 and b_is_1) or
+ (a_is_0 and result) or
+ (b_is_1 and result);
+ end loop;
+ return result;
+ end;
+
+
+
+
+ function "<"(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 305
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_is_less(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 306
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 307
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 308
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 309
+ constant length: INTEGER := L'length + 1;
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 310
+ constant length: INTEGER := R'length + 1;
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 311
+ constant length: INTEGER := L'length;
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+ function "<"(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to lt
+ -- synopsys subpgm_id 312
+ constant length: INTEGER := R'length;
+ begin
+ return is_less(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label lt
+ end;
+
+
+
+
+ function "<="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 314
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_is_less_or_equal(CONV_UNSIGNED(L, length),
+ CONV_UNSIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 315
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 316
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 317
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 318
+ constant length: INTEGER := L'length + 1;
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 319
+ constant length: INTEGER := R'length + 1;
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 320
+ constant length: INTEGER := L'length;
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+ function "<="(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to leq
+ -- synopsys subpgm_id 321
+ constant length: INTEGER := R'length;
+ begin
+ return is_less_or_equal(CONV_SIGNED(L, length),
+ CONV_SIGNED(R, length)); -- pragma label leq
+ end;
+
+
+
+
+ function ">"(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 323
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_is_less(CONV_UNSIGNED(R, length),
+ CONV_UNSIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 324
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 325
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 326
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 327
+ constant length: INTEGER := L'length + 1;
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 328
+ constant length: INTEGER := R'length + 1;
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 329
+ constant length: INTEGER := L'length;
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+ function ">"(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to gt
+ -- synopsys subpgm_id 330
+ constant length: INTEGER := R'length;
+ begin
+ return is_less(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label gt
+ end;
+
+
+
+
+ function ">="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 332
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return unsigned_is_less_or_equal(CONV_UNSIGNED(R, length),
+ CONV_UNSIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 333
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 334
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 335
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 336
+ constant length: INTEGER := L'length + 1;
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 337
+ constant length: INTEGER := R'length + 1;
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 338
+ constant length: INTEGER := L'length;
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+ function ">="(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- pragma label_applies_to geq
+ -- synopsys subpgm_id 339
+ constant length: INTEGER := R'length;
+ begin
+ return is_less_or_equal(CONV_SIGNED(R, length),
+ CONV_SIGNED(L, length)); -- pragma label geq
+ end;
+
+
+
+
+ -- for internal use only. Assumes SIGNED arguments of equal length.
+ function bitwise_eql(L: STD_ULOGIC_VECTOR; R: STD_ULOGIC_VECTOR)
+ return BOOLEAN is
+ -- pragma built_in SYN_EQL
+ begin
+ for i in L'range loop
+ if L(i) /= R(i) then
+ return FALSE;
+ end if;
+ end loop;
+ return TRUE;
+ end;
+
+ -- for internal use only. Assumes SIGNED arguments of equal length.
+ function bitwise_neq(L: STD_ULOGIC_VECTOR; R: STD_ULOGIC_VECTOR)
+ return BOOLEAN is
+ -- pragma built_in SYN_NEQ
+ begin
+ for i in L'range loop
+ if L(i) /= R(i) then
+ return TRUE;
+ end if;
+ end loop;
+ return FALSE;
+ end;
+
+
+ function "="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 341
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_UNSIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_UNSIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 342
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 343
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 344
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- synopsys subpgm_id 345
+ constant length: INTEGER := L'length + 1;
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 346
+ constant length: INTEGER := R'length + 1;
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- synopsys subpgm_id 347
+ constant length: INTEGER := L'length;
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "="(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 348
+ constant length: INTEGER := R'length;
+ begin
+ return bitwise_eql( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+
+
+ function "/="(L: UNSIGNED; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 350
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_UNSIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_UNSIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: SIGNED; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 351
+ constant length: INTEGER := max(L'length, R'length);
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: UNSIGNED; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 352
+ constant length: INTEGER := max(L'length + 1, R'length);
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: SIGNED; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 353
+ constant length: INTEGER := max(L'length, R'length + 1);
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: UNSIGNED; R: INTEGER) return BOOLEAN is
+ -- synopsys subpgm_id 354
+ constant length: INTEGER := L'length + 1;
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: INTEGER; R: UNSIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 355
+ constant length: INTEGER := R'length + 1;
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: SIGNED; R: INTEGER) return BOOLEAN is
+ -- synopsys subpgm_id 356
+ constant length: INTEGER := L'length;
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+ function "/="(L: INTEGER; R: SIGNED) return BOOLEAN is
+ -- synopsys subpgm_id 357
+ constant length: INTEGER := R'length;
+ begin
+ return bitwise_neq( STD_ULOGIC_VECTOR( CONV_SIGNED(L, length) ),
+ STD_ULOGIC_VECTOR( CONV_SIGNED(R, length) ) );
+ end;
+
+
+
+ function SHL(ARG: UNSIGNED; COUNT: UNSIGNED) return UNSIGNED is
+ -- synopsys subpgm_id 358
+ constant control_msb: INTEGER := COUNT'length - 1;
+ variable control: UNSIGNED (control_msb downto 0);
+ constant result_msb: INTEGER := ARG'length-1;
+ subtype rtype is UNSIGNED (result_msb downto 0);
+ variable result, temp: rtype;
+ begin
+ control := MAKE_BINARY(COUNT);
+ -- synopsys synthesis_off
+ if (control(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ -- synopsys synthesis_on
+ result := ARG;
+ for i in 0 to control_msb loop
+ if control(i) = '1' then
+ temp := rtype'(others => '0');
+ if 2**i <= result_msb then
+ temp(result_msb downto 2**i) :=
+ result(result_msb - 2**i downto 0);
+ end if;
+ result := temp;
+ end if;
+ end loop;
+ return result;
+ end;
+
+ function SHL(ARG: SIGNED; COUNT: UNSIGNED) return SIGNED is
+ -- synopsys subpgm_id 359
+ constant control_msb: INTEGER := COUNT'length - 1;
+ variable control: UNSIGNED (control_msb downto 0);
+ constant result_msb: INTEGER := ARG'length-1;
+ subtype rtype is SIGNED (result_msb downto 0);
+ variable result, temp: rtype;
+ begin
+ control := MAKE_BINARY(COUNT);
+ -- synopsys synthesis_off
+ if (control(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ -- synopsys synthesis_on
+ result := ARG;
+ for i in 0 to control_msb loop
+ if control(i) = '1' then
+ temp := rtype'(others => '0');
+ if 2**i <= result_msb then
+ temp(result_msb downto 2**i) :=
+ result(result_msb - 2**i downto 0);
+ end if;
+ result := temp;
+ end if;
+ end loop;
+ return result;
+ end;
+
+
+ function SHR(ARG: UNSIGNED; COUNT: UNSIGNED) return UNSIGNED is
+ -- synopsys subpgm_id 360
+ constant control_msb: INTEGER := COUNT'length - 1;
+ variable control: UNSIGNED (control_msb downto 0);
+ constant result_msb: INTEGER := ARG'length-1;
+ subtype rtype is UNSIGNED (result_msb downto 0);
+ variable result, temp: rtype;
+ begin
+ control := MAKE_BINARY(COUNT);
+ -- synopsys synthesis_off
+ if (control(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ -- synopsys synthesis_on
+ result := ARG;
+ for i in 0 to control_msb loop
+ if control(i) = '1' then
+ temp := rtype'(others => '0');
+ if 2**i <= result_msb then
+ temp(result_msb - 2**i downto 0) :=
+ result(result_msb downto 2**i);
+ end if;
+ result := temp;
+ end if;
+ end loop;
+ return result;
+ end;
+
+ function SHR(ARG: SIGNED; COUNT: UNSIGNED) return SIGNED is
+ -- synopsys subpgm_id 361
+ constant control_msb: INTEGER := COUNT'length - 1;
+ variable control: UNSIGNED (control_msb downto 0);
+ constant result_msb: INTEGER := ARG'length-1;
+ subtype rtype is SIGNED (result_msb downto 0);
+ variable result, temp: rtype;
+ variable sign_bit: STD_ULOGIC;
+ begin
+ control := MAKE_BINARY(COUNT);
+ -- synopsys synthesis_off
+ if (control(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ -- synopsys synthesis_on
+ result := ARG;
+ sign_bit := ARG(ARG'left);
+ for i in 0 to control_msb loop
+ if control(i) = '1' then
+ temp := rtype'(others => sign_bit);
+ if 2**i <= result_msb then
+ temp(result_msb - 2**i downto 0) :=
+ result(result_msb downto 2**i);
+ end if;
+ result := temp;
+ end if;
+ end loop;
+ return result;
+ end;
+
+
+
+
+ function CONV_INTEGER(ARG: INTEGER) return INTEGER is
+ -- synopsys subpgm_id 365
+ begin
+ return ARG;
+ end;
+
+ function CONV_INTEGER(ARG: UNSIGNED) return INTEGER is
+ variable result: INTEGER;
+ variable tmp: STD_ULOGIC;
+ -- synopsys built_in SYN_UNSIGNED_TO_INTEGER
+ -- synopsys subpgm_id 366
+ begin
+ -- synopsys synthesis_off
+ assert ARG'length <= 31
+ report "ARG is too large in CONV_INTEGER"
+ severity FAILURE;
+ result := 0;
+ for i in ARG'range loop
+ result := result * 2;
+ tmp := tbl_BINARY(ARG(i));
+ if tmp = '1' then
+ result := result + 1;
+ elsif tmp = 'X' then
+ assert false
+ report "CONV_INTEGER: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, and it has been converted to 0."
+ severity WARNING;
+ end if;
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_INTEGER(ARG: SIGNED) return INTEGER is
+ variable result: INTEGER;
+ variable tmp: STD_ULOGIC;
+ -- synopsys built_in SYN_SIGNED_TO_INTEGER
+ -- synopsys subpgm_id 367
+ begin
+ -- synopsys synthesis_off
+ assert ARG'length <= 32
+ report "ARG is too large in CONV_INTEGER"
+ severity FAILURE;
+ result := 0;
+ for i in ARG'range loop
+ if i /= ARG'left then
+ result := result * 2;
+ tmp := tbl_BINARY(ARG(i));
+ if tmp = '1' then
+ result := result + 1;
+ elsif tmp = 'X' then
+ assert false
+ report "CONV_INTEGER: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, and it has been converted to 0."
+ severity WARNING;
+ end if;
+ end if;
+ end loop;
+ tmp := MAKE_BINARY(ARG(ARG'left));
+ if tmp = '1' then
+ if ARG'length = 32 then
+ result := (result - 2**30) - 2**30;
+ else
+ result := result - (2 ** (ARG'length-1));
+ end if;
+ end if;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_INTEGER(ARG: STD_ULOGIC) return SMALL_INT is
+ variable tmp: STD_ULOGIC;
+ -- synopsys built_in SYN_FEED_THRU
+ -- synopsys subpgm_id 370
+ begin
+ -- synopsys synthesis_off
+ tmp := tbl_BINARY(ARG);
+ if tmp = '1' then
+ return 1;
+ elsif tmp = 'X' then
+ assert false
+ report "CONV_INTEGER: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, and it has been converted to 0."
+ severity WARNING;
+ return 0;
+ else
+ return 0;
+ end if;
+ -- synopsys synthesis_on
+ end;
+
+
+ -- convert an integer to a unsigned STD_ULOGIC_VECTOR
+ function CONV_UNSIGNED(ARG: INTEGER; SIZE: INTEGER) return UNSIGNED is
+ variable result: UNSIGNED(SIZE-1 downto 0);
+ variable temp: integer;
+ -- synopsys built_in SYN_INTEGER_TO_UNSIGNED
+ -- synopsys subpgm_id 371
+ begin
+ -- synopsys synthesis_off
+ temp := ARG;
+ for i in 0 to SIZE-1 loop
+ if (temp mod 2) = 1 then
+ result(i) := '1';
+ else
+ result(i) := '0';
+ end if;
+ if temp > 0 then
+ temp := temp / 2;
+ else
+ temp := (temp - 1) / 2; -- simulate ASR
+ end if;
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_UNSIGNED(ARG: UNSIGNED; SIZE: INTEGER) return UNSIGNED is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is UNSIGNED (SIZE-1 downto 0);
+ variable new_bounds: UNSIGNED (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 372
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => '0');
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_UNSIGNED(ARG: SIGNED; SIZE: INTEGER) return UNSIGNED is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is UNSIGNED (SIZE-1 downto 0);
+ variable new_bounds: UNSIGNED (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_SIGN_EXTEND
+ -- synopsys subpgm_id 373
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => new_bounds(new_bounds'left));
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_UNSIGNED(ARG: STD_ULOGIC; SIZE: INTEGER) return UNSIGNED is
+ subtype rtype is UNSIGNED (SIZE-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 375
+ begin
+ -- synopsys synthesis_off
+ result := rtype'(others => '0');
+ result(0) := MAKE_BINARY(ARG);
+ if (result(0) = 'X') then
+ result := rtype'(others => 'X');
+ end if;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ -- convert an integer to a 2's complement STD_ULOGIC_VECTOR
+ function CONV_SIGNED(ARG: INTEGER; SIZE: INTEGER) return SIGNED is
+ variable result: SIGNED (SIZE-1 downto 0);
+ variable temp: integer;
+ -- synopsys built_in SYN_INTEGER_TO_SIGNED
+ -- synopsys subpgm_id 376
+ begin
+ -- synopsys synthesis_off
+ temp := ARG;
+ for i in 0 to SIZE-1 loop
+ if (temp mod 2) = 1 then
+ result(i) := '1';
+ else
+ result(i) := '0';
+ end if;
+ if temp > 0 then
+ temp := temp / 2;
+ elsif (temp > integer'low) then
+ temp := (temp - 1) / 2; -- simulate ASR
+ else
+ temp := temp / 2; -- simulate ASR
+ end if;
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_SIGNED(ARG: UNSIGNED; SIZE: INTEGER) return SIGNED is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is SIGNED (SIZE-1 downto 0);
+ variable new_bounds : SIGNED (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 377
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => '0');
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function CONV_SIGNED(ARG: SIGNED; SIZE: INTEGER) return SIGNED is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is SIGNED (SIZE-1 downto 0);
+ variable new_bounds : SIGNED (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_SIGN_EXTEND
+ -- synopsys subpgm_id 378
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => new_bounds(new_bounds'left));
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_SIGNED(ARG: STD_ULOGIC; SIZE: INTEGER) return SIGNED is
+ subtype rtype is SIGNED (SIZE-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 380
+ begin
+ -- synopsys synthesis_off
+ result := rtype'(others => '0');
+ result(0) := MAKE_BINARY(ARG);
+ if (result(0) = 'X') then
+ result := rtype'(others => 'X');
+ end if;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ -- convert an integer to an STD_LOGIC_VECTOR
+ function CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ variable result: STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable temp: integer;
+ -- synopsys built_in SYN_INTEGER_TO_SIGNED
+ -- synopsys subpgm_id 381
+ begin
+ -- synopsys synthesis_off
+ temp := ARG;
+ for i in 0 to SIZE-1 loop
+ if (temp mod 2) = 1 then
+ result(i) := '1';
+ else
+ result(i) := '0';
+ end if;
+ if temp > 0 then
+ temp := temp / 2;
+ elsif (temp > integer'low) then
+ temp := (temp - 1) / 2; -- simulate ASR
+ else
+ temp := temp / 2; -- simulate ASR
+ end if;
+ end loop;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_STD_LOGIC_VECTOR(ARG: UNSIGNED; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable new_bounds : STD_LOGIC_VECTOR (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 382
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => '0');
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function CONV_STD_LOGIC_VECTOR(ARG: SIGNED; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable new_bounds : STD_LOGIC_VECTOR (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_SIGN_EXTEND
+ -- synopsys subpgm_id 383
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => new_bounds(new_bounds'left));
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function CONV_STD_LOGIC_VECTOR(ARG: STD_ULOGIC; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ subtype rtype is STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 384
+ begin
+ -- synopsys synthesis_off
+ result := rtype'(others => '0');
+ result(0) := MAKE_BINARY(ARG);
+ if (result(0) = 'X') then
+ result := rtype'(others => 'X');
+ end if;
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+ function EXT(ARG: STD_LOGIC_VECTOR; SIZE: INTEGER)
+ return STD_LOGIC_VECTOR is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable new_bounds: STD_LOGIC_VECTOR (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_ZERO_EXTEND
+ -- synopsys subpgm_id 385
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => '0');
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+ function SXT(ARG: STD_LOGIC_VECTOR; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ constant msb: INTEGER := min(ARG'length, SIZE) - 1;
+ subtype rtype is STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ variable new_bounds : STD_LOGIC_VECTOR (ARG'length-1 downto 0);
+ variable result: rtype;
+ -- synopsys built_in SYN_SIGN_EXTEND
+ -- synopsys subpgm_id 386
+ begin
+ -- synopsys synthesis_off
+ new_bounds := MAKE_BINARY(ARG);
+ if (new_bounds(0) = 'X') then
+ result := rtype'(others => 'X');
+ return result;
+ end if;
+ result := rtype'(others => new_bounds(new_bounds'left));
+ result(msb downto 0) := new_bounds(msb downto 0);
+ return result;
+ -- synopsys synthesis_on
+ end;
+
+
+end std_logic_arith;
diff --git a/libraries/synopsys/std_logic_misc-body.vhdl b/libraries/synopsys/std_logic_misc-body.vhdl
new file mode 100644
index 000000000..531328c3f
--- /dev/null
+++ b/libraries/synopsys/std_logic_misc-body.vhdl
@@ -0,0 +1,811 @@
+--------------------------------------------------------------------------
+--
+-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc. All rights reserved.
+--
+-- This source file may be used and distributed without restriction
+-- provided that this copyright statement is not removed from the file
+-- and that any derivative work contains this copyright notice.
+--
+-- Package name: std_logic_misc
+--
+-- Purpose: This package defines supplemental types, subtypes,
+-- constants, and functions for the Std_logic_1164 Package.
+--
+-- Author: GWH
+--
+--------------------------------------------------------------------------
+
+package body std_logic_misc is
+
+--synopsys synthesis_off
+
+ type STRN_STD_ULOGIC_TABLE is array (STD_ULOGIC,STRENGTH) of STD_ULOGIC;
+
+ --------------------------------------------------------------------
+ --
+ -- Truth tables for output strength --> STD_ULOGIC lookup
+ --
+ --------------------------------------------------------------------
+
+ -- truth table for output strength --> STD_ULOGIC lookup
+ constant tbl_STRN_STD_ULOGIC: STRN_STD_ULOGIC_TABLE :=
+ -- ------------------------------------------------------------------
+ -- | X01 X0H XL1 X0Z XZ1 WLH WLZ WZH W0H WL1 | strn/ output|
+ -- ------------------------------------------------------------------
+ (('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U'), -- | U |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W'), -- | X |
+ ('0', '0', 'L', '0', 'Z', 'L', 'L', 'Z', '0', 'L'), -- | 0 |
+ ('1', 'H', '1', 'Z', '1', 'H', 'Z', 'H', 'H', '1'), -- | 1 |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W'), -- | Z |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W'), -- | W |
+ ('0', '0', 'L', '0', 'Z', 'L', 'L', 'Z', '0', 'L'), -- | L |
+ ('1', 'H', '1', 'Z', '1', 'H', 'Z', 'H', 'H', '1'), -- | H |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W')); -- | - |
+
+
+
+ --------------------------------------------------------------------
+ --
+ -- Truth tables for strength --> STD_ULOGIC mapping ('Z' pass through)
+ --
+ --------------------------------------------------------------------
+
+ -- truth table for output strength --> STD_ULOGIC lookup
+ constant tbl_STRN_STD_ULOGIC_Z: STRN_STD_ULOGIC_TABLE :=
+ -- ------------------------------------------------------------------
+ -- | X01 X0H XL1 X0Z XZ1 WLH WLZ WZH W0H WL1 | strn/ output|
+ -- ------------------------------------------------------------------
+ (('U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U'), -- | U |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W'), -- | X |
+ ('0', '0', 'L', '0', 'Z', 'L', 'L', 'Z', '0', 'L'), -- | 0 |
+ ('1', 'H', '1', 'Z', '1', 'H', 'Z', 'H', 'H', '1'), -- | 1 |
+ ('Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z', 'Z'), -- | Z |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W'), -- | W |
+ ('0', '0', 'L', '0', 'Z', 'L', 'L', 'Z', '0', 'L'), -- | L |
+ ('1', 'H', '1', 'Z', '1', 'H', 'Z', 'H', 'H', '1'), -- | H |
+ ('X', 'X', 'X', 'X', 'X', 'W', 'W', 'W', 'W', 'W')); -- | - |
+
+
+
+ ---------------------------------------------------------------------
+ --
+ -- functions for mapping the STD_(U)LOGIC according to STRENGTH
+ --
+ ---------------------------------------------------------------------
+
+ function strength_map(input: STD_ULOGIC; strn: STRENGTH) return STD_LOGIC is
+ -- pragma subpgm_id 387
+ begin
+ return tbl_STRN_STD_ULOGIC(input, strn);
+ end strength_map;
+
+
+ function strength_map_z(input:STD_ULOGIC; strn:STRENGTH) return STD_LOGIC is
+ -- pragma subpgm_id 388
+ begin
+ return tbl_STRN_STD_ULOGIC_Z(input, strn);
+ end strength_map_z;
+
+
+ ---------------------------------------------------------------------
+ --
+ -- conversion functions for STD_LOGIC_VECTOR and STD_ULOGIC_VECTOR
+ --
+ ---------------------------------------------------------------------
+
+--synopsys synthesis_on
+ function Drive (V: STD_LOGIC_VECTOR) return STD_ULOGIC_VECTOR is
+ -- pragma built_in SYN_FEED_THRU
+ -- pragma subpgm_id 389
+--synopsys synthesis_off
+ alias Value: STD_LOGIC_VECTOR (V'length-1 downto 0) is V;
+--synopsys synthesis_on
+ begin
+--synopsys synthesis_off
+ return STD_ULOGIC_VECTOR(Value);
+--synopsys synthesis_on
+ end Drive;
+
+
+ function Drive (V: STD_ULOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma built_in SYN_FEED_THRU
+ -- pragma subpgm_id 390
+--synopsys synthesis_off
+ alias Value: STD_ULOGIC_VECTOR (V'length-1 downto 0) is V;
+--synopsys synthesis_on
+ begin
+--synopsys synthesis_off
+ return STD_LOGIC_VECTOR(Value);
+--synopsys synthesis_on
+ end Drive;
+--synopsys synthesis_off
+
+
+ ---------------------------------------------------------------------
+ --
+ -- conversion functions for sensing various types
+ --
+ -- (the second argument allows the user to specify the value to
+ -- be returned when the network is undriven)
+ --
+ ---------------------------------------------------------------------
+
+ function Sense (V: STD_ULOGIC; vZ, vU, vDC: STD_ULOGIC)
+ return STD_LOGIC is
+ -- pragma subpgm_id 391
+ begin
+ if V = 'Z' then
+ return vZ;
+ elsif V = 'U' then
+ return vU;
+ elsif V = '-' then
+ return vDC;
+ else
+ return V;
+ end if;
+ end Sense;
+
+
+ function Sense (V: STD_ULOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_LOGIC_VECTOR is
+ -- pragma subpgm_id 392
+ alias Value: STD_ULOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: STD_LOGIC_VECTOR (V'length-1 downto 0);
+ begin
+ for i in Value'range loop
+ if ( Value(i) = 'Z' ) then
+ Result(i) := vZ;
+ elsif Value(i) = 'U' then
+ Result(i) := vU;
+ elsif Value(i) = '-' then
+ Result(i) := vDC;
+ else
+ Result(i) := Value(i);
+ end if;
+ end loop;
+ return Result;
+ end Sense;
+
+
+ function Sense (V: STD_ULOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_ULOGIC_VECTOR is
+ -- pragma subpgm_id 393
+ alias Value: STD_ULOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: STD_ULOGIC_VECTOR (V'length-1 downto 0);
+ begin
+ for i in Value'range loop
+ if ( Value(i) = 'Z' ) then
+ Result(i) := vZ;
+ elsif Value(i) = 'U' then
+ Result(i) := vU;
+ elsif Value(i) = '-' then
+ Result(i) := vDC;
+ else
+ Result(i) := Value(i);
+ end if;
+ end loop;
+ return Result;
+ end Sense;
+
+
+ function Sense (V: STD_LOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_LOGIC_VECTOR is
+ -- pragma subpgm_id 394
+ alias Value: STD_LOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: STD_LOGIC_VECTOR (V'length-1 downto 0);
+ begin
+ for i in Value'range loop
+ if ( Value(i) = 'Z' ) then
+ Result(i) := vZ;
+ elsif Value(i) = 'U' then
+ Result(i) := vU;
+ elsif Value(i) = '-' then
+ Result(i) := vDC;
+ else
+ Result(i) := Value(i);
+ end if;
+ end loop;
+ return Result;
+ end Sense;
+
+
+ function Sense (V: STD_LOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_ULOGIC_VECTOR is
+ -- pragma subpgm_id 395
+ alias Value: STD_LOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: STD_ULOGIC_VECTOR (V'length-1 downto 0);
+ begin
+ for i in Value'range loop
+ if ( Value(i) = 'Z' ) then
+ Result(i) := vZ;
+ elsif Value(i) = 'U' then
+ Result(i) := vU;
+ elsif Value(i) = '-' then
+ Result(i) := vDC;
+ else
+ Result(i) := Value(i);
+ end if;
+ end loop;
+ return Result;
+ end Sense;
+
+ ---------------------------------------------------------------------
+ --
+ -- Function: STD_LOGIC_VECTORtoBIT_VECTOR
+ --
+ -- Purpose: Conversion fun. from STD_LOGIC_VECTOR to BIT_VECTOR
+ --
+ -- Mapping: 0, L --> 0
+ -- 1, H --> 1
+ -- X, W --> vX if Xflag is TRUE
+ -- X, W --> 0 if Xflag is FALSE
+ -- Z --> vZ if Zflag is TRUE
+ -- Z --> 0 if Zflag is FALSE
+ -- U --> vU if Uflag is TRUE
+ -- U --> 0 if Uflag is FALSE
+ -- - --> vDC if DCflag is TRUE
+ -- - --> 0 if DCflag is FALSE
+ --
+ ---------------------------------------------------------------------
+
+--synopsys synthesis_on
+ function STD_LOGIC_VECTORtoBIT_VECTOR (V: STD_LOGIC_VECTOR
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT_VECTOR is
+ -- pragma built_in SYN_FEED_THRU
+ -- pragma subpgm_id 396
+--synopsys synthesis_off
+ alias Value: STD_LOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: BIT_VECTOR (V'length-1 downto 0);
+--synopsys synthesis_on
+ begin
+--synopsys synthesis_off
+ for i in Value'range loop
+ case Value(i) is
+ when '0' | 'L' =>
+ Result(i) := '0';
+ when '1' | 'H' =>
+ Result(i) := '1';
+ when 'X' =>
+ if ( Xflag ) then
+ Result(i) := vX;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_LOGIC_VECTORtoBIT_VECTOR: X --> 0"
+ severity WARNING;
+ end if;
+ when 'W' =>
+ if ( Xflag ) then
+ Result(i) := vX;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_LOGIC_VECTORtoBIT_VECTOR: W --> 0"
+ severity WARNING;
+ end if;
+ when 'Z' =>
+ if ( Zflag ) then
+ Result(i) := vZ;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_LOGIC_VECTORtoBIT_VECTOR: Z --> 0"
+ severity WARNING;
+ end if;
+ when 'U' =>
+ if ( Uflag ) then
+ Result(i) := vU;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_LOGIC_VECTORtoBIT_VECTOR: U --> 0"
+ severity WARNING;
+ end if;
+ when '-' =>
+ if ( DCflag ) then
+ Result(i) := vDC;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_LOGIC_VECTORtoBIT_VECTOR: - --> 0"
+ severity WARNING;
+ end if;
+ end case;
+ end loop;
+ return Result;
+--synopsys synthesis_on
+ end STD_LOGIC_VECTORtoBIT_VECTOR;
+
+
+
+
+ ---------------------------------------------------------------------
+ --
+ -- Function: STD_ULOGIC_VECTORtoBIT_VECTOR
+ --
+ -- Purpose: Conversion fun. from STD_ULOGIC_VECTOR to BIT_VECTOR
+ --
+ -- Mapping: 0, L --> 0
+ -- 1, H --> 1
+ -- X, W --> vX if Xflag is TRUE
+ -- X, W --> 0 if Xflag is FALSE
+ -- Z --> vZ if Zflag is TRUE
+ -- Z --> 0 if Zflag is FALSE
+ -- U --> vU if Uflag is TRUE
+ -- U --> 0 if Uflag is FALSE
+ -- - --> vDC if DCflag is TRUE
+ -- - --> 0 if DCflag is FALSE
+ --
+ ---------------------------------------------------------------------
+
+ function STD_ULOGIC_VECTORtoBIT_VECTOR (V: STD_ULOGIC_VECTOR
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT_VECTOR is
+ -- pragma built_in SYN_FEED_THRU
+ -- pragma subpgm_id 397
+--synopsys synthesis_off
+ alias Value: STD_ULOGIC_VECTOR (V'length-1 downto 0) is V;
+ variable Result: BIT_VECTOR (V'length-1 downto 0);
+--synopsys synthesis_on
+ begin
+--synopsys synthesis_off
+ for i in Value'range loop
+ case Value(i) is
+ when '0' | 'L' =>
+ Result(i) := '0';
+ when '1' | 'H' =>
+ Result(i) := '1';
+ when 'X' =>
+ if ( Xflag ) then
+ Result(i) := vX;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_ULOGIC_VECTORtoBIT_VECTOR: X --> 0"
+ severity WARNING;
+ end if;
+ when 'W' =>
+ if ( Xflag ) then
+ Result(i) := vX;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_ULOGIC_VECTORtoBIT_VECTOR: W --> 0"
+ severity WARNING;
+ end if;
+ when 'Z' =>
+ if ( Zflag ) then
+ Result(i) := vZ;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_ULOGIC_VECTORtoBIT_VECTOR: Z --> 0"
+ severity WARNING;
+ end if;
+ when 'U' =>
+ if ( Uflag ) then
+ Result(i) := vU;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_ULOGIC_VECTORtoBIT_VECTOR: U --> 0"
+ severity WARNING;
+ end if;
+ when '-' =>
+ if ( DCflag ) then
+ Result(i) := vDC;
+ else
+ Result(i) := '0';
+ assert FALSE
+ report "STD_ULOGIC_VECTORtoBIT_VECTOR: - --> 0"
+ severity WARNING;
+ end if;
+ end case;
+ end loop;
+ return Result;
+--synopsys synthesis_on
+ end STD_ULOGIC_VECTORtoBIT_VECTOR;
+
+
+
+
+ ---------------------------------------------------------------------
+ --
+ -- Function: STD_ULOGICtoBIT
+ --
+ -- Purpose: Conversion function from STD_ULOGIC to BIT
+ --
+ -- Mapping: 0, L --> 0
+ -- 1, H --> 1
+ -- X, W --> vX if Xflag is TRUE
+ -- X, W --> 0 if Xflag is FALSE
+ -- Z --> vZ if Zflag is TRUE
+ -- Z --> 0 if Zflag is FALSE
+ -- U --> vU if Uflag is TRUE
+ -- U --> 0 if Uflag is FALSE
+ -- - --> vDC if DCflag is TRUE
+ -- - --> 0 if DCflag is FALSE
+ --
+ ---------------------------------------------------------------------
+
+ function STD_ULOGICtoBIT (V: STD_ULOGIC
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT is
+ -- pragma built_in SYN_FEED_THRU
+ -- pragma subpgm_id 398
+ variable Result: BIT;
+ begin
+--synopsys synthesis_off
+ case V is
+ when '0' | 'L' =>
+ Result := '0';
+ when '1' | 'H' =>
+ Result := '1';
+ when 'X' =>
+ if ( Xflag ) then
+ Result := vX;
+ else
+ Result := '0';
+ assert FALSE
+ report "STD_ULOGICtoBIT: X --> 0"
+ severity WARNING;
+ end if;
+ when 'W' =>
+ if ( Xflag ) then
+ Result := vX;
+ else
+ Result := '0';
+ assert FALSE
+ report "STD_ULOGICtoBIT: W --> 0"
+ severity WARNING;
+ end if;
+ when 'Z' =>
+ if ( Zflag ) then
+ Result := vZ;
+ else
+ Result := '0';
+ assert FALSE
+ report "STD_ULOGICtoBIT: Z --> 0"
+ severity WARNING;
+ end if;
+ when 'U' =>
+ if ( Uflag ) then
+ Result := vU;
+ else
+ Result := '0';
+ assert FALSE
+ report "STD_ULOGICtoBIT: U --> 0"
+ severity WARNING;
+ end if;
+ when '-' =>
+ if ( DCflag ) then
+ Result := vDC;
+ else
+ Result := '0';
+ assert FALSE
+ report "STD_ULOGICtoBIT: - --> 0"
+ severity WARNING;
+ end if;
+ end case;
+ return Result;
+--synopsys synthesis_on
+ end STD_ULOGICtoBIT;
+
+
+ --------------------------------------------------------------------------
+
+ function AND_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 399
+ variable result: STD_LOGIC;
+ begin
+ result := '1';
+ for i in ARG'range loop
+ result := result and ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function NAND_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 400
+ begin
+ return not AND_REDUCE(ARG);
+ end;
+
+ function OR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 401
+ variable result: STD_LOGIC;
+ begin
+ result := '0';
+ for i in ARG'range loop
+ result := result or ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function NOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 402
+ begin
+ return not OR_REDUCE(ARG);
+ end;
+
+ function XOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 403
+ variable result: STD_LOGIC;
+ begin
+ result := '0';
+ for i in ARG'range loop
+ result := result xor ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function XNOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 404
+ begin
+ return not XOR_REDUCE(ARG);
+ end;
+
+ function AND_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 405
+ variable result: STD_LOGIC;
+ begin
+ result := '1';
+ for i in ARG'range loop
+ result := result and ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function NAND_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 406
+ begin
+ return not AND_REDUCE(ARG);
+ end;
+
+ function OR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 407
+ variable result: STD_LOGIC;
+ begin
+ result := '0';
+ for i in ARG'range loop
+ result := result or ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function NOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 408
+ begin
+ return not OR_REDUCE(ARG);
+ end;
+
+ function XOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 409
+ variable result: STD_LOGIC;
+ begin
+ result := '0';
+ for i in ARG'range loop
+ result := result xor ARG(i);
+ end loop;
+ return result;
+ end;
+
+ function XNOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01 is
+ -- pragma subpgm_id 410
+ begin
+ return not XOR_REDUCE(ARG);
+ end;
+
+--synopsys synthesis_off
+
+ function fun_BUF3S(Input, Enable: UX01; Strn: STRENGTH) return STD_LOGIC is
+ -- pragma subpgm_id 411
+ type TRISTATE_TABLE is array(STRENGTH, UX01, UX01) of STD_LOGIC;
+
+ -- truth table for tristate "buf" function (Enable active Low)
+ constant tbl_BUF3S: TRISTATE_TABLE :=
+ -- ----------------------------------------------------
+ -- | Input U X 0 1 | Enable Strength |
+ -- ---------------------------------|-----------------|
+ ((('U', 'U', 'U', 'U'), --| U X01 |
+ ('U', 'X', 'X', 'X'), --| X X01 |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 X01 |
+ ('U', 'X', '0', '1')), --| 1 X01 |
+ (('U', 'U', 'U', 'U'), --| U X0H |
+ ('U', 'X', 'X', 'X'), --| X X0H |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 X0H |
+ ('U', 'X', '0', 'H')), --| 1 X0H |
+ (('U', 'U', 'U', 'U'), --| U XL1 |
+ ('U', 'X', 'X', 'X'), --| X XL1 |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 XL1 |
+ ('U', 'X', 'L', '1')), --| 1 XL1 |
+ (('U', 'U', 'U', 'Z'), --| U X0Z |
+ ('U', 'X', 'X', 'Z'), --| X X0Z |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 X0Z |
+ ('U', 'X', '0', 'Z')), --| 1 X0Z |
+ (('U', 'U', 'U', 'U'), --| U XZ1 |
+ ('U', 'X', 'X', 'X'), --| X XZ1 |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 XZ1 |
+ ('U', 'X', 'Z', '1')), --| 1 XZ1 |
+ (('U', 'U', 'U', 'U'), --| U WLH |
+ ('U', 'W', 'W', 'W'), --| X WLH |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 WLH |
+ ('U', 'W', 'L', 'H')), --| 1 WLH |
+ (('U', 'U', 'U', 'U'), --| U WLZ |
+ ('U', 'W', 'W', 'Z'), --| X WLZ |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 WLZ |
+ ('U', 'W', 'L', 'Z')), --| 1 WLZ |
+ (('U', 'U', 'U', 'U'), --| U WZH |
+ ('U', 'W', 'W', 'W'), --| X WZH |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 WZH |
+ ('U', 'W', 'Z', 'H')), --| 1 WZH |
+ (('U', 'U', 'U', 'U'), --| U W0H |
+ ('U', 'W', 'W', 'W'), --| X W0H |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 W0H |
+ ('U', 'W', '0', 'H')), --| 1 W0H |
+ (('U', 'U', 'U', 'U'), --| U WL1 |
+ ('U', 'W', 'W', 'W'), --| X WL1 |
+ ('Z', 'Z', 'Z', 'Z'), --| 0 WL1 |
+ ('U', 'W', 'L', '1')));--| 1 WL1 |
+ begin
+ return tbl_BUF3S(Strn, Enable, Input);
+ end fun_BUF3S;
+
+
+ function fun_BUF3SL(Input, Enable: UX01; Strn: STRENGTH) return STD_LOGIC is
+ -- pragma subpgm_id 412
+ type TRISTATE_TABLE is array(STRENGTH, UX01, UX01) of STD_LOGIC;
+
+ -- truth table for tristate "buf" function (Enable active Low)
+ constant tbl_BUF3SL: TRISTATE_TABLE :=
+ -- ----------------------------------------------------
+ -- | Input U X 0 1 | Enable Strength |
+ -- ---------------------------------|-----------------|
+ ((('U', 'U', 'U', 'U'), --| U X01 |
+ ('U', 'X', 'X', 'X'), --| X X01 |
+ ('U', 'X', '0', '1'), --| 0 X01 |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 X01 |
+ (('U', 'U', 'U', 'U'), --| U X0H |
+ ('U', 'X', 'X', 'X'), --| X X0H |
+ ('U', 'X', '0', 'H'), --| 0 X0H |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 X0H |
+ (('U', 'U', 'U', 'U'), --| U XL1 |
+ ('U', 'X', 'X', 'X'), --| X XL1 |
+ ('U', 'X', 'L', '1'), --| 0 XL1 |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 XL1 |
+ (('U', 'U', 'U', 'Z'), --| U X0Z |
+ ('U', 'X', 'X', 'Z'), --| X X0Z |
+ ('U', 'X', '0', 'Z'), --| 0 X0Z |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 X0Z |
+ (('U', 'U', 'U', 'U'), --| U XZ1 |
+ ('U', 'X', 'X', 'X'), --| X XZ1 |
+ ('U', 'X', 'Z', '1'), --| 0 XZ1 |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 XZ1 |
+ (('U', 'U', 'U', 'U'), --| U WLH |
+ ('U', 'W', 'W', 'W'), --| X WLH |
+ ('U', 'W', 'L', 'H'), --| 0 WLH |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 WLH |
+ (('U', 'U', 'U', 'U'), --| U WLZ |
+ ('U', 'W', 'W', 'Z'), --| X WLZ |
+ ('U', 'W', 'L', 'Z'), --| 0 WLZ |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 WLZ |
+ (('U', 'U', 'U', 'U'), --| U WZH |
+ ('U', 'W', 'W', 'W'), --| X WZH |
+ ('U', 'W', 'Z', 'H'), --| 0 WZH |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 WZH |
+ (('U', 'U', 'U', 'U'), --| U W0H |
+ ('U', 'W', 'W', 'W'), --| X W0H |
+ ('U', 'W', '0', 'H'), --| 0 W0H |
+ ('Z', 'Z', 'Z', 'Z')), --| 1 W0H |
+ (('U', 'U', 'U', 'U'), --| U WL1 |
+ ('U', 'W', 'W', 'W'), --| X WL1 |
+ ('U', 'W', 'L', '1'), --| 0 WL1 |
+ ('Z', 'Z', 'Z', 'Z')));--| 1 WL1 |
+ begin
+ return tbl_BUF3SL(Strn, Enable, Input);
+ end fun_BUF3SL;
+
+
+ function fun_MUX2x1(Input0, Input1, Sel: UX01) return UX01 is
+ -- pragma subpgm_id 413
+ type MUX_TABLE is array (UX01, UX01, UX01) of UX01;
+
+ -- truth table for "MUX2x1" function
+ constant tbl_MUX2x1: MUX_TABLE :=
+ --------------------------------------------
+ --| In0 'U' 'X' '0' '1' | Sel In1 |
+ --------------------------------------------
+ ((('U', 'U', 'U', 'U'), --| 'U' 'U' |
+ ('U', 'U', 'U', 'U'), --| 'X' 'U' |
+ ('U', 'X', '0', '1'), --| '0' 'U' |
+ ('U', 'U', 'U', 'U')), --| '1' 'U' |
+ (('U', 'X', 'U', 'U'), --| 'U' 'X' |
+ ('U', 'X', 'X', 'X'), --| 'X' 'X' |
+ ('U', 'X', '0', '1'), --| '0' 'X' |
+ ('X', 'X', 'X', 'X')), --| '1' 'X' |
+ (('U', 'U', '0', 'U'), --| 'U' '0' |
+ ('U', 'X', '0', 'X'), --| 'X' '0' |
+ ('U', 'X', '0', '1'), --| '0' '0' |
+ ('0', '0', '0', '0')), --| '1' '0' |
+ (('U', 'U', 'U', '1'), --| 'U' '1' |
+ ('U', 'X', 'X', '1'), --| 'X' '1' |
+ ('U', 'X', '0', '1'), --| '0' '1' |
+ ('1', '1', '1', '1')));--| '1' '1' |
+ begin
+ return tbl_MUX2x1(Input1, Sel, Input0);
+ end fun_MUX2x1;
+
+
+ function fun_MAJ23(Input0, Input1, Input2: UX01) return UX01 is
+ -- pragma subpgm_id 414
+ type MAJ23_TABLE is array (UX01, UX01, UX01) of UX01;
+
+ ----------------------------------------------------------------------------
+ -- The "tbl_MAJ23" truth table return 1 if the majority of three
+ -- inputs is 1, a 0 if the majority is 0, a X if unknown, and a U if
+ -- uninitialized.
+ ----------------------------------------------------------------------------
+ constant tbl_MAJ23: MAJ23_TABLE :=
+ --------------------------------------------
+ --| In0 'U' 'X' '0' '1' | In1 In2 |
+ --------------------------------------------
+ ((('U', 'U', 'U', 'U'), --| 'U' 'U' |
+ ('U', 'U', 'U', 'U'), --| 'X' 'U' |
+ ('U', 'U', '0', 'U'), --| '0' 'U' |
+ ('U', 'U', 'U', '1')), --| '1' 'U' |
+ (('U', 'U', 'U', 'U'), --| 'U' 'X' |
+ ('U', 'X', 'X', 'X'), --| 'X' 'X' |
+ ('U', 'X', '0', 'X'), --| '0' 'X' |
+ ('U', 'X', 'X', '1')), --| '1' 'X' |
+ (('U', 'U', '0', 'U'), --| 'U' '0' |
+ ('U', 'X', '0', 'X'), --| 'X' '0' |
+ ('0', '0', '0', '0'), --| '0' '0' |
+ ('U', 'X', '0', '1')), --| '1' '0' |
+ (('U', 'U', 'U', '1'), --| 'U' '1' |
+ ('U', 'X', 'X', '1'), --| 'X' '1' |
+ ('U', 'X', '0', '1'), --| '0' '1' |
+ ('1', '1', '1', '1')));--| '1' '1' |
+
+ begin
+ return tbl_MAJ23(Input0, Input1, Input2);
+ end fun_MAJ23;
+
+
+ function fun_WiredX(Input0, Input1: STD_ULOGIC) return STD_LOGIC is
+ -- pragma subpgm_id 415
+ TYPE stdlogic_table IS ARRAY(STD_ULOGIC, STD_ULOGIC) OF STD_LOGIC;
+
+ -- truth table for "WiredX" function
+ -------------------------------------------------------------------
+ -- resolution function
+ -------------------------------------------------------------------
+ CONSTANT resolution_table : stdlogic_table := (
+ -- ---------------------------------------------------------
+ -- | U X 0 1 Z W L H - | |
+ -- ---------------------------------------------------------
+ ( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |
+ ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |
+ ( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ), -- | 0 |
+ ( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ), -- | 1 |
+ ( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |
+ ( 'U', 'X', '0', '1', 'W', 'W', 'W', 'W', 'X' ), -- | W |
+ ( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |
+ ( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |
+ ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ));-- | - |
+ begin
+ return resolution_table(Input0, Input1);
+ end fun_WiredX;
+
+--synopsys synthesis_on
+
+end;
diff --git a/libraries/synopsys/std_logic_misc.vhdl b/libraries/synopsys/std_logic_misc.vhdl
new file mode 100644
index 000000000..999aa8391
--- /dev/null
+++ b/libraries/synopsys/std_logic_misc.vhdl
@@ -0,0 +1,170 @@
+--------------------------------------------------------------------------
+--
+-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc. All rights reserved.
+--
+-- This source file may be used and distributed without restriction
+-- provided that this copyright statement is not removed from the file
+-- and that any derivative work contains this copyright notice.
+--
+-- Package name: std_logic_misc
+--
+-- Purpose: This package defines supplemental types, subtypes,
+-- constants, and functions for the Std_logic_1164 Package.
+--
+-- Author: GWH
+--
+--------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+--library SYNOPSYS;
+--use SYNOPSYS.attributes.all;
+
+
+package std_logic_misc is
+
+ -- output-strength types
+
+ type STRENGTH is (strn_X01, strn_X0H, strn_XL1, strn_X0Z, strn_XZ1,
+ strn_WLH, strn_WLZ, strn_WZH, strn_W0H, strn_WL1);
+
+
+--synopsys synthesis_off
+
+ type MINOMAX is array (1 to 3) of TIME;
+
+
+ ---------------------------------------------------------------------
+ --
+ -- functions for mapping the STD_(U)LOGIC according to STRENGTH
+ --
+ ---------------------------------------------------------------------
+
+ function strength_map(input: STD_ULOGIC; strn: STRENGTH) return STD_LOGIC;
+
+ function strength_map_z(input:STD_ULOGIC; strn:STRENGTH) return STD_LOGIC;
+
+ ---------------------------------------------------------------------
+ --
+ -- conversion functions for STD_ULOGIC_VECTOR and STD_LOGIC_VECTOR
+ --
+ ---------------------------------------------------------------------
+
+--synopsys synthesis_on
+ function Drive (V: STD_ULOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function Drive (V: STD_LOGIC_VECTOR) return STD_ULOGIC_VECTOR;
+--synopsys synthesis_off
+
+ --attribute CLOSELY_RELATED_TCF of Drive: function is TRUE;
+
+ ---------------------------------------------------------------------
+ --
+ -- conversion functions for sensing various types
+ -- (the second argument allows the user to specify the value to
+ -- be returned when the network is undriven)
+ --
+ ---------------------------------------------------------------------
+
+ function Sense (V: STD_ULOGIC; vZ, vU, vDC: STD_ULOGIC) return STD_LOGIC;
+
+ function Sense (V: STD_ULOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_LOGIC_VECTOR;
+ function Sense (V: STD_ULOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_ULOGIC_VECTOR;
+
+ function Sense (V: STD_LOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_LOGIC_VECTOR;
+ function Sense (V: STD_LOGIC_VECTOR; vZ, vU, vDC: STD_ULOGIC)
+ return STD_ULOGIC_VECTOR;
+
+--synopsys synthesis_on
+
+
+ ---------------------------------------------------------------------
+ --
+ -- Function: STD_LOGIC_VECTORtoBIT_VECTOR STD_ULOGIC_VECTORtoBIT_VECTOR
+ --
+ -- Purpose: Conversion fun. from STD_(U)LOGIC_VECTOR to BIT_VECTOR
+ --
+ -- Mapping: 0, L --> 0
+ -- 1, H --> 1
+ -- X, W --> vX if Xflag is TRUE
+ -- X, W --> 0 if Xflag is FALSE
+ -- Z --> vZ if Zflag is TRUE
+ -- Z --> 0 if Zflag is FALSE
+ -- U --> vU if Uflag is TRUE
+ -- U --> 0 if Uflag is FALSE
+ -- - --> vDC if DCflag is TRUE
+ -- - --> 0 if DCflag is FALSE
+ --
+ ---------------------------------------------------------------------
+
+ function STD_LOGIC_VECTORtoBIT_VECTOR (V: STD_LOGIC_VECTOR
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT_VECTOR;
+
+ function STD_ULOGIC_VECTORtoBIT_VECTOR (V: STD_ULOGIC_VECTOR
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT_VECTOR;
+
+
+ ---------------------------------------------------------------------
+ --
+ -- Function: STD_ULOGICtoBIT
+ --
+ -- Purpose: Conversion function from STD_(U)LOGIC to BIT
+ --
+ -- Mapping: 0, L --> 0
+ -- 1, H --> 1
+ -- X, W --> vX if Xflag is TRUE
+ -- X, W --> 0 if Xflag is FALSE
+ -- Z --> vZ if Zflag is TRUE
+ -- Z --> 0 if Zflag is FALSE
+ -- U --> vU if Uflag is TRUE
+ -- U --> 0 if Uflag is FALSE
+ -- - --> vDC if DCflag is TRUE
+ -- - --> 0 if DCflag is FALSE
+ --
+ ---------------------------------------------------------------------
+
+ function STD_ULOGICtoBIT (V: STD_ULOGIC
+--synopsys synthesis_off
+ ; vX, vZ, vU, vDC: BIT := '0';
+ Xflag, Zflag, Uflag, DCflag: BOOLEAN := FALSE
+--synopsys synthesis_on
+ ) return BIT;
+
+ --------------------------------------------------------------------
+ function AND_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+ function NAND_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+ function OR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+ function NOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+ function XOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+ function XNOR_REDUCE(ARG: STD_LOGIC_VECTOR) return UX01;
+
+ function AND_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+ function NAND_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+ function OR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+ function NOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+ function XOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+ function XNOR_REDUCE(ARG: STD_ULOGIC_VECTOR) return UX01;
+
+--synopsys synthesis_off
+
+ function fun_BUF3S(Input, Enable: UX01; Strn: STRENGTH) return STD_LOGIC;
+ function fun_BUF3SL(Input, Enable: UX01; Strn: STRENGTH) return STD_LOGIC;
+ function fun_MUX2x1(Input0, Input1, Sel: UX01) return UX01;
+
+ function fun_MAJ23(Input0, Input1, Input2: UX01) return UX01;
+ function fun_WiredX(Input0, Input1: std_ulogic) return STD_LOGIC;
+
+--synopsys synthesis_on
+
+end;
diff --git a/libraries/synopsys/std_logic_signed.vhdl b/libraries/synopsys/std_logic_signed.vhdl
new file mode 100644
index 000000000..27d211be5
--- /dev/null
+++ b/libraries/synopsys/std_logic_signed.vhdl
@@ -0,0 +1,343 @@
+--------------------------------------------------------------------------
+-- --
+-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc. --
+-- All rights reserved. --
+-- --
+-- This source file may be used and distributed without restriction --
+-- provided that this copyright statement is not removed from the file --
+-- and that any derivative work contains this copyright notice. --
+-- --
+-- Package name: STD_LOGIC_SIGNED --
+-- --
+-- --
+-- Date: 09/11/91 KN --
+-- 10/08/92 AMT change std_ulogic to signed std_logic --
+-- 10/28/92 AMT added signed functions, -, ABS --
+-- --
+-- Purpose: --
+-- A set of signed arithemtic, conversion, --
+-- and comparision functions for STD_LOGIC_VECTOR. --
+-- --
+-- Note: Comparision of same length std_logic_vector is defined --
+-- in the LRM. The interpretation is for unsigned vectors --
+-- This package will "overload" that definition. --
+-- --
+--------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.std_logic_arith.all;
+
+package STD_LOGIC_SIGNED is
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "+"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "-"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "+"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "ABS"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+
+ function "*"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "<"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "<"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "<="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "<="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function ">"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function ">"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function ">="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function ">="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "/="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "/="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function SHL(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function SHR(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function CONV_INTEGER(ARG: STD_LOGIC_VECTOR) return INTEGER;
+
+-- remove this since it is already in std_logic_arith
+-- function CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR;
+
+end STD_LOGIC_SIGNED;
+
+
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.std_logic_arith.all;
+
+package body STD_LOGIC_SIGNED is
+
+
+ function maximum(L, R: INTEGER) return INTEGER is
+ begin
+ if L > R then
+ return L;
+ else
+ return R;
+ end if;
+ end;
+
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR (length-1 downto 0);
+ begin
+ result := SIGNED(L) + SIGNED(R); -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := SIGNED(L) + R; -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L + SIGNED(R); -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := SIGNED(L) + R; -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L + SIGNED(R); -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR (length-1 downto 0);
+ begin
+ result := SIGNED(L) - SIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := SIGNED(L) - R; -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L - SIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := SIGNED(L) - R; -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L - SIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := + SIGNED(L); -- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := - SIGNED(L); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "ABS"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := ABS( SIGNED(L));
+ return std_logic_vector(result);
+ end;
+
+ function "*"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR ((L'length+R'length-1) downto 0);
+ begin
+ result := SIGNED(L) * SIGNED(R); -- pragma label mult
+ return std_logic_vector(result);
+ end;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to lt
+ constant length: INTEGER := maximum(L'length, R'length);
+ begin
+ return SIGNED(L) < SIGNED(R); -- pragma label lt
+ end;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to lt
+ begin
+ return SIGNED(L) < R; -- pragma label lt
+ end;
+
+ function "<"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to lt
+ begin
+ return L < SIGNED(R); -- pragma label lt
+ end;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return SIGNED(L) <= SIGNED(R); -- pragma label leq
+ end;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return SIGNED(L) <= R; -- pragma label leq
+ end;
+
+ function "<="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return L <= SIGNED(R); -- pragma label leq
+ end;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return SIGNED(L) > SIGNED(R); -- pragma label gt
+ end;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return SIGNED(L) > R; -- pragma label gt
+ end;
+
+ function ">"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return L > SIGNED(R); -- pragma label gt
+ end;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return SIGNED(L) >= SIGNED(R); -- pragma label geq
+ end;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return SIGNED(L) >= R; -- pragma label geq
+ end;
+
+ function ">="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return L >= SIGNED(R); -- pragma label geq
+ end;
+
+ function "="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return SIGNED(L) = SIGNED(R);
+ end;
+
+ function "="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ begin
+ return SIGNED(L) = R;
+ end;
+
+ function "="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return L = SIGNED(R);
+ end;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return SIGNED(L) /= SIGNED(R);
+ end;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ begin
+ return SIGNED(L) /= R;
+ end;
+
+ function "/="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return L /= SIGNED(R);
+ end;
+
+ function SHL(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin
+ return STD_LOGIC_VECTOR(SHL(SIGNED(ARG),UNSIGNED(COUNT)));
+ end;
+
+ function SHR(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin
+ return STD_LOGIC_VECTOR(SHR(SIGNED(ARG),UNSIGNED(COUNT)));
+ end;
+
+
+
+-- This function converts std_logic_vector to a signed integer value
+-- using a conversion function in std_logic_arith
+ function CONV_INTEGER(ARG: STD_LOGIC_VECTOR) return INTEGER is
+ variable result : SIGNED(ARG'range);
+ begin
+ result := SIGNED(ARG);
+ return CONV_INTEGER(result);
+ end;
+end STD_LOGIC_SIGNED;
+
+
diff --git a/libraries/synopsys/std_logic_textio.vhdl b/libraries/synopsys/std_logic_textio.vhdl
new file mode 100644
index 000000000..d69a87e37
--- /dev/null
+++ b/libraries/synopsys/std_logic_textio.vhdl
@@ -0,0 +1,634 @@
+----------------------------------------------------------------------------
+--
+-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc. All rights reserved.
+--
+-- This source file may be used and distributed without restriction
+-- provided that this copyright statement is not removed from the file
+-- and that any derivative work contains this copyright notice.
+--
+-- Package name: STD_LOGIC_TEXTIO
+--
+-- Purpose: This package overloads the standard TEXTIO procedures
+-- READ and WRITE.
+--
+-- Author: CRC, TS
+--
+----------------------------------------------------------------------------
+
+use STD.textio.all;
+library IEEE;
+use IEEE.std_logic_1164.all;
+
+package STD_LOGIC_TEXTIO is
+--synopsys synthesis_off
+ -- Read and Write procedures for STD_ULOGIC and STD_ULOGIC_VECTOR
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC);
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC; GOOD: out BOOLEAN);
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+ procedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+
+ -- Read and Write procedures for STD_LOGIC_VECTOR
+ procedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);
+ procedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure WRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+
+ --
+ -- Read and Write procedures for Hex and Octal values.
+ -- The values appear in the file as a series of characters
+ -- between 0-F (Hex), or 0-7 (Octal) respectively.
+ --
+
+ -- Hex
+ procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);
+ procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure HWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+ procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);
+ procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure HWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+
+ -- Octal
+ procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR);
+ procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure OWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+ procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR);
+ procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN);
+ procedure OWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0);
+
+
+--synopsys synthesis_on
+end STD_LOGIC_TEXTIO;
+
+package body STD_LOGIC_TEXTIO is
+--synopsys synthesis_off
+
+ -- Type and constant definitions used to map STD_ULOGIC values
+ -- into/from character values.
+
+ type MVL9plus is ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-', ERROR);
+ type char_indexed_by_MVL9 is array (STD_ULOGIC) of character;
+ type MVL9_indexed_by_char is array (character) of STD_ULOGIC;
+ type MVL9plus_indexed_by_char is array (character) of MVL9plus;
+
+ constant MVL9_to_char: char_indexed_by_MVL9 := "UX01ZWLH-";
+ constant char_to_MVL9: MVL9_indexed_by_char :=
+ ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
+ 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => 'U');
+ constant char_to_MVL9plus: MVL9plus_indexed_by_char :=
+ ('U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z',
+ 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-', others => ERROR);
+
+
+ -- Overloaded procedures.
+
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC; GOOD:out BOOLEAN) is
+ variable c: character;
+ begin
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ if (char_to_MVL9plus(c) = ERROR) then
+ value := 'U';
+ good := FALSE;
+ else
+ value := char_to_MVL9(c);
+ good := TRUE;
+ end if;
+ end READ;
+
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR; GOOD:out BOOLEAN) is
+ variable m: STD_ULOGIC;
+ variable c: character;
+ variable s: string(1 to value'length-1);
+ variable mv: STD_ULOGIC_VECTOR(0 to value'length-1);
+ constant allU: STD_ULOGIC_VECTOR(0 to value'length-1)
+ := (others => 'U');
+ begin
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ if (char_to_MVL9plus(c) = ERROR) then
+ value := allU;
+ good := FALSE;
+ return;
+ end if;
+
+ read(l, s);
+ for i in integer range 1 to value'length-1 loop
+ if (char_to_MVL9plus(s(i)) = ERROR) then
+ value := allU;
+ good := FALSE;
+ return;
+ end if;
+ end loop;
+
+ mv(0) := char_to_MVL9(c);
+ for i in integer range 1 to value'length-1 loop
+ mv(i) := char_to_MVL9(s(i));
+ end loop;
+ value := mv;
+ good := TRUE;
+ end READ;
+
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC) is
+ variable c: character;
+ begin
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ if (char_to_MVL9plus(c) = ERROR) then
+ value := 'U';
+ assert FALSE report "READ(STD_ULOGIC) Error: Character '" &
+ c & "' read, expected STD_ULOGIC literal.";
+ else
+ value := char_to_MVL9(c);
+ end if;
+ end READ;
+
+ procedure READ(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is
+ variable m: STD_ULOGIC;
+ variable c: character;
+ variable s: string(1 to value'length-1);
+ variable mv: STD_ULOGIC_VECTOR(0 to value'length-1);
+ constant allU: STD_ULOGIC_VECTOR(0 to value'length-1)
+ := (others => 'U');
+ begin
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ if (char_to_MVL9plus(c) = ERROR) then
+ value := allU;
+ assert FALSE report
+ "READ(STD_ULOGIC_VECTOR) Error: Character '" &
+ c & "' read, expected STD_ULOGIC literal.";
+ return;
+ end if;
+
+ read(l, s);
+ for i in integer range 1 to value'length-1 loop
+ if (char_to_MVL9plus(s(i)) = ERROR) then
+ value := allU;
+ assert FALSE report
+ "READ(STD_ULOGIC_VECTOR) Error: Character '" &
+ s(i) & "' read, expected STD_ULOGIC literal.";
+ return;
+ end if;
+ end loop;
+
+ mv(0) := char_to_MVL9(c);
+ for i in integer range 1 to value'length-1 loop
+ mv(i) := char_to_MVL9(s(i));
+ end loop;
+ value := mv;
+ end READ;
+
+ procedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ write(l, MVL9_to_char(value), justified, field);
+ end WRITE;
+
+
+ procedure WRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ variable s: string(1 to value'length);
+ variable m: STD_ULOGIC_VECTOR(1 to value'length) := value;
+ begin
+ for i in 1 to value'length loop
+ s(i) := MVL9_to_char(m(i));
+ end loop;
+ write(l, s, justified, field);
+ end WRITE;
+
+ -- Read and Write procedures for STD_LOGIC_VECTOR
+ procedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ READ(L, tmp);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end READ;
+
+ procedure READ(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ READ(L, tmp, GOOD);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end READ;
+
+ procedure WRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ WRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);
+ end WRITE;
+
+
+ --
+ -- Hex Read and Write procedures.
+ --
+
+ --
+ -- Hex, and Octal Read and Write procedures for BIT_VECTOR
+ -- (these procedures are not exported, they are only used
+ -- by the STD_ULOGIC hex/octal reads and writes below.
+ --
+ --
+
+ procedure Char2QuadBits(C: Character;
+ RESULT: out Bit_Vector(3 downto 0);
+ GOOD: out Boolean;
+ ISSUE_ERROR: in Boolean) is
+ begin
+ case c is
+ when '0' => result := x"0"; good := TRUE;
+ when '1' => result := x"1"; good := TRUE;
+ when '2' => result := x"2"; good := TRUE;
+ when '3' => result := x"3"; good := TRUE;
+ when '4' => result := x"4"; good := TRUE;
+ when '5' => result := x"5"; good := TRUE;
+ when '6' => result := x"6"; good := TRUE;
+ when '7' => result := x"7"; good := TRUE;
+ when '8' => result := x"8"; good := TRUE;
+ when '9' => result := x"9"; good := TRUE;
+ when 'A' => result := x"A"; good := TRUE;
+ when 'B' => result := x"B"; good := TRUE;
+ when 'C' => result := x"C"; good := TRUE;
+ when 'D' => result := x"D"; good := TRUE;
+ when 'E' => result := x"E"; good := TRUE;
+ when 'F' => result := x"F"; good := TRUE;
+
+ when 'a' => result := x"A"; good := TRUE;
+ when 'b' => result := x"B"; good := TRUE;
+ when 'c' => result := x"C"; good := TRUE;
+ when 'd' => result := x"D"; good := TRUE;
+ when 'e' => result := x"E"; good := TRUE;
+ when 'f' => result := x"F"; good := TRUE;
+ when others =>
+ if ISSUE_ERROR then
+ assert FALSE report
+ "HREAD Error: Read a '" & c &
+ "', expected a Hex character (0-F).";
+ end if;
+ good := FALSE;
+ end case;
+ end;
+
+ procedure HREAD(L:inout LINE; VALUE:out BIT_VECTOR) is
+ variable ok: boolean;
+ variable c: character;
+ constant ne: integer := value'length/4;
+ variable bv: bit_vector(0 to value'length-1);
+ variable s: string(1 to ne-1);
+ begin
+ if value'length mod 4 /= 0 then
+ assert FALSE report
+ "HREAD Error: Trying to read vector " &
+ "with an odd (non multiple of 4) length";
+ return;
+ end if;
+
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ Char2QuadBits(c, bv(0 to 3), ok, TRUE);
+ if not ok then
+ return;
+ end if;
+
+ read(L, s, ok);
+ if not ok then
+ assert FALSE
+ report "HREAD Error: Failed to read the STRING";
+ return;
+ end if;
+
+ for i in 1 to ne-1 loop
+ Char2QuadBits(s(i), bv(4*i to 4*i+3), ok, TRUE);
+ if not ok then
+ return;
+ end if;
+ end loop;
+ value := bv;
+ end HREAD;
+
+ procedure HREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD: out BOOLEAN) is
+ variable ok: boolean;
+ variable c: character;
+ constant ne: integer := value'length/4;
+ variable bv: bit_vector(0 to value'length-1);
+ variable s: string(1 to ne-1);
+ begin
+ if value'length mod 4 /= 0 then
+ good := FALSE;
+ return;
+ end if;
+
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ Char2QuadBits(c, bv(0 to 3), ok, FALSE);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+
+ read(L, s, ok);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+
+ for i in 1 to ne-1 loop
+ Char2QuadBits(s(i), bv(4*i to 4*i+3), ok, FALSE);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+ end loop;
+ good := TRUE;
+ value := bv;
+ end HREAD;
+
+
+ procedure HWRITE(L:inout LINE; VALUE:in BIT_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ variable quad: bit_vector(0 to 3);
+ constant ne: integer := value'length/4;
+ variable bv: bit_vector(0 to value'length-1) := value;
+ variable s: string(1 to ne);
+ begin
+ if value'length mod 4 /= 0 then
+ assert FALSE report
+ "HWRITE Error: Trying to read vector " &
+ "with an odd (non multiple of 4) length";
+ return;
+ end if;
+
+ for i in 0 to ne-1 loop
+ quad := bv(4*i to 4*i+3);
+ case quad is
+ when x"0" => s(i+1) := '0';
+ when x"1" => s(i+1) := '1';
+ when x"2" => s(i+1) := '2';
+ when x"3" => s(i+1) := '3';
+ when x"4" => s(i+1) := '4';
+ when x"5" => s(i+1) := '5';
+ when x"6" => s(i+1) := '6';
+ when x"7" => s(i+1) := '7';
+ when x"8" => s(i+1) := '8';
+ when x"9" => s(i+1) := '9';
+ when x"A" => s(i+1) := 'A';
+ when x"B" => s(i+1) := 'B';
+ when x"C" => s(i+1) := 'C';
+ when x"D" => s(i+1) := 'D';
+ when x"E" => s(i+1) := 'E';
+ when x"F" => s(i+1) := 'F';
+ end case;
+ end loop;
+ write(L, s, JUSTIFIED, FIELD);
+ end HWRITE;
+
+ procedure Char2TriBits(C: Character;
+ RESULT: out bit_vector(2 downto 0);
+ GOOD: out Boolean;
+ ISSUE_ERROR: in Boolean) is
+ begin
+ case c is
+ when '0' => result := o"0"; good := TRUE;
+ when '1' => result := o"1"; good := TRUE;
+ when '2' => result := o"2"; good := TRUE;
+ when '3' => result := o"3"; good := TRUE;
+ when '4' => result := o"4"; good := TRUE;
+ when '5' => result := o"5"; good := TRUE;
+ when '6' => result := o"6"; good := TRUE;
+ when '7' => result := o"7"; good := TRUE;
+ when others =>
+ if ISSUE_ERROR then
+ assert FALSE report
+ "OREAD Error: Read a '" & c &
+ "', expected an Octal character (0-7).";
+ end if;
+ good := FALSE;
+ end case;
+ end;
+
+ procedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR) is
+ variable c: character;
+ variable ok: boolean;
+ constant ne: integer := value'length/3;
+ variable bv: bit_vector(0 to value'length-1);
+ variable s: string(1 to ne-1);
+ begin
+ if value'length mod 3 /= 0 then
+ assert FALSE report
+ "OREAD Error: Trying to read vector " &
+ "with an odd (non multiple of 3) length";
+ return;
+ end if;
+
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ Char2TriBits(c, bv(0 to 2), ok, TRUE);
+ if not ok then
+ return;
+ end if;
+
+ read(L, s, ok);
+ if not ok then
+ assert FALSE
+ report "OREAD Error: Failed to read the STRING";
+ return;
+ end if;
+
+ for i in 1 to ne-1 loop
+ Char2TriBits(s(i), bv(3*i to 3*i+2), ok, TRUE);
+ if not ok then
+ return;
+ end if;
+ end loop;
+ value := bv;
+ end OREAD;
+
+ procedure OREAD(L:inout LINE; VALUE:out BIT_VECTOR;GOOD: out BOOLEAN) is
+ variable ok: boolean;
+ variable c: character;
+ constant ne: integer := value'length/3;
+ variable bv: bit_vector(0 to value'length-1);
+ variable s: string(1 to ne-1);
+ begin
+ if value'length mod 3 /= 0 then
+ good := FALSE;
+ return;
+ end if;
+
+ loop -- skip white space
+ read(l,c);
+ exit when ((c /= ' ') and (c /= CR) and (c /= HT));
+ end loop;
+
+ Char2TriBits(c, bv(0 to 2), ok, FALSE);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+
+ read(L, s, ok);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+
+ for i in 1 to ne-1 loop
+ Char2TriBits(s(i), bv(3*i to 3*i+2), ok, FALSE);
+ if not ok then
+ good := FALSE;
+ return;
+ end if;
+ end loop;
+ good := TRUE;
+ value := bv;
+ end OREAD;
+
+
+ procedure OWRITE(L:inout LINE; VALUE:in BIT_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ variable tri: bit_vector(0 to 2);
+ constant ne: integer := value'length/3;
+ variable bv: bit_vector(0 to value'length-1) := value;
+ variable s: string(1 to ne);
+ begin
+ if value'length mod 3 /= 0 then
+ assert FALSE report
+ "OWRITE Error: Trying to read vector " &
+ "with an odd (non multiple of 3) length";
+ return;
+ end if;
+
+ for i in 0 to ne-1 loop
+ tri := bv(3*i to 3*i+2);
+ case tri is
+ when o"0" => s(i+1) := '0';
+ when o"1" => s(i+1) := '1';
+ when o"2" => s(i+1) := '2';
+ when o"3" => s(i+1) := '3';
+ when o"4" => s(i+1) := '4';
+ when o"5" => s(i+1) := '5';
+ when o"6" => s(i+1) := '6';
+ when o"7" => s(i+1) := '7';
+ end case;
+ end loop;
+ write(L, s, JUSTIFIED, FIELD);
+ end OWRITE;
+
+ -- Hex Read and Write procedures for STD_LOGIC_VECTOR
+ procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD:out BOOLEAN) is
+ variable tmp: bit_vector(VALUE'length-1 downto 0);
+ begin
+ HREAD(L, tmp, GOOD);
+ VALUE := To_X01(tmp);
+ end HREAD;
+
+ procedure HREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is
+ variable tmp: bit_vector(VALUE'length-1 downto 0);
+ begin
+ HREAD(L, tmp);
+ VALUE := To_X01(tmp);
+ end HREAD;
+
+ procedure HWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ HWRITE(L, To_bitvector(VALUE),JUSTIFIED, FIELD);
+ end HWRITE;
+
+ -- Hex Read and Write procedures for STD_LOGIC_VECTOR
+
+ procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ HREAD(L, tmp);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end HREAD;
+
+ procedure HREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ HREAD(L, tmp, GOOD);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end HREAD;
+
+ procedure HWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ HWRITE(L, To_bitvector(VALUE), JUSTIFIED, FIELD);
+ end HWRITE;
+
+
+ -- Octal Read and Write procedures for STD_ULOGIC_VECTOR
+ procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR;GOOD:out BOOLEAN) is
+ variable tmp: bit_vector(VALUE'length-1 downto 0);
+ begin
+ OREAD(L, tmp, GOOD);
+ VALUE := To_X01(tmp);
+ end OREAD;
+
+ procedure OREAD(L:inout LINE; VALUE:out STD_ULOGIC_VECTOR) is
+ variable tmp: bit_vector(VALUE'length-1 downto 0);
+ begin
+ OREAD(L, tmp);
+ VALUE := To_X01(tmp);
+ end OREAD;
+
+ procedure OWRITE(L:inout LINE; VALUE:in STD_ULOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ OWRITE(L, To_bitvector(VALUE),JUSTIFIED, FIELD);
+ end OWRITE;
+
+ -- Octal Read and Write procedures for STD_LOGIC_VECTOR
+
+ procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ OREAD(L, tmp);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end OREAD;
+
+ procedure OREAD(L:inout LINE; VALUE:out STD_LOGIC_VECTOR; GOOD: out BOOLEAN) is
+ variable tmp: STD_ULOGIC_VECTOR(VALUE'length-1 downto 0);
+ begin
+ OREAD(L, tmp, GOOD);
+ VALUE := STD_LOGIC_VECTOR(tmp);
+ end OREAD;
+
+ procedure OWRITE(L:inout LINE; VALUE:in STD_LOGIC_VECTOR;
+ JUSTIFIED:in SIDE := RIGHT; FIELD:in WIDTH := 0) is
+ begin
+ OWRITE(L, STD_ULOGIC_VECTOR(VALUE), JUSTIFIED, FIELD);
+ end OWRITE;
+
+
+--synopsys synthesis_on
+end STD_LOGIC_TEXTIO;
diff --git a/libraries/synopsys/std_logic_unsigned.vhdl b/libraries/synopsys/std_logic_unsigned.vhdl
new file mode 100644
index 000000000..3e29847a8
--- /dev/null
+++ b/libraries/synopsys/std_logic_unsigned.vhdl
@@ -0,0 +1,329 @@
+--------------------------------------------------------------------------
+-- --
+-- Copyright (c) 1990, 1991, 1992 by Synopsys, Inc. --
+-- All rights reserved. --
+-- --
+-- This source file may be used and distributed without restriction --
+-- provided that this copyright statement is not removed from the file --
+-- and that any derivative work contains this copyright notice. --
+-- --
+-- Package name: STD_LOGIC_UNSIGNED --
+-- --
+-- --
+-- Date: 09/11/92 KN --
+-- 10/08/92 AMT --
+-- --
+-- Purpose: --
+-- A set of unsigned arithemtic, conversion, --
+-- and comparision functions for STD_LOGIC_VECTOR. --
+-- --
+-- Note: comparision of same length discrete arrays is defined --
+-- by the LRM. This package will "overload" those --
+-- definitions --
+-- --
+--------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.std_logic_arith.all;
+
+package STD_LOGIC_UNSIGNED is
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "+"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR;
+ function "+"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR;
+ function "-"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR;
+ function "-"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "+"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "*"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "<"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "<"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "<="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "<="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function ">"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function ">"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function ">="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function ">="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function "/="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN;
+ function "/="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN;
+ function SHL(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+ function SHR(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR;
+
+ function CONV_INTEGER(ARG: STD_LOGIC_VECTOR) return INTEGER;
+
+-- remove this since it is already in std_logic_arith
+-- function CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR;
+
+end STD_LOGIC_UNSIGNED;
+
+
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.std_logic_arith.all;
+
+package body STD_LOGIC_UNSIGNED is
+
+
+ function maximum(L, R: INTEGER) return INTEGER is
+ begin
+ if L > R then
+ return L;
+ else
+ return R;
+ end if;
+ end;
+
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR (length-1 downto 0);
+ begin
+ result := UNSIGNED(L) + UNSIGNED(R);-- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := UNSIGNED(L) + R;-- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L + UNSIGNED(R);-- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := UNSIGNED(L) + R;-- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to plus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L + UNSIGNED(R);-- pragma label plus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR (length-1 downto 0);
+ begin
+ result := UNSIGNED(L) - UNSIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: INTEGER) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := UNSIGNED(L) - R; -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: INTEGER; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L - UNSIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC_VECTOR; R: STD_LOGIC) return STD_LOGIC_VECTOR is
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := UNSIGNED(L) - R;
+ return std_logic_vector(result);
+ end;
+
+ function "-"(L: STD_LOGIC; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to minus
+ variable result : STD_LOGIC_VECTOR (R'range);
+ begin
+ result := L - UNSIGNED(R); -- pragma label minus
+ return std_logic_vector(result);
+ end;
+
+ function "+"(L: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ variable result : STD_LOGIC_VECTOR (L'range);
+ begin
+ result := + UNSIGNED(L);
+ return std_logic_vector(result);
+ end;
+
+ function "*"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ -- pragma label_applies_to mult
+ constant length: INTEGER := maximum(L'length, R'length);
+ variable result : STD_LOGIC_VECTOR ((L'length+R'length-1) downto 0);
+ begin
+ result := UNSIGNED(L) * UNSIGNED(R); -- pragma label mult
+ return std_logic_vector(result);
+ end;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to lt
+ constant length: INTEGER := maximum(L'length, R'length);
+ begin
+ return UNSIGNED(L) < UNSIGNED(R); -- pragma label lt
+ end;
+
+ function "<"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to lt
+ begin
+ return UNSIGNED(L) < R; -- pragma label lt
+ end;
+
+ function "<"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to lt
+ begin
+ return L < UNSIGNED(R); -- pragma label lt
+ end;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return UNSIGNED(L) <= UNSIGNED(R); -- pragma label leq
+ end;
+
+ function "<="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return UNSIGNED(L) <= R; -- pragma label leq
+ end;
+
+ function "<="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to leq
+ begin
+ return L <= UNSIGNED(R); -- pragma label leq
+ end;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return UNSIGNED(L) > UNSIGNED(R); -- pragma label gt
+ end;
+
+ function ">"(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return UNSIGNED(L) > R; -- pragma label gt
+ end;
+
+ function ">"(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to gt
+ begin
+ return L > UNSIGNED(R); -- pragma label gt
+ end;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return UNSIGNED(L) >= UNSIGNED(R); -- pragma label geq
+ end;
+
+ function ">="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return UNSIGNED(L) >= R; -- pragma label geq
+ end;
+
+ function ">="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ -- pragma label_applies_to geq
+ begin
+ return L >= UNSIGNED(R); -- pragma label geq
+ end;
+
+ function "="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return UNSIGNED(L) = UNSIGNED(R);
+ end;
+
+ function "="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ begin
+ return UNSIGNED(L) = R;
+ end;
+
+ function "="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return L = UNSIGNED(R);
+ end;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return UNSIGNED(L) /= UNSIGNED(R);
+ end;
+
+ function "/="(L: STD_LOGIC_VECTOR; R: INTEGER) return BOOLEAN is
+ begin
+ return UNSIGNED(L) /= R;
+ end;
+
+ function "/="(L: INTEGER; R: STD_LOGIC_VECTOR) return BOOLEAN is
+ begin
+ return L /= UNSIGNED(R);
+ end;
+
+ function CONV_INTEGER(ARG: STD_LOGIC_VECTOR) return INTEGER is
+ variable result : UNSIGNED(ARG'range);
+ begin
+ result := UNSIGNED(ARG);
+ return CONV_INTEGER(result);
+ end;
+ function SHL(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin
+ return STD_LOGIC_VECTOR(SHL(UNSIGNED(ARG),UNSIGNED(COUNT)));
+ end;
+
+ function SHR(ARG:STD_LOGIC_VECTOR;COUNT: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is
+ begin
+ return STD_LOGIC_VECTOR(SHR(UNSIGNED(ARG),UNSIGNED(COUNT)));
+ end;
+
+
+-- remove this since it is already in std_logic_arith
+ --function CONV_STD_LOGIC_VECTOR(ARG: INTEGER; SIZE: INTEGER) return STD_LOGIC_VECTOR is
+ --variable result1 : UNSIGNED (SIZE-1 downto 0);
+ --variable result2 : STD_LOGIC_VECTOR (SIZE-1 downto 0);
+ --begin
+ --result1 := CONV_UNSIGNED(ARG,SIZE);
+ --return std_logic_vector(result1);
+ --end;
+
+
+end STD_LOGIC_UNSIGNED;
+
+