Beruflich Dokumente
Kultur Dokumente
A digital clock is a type of clock that displays the time digitally, i.e. in ciphers, as
opposed to an analog clock, where the time is displayed by hands. Usually, digitally
clocks are associated with electronic drives whereas; analog clocks are driven
mechanically or electronically. Digital clocks typically use the 50 or 60 hertz oscillation
of AC power or a crystal oscillator as in a quartz clock to keep time. Most digital clocks
display the hour of the day in 24 hour format
23:59:59
Problem Statement:
The main purpose is to simulate the working of digital clock over Modelsim or any other
simulator using VHDL (VHSIC hardware description language. It consists of 6 seven
segment displays. Each pair is used for second, minute and hour respectively. There is
one MOD 60 synchronous counter for seconds, one MOD 60 synchronous counter for
minutes and one MOD 24 synchronous counter for hour. MOD 60 counters consist of one
MOD 10 counter and one MOD 6 counter. MOD 24 counter consists of one MOD 10
counter and one MOD 3 counter. Output of each counter is fed to seven segment display.
Alarm - The alarm is operated by comparing the output of the seven segment code to
input given by the user. If both match, the alarm bit changes to 1.
Circuit Design –
1. Mod 10 Counter –
2. Mod 6 Counter –
Output of a Mod 6 counter
3. Mod 3 Counter –
4. Basic Block diagram for digital clock –
Implementation Issues -
When second counter completes 60 stages it sends an enable signal to the minute counter
and similarly when minute counter completes its 60 stages (ie.00 to 59) it enables the
hour counter. When hour counter completes 24 stages (ie.00 to 23), it resets all counters
to 00.
To actually see the seconds, then the output of the counters needs to drive a display. The
two counters produce binary numbers. The divide-by-10 counter is producing a 0-1-2-3-
4-5-6-7-8-9 sequence on its outputs, while the divide-by-6 counter is producing a 0-1-2-
3-4-5 sequence on its outputs.
The alarm is activated by comparing the output of the clock [hours and minutes only] to
input given by the user. If both match, the alarm bit changes to 1.
VHDL code for Mod 10 counter –
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mod10 is
Port (clk : in STD_LOGIC;
reset : in STD_LOGIC;
y: inout STD_LOGIC_vector(3 downto 0));
end mod10;
begin
begin
else y<=y+1;
end if;
else y<=y;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mod6 is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
y : inout STD_LOGIC_VECTOR (2 downto 0));
end mod6;
architecture Behavioral of mod6 is
begin
process (clk,reset)
begin
if reset ='1' then y<="000" ;
else y<=y+1;
end if;
else
y<=y;
end if ;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mod3 is
Port (clk : in STD_LOGIC;
reset : in STD_LOGIC;
y: inout STD_LOGIC_vector(1 downto 0));
end mod3;
begin
begin
else y<=y+1;
end if;
else y<=y;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity display is
Port ( i : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (6 downto 0));
end display;
begin
process (i)
begin
if i="0000" then y<="1111110" ;
end if;
end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity digitalalarmclock is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
insec1:in std_logic_vector(3 downto 0);
insec2:in std_logic_vector(2 downto 0);
inmin1:in std_logic_vector(3 downto 0);
inmin2:in std_logic_vector(2 downto 0);
inhour1:in std_logic_vector(3 downto 0);
inhour2:in std_logic_vector(1 downto 0);
inminalrm1:in std_logic_vector(3 downto 0);
inminalrm2:in std_logic_vector(2 downto 0);
inhouralrm1:in std_logic_vector(3 downto 0);
inhouralrm2:in std_logic_vector(1 downto 0);
component mod10
Port (clk : in STD_LOGIC;
reset : in STD_LOGIC;
y: inout STD_LOGIC_vector(3 downto 0));
end component;
component mod3
Port (clk : in STD_LOGIC;
reset : in STD_LOGIC;
y : inout STD_LOGIC_VECTOR (1 downto 0));
end component;
component mod6
Port (clk : in STD_LOGIC;
reset : in STD_LOGIC;
y : inout STD_LOGIC_VECTOR (2 downto 0));
end component;
component display5
Port (i : in STD_LOGIC_VECTOR (2 downto 0);
y : out STD_LOGIC_VECTOR (6 downto 0));
end component;
component display
Port (i : in STD_LOGIC_VECTOR (3 downto 0);
y : out STD_LOGIC_VECTOR (6 downto 0));
end component;
component display2
Port (i : in STD_LOGIC_VECTOR (1 downto 0);
y : out STD_LOGIC_VECTOR (6 downto 0));
end component;
signal s1,s2,s3,s4,s5,s6,s7:std_logic;
component and1
Port (a : in STD_LOGIC;
b : in STD_LOGIC;
c : out STD_LOGIC);
end component;
component or1
Port (a : in STD_LOGIC;
b : in STD_LOGIC;
c : out STD_LOGIC);
end component;
begin
process(insec1,insec2,inmin1,inmin2,inhour1,inhour2,sec1,sec2,min1,min2,h
our1,hour2 ,inminalrm1,inminalrm2,inhouralrm1,inhouralrm2)
begin
if insec1=sec1 and insec2=sec2 and inmin1=min1 and inmin2=min2 and
inhour1=hour1 and inhour2=hour2 then output<='1';
else output<='0';
end if;
else sout<='0';
end if;
end process;
end Behavioral;
Snapshots –
References –
Following is the list of books from which help has been taken for the completion of this
project.
1 VHDL-PRIMER J.Bhasker
Web References –