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

📄 超前进位加法器.txt

📁 超前进位加法器得VHDL实现小点资料代码
💻 TXT
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity add_n is
 generic
  (
  n:integer:=8
  );
 port
  (
  cin:in std_logic;
  cout:out std_logic;
  a,b: in std_logic_vector(n-1 downto 0);
  s:out std_logic_vector(n-1 downto 0)
  );
end entity ;
--advanced carry adder 1
architecture addn_arch3 of add_n is
 begin
 process(a,b,cin)
  variable c: std_logic_vector(n downto 0);
  variable g,p: std_logic_vector(n-1 downto 0);
  variable s1:std_logic_vector(n-1 downto 0);
  begin
  for i in 0 to n-1 loop
   g(i):=a(i) and b(i);
   p(i):=a(i)  or b(i);
  end loop;
  c(0):=cin;
  for i in 0 to n-1 loop
   c(i+1):=g(i) or (p(i) and c(i));
--   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--                      |  这里是进位的超前生成,我采用了递推的方法,实际上递
推展开就是
--                      |  c(i+1)=g(i)+p(i)g(i-1)+...+p(i)p(i-1)...p(1)g(0)
--                      |         +p(i)p(i-1)...p(0)c(0);   (1)
--                      |  这才是超前进位的组合逻辑表达式,但如果我就是按照程
序中的那样
--                      |  写,系统综合时会生成逻辑表达式(1),还是把每一个c(i)
作为c(i+1)的
--                      |  输入呢,如果是后者的话,传输会有很大延时,也就不是
超前进位了。
--                      |  这个涉及到综合的问题希望与各位高手讨论。
--                      ----------------------------------------------------
-------------
  end loop;
   cout<=c(n);
  for i in 0 to n-1 loop
   s1(i):=(not g(i)) and p(i);
  end loop;
  for i in 0 to n-1 loop
   s(i)<=s1(i) xor c(i);
  end loop;
 end process;
end architecture;  

⌨️ 快捷键说明

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