Half Subtractor (Structural Style Modelling)
Half Subtractor is a digital Circuit that subtracts two 1-bit number and returns two output signals, Difference and Borrow. The operation can be (A-B) or (B-A). The results will differ for these two operations. The following VHDL code is written for (A-B). VHDL Code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity HS_Struct is Port ( A,B : in STD_LOGIC; Diff, Borr : out STD_LOGIC); end HS_Struct; architecture Behavioral of HS_Struct is component andgate is port(A,B : IN STD_LOGIC; Y: OUT STD_LOGIC); end component; component xorgate is port(A,B : IN STD_LOGIC; Y: OUT STD_LOGIC); end component; signal invA : STD_LOGIC; begin invA <= (not A); G1: xorgate port map(A=>A,B=>B,Y=>Diff); G2: andgate port map(invA,B,Borr); end Behavioral; VHDL Code for components: AND Gate VHDL Code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity xorgate is Port ( A,B : in STD_LOGIC; ...