summaryrefslogtreecommitdiff
path: root/45/CH2/EX2.11/example_2_11.sce
blob: cd85ad755dc79c7222f55504041c661aa745a87b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// exmple 2.11
clc
clear
close
a=[0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1];
b=[0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1];
c=[0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1];
d=[0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1];
for i=1:16
    x=bitor(a(i),b(i));
    y=bitor(c(i),d(i));
    r(i)=bitand(x,y);
end
Y=r
ap=1;
bp=1;
cp=1;
dp=1;Yp=1;
for i=1:16     //Making array to plot the timing diagram
    if a(i)==1 then
        for o=1:100
        a1(ap)=1;
        ap=ap+1;
        end
    else
        for o=1:100
        a1(ap)=0;
        ap=ap+1;
        end
end
if b(i)==1 then
        for o=1:100
        b1(bp)=1;
        bp=bp+1;
                end
    else
        for o=1:100
        b1(bp)=0;
        bp=bp+1;
        end

end
if c(i)==1 then
        for o=1:100
        c1(cp)=1;
        cp=cp+1;
        end
    else
        for o=1:100
        c1(cp)=0;
        cp=cp+1;
        end
end
if d(i)==1 then
        for o=1:100
        d1(dp)=1;
        dp=dp+1;
        end
    else
        for o=1:100
        d1(dp)=0;
        dp=dp+1;
        end
    end
if Y(i)==1 then
        for o=1:100
        Y1(Yp)=1;
        Yp=Yp+1;
        end
    else
        for o=1:100
        Y1(Yp)=0;
        Yp=Yp+1;
        end
    end
end
z=[2 2];    
subplot(5,1,1);   //plotting timing diagram 
title('Timing Diagrm');
plot(z);
plot(a1);
ylabel('A');
subplot(5,1,2);
plot(z);
ylabel('B');
plot(b1);
subplot(5,1,3);
plot(z);
ylabel('C');
plot(c1);
subplot(5,1,4);
plot(z);
ylabel('D');
plot(d1);
subplot(5,1,5);
plot(z);
ylabel('Y');
xlabel('Time in milli seconds');
plot(Y1);