0% found this document useful (0 votes)
97 views8 pages

Ass2 Comp 5201 PDF

The document contains instructions for an assignment involving digital logic, binary and hexadecimal number conversion, fractional numbers and blackboard notation, integer multiplication, and modular addition. It provides examples and asks students to complete synthesis, conversion, representation, and calculation problems. The assignment is due on October 20, 2020 and must be submitted electronically with no extensions granted.

Uploaded by

Ashar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views8 pages

Ass2 Comp 5201 PDF

The document contains instructions for an assignment involving digital logic, binary and hexadecimal number conversion, fractional numbers and blackboard notation, integer multiplication, and modular addition. It provides examples and asks students to complete synthesis, conversion, representation, and calculation problems. The assignment is due on October 20, 2020 and must be submitted electronically with no extensions granted.

Uploaded by

Ashar Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ASSIGNMENT 2

Name: ________

ID: ___

COMP5201 Assignment 2
Fall 2020
Issued: September 29, 2020 Due: October 20,
2020
Submit electronically. No extension will be granted.

1. [24 marks] Digital Logic.

a) 'X' is the ternary connective such that 'Xpqr' is logically


equivalent to
'p /\ (p + q + r)'. '+' is 'xor'. 'F' and 'T' denote the 0-ary
connectives
'false' and true, respectively. Whenever possible, put letters in
alphabetical order, and put letters before any 0-place connectives.

Using {'X', 'F', 'T'}, synthesize: ~p |= =| XTFP ,


xtpf ____ _
Using {'X', 'T'}, synthesize: p /\ q |= =| X __p__ _q__T___

Using {'X', '~', 'T'}, synthesize: p \/ q |= =| __~__ X~P~QT

Solution:

p q r (P+q+r P/\(P+q+r
) = w )
T T T T T
T T F F F
T F F T T
F F F F F
T F T F F
F T T F F
F T F T F
F F T T F

p ~P XPTF XPFT XTFP XTPF XFPT XFTP


T F X(TTF)= X(TFT)= X(TFT)=F X(TTF)=F X(FTT)=F
F F
F T X(FTF)= X(FFT)= X(TFF)=T X(TFF)=T X(FFT)=T
T F
p q P /\ q XpqT
F F F X(FFT)=
F
F T F X(FTT)=
F
T F F X(TFT)=
F
T T T X(TTT)=
T

p q P \/ q X~PQT Xp~qt XPQT XQPT X~P~QT


F F F X(TFT)= X(FTT)= X(FFT)= X(FFT)= X(TTT)=
F F F F T
F T T X(TTT)= X(FFT)= X(FTT)= X(TFT)= X(TFT)=
T F F F F
T F T X(FFT)= X(TTT)= X(TFT)= X(FTT)= X(FTT)=
F T F F F
T T T X(FTT)= X(TFT)= X(TTT)= X(TTT)= X(FFT)=
F F T T F

b) 'Y' is the ternary connective such that 'Ypqr' is logically


equivalent to
'p /\ (q <--> r)'. 'p <--> q' is true iff 'p' and 'q' have the same
truth
value. 'F' and 'T' denote the two 0-ary connectives 'false' and
'true',
respectively. Whenever possible, put letters in alphabetical order,
and put
letters before any 0-place connectives.

Using {'Y', 'F', 'T'}, synthesize: ~p |= =| Y _ YTPF


___ _

Using {'Y', 'F', 'T'}, synthesize: p /\ q |= =| YPQT


___ ____ ____

Using {'Y', '~', 'F'}, synthesize: p \/ q |= =| __~_ Y ~PQF


____ ____ ____

Solution:

p q r (q<-->r) P/\(q<-->
= w r)
T T T T T
T T F F F
T F F T T
F F F T F
T F T F F
F T T T F
F T F F F
F F T F F

p q P \/ q YPQF Y~PQF
F F F Y(FFF)= Y(TFF)=
F T
F T T Y(FTF)= Y(TTF)=
F F
T F T Y(TFF)= Y(FFF)=
T F
T T T Y(TTF)= Y(FTF)=
F F

