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

📄 divarruns.vhd

📁 Cadence的VHDL运算库包
💻 VHD
字号:
--------------------------------------------------------------------------------- Title       : Unsigned array divider-- Project     : VHDL Library of Arithmetic Units--------------------------------------------------------------------------------- File        : DivArrUns.vhd-- Author      : Reto Zimmermann  <zimmi@iis.ee.ethz.ch>-- Company     : Integrated Systems Laboratory, ETH Zurich-- Date        : 1997/12/03--------------------------------------------------------------------------------- Copyright (c) 1998 Integrated Systems Laboratory, ETH Zurich--------------------------------------------------------------------------------- Description :-- Restoring array divider for unsigned numbers. Divisor must be normalized-- (i.e. Y(widthY-1) = '1')-------------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;library synergy;  use synergy.signed_arith.all;library arith_lib;use arith_lib.arith_lib.all;-------------------------------------------------------------------------------entity DivArrUns is  generic (widthX : positive := 16;	-- word width of X	   widthY : positive := 8);	-- word width of Y  port (X : in std_logic_vector(widthX-1 downto 0);  -- dividend	Y : in std_logic_vector(widthY-1 downto 0);  -- divisor, normalized        Q : out std_logic_vector(widthX-widthY downto 0);  -- quotient        R : out std_logic_vector(widthY-1 downto 0));  -- remainderend DivArrUns;-------------------------------------------------------------------------------architecture Behavioral of DivArrUns is  signal Xuns : unsigned(widthX-1 downto 0);  -- unsigned  signal Yuns : unsigned(widthY-1 downto 0);  -- unsigned  signal Quns : unsigned(widthX-1 downto 0);  -- unsigned  signal Runs : unsigned(widthY-1 downto 0);  -- unsignedbegin  -- type conversion: std_logic_vector -> unsigned  Xuns <= unsigned(X);  Yuns <= unsigned(Y);  -- division => quotient  Quns <= Xuns / Yuns;  -- modulo => remainder  Runs <= Xuns mod Yuns;  -- type conversion: unsigned -> std_logic_vector  Q <= std_logic_vector(Quns(widthX-widthY downto 0));  R <= std_logic_vector(Runs);end Behavioral;-------------------------------------------------------------------------------architecture Structural of DivArrUns is  constant widthQ : positive := widthX-widthY+1;  -- word width of Q  signal YI : std_logic_vector(widthY downto 0);  -- inverted Y  signal ST : std_logic_vector(widthQ*(widthY+1)-1 downto 0);  -- sums  signal RT : std_logic_vector((widthQ+1)*(widthY+2)-1 downto 0); -- remainders  signal CT : std_logic_vector(widthQ*(widthY+2)-1 downto 0);  -- carriesbegin  -- invert divisor Y for subtraction  YI <= '1' & not Y;  -- first partial remainder is dividend X  RT(widthQ*(widthY+2)+widthY downto widthQ*(widthY+2)+1) <=    '0' & X(widthX-1 downto widthX-widthY+1);  -- process one row for each quotient bit  row : for k in widthQ-1 downto 0 generate    -- carry-in = '1' for subtraction    CT(k*(widthY+2)) <= '1';    -- attach next dividend bit to current remainder    RT((k+1)*(widthY+2)) <= X(k);    -- perform subtraction using ripple-carry adder    -- (currend partial remainder - divisor)    bits : for i in widthY downto 0 generate      fa : FullAdder	port map (YI(i), RT((k+1)*(widthY+2)+i), CT(k*(widthY+2)+i),		  ST(k*(widthY+1)+i), CT(k*(widthY+2)+i+1));    end generate bits;    -- if subtraction result is negative => quotient bit = '0'    Q(k) <= CT(k*(widthY+2)+widthY+1);    -- restore previous partial remainder if quotient bit = '0'    RT(k*(widthY+2)+widthY+1 downto k*(widthY+2)+1) <=      RT((k+1)*(widthY+2)+widthY downto (k+1)*(widthY+2))				     when CT(k*(widthY+2)+widthY+1) = '0' else      ST(k*(widthY+1)+widthY downto k*(widthY+1));  end generate row;  -- last partial remainder is division remainder  R <= RT(widthY downto 1);end Structural;-------------------------------------------------------------------------------

⌨️ 快捷键说明

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