You are on page 1of 16

Name: Sudeep Sharma

Roll Number: 510818304

Learning Centre: 2882

Subject : Digital Systems, Computer


Organization & Architecture
Assignment No.: MC0062 – 01

Date of Submission at the learning centre:


31/05/2008

Faculty Signature :
DIGITAL SYSTEMS, COMPUTER ORGANIZATION & ARCHITECTURE
MC0062 – 01

Q1. Write the octal, decimal and binary equivalent of the following number
a) (AC81)16 b) (AF69)16
Answer:

a) (AC81)16

Firstly we have to convert the hexadecimal number to decimal.


 A  16 3  C  16 2  8  161  1  16 0
 10  4096  12  256  128  1
 40960  3072  128  1
 ( 44161)10

Now decimal to octal:

8 44161
8 5520  1
8 690  0
8 86 2
8 10 6
8 1 2
0 1
So (126201) 8 is the answer.

Hexadecimal to binary
(AC81)16
= 1010 1100 1000 0001(2)

b) (AF69) 16

Firstly we have to convert the hexadecimal number to decimal


 A  163  F  16 2  6  161  9  16 0
 40960  4096  96  1
 ( 45161)10
Now decimal to octal

8 45161
8 5645  1
8 705  5
8 88 1
8 11 0
8 1 3
0 1
So (130151) 8 is the answer.
Hexadecimal to binary
(AF69)16

2
= 1010 1111 0110 1001(2)

Q2. Explain and implement the following Boolean expression using basic logic
gates.
(a). abc  abc  abc  abc
(b). abc  (a  c)  b.c
Use Boolean theorems for simplification.

Answer:

(a) abc  abc  abc  abc


abc  ab c  ( a  a )bc
abc  ab c  1.bc a
abc  ab c  bc
abc  b( a c  c )
abc  b( a  c ) b
abc  ab  bc
a (bc  b)  bc
a (c  b)  bc
ab  ac  bc c

(b) abc  ( a  c )  b.c


abc  a.c  b.c a
a  b  c  a.c  b.c
a  b  c (1  a )  b.c
a  b  c (1  b)
b
abc

3
Q3. Realize AND, OR, NOT gates using
a) NAND agate only b) NOR gate only

Answer:

a.1) NOT using NAND

a.2) AND using NAND


a
b

a.3) OR using NAND

b.1) NOT using NOR

b.2) AND using NOR

4
b.3) OR using NOR

a
b

Q4. Write short note on


1a) Importance of ADC & DAC
2b) Synchronous & Asynchronous counters
c) Applications of flip-flops

Answer:

a) Importance of ADC & DAC:


Data or signal processing using digital systems are more efficient, reliable and
economical. Connecting digital circuitry to sensor devices is simple if the sensor
devices are inherently digital themselves. Switches, relays and encoders are easily
interfaced with gate circuits due to the on/off nature of their signals. Most of the
physical quantities such as voltage, current temperature, pressure are analog in
nature. The practical difficulties in processing, storing or transmitting when
analog devices are involved becomes much more complex. Therefore there is need
for electronically translate analog signals into digital and quantities, vice versa.
The circuit that performs this conversion is called an analog-to-digital converter,
or ADC and conversely, a digital-to-analog converter, or DAC, converts the
binary output from a digital system to an equivalent analog voltage or current.

b) Synchronous & Asynchronous counters


An Asynchronous counter is one in which the flip-flops are not triggered, whereas
a Synchronous counter is one in which all the flip-flops are simultaneous triggered
from the same clock input. Asynchronous counters are also called ripple counters.
Asynchronous counter uses J-K flip-flops with both J and K are connected to
HIGH all time, or flip-flops are used are T flip-flops.

A synchronous counter has the same sequence of counting as in an asynchronous


or ripple counter. Flip-flops changes state when a synchronous counter is
incremented on the positive or negative edge of a clock pulse. Whereas in the
asynchronous counter Flip-flops changes state for the positive or negative edge of
the preceding flip-flop’s output. Thus all the flip-flops are connected to a same
clock signal and changes state at the same time.

