[go: up one dir, main page]

0% found this document useful (0 votes)
121 views93 pages

Fundamentals of Computer Organization and Digital Electronics

The document provides an overview of basic computer organization and digital electronics. It discusses the differences between computer architecture and computer organization. The main components of a computer system including the processor, main memory, and I/O devices are described. The document then discusses the inner workings of the processor including registers, the control unit, arithmetic logic unit, and buses. Finally, it covers instruction formats, addressing modes, and the basic terminology related to computer organization.

Uploaded by

Gog
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)
121 views93 pages

Fundamentals of Computer Organization and Digital Electronics

The document provides an overview of basic computer organization and digital electronics. It discusses the differences between computer architecture and computer organization. The main components of a computer system including the processor, main memory, and I/O devices are described. The document then discusses the inner workings of the processor including registers, the control unit, arithmetic logic unit, and buses. Finally, it covers instruction formats, addressing modes, and the basic terminology related to computer organization.

Uploaded by

Gog
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/ 93

Fundamentals Of Computer

Organization and Digital


Electronics
Unit I
Computer Architecture VS Computer Organization
Computer Architecture Computer Organization

Computer Architecture is concerned with the way Computer Organization is concerned with the
hardware components are connected together to structure and behaviour of a computer system as
form a computer system. seen by the user.
It acts as the interface between hardware and It deals with the components of a connection in a
software. system.
Computer Architecture helps us to understand the Computer Organization tells us how exactly all the
functionalities of a system. units in the system are arranged and interconnected.

A programmer can view architecture in terms of Whereas Organization expresses the realization of
instructions, addressing modes and registers. architecture.
While designing a computer system architecture is An organization is done on the basis of architecture.
considered first.
Computer Architecture deals with high-level design Computer Organization deals with low-level design
issues. issues.
Architecture involves Logic (Instruction sets, Organization involves Physical Components (Circuit
Addressing modes, Data types, Cache optimization) design, Adders, Signals, Peripherals)
• Main parts of a computer system:
• Processor: Executes programs
• Main memory: Holds program and data
• I/O devices: For communication with outside

• Machine instruction: Description of primitive operation that machine


hardware is able to execute

• Instruction Set: Complete specification of all the kinds of instructions


that the processor hardware was built to execute
Basic Computer Organization
Inside the Processor…
• Hardware to manage instruction execution
• Arithmetic, logic hardware
• Registers: small units of memory to hold data/instructions
temporarily during execution

• Two kinds of registers


1. Special purpose registers
2. General purpose registers
Special Purpose Registers
• Program Counter (PC): specifies location in memory of instruction
being executed

• Instruction Register (IR): holds that instruction

• Processor Status Register: holds status information about current


state of processor, such as whether an arithmetic overflow has
occurred, etc
General Purpose Registers
• Available for use by programmer, possibly for keeping frequently used
data
• Why? Since there is a large speed disparity between processor and
main memory

• What do these numbers mean?


• Instruction operands can come from registers or from main memory
Basic Terminology

• Control Unit –A control unit (CU) handles all processor control signals.
It directs all input and output flow, fetches the code for instructions
and controlling how data moves around the system.
• Arithmetic and Logic Unit (ALU) –The arithmetic logic unit is that part
of the CPU that handles all the calculations the CPU may need, e.g.
Addition, Subtraction, Comparisons. It performs Logical Operations,
Bit Shifting Operations, and Arithmetic Operation.
Main Memory Unit (Registers) –
• Accumulator: Stores the results of calculations made by ALU.

• Program Counter (PC): Keeps track of the memory location of the next instructions
to be dealt with. The PC then passes this next address to Memory Address Register
(MAR).

• Memory Address Register (MAR): It stores the memory locations of instructions that
need to be fetched from memory or stored into memory.

• Memory Data Register (MDR): It stores instructions fetched from memory or any
data that is to be transferred to, and stored in, memory.

• Current Instruction Register (CIR): It stores the most recently fetched instructions
while it is waiting to be coded and executed.

• Instruction Buffer Register (IBR): The instruction that is not to be executed


immediately is placed in the instruction buffer register IBR.
• Input/Output Devices – Program or data is read into main memory
from the input device or secondary storage under the control of CPU
input instruction. Output devices are used to output the information
from a computer.

• Buses – Data is transmitted from one part of a computer to another,


connecting all major internal components to the CPU and memory, by
the means of Buses. Types:
• Data Bus: It carries data among the memory unit, the I/O devices, and the
processor.
• Address Bus: It carries the address of data (not the actual data) between
memory and processor.
• Control Bus: It carries control commands from the CPU (and status signals
from other devices) in order to control and coordinate all the activities within
the computer.
Instruction Formats (Zero, One, Two and Three
Address Instruction)
• A instruction is of various length depending upon the number of
addresses it contain. Generally CPU organization are of three types on
the basis of number of address fields:
• Single Accumulator organization
• General register organization
• Stack organization
• Zero Address Instructions –
Address is stored in the opcode, in the zero address instruction. A stack based
organization uses zero address instruction.

• One Address Instructions –


This use a implied ACCUMULATOR register for data manipulation. One operand is
in accumulator and other is in register or memory location. Implied means that
the CPU already know that one operand is in accumulator so there is no need to
specify it. i.e there will be one opcode field and one address field.

• Two Address Instructions –


Here two address can be specified in the instruction. Unlike earlier in one address
instruction, the result was stored in accumulator here result can be stored at a
different location rather than just accumulator, but require the number more of
the bit to represent address.

• Three Address Instructions –


This has three address field to specify a register or a memory location. The
program created is much short in size but the number of bits per instruction
increase.
Addressing Modes

• The term addressing modes refers to the way in which the operand of
an instruction is specified. The addressing mode specifies a rule for
interpreting or modifying the address field of the instruction before
the operand is actually executed.
• An assembly language program instruction consists of two parts
Addressing modes
• Implied mode::
• In implied addressing the operand is specified in the instruction itself.
In this mode the data is 8 bits or 16 bits long and data is the part of
instruction. .
• Zero address instruction are designed with implied addressing mode.
• Immediate addressing mode (symbol #):

• In this mode data is present in address field of instruction .Designed


like one address instruction format.
Note:Limitation in the immediate mode is that the range of constants
are restricted by size of address field.

• Example: MOV AL, 35H (move the data 35H into AL register)
• Register mode:
• In register addressing the operand is placed in one of 8 bit or 16 bit
general purpose registers. The data is in the register that is specified
by the instruction.
Here one register reference is required to access the data.
Example: MOV AX,CX (move the contents of CX register to AX register)
• Register Indirect mode:
• In this addressing the operand’s offset is placed in any one of the
registers BX,BP,SI,DI as specified in the instruction. The effective
address of the data is in the base register or an index register that is
specified by the instruction.
Here two register reference is required to access the data.
• MOV AX, [BX] (move the contents of memory location s addressed by
the register BX to the register AX)
• Auto Indexed (increment mode):

• Effective address of the operand is the contents of a register specified


in the instruction. After accessing the operand, the contents of this
register are automatically incremented to point to the next
consecutive memory location.(R1)+.
Here one register reference, one memory reference and one ALU
operation is required to access the data.
Example:
• Add R1, (R2)+ // OR
• R1 = R1 +M[R2]
• R2 = R2 + d
• Auto indexed ( decrement mode): Effective address of the operand is the
contents of a register specified in the instruction. Before accessing the
operand, the contents of this register are automatically decremented to
point to the previous consecutive memory location. –(R1)
Here one register reference,one memory reference and one ALU operation
is required to access the data.

• Example:

• Add R1,-(R2) //OR


• R2 = R2-d
• R1 = R1 + M[R2]

• Auto decrement mode is same as auto increment mode. Both can also be
used to implement a stack as push and pop . Auto increment and Auto
decrement modes are useful for implementing “Last-In-First-Out” data
structures.
• Direct addressing/ Absolute addressing Mode (symbol [ ]):
• The operand’s offset is given in the instruction as an 8 bit or 16 bit
displacement element. In this addressing mode the 16 bit effective
address of the data is the part of the instruction.
Here only one memory reference operation is required to access the
data.
• Example:ADD AL,[0301] //add the contents of offset address 0301 to
AL
• Indirect addressing Mode (symbol @ or () ):In this mode address
field of instruction contains the address of effective address.
• Here two references are required.
1st reference to get effective address.
2nd reference to access the data.
• Based on the availability of Effective address, Indirect mode is of two
kind:
• Register Indirect:In this mode effective address is in the register, and
corresponding register name will be maintained in the address field of an
instruction.
Here one register reference, one memory reference is required to access the
data.
• Memory Indirect: In this mode effective address is in the memory, and
corresponding memory address will be maintained in the address field of an
instruction.
Here two memory reference is required to access the data.
• Indexed addressing mode: The operand’s offset is the sum of the
content of an index register SI or DI and an 8 bit or 16 bit
displacement.
• Example:MOV AX, [SI +05]

• Based Indexed Addressing: The operand’s offset is sum of the


content of a base register BX or BP and an index register SI or DI.
• Example: ADD AX, [BX+SI]
• Advantages of Addressing Modes

• To give programmers to facilities such as Pointers, counters for loop


controls, indexing of data and program relocation.
• To reduce the number bits in the addressing field of the Instruction.
• RISC : Reduced Instruction Set Computer. is a type of microprocessor
architecture that utilizes a small, highly-optimized set of instructions,
rather than a more specialized set of instructions often found in other
types of architectures.

• Characteristic of RISC –
Simpler instruction, hence simple instruction decoding.
Instruction come under size of one word.
Instruction take single clock cycle to get executed.
More number of general purpose register.
Simple Addressing Modes.
Less Data types.
• CISC Complex Instruction Set Architecture :The main idea is that a
single instruction will do all loading, evaluating, and storing
operations just like a multiplication command will do stuff like loading
data, evaluating, and storing it, hence it’s complex.

• Characteristic of CISC –
• Complex instruction, hence complex instruction decoding.
• Instructions are larger than one-word size.
• Instruction may take more than a single clock cycle to get executed.
• Less number of general-purpose registers as operations get
performed in memory itself.
• Complex Addressing Modes.
• More Data types.
• Example – Suppose we have to add two 8-bit numbers:

• CISC approach: There will be a single command or instruction for this


like ADD which will perform the task.
• RISC approach: Here programmer will write the first load command
to load data in registers then it will use a suitable operator and then it
will store the result in the desired location.
RISC CISC

Focus on software Focus on hardware

Uses both hardwired and microprogrammed control


Uses only Hardwired control unit
unit

Transistors are used for storing complex


Transistors are used for more registers
Instructions

Fixed sized instructions Variable sized instructions

Can perform only Register to Register Arithmetic Can perform REG to REG or REG to MEM or MEM to
operations MEM

Requires more number of registers Requires less number of registers

Code size is large Code size is small

An instruction executed in a single clock cycle Instruction takes more than one clock cycle

An instruction fit in one word Instructions are larger than the size of one word
Hardwired v/s Micro-programmed Control Unit
• Hardwired Control Unit –

• Fixed logic circuits that correspond directly to the Boolean


expressions are used to generate the control signals.
• Hardwired control is faster than micro-programmed control.
• A controller that uses this approach can operate at high speed.
• RISC architecture is based on hardwired control unit
• Micro-programmed Control Unit –The control signals associated with
operations are stored in special memory units inaccessible by the programmer
as Control Words.

• Control signals are generated by a program are similar to machine language


programs.

• Micro-programmed control unit is slower in speed because of the time it takes


to fetch microinstructions from the control memory.
• There are two type Micro-programmed control Unit: Horizontal Micro-programmed
control Unit- The control signals are represented in the decoded binary format that is 1
bit/CS.
• Vertical Micro-programmed control Unit – The control signals re represented in the
encoded binary format. For N control signals- Logn(N) bits are required.
Instruction Cycle
• Registers Involved In Each Instruction Cycle:
• Memory address registers(MAR) : It is connected to the address lines of the system
bus. It specifies the address in memory for a read or write operation.
• Memory Buffer Register(MBR) : It is connected to the data lines of the system bus.
It contains the value to be stored in memory or the last value read from the
memory.
• Program Counter(PC) : Holds the address of the next instruction to be fetched.
• Instruction Register(IR) : Holds the last instruction fetched.
• The Fetch Cycle –
At the beginning of the fetch cycle, the address of the next instruction to be executed is in
the Program Counter(PC).

• The Indirect Cycles –


Once an instruction is fetched, the next step is to fetch source operands. Source Operand is
being fetched by indirect addressing it can be fetched by any addressing mode, here its done
by indirect addressing). Register-based operands need not be fetched. Once the opcode is
executed, a similar process may be needed to store the result in the main memory.

• The Execute CycleThe other three cycles(Fetch, Indirect and Interrupt) are simple and
predictable. Each of them requires a simple, small and fixed sequence of micro-operations. In
each case, the same micro-operation is repeated each time around. Execute Cycle is different
from them. Like, for a machine with N different opcodes there are N different sequences of
micro-operations that can occur.

• The Interrupt Cycle:


At the completion of the Execute Cycle, a test is made to determine whether any enabled
interrupt has occurred or not. If an enabled interrupt has occurred then Interrupt Cycle
occurs. The nature of this cycle varies greatly from one machine to another.
• Hardwired Control Unit –
• Fixed logic circuits that correspond directly to the Boolean expressions are used
to generate the control signals.
• Hardwired control is faster than micro-programmed control.
• A controller that uses this approach can operate at high speed.
• RISC architecture is based on hardwired control unit.
• Micro-programmed Control Unit –The control signals associated with operations
are stored in special memory units inaccessible by the programmer as Control
Words.
• Control signals are generated by a program are similar to machine language
programs.
• Micro-programmed control unit is slower in speed because of the time it takes to
fetch microinstructions from the control memory.
• There are two type Micro-programmed control Unit:Horizontal Micro-programmed control
Unit- The control signals are represented in the decoded binary format that is 1 bit/CS.
• Vertical Micro-programmed control Unit – The control signals re represented in the encoded
binary format. For N control signals- Logn(N) bits are required.
Computers: Micro, Mini, Mainframes and
Supercomputers!
• 1. Micro Computers:
• The smallest among them are micro computers. They are small in
physical size (most of them are desktop system; however, notebook
micro computers that can fit into a briefcase are also available). They
are economical in terms of costs and are friendly in use. Personal
computers (PCs) fall into this category.
• These computers can be used for small data processing jobs of bigger
companies or serve as complete computer systems for small firms. PC
can also be connected with bigger computers and be used as an
intelligent terminal to a bigger computer.
• 2. Mini computers:
• Mini computers are very popular among medium sized companies.
Mini computers offer facilities for faster processing of voluminous
information. Mini computers, of course, are bigger than micro-
computers but smaller than most of their elders called mainframes.

• They cost somewhere between Rs. 5 to 15 lac depending upon the


configuration. However, these prices are only indicative and are sub-
ject to substantial changes over time. The mini computers like VAX
8000 series from Digital Equipment Corporation (DEC) and AS/400
series from IBM have been quite popular in computer aided manu-
facturing, as well as departmental computers.
• 3. Mainframes:
• Mainframes are bigger computers, capable of handling data
processing needs of, say, head office of a bank, or a big multinational
company or may be a public utility office. Mainframe computer sys-
tems have larger storage and the speed of processing is also very
high.
• They also offer the advantage of wider choice with regard to up-
gradation of the system in future. They offer features such as parallel
processing. The parallel processing involves combining a large number
of processors that break down an application into many separate
parts in order to enhance processing speed.
• The speed of processing is expressed in terms of 10 to 100 millions of
instructions per second (MIPS), and cost somewhere between 1 to 5
million dollars depending upon the configuration. IBM still holds
almost 80 per cent of mainframe market with its popular mainframe
series IBM System 390.
• 4. Supercomputers:

• Supercomputers have a speed of between 100 to 900 MIPS. They are


quite expensive and cost somewhere around 10-30 million dollars
depending upon the configuration. The other competitors of Cray
supercomputers are machines from NEC of Japan.
• The above differences are primarily on the basis of three basic
factors, namely,
• i. The primary storage capacity,
• ii. Speed of processing data, and
• iii. Ability to support different input, output and mass storage devices
such as printers, tape drives, etc.
Program Execution • The PC contains 300, the address of the first
instruction. The instruction (the value 1940 in
hex) is loaded into IR and PC is incremented.
This process involves the use of MAR and
MBR.
• The first hexadecimal digit in IR indicates that
the AC is to be loaded. The remaining three
hexadecimal digits specify the address (940)
from which data are to be loaded.
• The next instruction (5941) is fetched from
location 301 and PC is incremented. The old
contents of AC and the contents of location 941
are added and the result is stored in the AC.
• The next instruction (2941) is fetched from
location 302 and the PC is incremented.
• The contents of the AC are stored in location
941.
What is PCI bus in computer architecture?
• Peripheral Component Interconnect (PCI) is a local computer bus for
attaching hardware devices in a computer and is part of the PCI Local
Bus standard.
• The PCI bus supports the functions found on a processor bus but in a
standardized format that is independent of any given processor’s
native bus.
• slot used mainly in devices like computer motherboards, in order to connect to
various hardware to the motherboard. These are manufactured by Intel .
• Adding PCI slots is an easy way to add more expansion cards into the
motherboard.
• PCI slots have mostly been replaced with PCI-e slots.
• PCI and PCIe slots can coexist on the same motherboards. In that case, PCIe slots
will be of a different color, shorter in width, and longer in length.
Peripheral Component Interconnect (PCI)
• It could be a standard information transport that was common in
computers from 1993 to 2007 or so.
• It was for a long time the standard transport for extension cards in
computers, like sound cards, network cards, etc.
• It was a parallel transport, that, in its most common shape, had a
clock speed of 66 MHz, and can either be 32 or 64 bits wide.
• It has since been replaced by PCI Express, which could be a serial
transport as contradicted to PCI.
• A PCI port, or, more precisely, PCI opening, is essentially the
connector that’s utilized to put through the card to the transport.
• When purge, it basically sits there and does nothing.
.NO PCI PCI express

An advanced version of PCI bus that connects


1. PCI is a computer bus that connects hardware devices.
graphic ports, Wifi and other devices.

It was introduced in the year 2003 by Intel, Dell and


2. It was introduced in the year 1992 by Intel.
other organizations.

3. It is a parallel bus interface It is a serial bus interface.

4. Conventional PCI is the other name for PCI. PCI-e is the abbreviated name for PCI Express.

5. It works slower. It works faster.

6. PCI provides a slower data rate PCI Express provides faster data rate.

7. The PCI slots are standardized The PCI-e slots depends upon number of lanes.

8. The speed of a PCI slot is upto 133MB/s. The speed of a PCI-e slot is upto 16 GB/s.

9. It has less features. It has more features.

10. It may or may not have hot swapping feature. It has the hot swapping feature.
• PCI 32 bits have a transport speed of 33 MHz and work at 132 MBps.
• PCI 64 bits have a transport speed of 33 MHz and work at 264 MBps.
• PCI 64 bits have a transport speed of 66 MHz and work at 512 MBps.
• PCI 64 bits have a transport speed of 66 MHz and work at 1 GBps.
• PCI slots are utilized to install sound cards, Ethernet and remote cards
and presently strong state drives utilizing NVMe(nonvolatile memory
express) innovation to supply SSD (solid-state drives)drive speeds that
are numerous times speedier than SATA SSD speeds.

• PCI openings too permit discrete design cards to be included to a


computer as well.

• The extension cards increment the machines capabilities past what


the motherboard may create alone, such as: upgraded illustrations,
extended sound, expanded USB and difficult drive controller, and
extra arrange interface options
• Advantage of PCI :
• You’ll interface a greatest of five components to the PCI and you’ll be
able moreover supplant each of them by settled gadgets on the
motherboard.
• You have different PCI buses on the same computer.
• The PCI transport will improve the speed of the exchanges from
33MHz to 133 MHz with a transfer rate of 1 gigabyte per second.
• The PCI can handle gadgets employing a greatest of 5 volts and the
pins utilized can exchange more that one flag through one stick.
• Disadvantage of PCI :
• PCI Graphics Card cannot get to to system memory.
• PCI does not support pipeline.
Interrupts
• Is a high Priority instruction generated by h/w Device or S/W program
instruction to get immediate attention of CPU
• The interrupt is a signal emitted by hardware or software when a
process or an event needs immediate attention.
• It alerts the processor to a high-priority process requiring interruption
of the current working process.
• In I/O devices one of the bus control lines is dedicated for this purpose
and is called the Interrupt Service Routine (ISR).
NEED FOR INTERRUPTS
• The operating system is a reactive program

• When you give some input it will perform computations and produces
output but meanwhile you can interact with the system by
interrupting the running process or you can stop and start another
process

• This reactiveness is due to the interrupts

• Modern operating systems are interrupt driven


INTERRUPT SERVICE ROUTINE AND IT’S WORKING
• The routine that gets executed when an interrupt
request is made is called as interrupt service
routine.
• Step 1: When the interrupt occurs the processor is
currently executing i’th instruction and the
program counter will be currently pointing to (i +
1)th instruction.
• Step 2: When the interrupt occurs the program
counter value is stored on the processes stack.
• Step 3: The program counter is now loaded with
the address of interrupt service routine.
• Step 4: Once the interrupt service routine is
completed the address on the processes stack is
pop and place back in the program counter.
• Step 5: Execution resumes from (i + 1)th line of
COMPUTE routine.
INTERRUPT HARDWARE
• Many computers have facility to connect two or more input and
output devices to it like laptop may have 3 USB slots. All these input
and output devices are connected via switches as shown -
• So there is a common interrupt line for all N input/output devices and the
interrupt handling works in the following manner ->
• When no interrupt is issued by the input/output devices then all the
switches are open and the entire voltage from Vdd is flown through the
single line INTR and reaches the processor. Which means the processor
gets a voltage of 1V.
• When the interrupt is issued by the input/output devices then the switch
associated with the input/output device is closed, so the entire current
now passes via the switches which means the hardware line reaching the
processes i.e INTR line gets 0 voltage. This is an indication for the processor
that an interrupt has occurred and the processor needs to identify which
input/output device has triggered the interrupt
• The value of INTR is a logical OR of the requests from individual devices.
• The resistor R is called as a pull up resistor because it pulls the line voltage
to high voltage state when all switches are open( no interrupt state).
• Our processor repeatedly keeps on checking for the SIN and SOUT
bits for the synchronization in the program.
• Hence, the processor does not do any things useful other than
running the infinite loop. To avoid this situation input/output devices
can have the concept of interrupts .
• When the input/output device is ready it could signal the processor
on a separate line called interrupt request line.
• On receiving the interrupt the processor reads the input output
device and hence removing the infinite loop waiting mechanism.
• TYPES OF INTERRUPTS
• Although interrupts have highest priority than other signals, there are many type
of interrupts but basic type of interrupts are ->
• Hardware Interrupts: If the signal for the processor is from external device or
hardware is called hardware interrupts.
• Example: from keyboard we will press the key to do some action this pressing of
key in keyboard will generate a signal which is given to the processor to do
action, such interrupts are called hardware interrupts.
• Hardware interrupts can be classified into two types ->
• Maskable Interrupt: The hardware interrupts which can be delayed when a much
highest priority interrupt has occurred to the processor.
• Non Maskable Interrupt: The hardware which cannot be delayed and should
process by the processor immediately.
• 2. Software Interrupts: Software interrupt can also divided in to two
types they are ->
• Normal Interrupts: the interrupts which are caused by the software
instructions are called software instructions.
• Exception: unplanned interrupts while executing a program is called
Exception. For example: while executing a program if we got a value
which should be divided by zero is called a exception.
• Advantages:
• It increases the efficiency of CPU.
• It decreases the waiting time of CPU.
• Stops the wastage of instruction cycle.

• Disadvantages:
• CPU has to do a lot of work to handle interrupts, resume its previous
execution of programs (in short, overhead required to handle the
interrupt request.).
Number Systems
• Types of Number System
List of Number
Type Base Numbers/Symbols

Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Binary 2 0, 1

Octal 8 0, 1, 2, 3, 4, 5, 6, 7

Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Binary Numbers
• Used to represent the voltage levels of a digital circuit.

• Only two voltage levels present in a digital circuit, logic High and logic Low.

• The high voltage is +5V and the low voltage is +0V.

• The binary numbers represent the logic low as a 0 and the logic high as a 1.
A binary number system is a code that uses only two basic symbols. The
digits can be any two distinct characters, but it should be 0 or 1. The binary
equivalent for some decimal numbers are given below
• Each digit in a binary number has a value or weight. The LSB has a
value of 1. The second from the right has a value of 2, the next 4 ,
etc.,
Decimal Binary Conversion
• A decimal number can be converted to a binary number by
successively dividing the number by 2 as follows:

• Note that the first remainder becomes the most significant bit (MSB).
The last remainder becomes the least significant bit (LSB).
Converting Fractional Decimal Number into
Binary Number
Binary to decimal conversion:

• Fractions: For fractions the weights of the digit positions are written
from right of the binary point and weights are given as follows.
Octal Number System
• Octal number system has a base of 8 i.e., it has eight basic symbols. First eight
decimal digits 0, 1,2,3,4,5,6,7 are used in this system.
• Octal to decimal conversion:
• In the octal number system each digit corresponds to the powers of 8. The
weight of digital position in octal number is as follows.

• To convert from octal to decimal multiply each octal digit by its weight and
add the resulting products.
• Decimal to Octal Conversion

• For converting decimal to octal, there are two steps required to


perform, which are as follows:
• In the first step, we perform the division operation on the integer and
the successive quotient with the base of octal(8).
• Next, we perform the multiplication on the integer and the successive
quotient with the base of octal(8).
• Example 1: (152.25)10
• Step 1:
• Divide the number 152 and its successive quotients with base 8.
• (152)10=(230)8
Operation Quotient Remainder

152/8 19 0
19/8 2 3
2/8 0 2

• Step 2:
• Now perform the multiplication of 0.25 and successive fraction with base 8.
• (0.25)10=(2)8
• So, the octal number of the decimal number 152.25 is 230.2
Operation Result carry

0.25×8 0 2
Decimal to octal conversion:
• Here the number is divided by 8 progressively and each time the
remainder is written and finally the remainders are written in the
reverse order to form the octal number. If the number has a fraction
part, that part is multiplied by 8 and carry in the integer part is taken.
Finally the carries are taken in the forward order.
• Octal to binary conversion:
• Since the base of octal number is 8, i.e., the third power of 2, each octal
number is converted into its equivalent binary digit of length three.

• Binary to octal: The given binary number is grouped into a group of 3 bits,
starting at the octal point and each group is converted into its octal
equivalent
Hexadecimal Number System:
• The hexadecimal number system has a base of 16. It has 16 symbols
from 0 through 9 and A through F.
Decimal Hexadecimal Conversion
• A decimal number can be converted to hex number by successively
dividing the number by 16 as follows:
Binary to Hexadecimal conversion
• Ex. : 6EA (16) convert in to binary equivalent.
• i. Write given Hexadecimal number as 6EA(16)

• ii. For each Hexadecimal digit write 4 bit binary equivalent as

6 E A

0110 1110 1010

• iii. Therefore , 6EA(16) = 011011101010(2)


Hexadecimal to Binary Conversion
• Each hex digit can be represented by a 4-bit binary number as shown above.
Conversion from hex to binary is very straightforward. Each hex digit is
replaced by 4-bit binary number.
Octal to hexadecimal conversion:-
• For conversion of octal to Hexadecimal, first convert the given octal
number to binary and then binary number to hexadecimal.
Hexadecimal to Octal conversion:-
• For conversion of hexadecimal to octal, first convert the given
hexadecimal number to binary and then binary number to octal.
Hexadecimal to Decimal conversion:
• By using positional value method i.e. multiply each hexadecimal digit
by its weight & add the resulting products.
BINARY ARITHEMATIC OPERATION :-
• BINARY ADDITION:- The binary addition rules are as follows 0 + 0 = 0 ;
0 + 1 = 1 ; 1 + 0 = 1 ; 1 + 1 = 10 , i.e 0 with a carry of 1
BINARY SUBTRACTION:-
• The binary subtraction rules are as follows 0 - 0 = 0 ; 1 - 1 = 0 ; 1 - 0 =
1 ; 0 - 1 = 1 , with a borrow of 1
1’s COMPLEMENT REPRESENTATION :-
• The 1’s complement of a binary number is obtained by changing each
0 to 1 and each 1 to 0.
• For example :- Find (1100)2 1’s complement.
2’s COMPLEMENT REPRESENTATION :-
• The 2’s complement of a binary number is a binary number which is
obtained by adding 1 to the 1’s complement of a number i.e. 2’s
complement = 1’s complement + 1
Fixed Point Number Representation
• Introduction: Real numbers in Real world
• In real life, we deal with real numbers -- numbers with fractional part.
Most modern computer have native (hardware) support for floating
point numbers. However, the use of floating point is not necessarily
the only way to represent fractional numbers.
• The use of fixed point data type is used widely in digital signal
processing (DSP) and game applications, where performance is
sometimes more important than precision.
• fixed point arithmetic is much faster than floating point arithmetic.
binary number:
1101012

represents the value:


1 * 25 + 1 * 24 + 0 * 23 + 1 * 22 + 0* 21 + 1 * 20
= 32 + 16 + 4 + 1
= 5310

if we divide the number 53 by 2, we know the result should be 26.5. However, how
do we represent it if we only had integer representations?
The Binary Point
• The key to represent fractional numbers, like 26.5 above, is the
concept of binary point.

• A binary point is like the decimal point in a decimal system. It acts as


a divider between the integer and the fractional part of a number.

• For example, in the numeral 26.5, the coefficient 6 has a weight of


100 = 1.
• 2 * 101 + 6 * 100 + 5 * 10-1 = 26.5
• same concept of decimal point can be applied to binary
representation, making a "binary point".

• As in the decimal system, a binary point represents the coefficient of


the term 20 = 1.

• All digits (or bits) to the left of the binary point carries a weight of 20,
21, 22, and so on. Digits (or bits) on the right of binary point carries a
weight of 2-1, 2-2, 2-3, and so on.
11010.12
represents the value:

5 4 3 2 1 0 -1 -2 -3
2 2 2 2 2 2 2 2 2
... 1 1 0 1 0 1 0 ...

= 1 * 24 + 1 * 23 + 0 * 22 + 1 * 21 + 0* 20 + 1 * 2-1
= 16 + 8 + 2 + 0.5
= 26.5
Shifting Is The Key
• bit pattern of 53 and 26.5 is exactly the same. The only difference, is
the position of binary point.
5 4 3 2 1 0 -1 -2 -3
2 2 2 2 2 2 Binary 2 2 2
Point
0 1 1 0 1 0 . 1 0 0

In the case of 26.510, binary point is located one position to the left of 5310:

5 4 3 2 1 0 -1 -2 -3
2 2 2 2 2 2 Binary 2 2 2
Point
1 1 0 1 0 1 . 0 0 0

In general, mathematically, given a fixed binary point position, shifting the bit pattern of
a number to the right by 1 bit always divide the number by 2. Similarly, shifting a
number to the left by 1 bit multiplies the number by 2.
Fixed Point Number Representation
• To define a fixed point type conceptually, all we need are two
parameters:

• width of the number representation, and


• binary point position within the number

• We will use notation fixed<w,b>, where w denotes thr number of bits


used as a whole(width of number ) and b denotes the the position of
the binary point from the least significant bit (LSB)
• For example, fixed<8,3> denotes a 8-bit fixed point number, of which 3 right most bits are fractional.
Therefore, the bit pattern:
0 0 0 1 0 1 1 0

represents a real number:


(00010.110)2
= 1 * 21 + 1 * 2-1 + 1 * 2-1
= 2 + 0.5 + 0.25
= 2.75

Note that on a computer, a bit patter can represents anything. Therefore the same bit pattern, if we "cast" it to
another type, such as a fixed<8,5> type, will represents the number:
(000.10110)2
= 1 * 2-1 + 1 * 2-3 + 1 * 2-4
= 0.5 + 0.125 + 0.0625
= 0.6875
If we treat this bit patter as integer, it represents the number:
(10110)2
= 1 * 24 + 1 * 22 + 1 * 21
= 16 + 4 + 2
= 22

You might also like