p q P /\ q YPQT
F F F Y(FFT)=
F
F T F Y(FTT)=
F
T F F Y(TFT)=
F
T T T Y(TTT)=
T

it is ternary connective and we need to use q and p SO We cannot use


T and F at the same time .
There is no answer with F, we have to use (p and q and T)
p ~P YPFT YPTF YTFP YFTP YFPT YTPF
T F Y(TFT)= Y(TTF)= Y(TFT)=F Y(FTT)=T Y(FTT)=T Y(TTF)=F
T T
F T Y(FFT)= Y(FTF)= Y(FFT)=F Y(FTF)=F Y(FFT)=F Y(TFF)=T
F F

2. [16 marks] Binary and Hexadecimal Numbers.

Convert each of the following six binary or hexadecimal natural


numbers into
decimal. Show work. For the last number, show either scientific
notation
with six decimal places, or the exact integer.
a) Binary numbers: 1111, 1111 1110, 1111 1110 1101 0111

Solution:

1111 = 1*2^3+1*2^2+1*2^1+1*2^0 = 8+4+2+1 = 15


1111 1110 = 1*2^7+1*2^6+1*2^5+1*2^4+1*2^3+1*2^2+1*2^1+0*2^0 =
128+64+32+16+8+4+2 = 254
1111 1110 1101 0111 =
1*2^16+1*2^15+0*2^14+1*2^13+1*2^12+1*2^11+1*2^10+0*2^9+1*2^8+1*2^7+0*
2^6+1*2^5+0*2^4+1*2^3+1*2^2+1*2^1+1*2^0 = 65239

b) Hexadecimal numbers: af, afba, afba 51de

Solution:

Af = 10*16^1+15*16^0 = 160+15=175
Afba = 10*16^3+15*16^2+11*16^1+10*16^0 = 44986
afba 51de =
10*16^7+15*16^6+11*16^5+10*16^4+5*16^3+1*16^2+13*16^1+14*16^0 =
2948223454

3. [25 marks] Fractional Numbers and Blackboard Notation.

Infinite binary expansions of rational numbers are either pure


recurring or
mixed recurring depending on whether the cycle starts immediately
after the
point.

a) [math] Show the infinite binary expansion of 6 4/9 without


normalization.

Solution:

We will deal with full and fraction part separately:


Convert 6 to binary:

2|6 0
2|3 1
2|1 1
0
Read from bottom to top: 6 is 110 in binary.

Convert 4/9 to binary:

4/9 * 2 8/9 0
8/9 * 2 16/9 1 + 7/9
7/9 * 2 14/9 1 + 5/9
5/9 * 2 10/9 1 + 1/9
1/9 * 2 2/9 0
2/9 * 2 4/9 0
4/9 * 2 8/9 0

4/9 in binary is .0111000111000111…

6 4/9 in binary is 110.0111000111000111…

b) [math] Show this infinite binary expansion in hexadecimal without


normalization.

Solution:
110.0111000111000… = 110.0111 0001 1100 0111… = 6.<71C>*

c) [math] Show the infinite binary expansion of 6 4/9 with


normalization. Do
not forget the scale factor. (This is a _scaled_ infinite binary
expansion).

Solution:
110.01110001110001… = 1.1001 1100 0111 0001 1100 0111 0001…2^2

d) [math] Show this infinite binary expansion in hexadecimal. Again,


do not
forget the scale factor, which may be shown in decimal.

Solution:

1.100111000111000…2^2 = 1.1001 1100 0111 0001 1100 0111 0001…2^2 =


1.9<C71>*2^2

e) Show the normalized (binary) blackboard notation that best


approximates
6 4/9. The fractional field is 16 bits. Show all 16 bits. Now,
show just
the 16-bit (4-hexit) fractional field in hexadecimal.

Solution:

the normalized (binary) blackboard notation that best approximates


6 4/9 is 1.1001 1100 0111 0001 [2]
fractional part 16 bits 1001 1100 0111 0001

4. [15 marks] Integer Multiplication I.