c) Applications of flip-flops
A flip-flop can be thought as an assembly of logic gates connected such a way that
it permits the information to be stored. Usually flip-flops used are memory
elements stores 1 bit of information over a specific time. Flip-flops form the
fundamental components of shift registers and counters.

5
Q5. Explain Von Neumann Architecture with a labeled diagram

Answer:

Von Neumann Architecture


The Von Neumann Architecture was first employed in IAS digital computer. The
general structure of the IAS computer is as shown in figure:

Arithmetic and
Logic Unit

Main I/O
Memory Equipment

Program Control
Unit

 A main memory, which stores both instructions and data.


 An arithmetic and logic unit (ALU) capable of operating on binary data.
 A control unit, which interprets the instructions in memory and causes them to
be executed.
 Input and Output (I/O) equipment operated by the control unit.

The Von Neumann Architecture is based on three key concepts:


1. Data and instructions are stored in a single read-write memory.
2. The content of this memory is addressable by location, without regard to
the type of data contained there.
3. Execution occurs in a sequential fashion unless explicitly modified from
one instruction to the next.

6
CPU Memory
...
PC MAR ...
Instruction
IR MBR Instruction
Instruction
I/O AR ...
...
I/O BR Data
Data
Data
I/O Module
PC = Program Counter
IR = Instruction Register
MAR = Memory address register
MBR = Memory buffer register
I/O AR = I/O address register
I/O BR = I/O register

The CPU consists of various registers as listed in the figure. They are
1. Program counter (PC): it contains an address of an instruction to be
fetched.
2. Instruction Register (IR): It contains the instruction most recently fetched.
3. Memory address registers (MAR): contains the address of a location in
memory.
4. Memory buffer register (MBR): It contains a word of data to be written to
memory or the word most recently used.
5. I/O address register (I/O AR): contains the address of a I/O.
6. I/O buffer register (I/O BR) L its contains a word of data to be written to
I/O device.
Any instruction to be executed must be present in the system Memory. The
instruction is read from a location pointed by PC of the memory, and then
transferred it to IR through the data bus. The instruction is decoded and then the
data is brought to the ALU either from memory or register etc. The ALU
computes the required operation on the data and stores the result in a special
register called Accumulator. All the sequence of actions is controlled by the
control signals generated by the control unit. Thus Accumulator is a special
purpose register designated to hold the result of an operation performed by the
ALU.

7
Q6. Describe the different number representations

Answer:
Computers are built using logic circuits that operates on information represented by two
valued electrical signals. We label the two values as 0 and 1; and we define the amount of
information represented by such a signal as a bit of information, where bit stands for
binary digit. The most natural way to represent a number in a computer system is by a
string of bits, called a binary number. An important part of the use of logic circuits is for
computing various mathematical operations such as addition, multiplication,
trigonometric operations, etc.

We must therefore have a way of representing numbers as binary data.

Non-negative integers
The easiest numbers to represent are the nonnegative integers in the decimal system, a
number such as 2034 is interpreted as:
2*103 + 0*102 + 3*101 + 4*100

We can just as well use base 2. In base 2, each digit value is either 0 or 1, which we can
represent for instance by false and true, respectively.

All the normal algorithms for decimal arithmetic have versions for binary arithmetic,
except that they are usually simpler.

For adding two numbers, it suffices to notice that there is a carry of 1 whenever we add 0
and 1, or 1 and 1:

1 1 1
- - -
1 0 1 1
+ 1 0 0 1
-----------
1 0 1 0 0

Subtraction work as follows:


10 10
-- --
1 0 0 1
- 1 1 0
--------------
0 0 1 1

For multiplying two numbers, we only multiply by 0 (which gives all zeros), or 1 (which
gives the original number):
1 1 0 1
* 1 0 1
-----------
1 1 0 1
0 0 0 0

8
1 1 0 1
--------------
1 0 0 0 0 0 1

Finally, division is just repeated subtraction as in decimal arithmetic:


0 1 1 0
--------
1 0 | 1 1 0 1
---- 1 0
---
1 0
1 0
---
0 1

Negative integers

