datapath_pack_body.vhd

来自「design compile synthesis user guide」· VHDL 代码 · 共 78 行

VHD
78
字号
----------------------------------------------------------------- Package body for DATAPATH functions and types-- RTL Analyzer tutorial design----------------------------------------------------------------- Revision 1.4  1998/06/08  dannyb-- format---- Revision 1.3  1997/03/06  baldrik-- none---- Revision 1.2  1997/02/08  baldrik-- use UNSIGNED for arithmetic---- Revision 1.1  1997/02/07  baldrik-- Initial revision---------------------------------------------------------------Library IEEE;use IEEE.Std_Logic_1164.all;use IEEE.Std_Logic_arith.all;use IEEE.Std_Logic_unsigned.all;package body DATAPATH is  function datapath ( POINTER    : in  POINT_TYPE;                      ADDR       : in  ADDR_TYPE) return                      CNT_TYPE is    constant P_TOP : POINT_TYPE :=       std_logic_vector(CONV_UNSIGNED(128, POINT_width));    constant C_ZERO: CNT_TYPE :=       std_logic_vector(CONV_UNSIGNED(0, CNT_width));    constant C_ONE : CNT_TYPE :=       std_logic_vector(CONV_UNSIGNED(1, CNT_width));    constant C_TWO : CNT_TYPE :=       std_logic_vector(CONV_UNSIGNED(2, CNT_width));    variable X,              D    : ADDR_TYPE;    variable A,              B,             C    : CNT_TYPE;    begin  X := ("00000000" &         (P_TOP - POINTER));    D := (ADDR  - X);    if  (X >= ADDR ) then    A := C_ZERO;  else -- A = D(10:0)    for i in CNT_width -1 downto 0 loop              A(i) := D(i);    end loop;            end if;    if  (X >= ADDR ) then    C := C_ZERO;  else    for i in POINT_width -1 downto 0 loop      C(i) := D(i);    end loop;  end if;    if (C = C_ZERO ) then    B := C_ONE;  else    B := C_TWO;  end if;      return (A + B);end datapath; -- functionend DATAPATH; -- package body

⌨️ 快捷键说明

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