Single bit comparator - PowerPoint PPT Presentation

About This Presentation
Title:

Single bit comparator

Description:

Single bit comparator Single bit comparator gr: a(1) a(0) A(1) sm: a(1) – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 11
Provided by: AmitP4
Learn more at: https://ewh.ieee.org
Category:
Tags: bit | comparator | single

less

Transcript and Presenter's Notes

Title: Single bit comparator


1
Single bit comparator
Single bit comparator
gr a(1) gta(0)
A(1)
sm a(1) lta(0)
A(0)
eq a(1)a(0)
2
Truth table
A(1) A(0) Gr Sm Eq
0 0 0 0 1
0 1 0 1 0
1 0 1 0 0
1 1 0 0 1
3
Boolean equation
  • Gr lt a(1) and (not a(0))
  • Le lt a

4
VHDL Code
  • entity singlebitcomparator is
  • Port ( a in std_logic_vector(1 downto 0)
  • en in std_logic
  • gt out std_logic
  • sm out std_logic
  • eq out std_logic)
  • end singlebitcomparator
  • architecture Behavioral of singlebitcomparator is
  • begin
  • process (en,a)
  • begin
  • if (a(1)gta(0)) then
  • gt lt '1' sm lt '0' eq lt '0'
  • elsif (a(1) lt a(0)) then
  • gt lt '0' sm lt '1' eq lt '0'
  • else
  • gt lt '0' sm lt '0' eq lt '1'
  • end if

5
Waveform of single bit comparator
6
4-bit comparator
4-bit comparator
1-bit comp
A
1-bit comp
B
1-bit comp
1-bit comp
7
Boolean equation for 4-bit comparator
  • Let Aa3a2a1a0
  • Let Bb3b2b1b0
  • Intermediate signal i3,i2,i1 and i0
  • AeqB i3i2i1i0
  • AgtB a3(b3bar)i3a2(b2bar)i3i2a1(b1bar)i3i2i1a
    0(b0bar)
  • AltB Not(AeqBAgtB)

8
VHDL code of 4-bit comp
  • entity comp4bit is
  • Port ( x in std_logic_vector(3 downto 0)
  • y in std_logic_vector(3 downto 0)
  • en in std_logic
  • greater out std_logic
  • smaller out std_logic
  • equal out std_logic)
  • end comp4bit
  • architecture Behavioral of comp4bit is
  • component singlebitcomparator is
  • Port ( a in std_logic_vector(1 downto 0)
  • en in std_logic
  • gt out std_logic
  • sm out std_logic
  • eq out std_logic)
  • end component singlebitcomparator
  • signal temp std_logic_vector(10 downto 0)

9
  • begin
  • u1 singlebitcomparator port map(a(1)gtx(3),a(0)
    gty(3),engten,gtgttemp(0),smgttemp(1),eqgttemp(2))
  • u2 singlebitcomparator port map(a(1)gtx(2),a(0)
    gty(2),engttemp(2),gtgttemp(3),smgttemp(4),eqgttemp
    (5))
  • u3 singlebitcomparator port map(a(1)gtx(1),a(0)
    gty(1),engttemp(5),gtgttemp(6),smgttemp(7),eqgttemp
    (8))
  • u4 singlebitcomparator port map(a(1)gtx(0),a(0)
    gty(0),engttemp(8),gtgttemp(9),smgttemp(10),eqgtequ
    al)
  • greater lt temp(0) or temp(3) or temp(6) or
    temp(9)
  • smaller lt temp(1) or temp(4) or temp(7) or
    temp(10)
  • end Behavioral

10
Waveform of 4-bit comparator
Write a Comment
User Comments (0)
About PowerShow.com