-------------------------------------------------------------------------------------------------- -- -- -- Copyright (c) 1992-1999, Knowledge Based Silicon Corporation -- -- Copyright (c) 1999-2003, SEDA Intuit Designs Sdn. Bhd. -- -- Copyright (c) 2003 , exsedia Sdn. Bhd. -- -- Worldwide Rights Reserved. -- -- -- -------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------- -- -- -- File name : Nimbus_Synopsys_MVL9.vhdl -- -- File Description : Macro-Function VHDL package. -- -- Version : R100 -- -- Author : Eric C. Smith -- -- Date : 2/20/95 -- -- -- -- -- -- Authors' Note: This new version of the package makes use of the -- -- Synopsys/IEEE package "std_logic_unsigned" and functions defined -- -- therein to implement ten (10) of the Nimbus functions previously -- -- defined with purely boolean expressions. This will improve Synopsys' -- -- simulation/synthesis efficiency when these macros are used. The -- -- affected functions are: -- -- -- -- function ADDNC (A, B: std_logic_vector) return std_logic_vector; -- -- function ADDNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector; -- -- function CMPL2NC (A: std_logic_vector) return std_logic_vector; -- -- function DECRNC (A: std_logic_vector) return std_logic_vector; -- -- function INCRNC (A: std_logic_vector) return std_logic_vector; -- -- function MUL (A, B: std_logic_vector) return std_logic_vector; -- -- function SHL0 (A: std_logic_vector) return std_logic_vector; -- -- function SHR0 (A: std_logic_vector) return std_logic_vector; -- -- function SUBNC (A, B: std_logic_vector) return std_logic_vector; -- -- function SUBNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector; -- -- -- -- This package should NOT be used with any other VHDL tools. -- -- -- -- ECS -- -- -- -------------------------------------------------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; package Nimbus_MVL9_Synopsys is function BOOL2MVL9 (A: boolean) return std_logic; function MVL92BOOL (A: std_logic) return boolean; -- ******************************************************************************************* -- ******************************************************************************************* function ADD (A, B: std_logic_vector; C: std_logic) return std_logic_vector; function ADD (A, B: std_logic_vector) return std_logic_vector; function ADD (A, B: std_logic) return std_logic_vector; function ADD (A, B, C: std_logic) return std_logic_vector; function ADDNC (A, B: std_logic_vector) return std_logic_vector; function ADDNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector; function ADDNC (A, B: std_logic) return std_logic; function ADDNC (A, B, C: std_logic) return std_logic; function BAND (A: std_logic_vector) return std_logic; function BOR (A: std_logic_vector) return std_logic; function BXOR (A: std_logic_vector) return std_logic; function CAT (A, B: std_logic_vector) return std_logic_vector; function CAT (A, B: std_logic) return std_logic_vector; function CAT (A: std_logic; B: std_logic_vector) return std_logic_vector; function CAT (A: std_logic_vector; B: std_logic) return std_logic_vector; function CMP (A, B: std_logic_vector) return std_logic_vector; function CMP (A, B: std_logic) return std_logic_vector; function CMPL2 (A: std_logic_vector) return std_logic_vector; function CMPL2 (A: std_logic) return std_logic_vector; function CMPL2NC (A: std_logic_vector) return std_logic_vector; function CMPL2NC (A: std_logic) return std_logic; function DECO (A: std_logic_vector) return std_logic_vector; function DECO (A: std_logic) return std_logic_vector; function DECR (A: std_logic_vector) return std_logic_vector; function DECR (A: std_logic) return std_logic_vector; function DECRNC (A: std_logic_vector) return std_logic_vector; function DECRNC (A: std_logic) return std_logic; function DMUX (A: std_logic; B: std_logic_vector) return std_logic_vector; function DMUX (A, B: std_logic) return std_logic_vector; function FAND (A, B: std_logic_vector) return std_logic_vector; function FAND (A, B, C: std_logic_vector) return std_logic_vector; function FAND (A, B, C, D: std_logic_vector) return std_logic_vector; function FAND (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FAND (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FAND (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FAND (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FAND (A, B: std_logic) return std_logic; function FAND (A, B, C: std_logic) return std_logic; function FAND (A, B, C, D: std_logic) return std_logic; function FAND (A, B, C, D, E: std_logic) return std_logic; function FAND (A, B, C, D, E, F: std_logic) return std_logic; function FAND (A, B, C, D, E, F, G: std_logic) return std_logic; function FAND (A, B, C, D, E, F, G, H: std_logic) return std_logic; function FFOR (A, B: std_logic_vector) return std_logic_vector; function FFOR (A, B, C: std_logic_vector) return std_logic_vector; function FFOR (A, B, C, D: std_logic_vector) return std_logic_vector; function FFOR (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FFOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FFOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FFOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FFOR (A, B: std_logic) return std_logic; function FFOR (A, B, C: std_logic) return std_logic; function FFOR (A, B, C, D: std_logic) return std_logic; function FFOR (A, B, C, D, E: std_logic) return std_logic; function FFOR (A, B, C, D, E, F: std_logic) return std_logic; function FFOR (A, B, C, D, E, F, G: std_logic) return std_logic; function FFOR (A, B, C, D, E, F, G, H: std_logic) return std_logic; function FNAND (A, B: std_logic_vector) return std_logic_vector; function FNAND (A, B, C: std_logic_vector) return std_logic_vector; function FNAND (A, B, C, D: std_logic_vector) return std_logic_vector; function FNAND (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FNAND (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FNAND (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FNAND (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FNAND (A, B: std_logic) return std_logic; function FNAND (A, B, C: std_logic) return std_logic; function FNAND (A, B, C, D: std_logic) return std_logic; function FNAND (A, B, C, D, E: std_logic) return std_logic; function FNAND (A, B, C, D, E, F: std_logic) return std_logic; function FNAND (A, B, C, D, E, F, G: std_logic) return std_logic; function FNAND (A, B, C, D, E, F, G, H: std_logic) return std_logic; function FNOR (A, B: std_logic_vector) return std_logic_vector; function FNOR (A, B, C: std_logic_vector) return std_logic_vector; function FNOR (A, B, C, D: std_logic_vector) return std_logic_vector; function FNOR (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FNOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FNOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FNOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FNOR (A, B: std_logic) return std_logic; function FNOR (A, B, C: std_logic) return std_logic; function FNOR (A, B, C, D: std_logic) return std_logic; function FNOR (A, B, C, D, E: std_logic) return std_logic; function FNOR (A, B, C, D, E, F: std_logic) return std_logic; function FNOR (A, B, C, D, E, F, G: std_logic) return std_logic; function FNOR (A, B, C, D, E, F, G, H: std_logic) return std_logic; function FNOT (A: std_logic_vector) return std_logic_vector; function FNOT (A: std_logic) return std_logic; function FXNOR (A, B: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C, D: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FXNOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FXNOR (A, B: std_logic) return std_logic; function FXNOR (A, B, C: std_logic) return std_logic; function FXNOR (A, B, C, D: std_logic) return std_logic; function FXNOR (A, B, C, D, E: std_logic) return std_logic; function FXNOR (A, B, C, D, E, F: std_logic) return std_logic; function FXNOR (A, B, C, D, E, F, G: std_logic) return std_logic; function FXNOR (A, B, C, D, E, F, G, H: std_logic) return std_logic; function FXOR (A, B: std_logic_vector) return std_logic_vector; function FXOR (A, B, C: std_logic_vector) return std_logic_vector; function FXOR (A, B, C, D: std_logic_vector) return std_logic_vector; function FXOR (A, B, C, D, E: std_logic_vector) return std_logic_vector; function FXOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector; function FXOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector; function FXOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector; function FXOR (A, B: std_logic) return std_logic; function FXOR (A, B, C: std_logic) return std_logic; function FXOR (A, B, C, D: std_logic) return std_logic; function FXOR (A, B, C, D, E: std_logic) return std_logic; function FXOR (A, B, C, D, E, F: std_logic) return std_logic; function FXOR (A, B, C, D, E, F, G: std_logic) return std_logic; function FXOR (A, B, C, D, E, F, G, H: std_logic) return std_logic; function INCR (A: std_logic_vector) return std_logic_vector; function INCR (A: std_logic) return std_logic_vector; function INCRNC (A: std_logic_vector) return std_logic_vector; function INCRNC (A: std_logic) return std_logic; function MUL (A, B: std_logic_vector) return std_logic_vector; function MUL (A, B: std_logic) return std_logic_vector; function MUX (A, B: std_logic_vector) return std_logic; function MUX (A: std_logic_vector; B: std_logic) return std_logic; function NMUX (A, B: std_logic_vector; C: std_logic) return std_logic_vector; function NMUX (A, B, C: std_logic) return std_logic; function REFL (A: std_logic_vector) return std_logic_vector; function ROTL (A: std_logic_vector) return std_logic_vector; function ROTL (A: std_logic) return std_logic; function ROTR (A: std_logic_vector) return std_logic_vector; function ROTR (A: std_logic) return std_logic; function SHL0 (A: std_logic_vector) return std_logic_vector; function SHL0 (A: std_logic) return std_logic; function SHL1 (A: std_logic_vector) return std_logic_vector; function SHL1 (A: std_logic) return std_logic; function SHLIN (A: std_logic_vector; B: std_logic) return std_logic_vector; function SHLIN (A, B: std_logic) return std_logic; function SHR0 (A: std_logic_vector) return std_logic_vector; function SHR0 (A: std_logic) return std_logic; function SHR1 (A: std_logic_vector) return std_logic_vector; function SHR1 (A: std_logic) return std_logic; function SHRIN (A: std_logic_vector; B: std_logic) return std_logic_vector; function SHRIN (A, B: std_logic) return std_logic; function SUB (A, B: std_logic_vector) return std_logic_vector; function SUB (A, B: std_logic_vector; C: std_logic) return std_logic_vector; function SUB (A, B: std_logic) return std_logic_vector; function SUB (A, B, C: std_logic) return std_logic_vector; function SUBNC (A, B: std_logic_vector) return std_logic_vector; function SUBNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector; function SUBNC (A, B: std_logic) return std_logic; function SUBNC (A, B, C: std_logic) return std_logic; end Nimbus_MVL9_Synopsys; -- ******************************************************************************************* -- ******************************************************************************************* package body Nimbus_MVL9_Synopsys is function BOOL2MVL9 (A: boolean) return std_logic is begin if (A = TRUE) then return '1'; else return '0'; end if; end BOOL2MVL9; function MVL92BOOL (A: std_logic) return boolean is begin if (A = '1' or A = 'H') then return TRUE; else return FALSE; end if; end MVL92BOOL; -- ***************************************************************** -- Nimbus_MVL9_Synopsys macro functions begin at this point -- ***************************************************************** function ADD (A, B, C: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := A xor B xor C; result(1) := (A and B) or (A and C) or (B and C); return result; end ADD; function ADD (A, B: std_logic_vector; C: std_logic) return std_logic_vector is variable result : std_logic_vector(A'range); variable carry : std_logic; variable j : integer; begin carry := C; j := B'right; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor B(j) xor carry; carry := (A(i) and B(j)) or (A(i) and carry) or (B(j) and carry); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor B(j) xor carry; carry := (A(i) and B(j)) or (A(i) and carry) or (B(j) and carry); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; end if; return (carry & result); end ADD; function ADD (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable carry : std_logic; variable j : integer; begin carry := '0'; j := B'right; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor B(j) xor carry; carry:= (A(i) and B(j)) or (A(i) and carry) or (B(j) and carry); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor B(j) xor carry; carry := (A(i) and B(j)) or (A(i) and carry) or (B(j) and carry); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; end if; return (carry & result); end ADD; function ADD (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := A xor B; result(1) := A and B; return result; end ADD; function ADDNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A + B + C; return result; end ADDNC; function ADDNC (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A + B; return result; end ADDNC; function ADDNC (A, B: std_logic) return std_logic is variable result : std_logic; begin result := A xor B; return result; end ADDNC; function ADDNC (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C; return result; end ADDNC; -- ***************************************************************** function BAND (A: std_logic_vector) return std_logic is variable result : std_logic; begin result := '1'; for i in A'range loop result := result and A(i); end loop; return result; end BAND; -- ***************************************************************** function BOR (A: std_logic_vector) return std_logic is variable result : std_logic; begin result := '0'; for i in A'range loop result := result or A(i); end loop; return result; end BOR; -- ***************************************************************** function BXOR (A: std_logic_vector) return std_logic is variable result : std_logic; begin result := A(A'low); for i in A'low+1 to A'high loop result := result xor A(i); end loop; return result; end BXOR; -- ***************************************************************** function CAT (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'length + B'length - 1 downto 0); begin result := A & B; return result; end CAT; function CAT (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(1) := A; result(0) := B; return result; end CAT; function CAT (A: std_logic; B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(B'length downto 0); begin result(B'length) := A; result(B'length - 1 downto 0) := B; return result; end CAT; function CAT (A: std_logic_vector; B: std_logic) return std_logic_vector is variable result : std_logic_vector(A'length downto 0); begin result := A & B; return result; end CAT; -- ***************************************************************** function CMP (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (1 downto 0); variable j : integer; variable temp : std_logic_vector (1 downto 0); begin result := "00"; j := B'left; if (A'left > A'right) then for i in A'left downto A'right loop temp := (A(i) and not B(j)) & (not A(i) and B(j)); result(0) := result(0) or (temp(0) and (result(0) nor result(1))); result(1) := result(1) or (temp(1) and (result(0) nor result(1))); if (B'left > B'right) then j := j - 1; else j := j + 1; end if; end loop; else for i in A'left to A'right loop temp := (A(i) and not B(j)) & (not A(i) and B(j)); result(0) := result(0) or (temp(0) and (result(0) nor result(1))); result(1) := result(1) or (temp(1) and (result(0) nor result(1))); if (B'left > B'right) then j := j - 1; else j := j + 1; end if; end loop; end if; return result; end CMP; function CMP (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector (1 downto 0); begin result := (A and not B) & (not A and B); return result; end CMP; -- ***************************************************************** function CMPL2 (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable carry : std_logic; begin carry := '1'; if (A'left > A'right) then for i in A'right to A'left loop result(i) := not A(i) xor carry; carry := not A(i) and carry; end loop; else for i in A'right downto A'left loop result(i) := not A(i) xor carry; carry := not A(i) and carry; end loop; end if; return (carry & result); end CMPL2; function CMPL2 (A: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := A; result(1) := not A; return result; end CMPL2; function CMPL2NC (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := (not A) + '1'; return result; end CMPL2NC; function CMPL2NC (A: std_logic) return std_logic is variable result : std_logic; begin result := A; return result; end CMPL2NC; -- ***************************************************************** function DECO (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(((2**A'length)-1) downto 0); variable temp : std_logic_vector(A'range); variable temp2 : std_logic_vector(A'range); variable temp3 : std_logic_vector(A'range); variable carry : std_logic; begin for i in temp'range loop temp(i) := '0'; end loop; for i in result'range loop result(i) := '1'; end loop; for i in result'low to result'high loop temp2 := not(A xor temp); for j in temp2'range loop result(i) := result(i) and temp2(j); end loop; temp3 := temp; carry := '1'; if (temp'left > temp'right) then for i in temp'right to temp'left loop temp(i) := temp3(i) xor carry; carry := temp3(i) and carry; end loop; else for i in temp'right downto temp'left loop temp(i) := temp3(i) xor carry; carry := temp3(i) and carry; end loop; end if; end loop; return result; end DECO; function DECO (A: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result := A & not A; return result; end DECO; -- ***************************************************************** function DECR (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable borrow : std_logic; begin borrow := '1'; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor borrow; borrow := not A(i) and borrow; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor borrow; borrow := not A(i) and borrow; end loop; end if; return (borrow & result); end DECR; function DECR (A: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := not A; result(1) := not A; return result; end DECR; function DECRNC (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A - '1'; return result; end DECRNC; function DECRNC (A: std_logic) return std_logic is variable result : std_logic; begin result := not A; return result; end DECRNC; -- ***************************************************************** function DMUX (A: std_logic; B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(((2**B'length)-1) downto 0); variable temp : std_logic_vector(B'range); variable temp3 : std_logic_vector(B'range); variable temp2 : std_logic_vector(B'length downto 0); variable carry : std_logic; begin for i in temp'range loop temp(i) := '0'; end loop; for i in result'range loop result(i) := '1'; end loop; for i in result'low to result'high loop temp2 := not(B xor temp) & A; for j in temp2'range loop result(i) := result(i) and temp2(j); end loop; temp3 := temp; carry := '1'; if (temp'left > temp'right) then for i in temp'right to temp'left loop temp(i) := temp3(i) xor carry; carry := temp3(i) and carry; end loop; else for i in temp'right downto temp'left loop temp(i) := temp3(i) xor carry; carry := temp3(i) and carry; end loop; end if; end loop; return result; end DMUX; function DMUX (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result := (B and A) & ((not B) and A); return result; end DMUX; -- ***************************************************************** function FAND (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B; return result; end FAND; function FAND (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C; return result; end FAND; function FAND (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C and D; return result; end FAND; function FAND (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C and D and E; return result; end FAND; function FAND (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C and D and E and F; return result; end FAND; function FAND (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C and D and E and F and G; return result; end FAND; function FAND (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A and B and C and D and E and F and G and H; return result; end FAND; function FAND (A, B: std_logic) return std_logic is variable result : std_logic; begin result := A and B; return result; end FAND; function FAND (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C; return result; end FAND; function FAND (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C and D; return result; end FAND; function FAND (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C and D and E; return result; end FAND; function FAND (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C and D and E and F; return result; end FAND; function FAND (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C and D and E and F and G; return result; end FAND; function FAND (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := A and B and C and D and E and F and G and H; return result; end FAND; -- ***************************************************************** function FFOR (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B; return result; end FFOR; function FFOR (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C; return result; end FFOR; function FFOR (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C or D; return result; end FFOR; function FFOR (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C or D or E; return result; end FFOR; function FFOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C or D or E or F; return result; end FFOR; function FFOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C or D or E or F or G; return result; end FFOR; function FFOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A or B or C or D or E or F or G or H; return result; end FFOR; function FFOR (A, B: std_logic) return std_logic is variable result : std_logic; begin result := A or B; return result; end FFOR; function FFOR (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C; return result; end FFOR; function FFOR (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C or D; return result; end FFOR; function FFOR (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C or D or E; return result; end FFOR; function FFOR (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C or D or E or F; return result; end FFOR; function FFOR (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C or D or E or F or G; return result; end FFOR; function FFOR (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := A or B or C or D or E or F or G or H; return result; end FFOR; -- ***************************************************************** function FNAND (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B); return result; end FNAND; function FNAND (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C); return result; end FNAND; function FNAND (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C and D); return result; end FNAND; function FNAND (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C and D and E); return result; end FNAND; function FNAND (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C and D and E and F); return result; end FNAND; function FNAND (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C and D and E and F and G); return result; end FNAND; function FNAND (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A and B and C and D and E and F and G and H); return result; end FNAND; function FNAND (A, B: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B); return result; end FNAND; function FNAND (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C); return result; end FNAND; function FNAND (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C and D); return result; end FNAND; function FNAND (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C and D and E); return result; end FNAND; function FNAND (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C and D and E and F); return result; end FNAND; function FNAND (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C and D and E and F and G); return result; end FNAND; function FNAND (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := not (A and B and C and D and E and F and G and H); return result; end FNAND; -- ***************************************************************** function FNOR (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B); return result; end FNOR; function FNOR (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C); return result; end FNOR; function FNOR (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C or D); return result; end FNOR; function FNOR (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C or D or E); return result; end FNOR; function FNOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C or D or E or F); return result; end FNOR; function FNOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C or D or E or F or G); return result; end FNOR; function FNOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not (A or B or C or D or E or F or G or H); return result; end FNOR; function FNOR (A, B: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B); return result; end FNOR; function FNOR (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C); return result; end FNOR; function FNOR (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C or D); return result; end FNOR; function FNOR (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C or D or E); return result; end FNOR; function FNOR (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C or D or E or F); return result; end FNOR; function FNOR (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C or D or E or F or G); return result; end FNOR; function FNOR (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := not (A or B or C or D or E or F or G or H); return result; end FNOR; -- ***************************************************************** function FNOT (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := not A; return result; end FNOT; function FNOT (A: std_logic) return std_logic is variable result : std_logic; begin result := not A; return result; end FNOT; -- ***************************************************************** function FXNOR (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B); return result; end FXNOR; function FXNOR (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C); return result; end FXNOR; function FXNOR (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C xor D); return result; end FXNOR; function FXNOR (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C xor D xor E); return result; end FXNOR; function FXNOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C xor D xor E xor F); return result; end FXNOR; function FXNOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C xor D xor E xor F xor G); return result; end FXNOR; function FXNOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'high downto A'low); begin result := not (A xor B xor C xor D xor E xor F xor G xor H); return result; end FXNOR; function FXNOR (A, B: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B); return result; end FXNOR; function FXNOR (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C); return result; end FXNOR; function FXNOR (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C xor D); return result; end FXNOR; function FXNOR (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C xor D xor E); return result; end FXNOR; function FXNOR (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C xor D xor E xor F); return result; end FXNOR; function FXNOR (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C xor D xor E xor F xor G); return result; end FXNOR; function FXNOR (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := not (A xor B xor C xor D xor E xor F xor G xor H); return result; end FXNOR; -- ***************************************************************** function FXOR (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B; return result; end FXOR; function FXOR (A, B, C: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C; return result; end FXOR; function FXOR (A, B, C, D: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C xor D; return result; end FXOR; function FXOR (A, B, C, D, E: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C xor D xor E; return result; end FXOR; function FXOR (A, B, C, D, E, F: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C xor D xor E xor F; return result; end FXOR; function FXOR (A, B, C, D, E, F, G: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C xor D xor E xor F xor G; return result; end FXOR; function FXOR (A, B, C, D, E, F, G, H: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := A xor B xor C xor D xor E xor F xor G xor H; return result; end FXOR; function FXOR (A, B: std_logic) return std_logic is variable result : std_logic; begin result := A xor B; return result; end FXOR; function FXOR (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C; return result; end FXOR; function FXOR (A, B, C, D: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C xor D; return result; end FXOR; function FXOR (A, B, C, D, E: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C xor D xor E; return result; end FXOR; function FXOR (A, B, C, D, E, F: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C xor D xor E xor F; return result; end FXOR; function FXOR (A, B, C, D, E, F, G: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C xor D xor E xor F xor G; return result; end FXOR; function FXOR (A, B, C, D, E, F, G, H: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C xor D xor E xor F xor G xor H; return result; end FXOR; -- ***************************************************************** function INCR (A : std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable carry : std_logic; begin carry := '1'; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor carry; carry := A(i) and carry; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor carry; carry := A(i) and carry; end loop; end if; return (carry & result); end INCR; function INCR (A: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := not A; result(1) := A; return result; end INCR; function INCRNC (A : std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A + '1'; return result; end INCRNC; function INCRNC (A: std_logic) return std_logic is variable result : std_logic; begin result := not A; return result; end INCRNC; -- ***************************************************************** function MUL (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector((2*A'length)-1 downto 0); begin result := A * B; return result; end MUL; function MUL (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result := '0' & (A and B); return result; end MUL; -- ***************************************************************** function MUX (A, B: std_logic_vector) return std_logic is variable G : std_logic_vector(A'range); variable C : std_logic_vector(B'range); variable result : std_logic; variable temp : std_logic_vector(B'length downto 0); variable carry : std_logic; variable temp2 : std_logic_vector(B'range); begin for i in C'range loop C(i) := '0'; end loop; for i in G'range loop G(i) := '1'; end loop; for i in A'reverse_range loop temp := not(B xor C) & A(i); for j in temp'range loop G(i) := G(i) and temp(j); end loop; temp2 := C; carry := '1'; if (B'left > B'right) then for j in B'right to B'left loop C(j) := temp2(j) xor carry; carry := temp2(j) and carry; end loop; end if; if (B'left < B'right) then for j in B'right downto B'left loop C(j) := temp2(j) xor carry; carry := temp2(j) and carry; end loop; end if; end loop; result := '0'; for i in G'range loop result := result or G(i); end loop; return result; end MUX; function MUX (A: std_logic_vector; B: std_logic) return std_logic is variable result : std_logic; begin result := (A(A'low) and not B) or (A(A'high) and B); return result; end MUX; -- ***************************************************************** function NMUX (A, B: std_logic_vector; C: std_logic) return std_logic_vector is variable result : std_logic_vector(A'range); variable j : integer; begin j := B'left; if (A'left > A'right) then for i in A'left downto A'right loop result(i) := (A(i) and not C) or (B(j) and C); if (B'left > B'right) then j := j - 1; else j := j + 1; end if; end loop; else for i in A'left to A'right loop result(i) := (A(i) and not C) or (B(j) and C); if (B'left > B'right) then j := j - 1; else j := j + 1; end if; end loop; end if; return result; end NMUX; function NMUX (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := (A and not C) or (B and C); return result; end NMUX; -- ***************************************************************** function REFL (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin if (A'left > A'right) then for i in A'left downto A'right loop result(i) := A(A'high - i); end loop; else for i in A'left to A'right loop result(i) := A(A'high - i); end loop; end if; return result; end REFL; -- ***************************************************************** function ROTL (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable temp : std_logic; begin temp := A(A'left); if (A'left > A'right) then for i in result'right+1 to result'left loop result(i) := A(i - 1); end loop; else for i in result'right-1 downto result'left loop result(i) := A(i + 1); end loop; end if; result(result'right) := temp; return result; end ROTL; function ROTL (A: std_logic) return std_logic is variable result : std_logic; begin result := A; return result; end ROTL; -- ***************************************************************** function ROTR (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable temp : std_logic; begin temp := A(A'right); if (A'left > A'right) then for i in result'left-1 downto result'right loop result(i) := A(i + 1); end loop; else for i in result'left+1 to result'right loop result(i) := A(i - 1); end loop; end if; result(result'left) := temp; return result; end ROTR; function ROTR (A: std_logic) return std_logic is variable result : std_logic; begin result := A; return result; end ROTR; -- ***************************************************************** function SHL0 (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := SHL(A, "01"); return result; end SHL0; function SHL0 (A: std_logic) return std_logic is variable result : std_logic; begin result := '0'; return result; end SHL0; -- ***************************************************************** function SHL1 (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result(result'right) := '1'; if (A'left > A'right) then for i in result'right+1 to result'left loop result(i) := A(i - 1); end loop; else for i in result'right-1 downto result'left loop result(i) := A(i + 1); end loop; end if; return result; end SHL1; function SHL1 (A: std_logic) return std_logic is variable result : std_logic; begin result := '1'; return result; end SHL1; -- ***************************************************************** function SHLIN (A: std_logic_vector; B: std_logic) return std_logic_vector is variable result : std_logic_vector (A'range); begin result(result'right) := B; if (A'left > A'right) then for i in result'right+1 to result'left loop result(i) := A(i - 1); end loop; else for i in result'right-1 downto result'left loop result(i) := A(i + 1); end loop; end if; return result; end SHLIN; function SHLIN (A, B: std_logic) return std_logic is variable result : std_logic; begin result := B; return result; end SHLIN; -- ***************************************************************** function SHR0 (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result := SHR(A, "01"); return result; end SHR0; function SHR0 (A: std_logic) return std_logic is variable result : std_logic; begin result := '0'; return result; end SHR0; -- ***************************************************************** function SHR1 (A: std_logic_vector) return std_logic_vector is variable result : std_logic_vector (A'range); begin result(result'left) := '1'; if (A'left > A'right) then for i in result'left-1 downto result'right loop result(i) := A(i + 1); end loop; else for i in result'left+1 to result'right loop result(i) := A(i - 1); end loop; end if; return result; end SHR1; function SHR1 (A: std_logic) return std_logic is variable result : std_logic; begin result := '1'; return result; end SHR1; -- ***************************************************************** function SHRIN (A: std_logic_vector; B: std_logic) return std_logic_vector is variable result : std_logic_vector (A'range); begin result(result'left) := B; if (A'left > A'right) then for i in result'left-1 downto result'right loop result(i) := A(i + 1); end loop; else for i in result'left+1 to result'right loop result(i) := A(i - 1); end loop; end if; return result; end SHRIN; function SHRIN (A, B: std_logic) return std_logic is variable result : std_logic; begin result := B; return result; end SHRIN; -- ***************************************************************** function SUB (A, B, C: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := A xor B xor C; result(1) := ((not A) and (C or B)) or (C and B); return result; end SUB; function SUB (A, B: std_logic_vector; C: std_logic) return std_logic_vector is variable result : std_logic_vector(A'range); variable borrow : std_logic; variable j : integer; begin borrow := C; j := B'right; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor B(j) xor borrow; borrow := ((not A(i)) and (borrow or B(j))) or (borrow and B(j)); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor B(j) xor borrow; borrow := ((not A(i)) and (borrow or B(j))) or (borrow and B(j)); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; end if; return (borrow & result); end SUB; function SUB (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); variable borrow : std_logic; variable j : integer; begin borrow := '0'; j := B'right; if (A'left > A'right) then for i in A'right to A'left loop result(i) := A(i) xor B(j) xor borrow; borrow := ((not A(i)) and (borrow or B(j))) or (borrow and B(j)); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; else for i in A'right downto A'left loop result(i) := A(i) xor B(j) xor borrow; borrow := ((not A(i)) and (borrow or B(j))) or (borrow and B(j)); if (B'left > B'right) then j := j + 1; else j := j - 1; end if; end loop; end if; return (borrow & result); end SUB; function SUB (A, B: std_logic) return std_logic_vector is variable result : std_logic_vector(1 downto 0); begin result(0) := A xor B; result(1) := (not A) and B; return result; end SUB; function SUBNC (A, B: std_logic_vector) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A - B; return result; end SUBNC; function SUBNC (A, B: std_logic_vector; C: std_logic) return std_logic_vector is variable result : std_logic_vector(A'range); begin result := A - B - C; return result; end SUBNC; function SUBNC (A, B: std_logic) return std_logic is variable result : std_logic; begin result := A xor B; return result; end SUBNC; function SUBNC (A, B, C: std_logic) return std_logic is variable result : std_logic; begin result := A xor B xor C; return result; end SUBNC; -- ***************************************************************** end Nimbus_MVL9_Synopsys;