summaryrefslogtreecommitdiff
path: root/1850/CH8/EX8.12/exa_8_12.sce
blob: abbf475b12ec7656a6d16fbf4bd097310ad8b462 (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
// Exa 8.12
clc;
clear;
close;
//given data
// For the word 100100
N=6;// Number of bits
a5= 1;// Value of bits
a4= 0;// Value of bits
a3= 0;// Value of bits
a2= 1;// Value of bits
a1= 0;// Value of bits
a0= 0;// Value of bits
Vo= 3.6;// in volt
// Formula Vo= (2^(N-1)*a5 + 2^(N-2)*a4 + 2^(N-3)*a3 + 2^(N-4)*a2 + 2^(N-5)*a1 + 2^(N-6)*a0 ) * K
K= Vo/(2^(N-1)*a5 + 2^(N-2)*a4 + 2^(N-3)*a3 + 2^(N-4)*a2 + 2^(N-5)*a1 + 2^(N-6)*a0 );
// For the word 110011
N=6;// Number of bits
a5= 1;// Value of bits
a4= 1;// Value of bits
a3= 0;// Value of bits
a2= 0;// Value of bits
a1= 1;// Value of bits
a0= 1;// Value of bits
Vo= (2^(N-1)*a5 + 2^(N-2)*a4 + 2^(N-3)*a3 + 2^(N-4)*a2 + 2^(N-5)*a1 + 2^(N-6)*a0 ) * K;// in volt
disp(Vo,"The value of Vo for the word 110011 in volt")

// Part(ii)
// For the word 1010
N=4;// Number of bits
a3= 1;// Value of bits
a2= 0;// Value of bits
a1= 1;// Value of bits
a0= 0;// Value of bits
VR= 6;// in volt
Vo= VR/2^N*( 2^(N-1)*a3 + 2^(N-2)*a2 + 2^(N-3)*a1 + 2^(N-4)*a0  );
disp(Vo,"Value of output voltage in volt")