In binary arithmetic, we reserve one bit to determine the sign. In the circuitry for
addition, we would have one circuit for adding two numbers, and another for subtracting
two numbers. The combination of signs of the two inputs would determine which circuit
to use on the absolute values, as well as the sign of the output.

While this method works, it turns out that there is one that is much easier to deal with by
electronic circuits. This method is called the "two's complement" method. It turns out that
with this method, we do not need a special circuit for subtracting two numbers.

In order to explain this method, we first show how it would work in decimal arithmetic
with infinite precision. Then we show how it works with binary arithmetic, and finally
how it works with finite precision.

Infinite-precision ten's complement


Imagine the odometer of an automobile. It has a certain number of wheels, each with the
ten digits on it. When one wheel goes from 9 to 0, the wheel immediately to the left of it,
advances by one position. If that wheel already showed 9, it too goes to 0 and advances
the wheel to its left, etc. Suppose we run the car backwards. Then the reverse happens,
i.e. when a wheel goes from 0 to 9, the wheel to its left decreases by one.

Now suppose we have an odometer with an infinite number of wheels. We are going to
use this infinite odometer to represent all the integers.

When all the wheels are 0, we interpret the value as the integer 0.

A positive integer n is represented by an odometer position obtained by advancing the


rightmost wheel n positions from 0. Notice that for each such positive number, there will
be an infinite number of wheels with the value 0 to the left.

9
A negative integer n is represented by an odometer position obtained by decreasing the
rightmost wheel n positions from 0. Notice that for each such positive number, there will
be an infinite number of wheels with the value 9 to the left.

In fact, we don't need an infinite number of wheels. For each number only a finite number
of wheels is needed. We simply assume that the leftmost wheel (which will be either 0 or
9) is duplicated an infinite number of times to the left.

While for each number we only need a finite number of wheels, the number of wheels is
unbounded, i.e., we cannot use a particular finite number of wheels to represent all the
numbers. The difference is subtle but important (but perhaps not that important for this
particular course). If we need an infinite number of wheels, then there is no hope of ever
using this representation in a program, since that would require an infinite-size memory.
If we only need an unbounded number of wheels, we may run out of memory, but we can
represent a lot of numbers (each of finite size) in a useful way. Since any program that
runs in finite time only uses a finite number of numbers, with a large enough memory, we
might be able to run our program.

Now suppose we have an addition circuit that can handle nonzero integers with an
infinite number of digits. In other words, when given a number starting with an infinite
number of 9s, it will interpret this as an infinitely large positive number, whereas our
interpretation of it will be a negative number. Let us say, we give this circuit the two
numbers ...9998 (which we interpret as -2) and ...0005 (which we interpret as
+5). It will add the two numbers. First it adds 8 and 5 which gives 3 and a carry of 1.
Next, it adds 9 and the carry 1, giving 0 and a carry of 1. For all remaining (infinitely
many) positions, the value will be 0 with a carry of 1, so the final result is ...0003.
This result is the correct one, even with our interpretation of negative numbers. You may
argue that the carry must end up somewhere, and it does, but in infinity. In some ways,
we are doing arithmetic modulo infinity.

Finite-precision ten's complement


What we have said in the previous section works almost as well with a fixed bounded
number of odometer wheels. The only problem is that we have to deal with overflow and
underflow.

Suppose we have only a fixed number of wheels say 3. In this case, we shall use the
convention that if the leftmost wheel shows a digit between 0 and 4 inclusive, then we
have a positive number, equal to its representation. When instead the leftmost wheel
shows a digit between 5 and 9 inclusive, we have a negative number, whose absolute
value can be computed with the method that we have in the previous section.

We now assume that we have a circuit that can add positive three-digit numbers, and we
shall see how we can use it to add negative numbers in our representation.

10
Suppose again we want to add -2 and +5. The representations for these numbers with
three wheels are 998 and 005 respectively. Our addition circuit will attempt to add the
two positive numbers 998 and 005, which gives 1003. But since the addition circuit
only has three digits, it will truncate the result to 003, which is the right answer for our
interpretation.

