Computer Engineering/Digital System Architenture
Variable을 이용한 전가산기의 구현 VHDL
MINOK
2008. 10. 8. 22:26
Variable 방식 : process나 부프로그램(function과 procedure)에서만 사용되며 variable이 지니는 값도 내적변수이다. 대입기호 :=는 즉시라는 의미를 가지고 있으며 <=과 달리 즉시 대입된다.
VHDL code
library ieee;
use ieee.std_logic_1164.all;
entity exam4 is
port( a, b, c_in : in std_logic;
s, c_out : out std_logic);
end exam4;
architecture exam of exam4 is
begin
process(a, b, c_in)
variable s1,c1,c2 : std_logic;
begin
s1 := a xor b;
c1 := a and b;
s <= s1 xor c_in;
c2 := s1 and c_in;
c_out <= c1 or c2;
end process;
end exam;