Vlsi Manual
Vlsi Manual
TRUTH TABLE
Input Output
A B S C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
3-BIT ADDER (FULL ADDER)
TRUTH TABLE
Input Output
A B Cin Sum Carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
1
EX NO:
DATE:
AIM:
TOOLS REQUIRED:
PROCEDURE:
2. The main page is opened,click the file option to create a new source in VHDL.
6. Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7. Then in the edit option, force is selected and the values are given.
PROGRAM :
library ieee;
use ieee.std_logic_1164.all;
entity half is
port ( A,B : in std_logic ;
S , C : out std_logic);
end half ;
architecture ha of half is
begin
S<= A xor B ;
C <= (A and B);
end ha ;
2
SIMULATION RESULTS:
3
PROGRAM:
Entity fulladder is
port( A,B,Cin : in std_logic;
sum,Cout: out std_logic);
end;
RESULT:
Thus the adders was designed using VHDL & simulated using modelsim.
4
BLOCK DIAGRAM:
TRUTH TABLE(8:1)
Selection Output
Input
lines
S Y
a b c d e f g h S1 S2
0
D 0 0 0 0 0 0 0 0 0 0 a
0 D 0 0 0 0 0 0 0 0 1 b
0 0 D 0 0 0 0 0 0 1 0 C
0 0 0 D 0 0 0 0 0 1 1 d
0 0 0 0 D 0 0 0 1 0 0 e
0 0 0 0 0 D 0 0 1 0 1 f
0 0 0 0 0 0 D 0 1 1 0 g
0 0 0 0 0 0 0 D 1 1 1 h
5
6
EX NO:
DATE:
AIM:
To design 8:1 mux and 1:8 demux using VHDL & simulate using modelsim.
TOOLS REQUIRED:
Simulation:modelsim
2.The main page is opened;click the file option to create a new source in VHDL.
6.Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7.Then in the edit option,force is selected and the values are given.
MULTIPLEXER
PROGRAM:
Behavioral Model
library ieee;
use ieee.std_logic_1164.all;
entity mux8 is
port(a,b,c,d,e,f,g,h:in std_logic;
s:in std_logic_vector(2 downto 0);
y:out std_logic);
7
CIRCUIT DIAGRAM:
EQUATION:
8
end mux8;
architecture arch of mux8 is
begin
process(a,b,c,d,e,f,g,h,s)
begin
case s is
when"000"=>
y<=a;
when"001"=>
y<=b;
when"010"=>
y<=c;
when"011"=>
y<=d;
when"100"=>
y<=e;
when"101"=>
y<=f;
when"110"=>
y<=g;
when"111"=>
y<=h;
when others=>
null;
end case;
end process;
end arch;
9
EQUATION:
D S0 S1 S2 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
1 0 0 0 D 0 0 0 0 0 0 0
1 0 0 1 0 D 0 0 0 0 0 0
1 0 1 0 0 0 D 0 0 0 0 0
1 0 1 1 0 0 0 D 0 0 0 0
1 1 0 0 0 0 0 0 D 0 0 0
1 1 0 1 0 0 0 0 0 D 0 0
1 1 1 0 0 0 0 0 0 0 D 0
1 1 1 1 0 0 0 0 0 0 0 D
10
DEMULTIPLEXER
PROGRAM:
Dataflow Model
library ieee;
use ieee.std_logic_1164.all;
entity demuxx is
port(s:in std_logic_vector(2 downto 0);
d:in std_logic;
y:out std_logic_vector(0 to 7));
end demuxx;
architecture data of demuxx is
begin
y(0)<=((not s(0)) and (not s(1)) and (not s(2)) and d);
y(1)<=(s(0) and (not s(1)) and (not s(2)) and d);
y(2)<=((not s(0)) and s(1) and (not s(2)) and d);
y(3)<=(s(0) and s(1) and (not s(2)) and d);
y(4)<=((not s(0)) and (not s(1)) and s(2) and d);
y(5)<=(s(0) and (not s(1)) and s(2) and d);
y(6)<=((not s(0)) and s(1) and s(2) and d);
y(7)<=(s(0) and s(1) and s(2) and d);
end data;
11
SIMULATION RESULTS:
12
RESULT:
Thus the design of 8:1 mux and 1:8 demux using VHDL & simulated using
modelsim.
13
CIRCUIT DIAGRAM:
TRUTH TABLE
I0 I1 I2 I3 I4 I5 I6 I7 Y2 Y1 Y0
1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0 1
0 0 0 0 0 0 1 0 1 1 0
0 0 0 0 0 0 0 1 1 1 1
14
EXP.NO:
DATE:
AIM:
To design encoder and decoder using VHDL & simulate using modelsim.
TOOLS REQUIRED:
Simulation: Modelsim
2. The main page is opened; click the file option to create a new source in VHDL.
6. Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7. Then in the edit option, force is selected and the values are given.
ENCODER
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity encoder is
port (i: in std_logic_vector(7 downto 0);
y:out std_logic_vector(2 downto 0));
15
BLOCK DIAGRAM:
TRUTH TABLE
16
end encoder;
DECODER
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity decoder1 is
port(a0:in bit;
a1:in bit;
a2:in bit;
d0:out bit;
d1:out bit;
d2:out bit;
d3:out bit;
d4:out bit;
d5:out bit;
d6:out bit;
d7:out bit);
17
CIRCUIT DIAGRAM:
SIMULATION RESULTS:
18
end decoder1;
begin
end decd;
RESULT:
Thus the encoder and decoder was designed using VHDL and simulated using
modelsim.
19
CIRCUIT DIAGRAM
20
EX NO:
DATE:
DESIGN AND SIMULATION OF MULTIPLIER USING VHDL
AIM:
TOOLS REQUIRED:
Simulation:modelsim
2.The main page is opened;click the file option to create a new source in VHDL.
6.Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7.Then in the edit option,force is selected and the values are given.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity multiplier1 is
port (
A0 : in bit;
A1 : in bit;
B0 : in bit;
B1 : in bit;
21
MULTIPLIER FUNCTION TABLE
22
1 1 1 0 0 1 1 0
C0 : out bit;
C1 : out bit;
C2 : out bit;
C3 : out bit);
end multiplier1;
begin
C1<=((not A1 and A0 and B1)or(A0 and B1 and not B0)or(A1 and not B1 and B0)or(A1
and not A0 and B0));
end ece;
SIMULATION RESULT:
23
RESULT:
Thus the multiplier was designed using vhdl and simulated using modelsim.
24
BLOCK DIAGRAM OF DFF:
25
EX NO:
DATE:
DESIGN AND SIMULATION OF FLIP FLOPS USING VHDL
AIM:
TOOLS REQUIRED:
PROCEDURE:
2. The main page is opened,click the file option to create a new source in VHDL.
6. Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7. Then in the edit option, force is selected and the values are given.
PROGRAM:
DFF(VHDL) using Behavioral:
library ieee;
use ieee.std_logic_1164.all;
entity dff is
port ( d,res,clk : in std_logic;
q : out std_logic);
end dff;
architecture behavioral of dff is
begin
process(clk)
begin
if(res='0') then q<='0';
elsif clk'event and clk='1'
26
SIMULATION RESULTS:
27
then q<=d;
end if;
end process;
end behavioral;
JKFF(VHDL) using Behavioral:
library ieee;
use ieee.std_logic_1164.all;
entity jkff is
port(j,k,clk,reset : in std_logic;
q,qn : out std_logic);
end jkff;
architecture behavioral of jkff is
signal ff:std_logic;
begin
process(j,k,clk,reset)
variable jk:std_logic_vector(1 downto 0);
begin
jk:=j&k;
if(reset='0')then ff<='0';
elsif(clk'event and clk='1')then
case jk is
when"01"=>ff<='0';
when"10"=>ff<='1';
when"11"=>ff<=not(ff);
when others=>ff<=ff;
end case;
end if ;
end process;
q<=ff;
qn<=not(ff);
end behavioral;
RESULT :
Thus the design of flip flops using VHDL in done and simulated using modelsim.
28
STATE DIAGRAM:
FIGURE 1: UP COUNTER
29
EX NO:
DATE:
DESIGN AND SIMULATION OF COUNTER USING VHDL
AIM :
TOOLS REQUIRED:
PROCEDURE:
2. The main page is opened,click the file option to create a new source in VHDL.
6. Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7. Then in the edit option, force is selected and the values are given.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity upcounter is
end upcounter;
begin
process(clk)
30
STATE DIAGRAM:
31
begin
if clr='0' then
case temp is
when "000"=>temp:="001";
when "001"=>temp:="010";
when "010"=>temp:="011";
when "011"=>temp:="100";
when "100"=>temp:="101";
when "101"=>temp:="110";
when "110"=>temp:="111";
when "111"=>temp:="000";
when others=>temp:="000";
end case;
else
temp:="000";
end if;
end if;
q<=temp;
end process;
end behavioral;
library ieee;
use ieee.std_logic_1164.all;
entity downcounter is
port ( clk,clr : in std_logic;
q : inout std_logic_vector (2 downto 0));
end downcounter;
32
SIMULATION RESULTS:
33
architecture behavioral of downcounter is
begin
process(clk)
variable temp: std_logic_vector (2 downto 0):="000";
begin
if (rising_edge (clk)) then
if clr='0' then
case temp is
when "000"=>temp:="111";
when "111"=>temp:="110";
when "110"=>temp:="101";
when "101"=>temp:="100";
when "100"=>temp:="011";
when "011"=>temp:="010";
when "010"=>temp:="001";
when "001"=>temp:="000";
when others=>temp:="000";
end case;
else
temp:="000";
end if;
end if;
q<=temp;
end process;
end behavioral;
RESULT:
Thus the design of counters using VHDL is done and simulated using modelsim.
34
BLOCK DIAGRAM: SISO
35
EX NO:
DATE:
AIM :
TOOLS REQUIRED:
PROCEDURE:
2. The main page is opened,click the file option to create a new source in VHDL.
6. Then the program is viewed and the signal option is clicked from the view menu and
input signals are given.
7. Then in the edit option, force is selected and the values are given.
PROGRAM:
8-bit Shift Register with Positive edge Clock - Serial In and Serial Out:
library ieee;
use ieee.std_logic_1164.all;
entity siso is
port(C, SI : in std_logic;
SO : out std_logic);
end siso;
architecture archi of siso is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
36
begin
SIMULATION RESULTS:
37
if (C'event and C='1') then
for i in 0 to 6 loop
tmp(i+1) <= tmp(i);
end loop;
tmp(0) <= SI;
end if;
end process;
SO <= tmp(7);
end archi;
8-bit Shift Register with Positive edge Clock -Serial In and Parallel Out:
library ieee;
use ieee.std_logic_1164.all;
entity sipo is
port(C, SI : in std_logic;
PO : out std_logic_vector(7 downto 0));
end sipo;
architecture archi of sipo is
signal tmp: std_logic_vector(7 downto 0);
begin
process (C)
begin
end if;
end process;
PO <= tmp;
end archi;
RESULT:
Thus the design of shift registers is done using VHDL and simulated using
modelsim
38
BLOCK DIAGRAM:
39
EX.NO :
DATE :
AIM:
APPARATUS REQUIRED:
Simulation : ModelSim
PROCEDURE:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity freq is
generic(n:positive:=5);
port(clk,rst:in std_logic;
end freq;
begin
process(clk,rst)
40
SIMULATION RESULT:
41
variable count: natural;
begin
if(rst='1')then
count:=0;
qa<='0';
count:=count+1;
if (count = n) then
qa<=not qa;
count:=0;
end if;
end if;
end process;
end behavioral;
RESULT:
Thus the frequency divider was designed using VHDL and Simulated using
modelsim successfully.
42
Inverter Circuit:
43
EX.NO :
DATE :
AIM:
To Design CMOS Inverter Using Multisim Software and verify the output.
APPARATUS REQUIRED:
1. Multisim Software
2. PC:XP/WINDOWS
2.The main page is opened; click the file to create a new source.
3.Design the circuit by selecting the appropriate components from the place menu.
44
TRANSIENT ANALYSIS :
45
RESULT:
Thus the CMOS Inverter is Designed using Multisim and output was verified.
46
NAND Gate Circuit:
47
EX.NO :
DATE :
AIM:
To Design CMOS NAND and NOR Gates Using Multisim Software and verify the
output.
APPARATUS REQUIRED:
1. Multisim Software
2. PC:XP/WINDOWS
2.The main page is opened; click the file to create a new source.
3.Design the circuit by selecting the appropriate components from the place menu.
48
TRANSIENT ANALYSIS:
49
RESULT:
Thus the CMOS NAND and NOR Gates is Designed using Multisim and output was
verified.
50
D latch Circuit:
EX.NO :
51
DATE :
CMOS D LATCH
AIM
To Design CMOS D LATCH Using Multisim Software and verify the output.
APPARATUS REQUIRED
1. Multisim Software
2. PC:XP/WINDOWS
PROCEDURE FOR SIMULATION
2.The main page is opened; click the file to create a new source.
3.Design the circuit by selecting the appropriate components from the place menu.
52
TRANSIENT ANALYSIS :
53
RESULT:
Thus the CMOS D LATCH is Designed using Multisim and output was verified.
54
TRUTH TABLE:
INPUT OUTPUT
a3 a2 a1 a0 b3 b2 b1 b0 cout s3 s2 s1 s0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 1 0
0 0 1 0 0 0 1 0 0 0 1 0 0
0 0 1 1 0 0 1 1 0 0 1 1 0
0 1 0 0 0 1 0 0 0 1 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0
0 1 1 0 0 1 1 0 0 1 1 0 0
0 1 1 1 0 1 1 1 0 1 1 1 0
1 0 0 0 1 0 0 0 1 0 0 0 0
1 0 0 1 1 0 0 1 1 0 0 1 0
1 0 1 0 1 0 1 0 1 0 1 0 0
1 0 1 1 1 0 1 1 1 0 1 1 0
1 1 0 0 1 1 0 0 1 1 0 0 0
1 1 0 1 1 1 0 1 1 1 0 1 0
1 1 1 0 1 1 1 0 1 1 1 0 0
1 1 1 1 1 1 1 1 1 1 1 1 0
55
EX.NO:
DATE:
FPGA IMPLEMENTATION OF 4 BIT ADDER
AIM:
To design “4 BIT ADDER” in Spartan-3 Trainer and to demonstrate its working is on
FPGA board.
PROCEDURE:
1.In the Xilinx,open a new project and give the file name.
2.Select Verilog module from XC3S400-4pq208.
3.Type the program and create new source.
4.Select implementation constraint file and give the file name.
5.Then click assign package pin(run) from user constraints.
6.Give the pin location and save the file.
7.Run the synthesis XST,implement design and generate program file sequentially.
8.select program and wait until it gets succeed.
9.Give the input and observe the output in the Xilinx kit.
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
entity fa is
port(a3,a2,a1,a0,b3,b2,b1,b0:in bit;
cout,s3,s2,s1,s0:out bit);
end fa;
architecture ece of fa is
begin
process(a3,a2,a1,a0,b3,b2,b1,b0)
begin
if(a3='0' and a2='0' and a1='0' and a0='0' and b3='0' and b2='0' and b1='0' and
b0='0')then
cout<='0';
s3<='0';
s2<='0';
56
BLOCK DIAGRAM
s1<='0';
57
s0<='0';
elsif(a3='0' and a2='0' and a1='0' and a0='1' and b3='0' and b2='0' and b1='0' and
b0='1')then
cout<='0';
s3<='0';
s2<='0';
s1<='1';
s0<='0';
elsif(a3='0' and a2='0' and a1='1' and a0='0' and b3='0' and b2='0' and b1='1' and
b0='0')then
cout<='0';
s3<='0';
s2<='1';
s1<='0';
s0<='0';
elsif(a3='0' and a2='0' and a1='1' and a0='1' and b3='0' and b2='0' and b1='1' and
b0='1')then
cout<='0';
s3<='0';
s2<='1';
s1<='1';
s0<='0';
elsif(a3='0' and a2='1' and a1='0' and a0='0' and b3='0' and b2='1' and b1='0' and
b0='0')then
cout<='0';
s3<='1';
s2<='0';
s1<='0';
s0<='0';
elsif(a3='0' and a2='1' and a1='0' and a0='1' and b3='0' and b2='1' and b1='0' and
b0='1')then
cout<='0';
s3<='1';
s2<='0';
s1<='1';
58
s0<='0';
elsif(a3='0' and a2='1' and a1='1' and a0='0' and b3='0' and b2='1' and b1='1' and
b0='0')then
cout<='0';
s3<='1';
s2<='1';
s1<='0';
s0<='0';
elsif(a3='0' and a2='1' and a1='1' and a0='1' and b3='0' and b2='1' and b1='1' and
b0='1')then
cout<='0';
s3<='1';
s2<='1';
s1<='1';
s0<='0';
elsif(a3='1' and a2='0' and a1='0' and a0='0' and b3='1' and b2='0' and b1='0' and
b0='0')then
cout<='1';
s3<='0';
s2<='0';
s1<='0';
s0<='0';
elsif(a3='1' and a2='0' and a1='0' and a0='1' and b3='1' and b2='0' and b1='0' and
b0='1')then
cout<='1';
s3<='0';
s2<='0';
s1<='1';
s0<='0';
elsif(a3='1' and a2='0' and a1='1' and a0='0' and b3='1' and b2='0' and b1='1' and
b0='0')then
cout<='1';
s3<='0';
s2<='1';
s1<='0';
s0<='0';
59
elsif(a3='1' and a2='0' and a1='1' and a0='1' and b3='1' and b2='0' and b1='1' and
b0='1')then
cout<='1';
s3<='0';
s2<='1';
s1<='1';
s0<='0';
elsif(a3='1' and a2='1' and a1='0' and a0='0' and b3='1' and b2='1' and b1='0' and
b0='0')then
cout<='1';
s3<='1';
s2<='0';
s1<='0';
s0<='0';
elsif(a3='1' and a2='1' and a1='0' and a0='1' and b3='1' and b2='1' and b1='0' and
b0='1')then
cout<='1';
s3<='1';
s2<='0';
s1<='1';
s0<='0';
elsif(a3='1' and a2='1' and a1='1' and a0='0' and b3='1' and b2='1' and b1='1' and
b0='0')then
cout<='1';
s3<='1';
s2<='1';
s1<='0';
s0<='0';
elsif(a3='1' and a2='1' and a1='1' and a0='1' and b3='1' and b2='1' and b1='1' and
b0='1')then
cout<='1';
s3<='1';
s2<='1';
s1<='1';
s0<='0';
60
else
cout<='0';
s3<='0';
s2<='0';
s1<='0';
s0<='0';
end if;
end process;
end ece;
Block diagram:
61
RESULT:
Thus the “4-BIT ADDER” was implemented in Spartan-3 Trainer and its working
is demonstrated on interfacing board.
62
EX.NO:
DATE:
FPGA IMPLEMENTATION OF REAL TIME CLOCK
AIM:
63
To design “REALTIME CLOCK” in Spartan-3 Trainer and to demonstrate its working
is on FPGA board.
PROCEDURE;
1.In the Xilinx,open a new project and give the file name.
2.Select Verilog module from XC3S400-4pq208.
3.Type the program and create new source.
4.Select implementation constraint file and give the file name.
5.Then click assign package pin(run) from user constraints.
6.Give the pin location and save the file.
7.Run the synthesis XST,implement design and generate program file sequentially.
8.select program and wait until it gets succeed.
9.Give the input and observe the output in the Xilinx kit.
VHD Code for Real Clock Timer:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
-----------------------------------------------------------------------------------
--This is real time clock in this we use
-- to generate 1 sec clock we use enable signal high for last 1 count
-- sec1 counter for reading sec
-- sec2 counter for reading sec
-- min1 counter for reading min
-- min2 counter for reading min
-- hr1 counter for reading hr
64
Table: Real Clock Timer Interface to SPARTAN-3 FPGA
ne
CLK_4M loc = p181;
t
ne
RESET loc = p182;
t
ne
Load loc = p102;
t
ne
control loc = p101;
t
ne
RTC_SEG<0> loc = P24;
t
ne
RTC_SEG<1> loc = P20;
t
ne
RTC_SEG<2> loc = P27;
t
ne
RTC_SEG<3> loc = P26;
t
ne
RTC_SEG<4> loc = P29;
t
ne
RTC_SEG<5> loc = P28;
t
ne
RTC_SEG<6> loc = P33;
t
ne
RTC_SEG<7> loc = P31;
t
ne
RTC_Dis<0> loc = P22;
t
ne
RTC_Dis<1> loc = P21;
t
ne
RTC_Dis<2> loc = P18;
t
ne
RTC_Dis<3> loc = P19;
t
65
ne
RTC_Dis<4> loc = P15;
t
ne
RTC_Dis<5> loc = P16;
t
--4mhz clock
-- hr2 counter for reading hr
entity RTC_IM is
port(RESET,CLK_4M,load,control:in std_logic;
RTC_SEG:out std_logic_vector(7 downto 0);
RTC_DIS:out std_logic_vector(5 downto 0));
end RTC_IM;
architecture Behavioral of RTC_IM is
signal tc,tc1,tc2,tc3,tc4,tc5,tc6,enable:std_logic;
signal sec1,sec2,min1,min2,hr1,hr2: std_logic_vector(3 downto 0);
signal sec1_rg:std_logic_vector(3 downto 0);
signal sec2_rg:std_logic_vector(3 downto 0);
signal min1_rg:std_logic_vector(3 downto 0);
signal min2_rg:std_logic_vector(3 downto 0);
signal hr1_rg:std_logic_vector(3 downto 0);
signal hr2_rg:std_logic_vector(3 downto 0);
signal pulsegen:std_logic_vector(21 downto 0);
signal sel:std_logic_vector(2 downto 0);
signal mout:std_logic_vector(3 downto 0);
signal sgout:std_logic_vector(7 downto 0);
signal dis_sig:std_logic_vector(5 downto 0);
signal cnk2:std_logic_vector(2 downto 0);
begin
--*************************** Pulse Generator ******************
p0:process(RESET,CLK_4M,pulsegen)
begin
66
if (RESET = '1') then
pulsegen <= "0000000000000000000000";
elsif rising_edge (CLK_4M) then
if (pulsegen = "1111010000100100000000") then
enable <= '1' when pulsegen = "1111010000100100000000" else --enable signal for
sec1 counter
'0';
67
sec1 <= sec1_rg;
end process ;
-----------------------tc signal to start sec2 counter----------------------------------
tc <= '1' when (sec1_rg = "1001") and (enable = '1') else --signal for sec2 counter
'0';
--************************* Second_cntr2 ***********************
p2:process (RESET,CLK_4M,sec2_rg,tc,load) --sec2 counter for reading upto 59 sec
begin
if (RESET = '1') then
if (sec2_rg = "0101")then
sec2_rg <= "0000";
else
sec2_rg <= sec2_rg + 1;
end if;
end if;
end if;
sec2_rg <= "0000";
elsif (load = '1') then
sec2_rg <= "0100";
elsif rising_edge(CLK_4M) then
if (tc = '1') then
end if;
end if;
min1 <= min1_rg;
end process;
--------------------------tc2 signal to start min2 counter----------------------------
if (RESET = '1') then
min2_rg <= "0000";
elsif load = '1' then
min2_rg <= "0100";
elsif rising_edge(CLK_4M) then
tc2 <= '1' when (min1_rg ="1001") and (tc1 = '1') else --pulse for min2 counter
'0';
--************************ Minute_cntr2 *************************
p4:process(RESET,CLK_4M,min2_rg,tc2,load) --min2 counter
begin
if (tc2 = '1') then
if (min2_rg = "0101")then
min2_rg <= "0000";
else
min2_rg <= min2_rg + 1;
end if;
end if;
end if;
min2 <= min2_rg;
end process;
--------------------------tc3 signal to start hr1 counter----------------------------------
tc3 <= '1' when (min2_rg ="0101") and (tc2 = '1') else
69
'0';
--************************ Hour_cntr1 *************************
p5:process(RESET,CLK_4M,hr1_rg,tc3,load,control,tc6,tc5) --hr1 counter
begin
if (RESET = '1') then
hr1_rg <= "0000";
elsif (load = '1') then
hr1_rg <= "0001";
elsif rising_edge(CLK_4M) then
if control = '1' then
if (tc5 = '1') then
hr1_rg <= "0000";
else
if (tc3 = '1') then
end if;
end if;
else
if (tc6 = '1') then
hr1_rg <= "0001";
if (hr1_rg = "1001")then
hr1_rg <= "0000";
else
hr1_rg <= hr1_rg + 1;
end if;
else
73
RESULT:
Thus the “REAL TIME CLOCK” was implemented in Spartan-3 Trainer and its
working is demonstrated on interfacing board.
74