?? ihdlutil.vhd
字號:
---- interHDL proprietary information-- Copyright (C) 1990-1998 interHDL inc.-- All rights reserved.---- ihdlutil package. produced by interVHDL (R)-- ihdlutil package. Implements utility functions for the VtoVH translator. Use the m4-- Unix utility to convert from vrlgutils.vhd.template to vrlgutils.vhd or use a text-- editor to manually do the conversion as shown in the line below.library ieee;USE ieee.std_logic_1164.all;USE ieee.std_logic_arith.all;--USE ieee.std_logic_unsigned.all;package ihdlutil isfunction COND(c: std_logic; l, r: integer) return integer;function COND(c: std_logic; l, r: std_logic) return std_logic;function COND(c: std_logic; l, r: std_logic_vector) return std_logic_vector;function bool2stdlogic(c: boolean) return std_logic;function bool2integer(c: boolean) return integer;function bool2stdlogic_vector(c: boolean; l: integer) return std_logic_vector;function eq2std_logic (l, r: std_logic) return std_logic;function eq2std_logic (l, r: std_logic_vector) return std_logic;function eq2std_logic (l, r: integer) return std_logic;function eq2std_logic (l, r: boolean) return std_logic;function eq2integer (l, r: std_logic) return integer;function eq2integer (l, r: std_logic_vector) return integer;function eq2integer (l, r: integer) return integer;function eq2integer (l, r: boolean) return integer;function neq2std_logic (l, r: std_logic) return std_logic;function neq2std_logic (l, r: std_logic_vector) return std_logic;function neq2std_logic (l, r: integer) return std_logic;function neq2std_logic (l, r: boolean) return std_logic;function neq2integer (l, r: std_logic) return integer;function neq2integer (l, r: std_logic_vector) return integer;function neq2integer (l, r: integer) return integer;function neq2integer (l, r: boolean) return integer;function OR_REDUCE(v: std_logic_vector) return std_logic;function OR_REDUCE(v: std_logic) return std_logic;function NOR_REDUCE(v: std_logic_vector) return std_logic;function NOR_REDUCE(v: std_logic) return std_logic;function AND_REDUCE(v: std_logic_vector) return std_logic;function AND_REDUCE(v: std_logic) return std_logic;function NAND_REDUCE(v: std_logic_vector) return std_logic;function NAND_REDUCE(v: std_logic) return std_logic;function XOR_REDUCE(v: std_logic_vector) return std_logic;function XOR_REDUCE(v: std_logic) return std_logic;function XNOR_REDUCE(v: std_logic_vector) return std_logic;function XNOR_REDUCE(v: std_logic) return std_logic;function stdlogic_to_int(v:std_logic_vector) return integer;function shl (v: std_logic_vector; count: integer) return std_logic_vector;function shr (v: std_logic_vector; count: integer) return std_logic_vector;function shl (v: std_logic_vector; count: std_logic_vector) return std_logic_vector;function shr (v: std_logic_vector; count: std_logic_vector) return std_logic_vector;function shl (v: std_logic_vector; count: std_logic) return std_logic_vector;function shr (v: std_logic_vector; count: std_logic) return std_logic_vector;function shl (v: integer; count: integer) return integer;function shr (v: integer; count: integer) return integer;function shl (v: std_logic; count: integer) return std_logic;function shr (v: std_logic; count: integer) return std_logic;function "=" (l: integer; r: std_logic_vector) return boolean;function "=" (l: std_logic_vector; r: integer) return boolean;function "=" (l: integer; r: std_logic) return boolean;function "=" (l: std_logic; r: integer) return boolean;function compareX (lft, rgt: integer) return boolean;function compareZ (lft, rgt: integer) return boolean;function compareX (lft, rgt: std_logic) return boolean;function compareZ (lft, rgt: std_logic) return boolean;function compareX (lft, rgt: std_logic_vector) return boolean;function compareZ (lft, rgt: std_logic_vector) return boolean;function "+" (lft: std_ulogic; rgt: std_ulogic) return std_logic_vector;function "+" (lft: std_ulogic; rgt: std_ulogic) return std_logic;function "+" (lft: std_logic_vector; rgt: std_logic_vector) return std_logic_vector;function "-" (lft: std_ulogic; rgt: std_ulogic) return std_logic_vector;function "-" (lft: std_ulogic; rgt: std_ulogic) return std_logic;function "-" (lft: std_logic_vector; rgt: std_logic_vector) return std_logic_vector;function conv_std_logic (lft: integer) return std_logic;function conv_std_logic (lft: std_logic_vector) return std_logic;function conv_std_logic_vector (lft: std_logic) return std_logic_vector;function conv_std_logic_vector (lft: boolean) return std_logic_vector;function conv_integer (lft: std_logic_vector) return integer;function mult_concat(i : integer; s: std_logic) return std_logic_vector;function mult_concat(i : integer; s: std_logic_vector) return std_logic_vector;end ihdlutil;package body ihdlutil isfunction COND(c: std_logic; l, r: integer) return integer is variable cc: integer;begin if l = r then cc := l; elsif c = '1' then cc := l; elsif c = '0' then cc := r; else cc := 0; end if; return cc;end COND;function COND(c: std_logic; l, r: std_logic) return std_logic is variable cc: std_logic;begin if l = r then cc := l; elsif c = '1' then cc := l; elsif c = '0' then cc := r; else cc := 'X'; end if; return cc;end COND;function COND(c: std_logic; l, r: std_logic_vector) return std_logic_vector is variable cc: std_logic_vector (l'length-1 downto 0);begin if l = r then cc := l; elsif c = '1' then cc := l; elsif c = '0' then cc := r; else for i in l'length-1 downto 0 loop cc(i) := 'X'; end loop; end if; return cc;end COND;function bool2stdlogic(c: boolean) return std_logic is begin if c then return '1'; else return '0'; end if;end bool2stdlogic;function bool2integer(c: boolean) return integer is begin if c then return 1; else return 0; end if;end bool2integer;function bool2stdlogic_vector(c: boolean; l: integer) return std_logic_vector is variable cc: std_logic_vector (l-1 downto 0);begin for i in l-1 downto 0 loop cc(i) := '0'; end loop; if c then cc(0) := '1'; else cc(0) := '0'; end if; return cc;end bool2stdlogic_vector;function eq2std_logic (l, r: std_logic) return std_logic isbegin if (l XOR r) = 'X' then return 'X'; elsif l = r then return '1'; else return '0'; end if;end eq2std_logic;function eq2std_logic (l, r: std_logic_vector) return std_logic isbegin if XOR_REDUCE(l)='X' OR XOR_REDUCE(r)='X' then return 'X'; elsif l = r then return '1'; else return '0'; end if;end eq2std_logic;function eq2std_logic (l, r: integer) return std_logic isbegin if l = r then return '1'; else return '0'; end if;end eq2std_logic;function eq2std_logic (l, r: boolean) return std_logic isbegin if l = r then return '1'; else return '0'; end if;end eq2std_logic;function eq2integer (l, r: std_logic) return integer isbegin if (l XOR r) = 'X' then return 0; elsif l = r then return 1; else return 0; end if;end eq2integer;function eq2integer (l, r: std_logic_vector) return integer isbegin if XOR_REDUCE(l)='X' OR XOR_REDUCE(r)='X' then return 0; elsif l = r then return 1; else return 0; end if;end eq2integer;function eq2integer (l, r: integer) return integer isbegin if l = r then return 1; else return 0; end if;end eq2integer;function eq2integer (l, r: boolean) return integer isbegin if l = r then return 1; else return 0; end if;end eq2integer;function neq2std_logic (l, r: std_logic) return std_logic isbegin if (l XOR r) = 'X' then return 'X'; elsif l /= r then return '1'; else return '0'; end if;end neq2std_logic;function neq2std_logic (l, r: std_logic_vector) return std_logic isbegin if XOR_REDUCE(l)='X' OR XOR_REDUCE(r)='X' then return 'X'; elsif l /= r then return '1'; else return '0'; end if;end neq2std_logic;function neq2std_logic (l, r: integer) return std_logic isbegin if l /= r then return '1'; else return '0'; end if;end neq2std_logic;function neq2std_logic (l, r: boolean) return std_logic isbegin if l /= r then return '1'; else return '0'; end if;end neq2std_logic;function neq2integer (l, r: std_logic) return integer isbegin if (l XOR r) = 'X' then return 1; elsif l /= r then return 1; else return 0; end if;end neq2integer;function neq2integer (l, r: std_logic_vector) return integer isbegin if XOR_REDUCE(l)='X' OR XOR_REDUCE(r)='X' then return 1; elsif l /= r then return 1; else return 0; end if;end neq2integer;function neq2integer (l, r: integer) return integer isbegin if l /= r then return 1; else return 0; end if;end neq2integer;function neq2integer (l, r: boolean) return integer isbegin if l /= r then return 1; else return 0; end if;end neq2integer;function OR_REDUCE(v: std_logic_vector) return std_logic isvariable result: std_logic;begin result:='0'; for i in v'high downto v'low loop if v(i)='1' then return '1'; elsif v(i)='Z' or v(i)='X' then result:='X'; end if; end loop; return result;end OR_REDUCE;function OR_REDUCE(v: std_logic) return std_logic isbegin return v;end OR_REDUCE;function NOR_REDUCE(v: std_logic_vector) return std_logic isbegin return NOT OR_REDUCE(v);end NOR_REDUCE;function NOR_REDUCE(v: std_logic) return std_logic isbegin return NOT OR_REDUCE(v);end NOR_REDUCE;function AND_REDUCE(v: std_logic_vector) return std_logic isvariable result: std_logic;begin result:='1'; for i in v'high downto v'low loop if v(i)='0' then return '0'; elsif v(i)='Z' or v(i)='X' then result:='X'; end if; end loop; return result;end AND_REDUCE;function AND_REDUCE(v: std_logic) return std_logic isbegin return v;end AND_REDUCE;function NAND_REDUCE(v: std_logic_vector) return std_logic isbegin return NOT AND_REDUCE(v);end NAND_REDUCE;function NAND_REDUCE(v: std_logic) return std_logic isbegin return NOT AND_REDUCE(v);end NAND_REDUCE;function XOR_REDUCE(v: std_logic_vector) return std_logic isvariable result: std_logic;begin result:='0'; for i in v'high downto v'low loop if v(i)='X' or v(i)='Z' or v(i)='U' then return 'X'; elsif v(i)='1' then result:=not result; end if; end loop; return result;end XOR_REDUCE;function XOR_REDUCE(v: std_logic) return std_logic isbegin return v;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -