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

📄 packagecpu.vhd

📁 debussy中文使用手册
💻 VHD
字号:
library ieee;use ieee.std_logic_1164.all;-- use ieee.numeric_std.all;package packageCPU is    function to_natural(addr : in std_logic_vector) return natural;    function is_zero(data : in std_logic_vector) return BOOLEAN;    function is_zero(data : in bit_vector) return BOOLEAN;---------------------std_logic_signed.vhd--    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;end;-----------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;-- use ieee.numeric_std.all;package body packageCPU is    function to_natural(addr : in std_logic_vector) return natural is        variable s : natural;    begin        s := 0;        for i in addr'range loop            s := s * 2;            if (addr(i) = '1') then                s := s + 1;            end if;        end loop;        return s;    end;    function is_zero(data : in std_logic_vector) return BOOLEAN is    begin	for i in data'range loop	    if (data(i) /= '0') then		return FALSE;	    end if;	end loop;	return TRUE;    end;    function is_zero(data : in bit_vector) return BOOLEAN is    begin	for i in data'range loop	    if (data(i) /= '0') then		return FALSE;	    end if;	end loop;	return TRUE;    end;    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;--    function "+"(L: STD_LOGIC_VECTOR; R: STD_LOGIC_VECTOR) return STD_LOGIC_VECTOR is        -- pragma label_applies_to plus--        constant length: INTEGER := max(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;end;

⌨️ 快捷键说明

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