3 Rdunitcso
3 Rdunitcso
CPU design
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.
In computer organization, an instruction cycle, also known as a fetch-
decode-execute cycle, is the basic operation performed by a central
processing unit (CPU) to execute an instruction. The instruction cycle
consists of several steps, each of which performs a specific function in the
execution of the instruction. The major steps in the instruction cycle are:
1. Fetch: In the fetch cycle, the CPU retrieves the instruction from
memory. The instruction is typically stored at the address specified
by the program counter (PC). The PC is then incremented to point
to the next instruction in memory.
2. Decode: In the decode cycle, the CPU interprets the instruction and
determines what operation needs to be performed. This involves
identifying the opcode and any operands that are needed to
execute the instruction.
3. Execute: In the execute cycle, the CPU performs the operation
specified by the instruction. This may involve reading or writing
data from or to memory, performing arithmetic or logic operations
on data, or manipulating the control flow of the program.
4. There are also some additional steps that may be performed
during the instruction cycle, depending on the CPU architecture
and instruction set:
5. Fetch operands: In some CPUs, the operands needed for an
instruction are fetched during a separate cycle before the execute
cycle. This is called the fetch operands cycle.
6. Store results: In some CPUs, the results of an instruction are stored
during a separate cycle after the execute cycle. This is called the
store results cycle.
7. Interrupt handling: In some CPUs, interrupt handling may occur
during any cycle of the instruction cycle. An interrupt is a signal
that the CPU receives from an external device or software that
requires immediate attention. When an interrupt occurs, the CPU
suspends the current instruction and executes an interrupt handler
to service the interrupt.
These cycles are the basic building blocks of the CPU’s operation and are
performed for every instruction executed by the CPU. By optimizing these
cycles, CPU designers can improve the performance and efficiency of the
CPU, allowing it to execute instructions faster and more efficiently.
The Instruction Cycle –
Each phase of Instruction Cycle can be decomposed into a sequence of
elementary micro-operations. In the above examples, there is one sequence
each for the Fetch, Indirect, Execute and Interrupt Cycles.
The Indirect Cycle is always followed by the Execute Cycle. The Interrupt
Cycle is always followed by the Fetch Cycle. For both fetch and execute
cycles, the next cycle depends on the state of the system.
We assumed a new 2-bit register called Instruction Cycle Code (ICC). The
ICC designates the state of processor in terms of which portion of the cycle
it is in:-
00 : Fetch Cycle
01 : Indirect Cycle
10 : Execute Cycle
11 : Interrupt Cycle
At the end of the each cycles, the ICC is set appropriately. The above
flowchart of Instruction Cycle describes the complete sequence of micro-
operations, depending only on the instruction sequence and the interrupt
pattern(this is a simplified example). The operation of the processor is
described as the performance of a sequence of micro-operation.
Different Instruction Cycles:
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).
Step 2: The address in MAR is placed on the address bus, now the
control unit issues a READ command on the control bus, and the
result appears on the data bus and is then copied into the memory
buffer register(MBR). Program counter is incremented by one, to
get ready for the next instruction. (These two action can be
performed simultaneously to save time)
Step 3: The content of the MBR is moved to the instruction
register(IR).
Thus, a simple Fetch Cycle consist of three steps and four micro-
operation. Symbolically, we can write these sequence of events as
follows:-
Here ‘I’ is the instruction length. The notations (t1, t2, t3)
represents successive time units. We assume that a clock is
available for timing purposes and it emits regularly spaced clock
pulses. Each clock pulse defines a time unit. Thus, all time units are
of equal duration. Each micro-operation can be performed within
the time of a single time unit.
First time unit: Move the contents of the PC to MAR.
Second time unit: Move contents of memory location specified by
MAR to MBR. Increment content of PC by I.
Third time unit: Move contents of MBR to IR.
Note: Second and third micro-operations both take place during
the second time unit.
Advantages:
1. Standardization: The instruction cycle provides a standard way for
CPUs to execute instructions, which allows software developers to
write programs that can run on multiple CPU architectures. This
standardization also makes it easier for hardware designers to
build CPUs that can execute a wide range of instructions.
2. Efficiency: By breaking down the instruction execution into
multiple steps, the CPU can execute instructions more efficiently.
For example, while the CPU is performing the execute cycle for
one instruction, it can simultaneously fetch the next instruction.
3. Pipelining: The instruction cycle can be pipelined, which means
that multiple instructions can be in different stages of execution at
the same time. This improves the overall performance of the CPU,
as it can process multiple instructions simultaneously.
Disadvantages:
Data representation
Data Representation in Computer
Organization
In computer organization, data refers to the symbols that are used to represent
events, people, things and ideas.
Data Representation
The data can be represented in the following ways:
Data
Data can be anything like a number, a name, notes in a musical composition, or the
color in a photograph. Data representation can be referred to as the form in which
we stored the data, processed it and transmitted it. In order to store the data in
digital format, we can use any device like computers, smartphones, and iPads.
Electronic circuitry is used to handle the stored data.
Digitization
Binary Digits
The binary digits or bits are used to show the digital data, which is represented by 0
and 1. The binary digits can be called the smallest unit of information in a computer.
The main use of binary digit is that it can store the information or data in the form of
0s and 1s. It contains a value that can be on/off or true/false. On or true will be
represented by the 1, and off or false will be represented by the 0. The digital file is a
simple file, which is used to collect data contained by the storage medium like the
flash drive, CD, hard disk, or DVD.
Representing Numbers
The number can be represented in the following way:
Numeric Data
Representing Text
The text can be represented in the following ways:
Character Data
Character data can be formed with the help of symbols, letters, and numerals, but
they can?t be used in calculations. Using the character data, we can form our
address, hair colour, name, etc. Character data normally takes the data in the form of
text. With the help of the text, we can describe many things like our father name,
mother name, etc.
Digital Devices
Several types of codes are employed by the digital devices to represent character
data, including Unicode, ASCII, and other types of variants. The full form of ASCII is
American Standard Code for Information Interchange. It is a type of character
encoding standard, which is used for electronic communication. With the help of
telecommunication equipment, computers and many other devices, ASCII code can
represent the text. The ASCII code needs 7 bits for each character, where the unique
character is represented by every single bit. For the uppercase letter A, the ASCII
code is represented as 1000001.
Extended ASCII
Extended ASCII can be described as a superset of ASCII. The ASCII set uses 7 bits to
represent every character, but the Extended ASCII uses 8 bits to represent each
character. The extended ASCII contains 7 bits of ASCII characters and 1 bit for
additional characters. Using the 7 bits, the ASCII code provides code for 128 unique
symbols or characters, but Extended ASCII provides code for 256 unique symbols or
characters. For the uppercase letter A, the Extended ASCII code is represented as
01000001.
Unicode
ASCII code provides code for 128 characters, while Unicode provide code for roughly
65,000 characters with the help of 16 bits. In order to represent each character, ASCII
code only uses 1 bit, while Unicode supports up to 4 bytes. The Unicode encoding
has several different types, but UTF-8 and UTF-16 are the most commonly used. UTF-
8 is a type of variable length coding scheme. It has also become the standard
character encoding, which is used on the web. Many software programs also set UTF-
8 as their default encoding.
ASCII Code
ASCII code can be used for numerals like phone numbers and social security
numbers. ASCII text contains plain and unformatted text. This type of file will be
saved in a text file format, which contains a name ending with .txt. These files are
labelled differently on different systems, like Windows operating system labelled
these files as "Text document" and Apple devices labelled these files as "Plain Text".
There will have no formatting in the ASCII text files. If we want to make the
documents with styles and formats, then we have to embed formatting codes in the
text.
Microsoft Excel
Microsoft word is used to create formatted text and documents. It uses the DOCX
format to do this. If we create a new document using the Microsoft Word 2007 or
later version, then it always uses DOCX as the default file format. Apple
pages use PAGES format to produce the documents. As compared to Microsoft
Word, it is simpler to create and edit documents using page format. Adobe
Acrobat uses the PDF format to create the documents. The files that saved in the
PDF format cannot be modified. But we can easily print and share these files. If we
save our document in PDF format, then we cannot change that file into the Microsoft
Office file or any other file without specified software.
HTML is the hypertext markup language. It is used for document designing, which
will be displayed in a web browser. It uses HTML format to design the documents.
In HTML, hypertext is a type of text in any document containing links through which
we can go to other places in the document or in other documents also. The markup
language can be called as a computer language. In order to define the element
within a document, this language uses tags.
In the field of digital communication or computers, bits are the most basic unit of
information or smallest unit of data. It is short of binary digit, which means it can
contain only one value, either 0 or 1. So bits can be represented by 0 or 1, - or +,
false or true, off or on, or no or yes. Many technologies are based on bits and bytes,
which is extensively useful to describe the network access speed and storage
capacity. The bit is usually abbreviated as a lowercase b.
In order to execute the instructions and store the data, the bits are grouped into
multiple bits, which are known as bytes. Bytes can be defined as a group of eight bits,
and it is usually abbreviated as an uppercase B. If we have four bytes, it will equal 32
bits (4*8 = 32), and 10 bytes will equal 80 bits (8*10 = 80).
Uses
Bits are used for data rates like speeds while movie download, speed while internet
connection, etc. Bytes are used to get the storage capacity and file sizes. When we
are reading something related to digital devices, it will be frequently encountered
references like 90 kilobits per second, 1.44 megabytes, 2.8 gigahertz, and 2 terabytes.
To quantify digital data, we have many options such as Kilo, Mega, Giga, Tera and
many more similar terms, which are described as follows:
104 KB: Kb is also called a kilobyte or Kbyte. It is mostly used while referring to the
size of small computer files.
56 Kbps: Kbps is also called kilobit, Kbit or Kb. The 56 kbps means 56 kilobits per
second which are used to show the slow data rates. If our internet speed is 56 kbps,
we have to face difficulty while connecting more than one device, buffering while
streaming videos, slow downloading, and many other internet connectivity problems.
50 Mbps: Mbps is also called Megabit, MB or Mbit. The 50 Mbps means 50 Megabit
per second, which are used to show the faster data rates. If our internet speed is 50
Mbps, we will experience online activity without any buffering, such as online
gaming, downloading music, streaming HD, web browsing, etc. 50 Mbps or more
than that will be known as fast internet speed. With the help of fast speed, we can
easily handle more than one online activity for more than one user at a time without
major interruptions in services.
3.2 MB: 3.2 MB is also called Megabyte, MB or MByte. It is used when we are
referring to the size of files, which contains videos and photos.
100 Gbit: 100 Gbit is also called Gigabit or GB. It is used to show the really fast
network speeds.
Compression uses some programs, which also uses algorithms and functions to find
out the way to reduce the data size. Compression can be referred "zipping". The
process of reconstructing files will be known as unzipping or extracting. The
compressed files will contain .gz, or.tar.gz, .pkg, or .zip at the end of the files.
Compression can be divided into two techniques: Lossless compression and Lossy
compression.
Lossless Compression
As the name implies, lossless compression is the process of compressing the data
without any loss of information or data. If we compressed the data with the help of
lossless compression, then we can exactly recover the original data from the
compressed data. That means all the information can be completely restored by
lossless compression.
Many applications want to use data loss compression. For example, lossless
compression can be used in the format of ZIP files and in the GNU tool gzip. The
lossless data compression can also be used as a component within the technologies
of lossy data compression. It is generally used for discrete data like word processing
files, database records, some images, and information of the video.
According to this image, when we compress the original data using the lossless, we
are able to restore all the original data.
Lossy Compression
Lossy compression is the process of compressing the data, but that data cannot be
recovered 100% of original data. This compression is able to provide a high degree
of compression, and the result of this compression will be in smaller compressed
files. But in this process, some number of video frames, sound waves and original
pixels are removed forever.
If the compression is greater, then the size of files will be smaller. Business data and
text, which needs a full restoration, will never use lossy compression. Nobody likes to
lose the information, but there are a lot of files that are very large, and we don't have
enough space to maintain all of the original data or many times, we don't require all
the original data in the first place. For example, videos, photos and audio recording
files to capture the beauty of our world. In this case, we use lossy compression.
According to this image, when we compress the original data using the lossy, we are
only able to restore some amount of data. We will not restore 100% of the original
data.
2. **Central Processing Unit (CPU)**: The CPU is like the brain of the
computer. It processes instructions, performs calculations, and
controls all the operations.
3. **Memory Reference Instructions**: These are commands given
to the CPU to interact with memory. They tell the CPU what to do
with data in memory, like reading (fetching) or writing (storing) data.
- **Load**: When the CPU receives a "load" instruction, it's like the
CPU sending someone to the memory bookshelf to fetch a specific
book. In computer terms, it's reading (loading) data from memory
into the CPU so it can work with that data.
Input-output
Input-Output Interface is used as an method which helps in transferring of
information between the internal storage devices i.e. memory and the
external peripheral device . A peripheral device is that which provide input
and output for the computer, it is also called Input-Output devices. For
Example: A keyboard and mouse provide Input to the computer are called
input devices while a monitor and printer that provide output to the
computer are called output devices. Just like the external hard-drives, there
is also availability of some peripheral devices which are able to provide both
input and output.
Input-Output Interface
Read state :
Chip Select Operation Select lines Selection of
S S Interface unit
CS Read Write 0 1
0 0 1 0 0 Port A
0 0 1 0 1 Port B
0 0 1 1 0 Control Register
0 0 1 1 1 Status Register
Write State :
Chip Select Operation Select lines
S S Selection of
CS Read Write 0 1 Interface unit
0 1 0 0 0 Port A
0 1 0 0 1 Port B
0 1 0 1 0 Control Register
0 1 0 1 1 Status Register
Example :
If S0, S1 = 0 1, then Port B data register is selected for data transfer
between CPU and I/O device.
If S0, S1 = 1 0, then Control register is selected and store the
control information send by the CPU.
Interrupts
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).
When a device raises an interrupt at let’s say process i, the processor first
completes the execution of instruction i. Then it loads the Program Counter
(PC) with the address of the first instruction of the ISR. Before loading the
Program Counter with the address, the address of the interrupted
instruction is moved to a temporary location. Therefore, after handling the
interrupt the processor can continue with process i+1.
While the processor is handling the interrupts, it must inform the device
that its request has been recognized so that it stops sending the interrupt
request signal. Also, saving the registers so that the interrupted process can
be restored in the future, increases the delay between the time an interrupt
is received and the start of the execution of the ISR. This is called Interrupt
Latency.
Addressing modes
Addressing modes in CPU design refer to the various methods by
which a CPU can access data or operands in memory or registers.
These modes determine how the CPU specifies the source or
destination of data for an instruction. Here, we'll explain common
addressing modes in an easy-to-understand manner:
1. **Immediate Addressing Mode:**
In this mode, the operand is part of the instruction itself. For
example, if you have an instruction like "ADD R1, #5," the value 5 is
the immediate operand. It's directly used by the instruction.
Each addressing mode serves specific purposes and allows the CPU to
work with data efficiently based on the type of operation being
performed and the structure of the data. The CPU designer chooses
which addressing modes to include to meet the requirements of the
intended applications.
2. **Data Manipulation**:
Data manipulation involves performing operations on data to
transform or process it. The ALU (Arithmetic Logic Unit) in the CPU is
responsible for executing arithmetic and logical operations. Here's
how data manipulation works:
3. **Data Flow**:
Understanding the flow of data through the CPU is vital.
Instructions are fetched from memory, and their operands are read
from registers or memory. After execution, results may be stored
back in registers or memory. Data flow also includes considerations
for pipelining and parallel processing.
Enable
interrupt EI EI It will enable the interrupt
Disable
interrupt DI DI It will disable the interrupt
1. Shift Instructions: Shifts are operations in which the bits of a word
are moved to the left or right. Shift instructions may specify either
logical shifts, arithmetic shifts, or rotate-type operations. Typical
Shift Instructions –
Name Mnemonic