Professional Documents
Culture Documents
College of Engineering KIET, Karachi: I. Objectives
College of Engineering KIET, Karachi: I. Objectives
KIET, Karachi
Advanced Digital
System Design
04
I. Objectives:
III. Background:
IV.
Procedure (part A)
Write VHDL code for BCD to seven segment decoder and implement it on
Nexys2 board making use of slide switches as input and one of the 7-segment display as
its output.
V.
Exploratory Exercises:
1. Use two seven segment displays to show numbers greater than 9 as two
digit decimal numbers.
2. To use more than one seven-segment displays you will have to use
advanced technique as data lines are only 8-bit and are multiplexed. Code
snippets are some hints are given in the following:
Help will also be given during the lab.
-- This block shows an example to illustrate multiplexing output to more than one 7segments
-- This block shows how to multiplex output to different 7-segments
process (khertz_en, ChangeDigit)
begin
if khertz_en'event and khertz_en = '1' then
ChangeDigit <=std_logic_vector(unsigned(ChangeDigit) + 1);
else
ChangeDigit <= ChangeDigit;
end if ;
case ChangeDigit is
when "00" => SSgSel <= "0111" ; curr <= BCDOut(11 downto 8);--curr <=OutPutToSSG1;
when "01"
=> SSgSel <= "1011" ;
curr <= BCDOut(7 downto 4);--curr <=
OutPutToSSG2;
when "10"
=> SSgSel <= "1101" ;
curr <= BCDOut(3 downto 0);--curr
<=OutPutToSSG3;
when others => SSgSel <= "1110" ; curr <= CandyCount;
--curr <=OutPutToSSG4;
end case;
--Binary to seven-segment decoder
case curr is
--.gfedbca
when "0000" => ssg <= "11000000" ;
when "0001" => ssg <= "11111001" ;
when "0010" => ssg <= "10100100" ;
when "0011" => ssg <= "10110000" ;
when "0100" => ssg <= "10011001" ;
when "0101" => ssg <= "10010010" ;
when "0110" => ssg <= "10000010" ;
when "0111" => ssg <= "11111000" ;
when "1000" => ssg <= "10000000" ;
when "1001" => ssg <= "10010000" ;
when "1010" => ssg <= "10001000" ;
when "1011" => ssg <= "10000011" ;
when "1100" => ssg <= "11000110" ;
when "1101" => ssg <= "10100001" ;
when "1110" => ssg <= "10000110" ;
when "1111" => ssg <= "10001110" ;
when others => ssg <= "11000000" ;
end case ;
end process ;