Beruflich Dokumente
Kultur Dokumente
Technology
Tircuhengode
Department of ECE
Name
Register No
Class
Subject Code
Subject Name
:
:
INDEX
EX.
NO
DATE
PAGE
NO
MARKS
SIGN
PROGRAM:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity alarm is
PORT (clk, rst, remote, sensors: IN STD_LOGIC;
siren: OUT STD_LOGIC);
end alarm;
architecture Behavioral of alarm is
TYPE alarm_state is (disarmed, armed, intrusion);
ATTRIBUTE enum_encoding: STRING;
ATTRIBUTE enum_encoding OF alarm_state: TYPE IS "sequential";
SIGNAL pr_state, nx_state: alarm_state;
SIGNAL flag: STD_LOGIC;
begin
----- Flag: ----------------------------PROCESS (remote, rst)
BEGIN
IF (rst='1') THEN
flag <= '0';
ELSIF (remote'EVENT AND remote='0') THEN
flag <= NOT flag;
END IF;
END PROCESS;
----- Lower section: -------------------PROCESS (clk, rst)
BEGIN
IF (rst='1') THEN
pr_state <= disarmed;
ELSIF (clk'EVENT AND clk='1') THEN
pr_state <= nx_state;
END IF;
END PROCESS;
----- Upper section: ------------------PROCESS (pr_state, flag, remote, sensors)
BEGIN
CASE pr_state IS
WHEN disarmed =>
siren <= '0';
IF (remote='1' AND flag='0') THEN
nx_state <= armed;
ELSE
nx_state <= disarmed;
END IF;
WHEN armed =>
siren <= '0';
IF (sensors='1') THEN
nx_state <= intrusion;
ELSIF (remote='1' AND flag='1') THEN
nx_state <= disarmed;
ELSE
nx_state <= armed;
END IF;
RESULT
Thus the Simple Alarm System was implemented in Spartan-3
Trainer and its working is demonstrated on interfacing board.
elsif(x='0' and
c<='0';
elsif(x='0' and
c<='0';
elsif(x='0' and
c<='1';
elsif(x='1' and
c<='1';
elsif(x='1' and
c<='0';
elsif(x='1' and
c<='0';
elsif(x='1' and
c<='1';
elsif(x='1' and
c<='0';
elsif(x='1' and
c<='1';
elsif(x='1' and
c<='1';
elsif(x='1' and
c<='0';
else
c<='x';
end if;
end process;
end tms;
Truth Table
Three bit message
Parity bit
Truth Table
Four bits Received
X
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
Y
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
Z
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
Parity Error
P
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Check
C
0
1
1
0
1
0
0
1
1
0
0
1
0
1
1
0
RESULT
Thus the parity checker was implemented in Spartan-3 Trainer and
its working is demonstrated on interfacing board.
d<='0';
e<='0';
f<='0';
g<='0';
elsif(h='0'
a<='1';
b<='1';
c<='0';
d<='1';
e<='1';
f<='0';
g<='1';
elsif(h='0'
a<='1';
b<='1';
c<='0';
d<='1';
e<='1';
f<='0';
g<='0';
elsif(h='0'
a<='0';
b<='1';
c<='1';
d<='1';
e<='0';
f<='1';
g<='1';
elsif(h='0'
a<='1';
b<='0';
c<='1';
d<='1';
e<='0';
f<='1';
g<='1';
elsif(h='0'
a<='1';
b<='0';
c<='1';
d<='1';
e<='1';
f<='1';
g<='0';
elsif(h='0'
a<='1';
b<='1';
c<='1';
d<='0';
e<='0';
f<='1';
g<='0';
elsif(h='1'
a<='1';
b<='1';
c<='1';
d<='1';
e<='1';
f<='1';
g<='1';
elsif(h='1' and i='0' and j='0' and k='1')then
a<='1';
b<='1';
c<='1';
d<='1';
e<='0';
f<='1';
g<='1';
end if;
end process;
end display;
Truth table
Numb
inputs
er to
h
be
display
0
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
1
9
1
outputs
a
b
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
1
0
1
1
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
1
0
1
1
0
0
1
0
1
0
1
0
0
0
1
1
1
1
1
1
0
0
1
0
1
1
1
0
1
1
1
1
1
1
1
0
0
1
1
1
RESULT
Thus the Scrolling display was implemented in Spartan-3 Trainer and
its working is demonstrated on interfacing board.
1. D) FPGA IMPLEMENTATION OF MULTIMODE
CALCULATORS
AIM:
PROGRAM:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity cal is
port (a, b: in std_logic_vector (7 downto 0);
sel: in std_logic_vector (3 downto 0);
result: out std_logic_vector (7 downto 0);
mulresult: out std_logic_vector (15 downto 0));
end cal;
architecture Behavioral of cal is
begin
process (a, b, sel)
begin
case sel is
when"0000"=>result<=a+b;
when"0001"=>result<=a-b;
when "0010"=>mulresult<=a*b;
when"0100"=>result<=a and b;
when"0101"=>result<=a or b;
when"0110"=>result<=a xor b;
when"0111"=>result<=a nor b;
when"1000"=>result<=a nand b;
when"1001"=>result<=a+1;
when"1010"=>result<=a-1;
when"1011"=>result<=b+1;
when"1100"=>result<=b-1;
when"1101"=>result<=not a;
when"1110"=>result<=not b;
when others =>result<="00000000";
end case;
end process;
end Behavioral;
OUTPUT:
RESULT:
Thus the multimode calculator was implemented in Spartan-3 Trainer
and its working is demonstrated on interfacing board.
2. PCB DESIGN USING CAD
AIM:
To design and implement 3 to 8 decoder SPICE
TOOLS REQUIRED:
1. Orcad 9.1
2. Desktop computer
PROCEDURE:
Simulation:
1. Open Orcad release and open new project.
2. Create a new folder at a particular path and select analog and mixed
circuit wizard option.
3. Select components from PSPICE library.
4. Place components in appropriate locations on schematic page, then make
routing between the components.
5. Save the content and create netlist.
6. Open new simulation option in the PSICE tool and give run time details.
7. Place the markers and run the PSPICE model.
8. End of the process.
Layout:
1. Select the *.dsn file in the left panel
2. Select the create net list menu in the tools menu bar
3. Select layout tag (PCB Foot print)
4. Browse the location to save the *.mnl file then click OK
5. Open the layout application
6. Click new menu in file menu bar
7. Load the template file (default.tch) in the working directory(C:\Program
files\orcad\layout\data\default.tch) then click open
8. Load the text list source file where you have stored *.mnl file then click
open
9. Save the board file *.max
10.Rearrange the components as you like
11.Select the obstacle tool from the tool bar
12.Draw space to cover all the footprints.
13.Go to auto menu-choose place board then click auto route board
3 TO 8 DECODER
U
A
D
1
S
T M
A
2
7 4
1
2
L S
1
7 4
S
I N
B
S
T M
0
7 4
7 4
L S
4
1
1
U
5
8
0
L S
7 4
L S
1
2
7 4
L S
S
I N
L S
1
T M
0
1
D
V
7 4
S
I N
L S
D
V
3
4
5
U
2
3
4
5
6
0
0
7 4
0
L S
9
1
1
0
1
8
0
7 4
U
1
2
1
L S
0
7 4
U
L S
3
4
5
6
0
7 4
L S
OUTPUT
RESULT:
Thus the given digital circuits were designed and layout was drawn using
PSPICE
Step 3: Create a new model - Select File > New > Model in the Simulink Library
Browser.
Step 4: From the Simulink Library Browser click simulink. Select the sources
required and track it to the new file created. Join all the blocks.
Step 5: Click Start simulation icon in the created new file and double click the
scope
Step 6: Display Screen Scope will be opened and the respective output can be
viewed.
Step 7: Errors and warnings will be displayed in the Mat lab Command Window.
OUTPUT DISPLAY
OUTPUT DISPLAY
OUTPUT DISPLAY
OUTPUT DISPLAY
RESULT
1:
2:
3:
4:
5:
PROGRAM:
DELTA MODULATION:
% function to generate Linear Delta Modulation for sin wave
% generating sin wave
t=[0:2*pi/100:2*pi];
a=10*sin(t);
n=length(a);
dels=1;
xhat(1:n)=0;
x(1:n)=a;
d(1:n)=0;
% Linear Delta Modulation
for k=1: n
if (x(k)-xhat(k)) > 0
d(k)=1;
else d(k)=-1;
end %if
xtilde(k)=xhat(k)+d(k)*dels;
xhat(k+1)=xtilde(k);
end %k
%Prints
figure(1); hold on;
plot(a)
plot(xhat);
plot(d-15);
axis([0 100 -20 20])
OUTPUT:
20
15
10
5
0
-5
-10
-15
-20
10
20
30
40
50
60
70
80
90
100
PROGRAM:
ADAPTIVE DELTA MODULATION:
% adaptive delta modulation for sin wave
% generating sin wave
t=[0:2*pi/100:2*pi];
a=10*sin(t);
n=length(a);
mindels=1;
dels(1:n)=mindels;
xhat(1:n)=0;
x(1:n)=a;
% Adaptive Delta Modulation
d(1:n)=1;
for k=2:n
if ((x(k)-xhat(k-1)) > 0 )
d(k)=1;
else d(k)=-1;
end %if
if k==2
xhat(k)=d(k)*mindels+xhat(k-1);
end
if ((xhat(k)-xhat(k-1)) > 0)
if (d(k-1) == -1 &d(k) ==1)
xhat(k+1)=xhat(k)+0.5*(xhat(k)-xhat(k-1));
elseif (d(k-1) == 1 &d(k) ==1)
xhat(k+1)=xhat(k)+1.15*(xhat(k)-xhat(k-1));
elseif (d(k-1) == 1 &d(k) ==-1)
xhat(k+1)=xhat(k)-0.5*(xhat(k)-xhat(k-1));
elseif (d(k-1) == -1 &d(k) ==-1)
xhat(k+1)=xhat(k)-1.15*(xhat(k)-xhat(k-1));
end
else
if (d(k-1) == -1 &d(k) ==1)
xhat(k+1)=xhat(k)-0.5*(xhat(k)-xhat(k-1));
elseif (d(k-1) == 1 &d(k) ==1)
xhat(k+1)=xhat(k)-1.15*(xhat(k)-xhat(k-1));
elseif (d(k-1) == 1 &d(k) ==-1)
xhat(k+1)=xhat(k)+0.5*(xhat(k)-xhat(k-1));
elseif (d(k-1) == -1 &d(k) ==-1)
xhat(k+1)=xhat(k)+1.15*(xhat(k)-xhat(k-1));
end
end
end
%Plots
figure(1);hold on;
plot(a);
plot(xhat);
plot(d-15)
OUTPUT:
15
10
-5
-10
-15
-20
20
40
60
80
100
120
Result:
Thus the Mat lab program was simulated for delta and adaptive
modulation the waveforms are plotted.
OUTPUT:
S
c
a
tte
rp
lo
t
1
.5
Q
u
a
d
ra
tu
re
0
.5
0
.5
1
.5
1
.5
0
.5
0
I
n
P
h
a
s
e
0
.5
1
.5
Scatter plot
1
0.8
0.6
Quadrature
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.5
0
In-Phase
0.5
2.5
Amplitude
1.5
0.5
0
0
Time
RESULT:
Thus the corresponding plot for the QPSK constellation and BER were
obtained.