a) Multiply the following 10-bit binary natural numbers. The


multiplicand
is 10011 11100 (27c hex) and the multiplier is 11010 (1a hex).
Show, in
hexadecimal, i) the initial value of the accumulator, and ii) each
term
added to the accumulator, and the partial sum after the addition.
The last
addition yields the final value.

Solution:

Since multiplier is 5 bits we will have 5 iterations: We start with


Accumulator 00000 00000 in Hex it is 0

a)
After 1 iteration Accumulator is:
00000 00000 in Hex it is 0

After 2 iteration Accumulator is:


10011111000 in Hex it is 4F8

After 3 iteration Accumulator is:


10011111000 in Hex it is 4F8

After 4 iteration Accumulator is:


1100011011000 Hex: 18D8

After 5 iteration Accumulator is:


100000010011000 - Final Hex: 4098

b) Redo the multiplication steps exactly as in question 4 a), but


initialize
the accumulator to s = 11011 (1b hex) instead of 0. Show the same
intermediate and final values. (This is called "fused
multiply-add").

We start with Accumulator 00000 11011 in Hex it is 1B

a)
After 1 iteration Accumulator is:
00000 11011 in Hex it is 1B

After 2 iteration Accumulator is:


10100010011 - Hex: 513

After 3 iteration Accumulator is:


10100010011 - Hex: 513

After 4 iteration Accumulator is:


1100011110011 - Hex:18F3

After 5 iteration Accumulator is:


100000010110011 - Hex:40B3
5. [20 marks] Integer Multiplication II.

a) Show that, regardless of the initial n-bit value of the


accumulator, the
fused multiply-add result of two n-bit natural-number operands is
always
representable in 2n bits. Now, suppose n = 16. Starting from the
largest
possible FMA result, what is the hexadecimal representation of the
largest
n = 16-bit number that can _still_ be added without producing
overflow?

Solution:

It can be done by simple examples;


11*11 = 1001 2bit*2bit – 4 bit result
111*111 = 110001 3bit*3bit – 6 bit result
1111*1111 = 11100001 4bit*4bit – 8 bit result

So it shows that the fused multiply-add result of two n-bit


natural-number operands is always representable in 2n bits

If n=16 the largest possible FMA result is 32 bits which contains 1s,
the multiplicand and multiplier can be (2^16)-1 which contains 1s, so
in hex the largest added number can be (2^16)-1 will be ffff

1111111111111111 × 1111111111111111
= 11111111111111100000000000000001

b) A modular-adder device 'M' operates with 16-bit registers. You


give it
two 16-bit natural numbers 'a' and 'b'. It adds them, divides by
2^16,
keeps the quotient 'q' a secret, and publishes the remainder 'r'.
Hint:
Before answering, experiment with small addition tables.

i) If a = 31,465 and r = 53,576, what are 'b' and 'q'?

ii) If a = 35,492 and r = 11,087, what are 'b' and 'q'?

(a+b)=Q*2^16+R
If we try on small addition tables:
N=3, a and b can be from 0 to 7.
Let a=0, b=1, then a+b = 1; 1/8 gives us q = 0 and r = 1
Let a=7, b=7, then a+b = 14; 14/8 gives us q = 1 and r = 6
So q can be either 1 or 0.
1) If a = 31,465 and r = 53,576, what are 'b' and 'q'?
31,465+b = Q*2^16+53,576
B= Q*2^16+53,576-31,465 = Q*2^16 +22,111
If Q is 0 then b =22,111
r/2^16 = 0.81750488, the equality will work if Q = 0 and b =
22,111
if Q is 1 then b = 87,647 does not work

2) ii) If a = 35,492 and r = 11,087, what are 'b' and 'q'?


35,492+b = Q*2^16+11,087
B= Q*2^16+11,087-35,492 = Q*2^16-24,405
If Q is 0 then b =-24,405 this can not be a solution as we have
natural numbers in the exercise
if Q is 1 then b = 41,131

Powered by TCPDF (www.tcpdf.org)

You might also like