A valid question at this point is in which situation our finite addition circuit will not
work. The answer is somewhat complicated. It is clear that it always gives the correct
result when a positive and a negative number are added. It is incorrect in two situations.
The first situation is when two positive numbers are added, and the result comes out
looking like a negative number, i.e., with a first digit somewhere between 5 and 9. You
should convince yourself that no addition of two positive numbers can yield an overflow
and still look like a positive number. The second situation is when two negative numbers
are added and the result comes out looking like a nonnegative number, i.e., with a first
digit somewhere between 0 and 4. Again, you should convince yourself that no addition
of two negative numbers can yield an underflow and still look like a negative number.

We now have a circuit for addition of integers (positive or negative) in our


representation. We simply use a circuit for addition of only positive numbers, plus some
circuits that check:

 If both numbers are positive and the result is negative, then report overflow.
 If both numbers are negative and the result is positive, then report underflow.

Finite-precision two's complement


So far, we have studied the representation of negative numbers using ten's complement.
In a computer, we prefer using base two rather than base ten. Luckily, the exact method
described in the previous section works just as well for base two. For an n-bit adder (n is
usually 32 or 64), we can represent positive numbers with a leftmost digit of 0, which
gives values between 0 and 2(n-1) - 1, and negative numbers with a leftmost digit of 1,
which gives values between -2(n - 1) and -1.

The exact same rule for overflow and underflow detection works. If, when adding two
positive numbers, we get a result that looks negative (i.e. with its leftmost bit 1), then we
have an overflow. Similarly, if, when adding two negative numbers, we get a result that
looks positive (i.e. with its leftmost bit 0), then we have an underflow.

Rational numbers

There is no particular difficulty in representing rational numbers in a computer. It suffices


to have a pair of integers, one for the numerator and one for the denominator.

To implement arithmetic on rational numbers, we can use some additional restrictions on


our representation. We may, for instance, decide that:

11
 positive rational numbers are always represented as two positive integers (the
other possibility is as two negative numbers),
 negative rational numbers are always represented with a negative numerator and a
positive denominator (the other possibility is with a positive numerator and a
negative denominator),
 the numerator and the denominator are always relative prime (they have no
common factors).

Such a set of rules makes sure that our representation is canonical, i.e., that the
representation for a value is unique, even though, a priori, many representations would
work.

Circuits for implementing rational arithmetic would have to take such rules into account.
In particular, the last rule would imply dividing the two integers resulting from every
arithmetic operation with their largest common factor to obtain the canonical
representation.

Rational numbers and rational arithmetic is not very common in the hardware of a
computer. The reason is probably that rational numbers don't behave very well with
respect to the size of the representation. For rational numbers to be truly useful, their
components, i.e., the numerator and the denominator both need to be arbitrary-precision
integers. As we have mentioned before, arbitrary precision anything does not go very
well with fixed-size circuits inside the CPU of a computer.

Floating-point numbers

Floating-point numbers use inexact arithmetic, and in return require only a fixed-size
representation. For many computations (so-called scientific computations, as if other
computations weren't scientific) such a representation has the great advantage that it is
fast, while at the same time usually giving adequate precision.

There are some (sometimes spectacular) exceptions to the "adequate precision" statement
in the previous paragraph, though. As a result, an entire discipline of applied
mathematics, called numerical analysis, has been created for the purpose of analyzing
how algorithms behave with respect to maintaining adequate precision, and of inventing
new algorithms with better properties in this respect.

The basic idea behind floating-point numbers is to represent a number as mantissa and an
exponent, each with a fixed number of bits of precision. If we denote the mantissa with m
and the exponent with e, then the number thus represented is m*2e.

Again, we have a problem that a number can have several representations. To obtain a
canonical form, we simply add a rule that m must be greater than or equal to 1/2 and
strictly less than 1. If we write such a mantissa in binal (analogous to decimal) form, we
always get a number that starts with 0.1. This initial information therefore does not have
to be represented, and we represent only the remaining "binals".

12
The reason floating-point representations work well for so-called scientific applications,
are that we more often need to multiply or divide two numbers. Multiplication of two
floating-point numbers is easy to obtain. It suffices to multiply the mantissas and add the
exponents. The resulting mantissa might be smaller than 1/2, in fact, it can be as small
as 1/4. In this case, the result needs to be canonicalized. We do this by shifting the
mantissa left by one position and subtracting one from the exponent. Division is only
slightly more complicated. Notice that the imprecision in the result of a multiplication or
a division is only due to the imprecision in the original operands. No additional
imprecision is introduced by the operation itself (except possibly 1 unit in the least
significant digit). Floating-point addition and subtraction do not have this property.

To add two floating-point numbers, the one with the smallest exponent must first have its
mantissa shifted right by n steps, where n is the difference of the exponents. If n is greater
than the number of bits in the representation of the mantissa, the second number will be
treated as 0 as far as addition is concerned. The situation is even worse for subtraction (or
addition of one positive and one negative number). If the numbers have roughly the same
absolute value, the result of the operation is roughly zero, and the resulting representation
may have no correct significant digits.

The two's complement representation that we mentioned above is mostly useful for
addition and subtraction. It only complicates things for multiplication and division. For
multiplication and division, it is better to use a representation with sign + absolute value.
Since multiplication and division is more common with floating-point numbers, and since
they result in multiplication and division of the mantissa, it is more advantageous to have
the mantissa represented as sign + absolute value. The exponents are added, so it is more
common to use two's complement (or some related representation) for the exponent.

Real numbers
One sometimes hears variations on the phrase "computers can't represent real numbers
exactly". This, of course is not true. Nothing prevents us from representing (say) the
square-root of two as the number two and a bit indicating that the value is the square root
of the representation. Some useful operations could be very fast this way. It is true,
though that we cannot represent all real numbers exactly. In fact, we have a similar
problem that we have with rational numbers, in that it is hard to pick a useful subset that
we can represent exactly, other than the floating-point numbers.

For this reason, no widespread hardware contains built-in real numbers other than the
usual approximations in the form of floating-point.

13
Q7. Explain the following with necessary diagrams:
a) Programmed I/O
b) Interrupt Driven I/O

Answer:

a) Programmed I/O
When the CPU is executed a program and encounters an instruction relating to I/O, it
executes the instructions by issuing a command to the appropriate I/O module. When
CPU issues a command to I/O module, it must wait until I/O operation is complete. The
I/O module will perform the requested action and then set appropriate bits in the status
register. It is the responsibility of the CPU to periodically check the status of the I/O
module until it finds that the operation is complete.

The sequences of the actions that take place with programmed I/O are:
 CPU requests I/O operation
 I/O module performs operation
 I/O module sets status bits
 CPU checks status bit periodically
 I/O module does not inform CPU directly
 I/O module does not interrupt CPU
 CPU may wait or come back later

A flow chart for input of a block of data using programmed I/O is as shown in figure. It
read in a block of data from a peripheral device into memory. Data is read in one word at
a time. For each word read in, the CPU keeps checking the status until the word is
available in I/O module’s data register.

14
Issue Read
command to I/ CPU à I/O
O module

Read status of
I/O à CPU
I/O module

Not
Ready
Check Error
Status condition

Ready

Read word
from I/O I/O à CPU
Module

Write word into


memory CPU à memory

No
Done?

Yes

Next instruction

b) Interrupt Driven I/O


With Interrupt driven I/O, the CPU issues a command to I/O module and it does not wait
until I/O operation is complete but instead continues to execute other instructions. When
I/O module has completed its work and ready to exchange data, it interrupts the CPU.
The CPU will then execute the data transfer and then resumes the former processing. This
technique improves the utilization if the processor as CPU does not have to wait until I/O
operation is complete.

A flow chart for input of a block of data using interrupt I/O is as shown in figure.

15
Issue Read CPU à I/O
command to I/
Do something
O module
else

Interrupt
Read status of
I/O module
I/O à CPU

Check Error
Status condition

Ready

Read word
from I/O I/O à CPU
Module

Write word into


memory CPU à memory

No
Done?

Yes

Next instruction

Using Interrupt Driven I/O technique CPU issues read command. I/O module gets data
from peripheral while CPU does other work and I/O module interrupts CPU. CPU checks
the status and if no error occurs and the device is ready then CPU requests data and I/O
module transfers data. Thus CPU reads the data and stores it in the main memory.

16

You might also like