Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Comparators
Comparator Structure
• The 74x86 XOR gate can be used as a 1-bit comparator. The active-high
output, DIFF, is asserted if the inputs are different.
• Given enough XOR gates and wide enough OR gates, comparators with any
number of input bits can be built.
Iterative Circuits
• The circuit contains n identical modules, each of which has both primary inputs and outputs
and cascading inputs and outputs.
• The leftmost cascading inputs are called boundary inputs and are connected to fixed logic
values in most iterative circuits.
• The rightmost cascading outputs are called boundary outputs and usually provide important
information.
• Iterative circuits are well suited to problems that can be solved by a simple iterative
algorithm:
• Eg: The 74x85 4-bit comparator and the 74x283 4-bit adder are MSI circuits that can be used
as the individual modules in a larger iterative circuit.
Iterative Circuits
An Iterative Comparator Circuit
• Two n-bit values X and Y can be compared one bit at a time using a single bit EQi at each step to
keep track of whether all of the bit-pairs have been equal so far:
end process;
end vcompare_arch;
VHDL Program
library IEEE; architecture vcompa_arch of vcompa is
use IEEE.std_logic_1164.all; begin
use IEEE.std_logic_arith.all; process (A, B, C, D)
Begin
entity vcompa is
port ( A_LT_B <= '0'; B_GE_C <= '0'; A_EQ_C <=
A, B: in UNSIGNED (7 downto 0); '0'; C_NEG <= '0'; D_BIG <= '0'; D_NEG
C: in SIGNED (7 downto 0); <= '0';
D: in STD_LOGIC_VECTOR (7 downto 0); if A < B then A_LT_B <= '1'; end if;
A_LT_B, B_GE_C, A_EQ_C, C_NEG, if B >= C then B_GE_C <= '1'; end if;
D_BIG, D_NEG: out STD_LOGIC if A = C then A_EQ_C <= '1'; end if;
); if C < 0 then C_NEG <= '1'; end if;
end vcompa; if UNSIGNED(D) > 200 then D_BIG <= '1';
end if;
if SIGNED(D) < 0 then D_NEG <= '1'; end
if;
end process;
end vcompa_arch;