⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synopsys.vhd

📁 design compile synthesis user guide
💻 VHD
📖 第 1 页 / 共 3 页
字号:
    function "-"(L: UNSIGNED; R: INTEGER) return UNSIGNED is	-- pragma label_applies_to minus	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	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	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	constant length: INTEGER := R'length;    begin	return minus(CONV_SIGNED(L, length),		     CONV_SIGNED(R, length)); -- pragma label minus    end;    function "-"(L: UNSIGNED; R: BIT) return UNSIGNED is	-- pragma label_applies_to minus	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: BIT; R: UNSIGNED) return UNSIGNED is	-- pragma label_applies_to minus	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: BIT) return SIGNED is	-- pragma label_applies_to minus	constant length: INTEGER := L'length;    begin	return minus(CONV_SIGNED(L, length),		     CONV_SIGNED(R, length)); -- pragma label minus    end;    function "-"(L: BIT; R: SIGNED) return SIGNED is	-- pragma label_applies_to minus	constant length: INTEGER := R'length;    begin	return minus(CONV_SIGNED(L, length),		     CONV_SIGNED(R, length)); -- pragma label minus    end;    function "+"(L: UNSIGNED) return UNSIGNED is    begin	return L;    end;    function "+"(L: SIGNED) return SIGNED is    begin	return L;    end;    function "-"(L: SIGNED) return SIGNED is	-- pragma label_applies_to minus    begin	return 0 - L; -- pragma label minus    end;    function "ABS"(L: SIGNED) return SIGNED is    begin	if L(L'left) = '0' then	    return L;	else	    return 0 - L;	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	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	constant length: INTEGER := max(L'length, R'length) + 1;    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	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	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	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	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	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	constant length: INTEGER := L'length;    begin	return is_less_or_equal(CONV_SIGNED(R, length),				CONV_SIGNED(L, length)); -- pragma label geq

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -