教材:VHDL硬件描述语言与数字逻辑电路设计(第三版)
软件:Quartus II
要求:设计一个一位全加器,实体名称为“full_adder”,其引脚与功能如下表。
说明:XOR为逻辑异或
输入包括两个加数和一个进位信号,输出一个和与进位信号。
代码:
library ieee;
use ieee.std_logic_1164.all;
entity full_adder is
port ( a,b,ci: in std_logic;
s,co : out std_logic );
end entity;
architecture rtl of full_adder is
begin
s <= a xor b xor ci;
co <= (a and b) or (a and ci) or (b and ci);
end rtl;
RTL view:
仿真:
注:仿真与RTL view具体操作见关联文章。