VHDL

반감산기 전감산기(schematic,소스코드)

전자자연인 2021. 6. 8. 21:36
반응형

반감산기


 두입력 A와 B에 대해서 Y = A - B 의 형식으로 출력을 얻고 이때 감산의 경우에는 10진산술연산에서와 같이 자리 빌림수가 발생하기 때문에 그에 대한 해석을 진행 따라서 반감산기의 출력은 2가지로 구성 차(difference)와 자리빌림(borrow)가 출력

반감산기의 논리식과 논리회로

 

반감산기 schematic

■반감산기 자료흐름적 모델링

library ieee;
use ieee.std_logic_1164.all;

entity half_substractor_dataflow is
port ( X : in std_logic;
Y : in std_logic;
D : out std_logic;
Bo : out std_logic);
end half_substractor_dataflow;

architecture Dataflow of half_substractor_dataflow is

begin
D <= X xor Y; --D는 X xor Y의 연산
Bo <= (not X) and Y; -- Bo는 notX and Y 연산
end Dataflow;

 

전감산기

 

전감산기의 schematic, (temp1,temp2.temp3는 구조적모델링에 신호할당을 위한 설명)


library ieee;
use ieee.std_logic_1164.all;
 
entity ful_substractor_structure is
Port (X : in std_logic;
Y : in std_logic;
Bi : in std_logic;
D : out std_logic;
Bo : out std_logic);
end ful_substractor_structure;
 
architecture Structural of ful_substractor_structure is
signal temp1: std_logic; --신호 temp1 정의
signal temp2: std_logic; --신호 temp2 정의
signal temp3: std_logic; --신호 temp3 정의

component half_substractor_dataflow is --사용할반감산기
port (X, Y : in std_logic; D,Bo:out std_logic); --입력출력 포트
end component;

component OR_gate is --사용할 OR게이트
port (A,B: in std_logic; C:out std_logic); --입력출력포트
end component;

begin

HALF1: half_substractor_dataflow port map(X,Y,temp1,temp2); -- 첫 번째 반감산기에 X,Y를 입력으로 temp1, temp2를 반감산기의 D,Bo신호에 출력
HALF2: half_substractor_dataflow port map(temp1,Bi,D,temp3); --
두 번째 반감산기에 temp1,Bi를 입력으로 D,temp3를 반감산기의 D,Bo신호에 출력
ORG: OR_gate port map(temp3,temp2,Bo); --OR게이트의 temp3,temp2를 입력으로 Bo를 출력

end structural;

반응형