DPCO Course File
DPCO Course File
COURSE FILE
CS3351
Digital Principles and Computer Organization
Prepared By
[Link]
Head of the Department
Artificial Intelligence & Data Science
MON
TUE CS3351
WED CS3351
THU CS3351
3. Copy of Syllabus
4. Lesson Plan
COURSE OBJECTIVES:
COURSE OUTCOMES:
C302.3 : State the fundamentals of computer systems and analyze the execution of an instruction
C302.5 : Identify the characteristics of various memory systems and I/O communication
1.3- chalk
2 Karnaugh Map 1.15 and
3
board
1.16- chalk
3 Analysis and Design
1.18 and
Procedures 1 Michael D.
board
Ciletti,
“Digital 1.48- chalk
4 Binary Adder Design : 1.50 and
3
With an board
Introduction
to the Verilog 1.52- chalk
5 Subtractor HDL, 1.55 and
2
VHDL, and board
System
1.62- chalk
Verilog”,
6 Decimal Adder 1.63 and
1 Sixth Edition,
board
Pearson
Education, 1.77- chalk
7 Magnitude 2018. 1.81 and
Comparator 1
board
1.84- chalk
8 Decoder – Encoder 1.90 and
2
board
1.91- chalk
9 Multiplexers -
1.94 and
Demultiplexers 2
board
1
Dates Text / Reference Page Delivery Course
Topics Period book No. method Outcome
[Link]
Planned Completed
3.33- chalk
15 state minimization,
3.35 and
state assignment 2
board
3.36- chalk
16 circuit implementation 3.48 and
1
board
4.2- chalk
17 Registers 4.10 and
1
board
4.12- chalk
18 Counters 4.15 and
1
board
6.46- chalk
26 Encoding ofMachine
6.47 and
Instruction 1
board
UNIT-IV PROCESSOR
7.46- chalk
33 Pipelining 7.51 and
1
board
7.53.7 chalk
34 Pipelined data path
.57 and
&control 1
board
7.60- chalk
35 Data Hazard 7.63 and
1
board
8.2- chalk
37 Memory Concepts and
8.8 and
Hierarchy 1
board
8.3- chalk
38 Memory Management 8.9 and
1
board
8.8- chalk
39 Cache Memories:
8.11 and
Mapping 1 David A.
board
Patterson,
Cache Memories John L. 8.41- chalk
40 Replacement Hennessy, 8.42 and
1 “Computer
Techniques board
Organization
and Design, 8.44- chalk
41 Virtual Memory –
The 8.54 and
DMA 1
Hardware/So board
ftware
Interface”, 8.58- chalk
42 I/O – Accessing I/O 8.69 and
1 Sixth Edition,
Morgan board
Kaufmann/El 8.71- chalk
43 Parallel and Serial sevier, 2020 8.79 and
Interface 1
board
8.66- chalk
44 Interrupt I/O from an
8.69 and
application 1
board
PRACTICAL EXERCISES
46 Verification of 2
Boolean theorems
using logic gates.
Design and
implementation of
47 combinational circuits 2
using gates for
arbitrary functions.
Implementation of 4-
48 bit binary
adder/subtractor 2
circuits.
49 Implementation of
code converters. 2
Implementation of
50 BCD adder, encoder 2
and decoder circuits
Implementation of
51 functions using 2
Multiplexers.
52 Implementation of the
synchronous Counters. 2
Implementation of a
53 Universal Shift 2
register.
TEXT BOOKS:
1. M. Morris Mano, Michael D. Ciletti, “Digital Design : With an Introduction to the Verilog HDL, VHDL, and System
Verilog”, Sixth Edition, Pearson Education, 2018.
2. David A. Patterson, John L. Hennessy, “Computer Organization and Design, The Hardware/Software Interface”, Sixth
Edition, Morgan Kaufmann/Elsevier, 2020.
REFERENCES
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, Naraig Manjikian, “Computer Organization and Embedded Systems”,
Sixth Edition, Tata McGraw-Hill, 2012.
2. William Stallings, “Computer Organization and Architecture – Designing for Performance”, Tenth Edition, Pearson
Education, 2016.
3. M. Morris Mano, “Digital Logic and Computer Design”, Pearson Education, 2016.
Course Head of the
Staff in Charge Vice - Principal Principal
Coordinator Department
I. Combinational Circuits
Combinational circuits are a type of digital circuit where the output is a pure function of the present input values.
Unlike sequential circuits, combinational circuits have no memory element, meaning that the output depends solely on
the current inputs and not on any past inputs or states.
Definition: A combinational circuit is a circuit that produces an output based on the present inputs, without
any memory or feedback.
Key Property: The output at any given time is determined only by the current input values.
2. Components of Combinational Circuits
Logic Gates: Basic components like AND, OR, NOT, NAND, NOR, XOR, and XNOR gates.
Interconnecting Wires: Connects the logic gates and provides the necessary links between them.
Input and Output Lines: The circuit takes binary inputs and produces corresponding binary outputs.
Combinational circuits can be classified into various types depending on their function. Some common types include:
1. Arithmetic Circuits:
o Adders (e.g., Half Adder, Full Adder)
o Subtraction circuits
o Multipliers
o Dividers
2. Code Converters:
o Binary to BCD (Binary Coded Decimal) converters
o Gray Code to Binary converters
o BCD to Seven-segment display decoders
3. Multiplexers (MUX):
o A multiplexer selects one of many input lines and forwards the selected input to the output.
o A multiplexer with nnn data inputs has log2n\log_2 nlog2n select lines.
4. Demultiplexers (DEMUX):
o A demultiplexer takes a single input and routes it to one of many output lines based on select lines.
5. Encoders:
o An encoder converts an active input line to a binary code.
o Example: 8-to-3 priority encoder.
6. Decoders:
o A decoder takes an nnn-bit binary input and activates one of 2n2^n2n output lines.
o Example: 3-to-8 line decoder.
7. Comparators:
o Compares two numbers and outputs the result as "greater than", "equal to", or "less than."
A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
A B A OR B
0 0 0
A B A OR B
0 1 1
1 0 1
1 1 1
NOT Gate: Inverts the input. If the input is 0, the output is 1; if the input is 1, the output is 0.
o Truth Table:
A NOT A
0 1
1 0
NAND Gate: Produces a 0 output only if all its inputs are 1 (inverse of AND).
NOR Gate: Produces a 1 output only if all its inputs are 0 (inverse of OR).
XOR Gate: Produces a 1 output if the number of 1 inputs is odd.
XNOR Gate: Produces a 1 output if the number of 1 inputs is even (inverse of XOR).
Half Adder: Adds two single-bit numbers and provides a sum and a carry output.
o Truth Table:
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
o Boolean Expressions:
Sum = A⊕BA \oplus BA⊕B (XOR operation)
Carry = A⋅BA \cdot BA⋅B (AND operation)
Full Adder: Adds three bits (two significant bits and a carry-in bit) and outputs a sum and a carry-out bit.
o Truth Table:
o Boolean Expressions:
Sum = A⊕B⊕CinA \oplus B \oplus CinA⊕B⊕Cin
Carry Out = (A⋅B)+(Cin⋅(A⊕B))(A \cdot B) + (Cin \cdot (A \oplus B))(A⋅B)+(Cin⋅(A⊕B))
Digital Arithmetic: In devices like calculators, CPUs, and digital signal processors (DSPs).
Data Routing: Multiplexers and demultiplexers are used in communication systems for routing data.
Code Conversion: Circuits for converting data from one form to another (e.g., Binary to Gray Code).
Control Systems: Used in digital controllers to perform logical decision-making processes.
Simplicity: They are easy to design and do not require memory elements.
Speed: Since the output depends solely on the current inputs, combinational circuits generally operate faster
than sequential circuits.
Parallel Processing: The logic gates in a combinational circuit work in parallel, making these circuits efficient
for many tasks.
Lack of Memory: Combinational circuits cannot store information. They can't retain the state of previous
inputs or produce outputs based on history.
Complexity: For large numbers of inputs, the design of a combinational circuit can become highly complex.
2. Decimal Adder
A decimal adder is a digital circuit designed to add two decimal numbers (base-10). Unlike binary adders, which deal
with binary numbers (base-2), decimal adders work with the decimal system and need to account for the carry
generated when the sum exceeds 9.
1. Basics of Decimal Addition
In the decimal system, the sum of two digits can be from 0 to 18 (if adding two 9's, which are the largest single-digit
numbers in base 10). The key difference between decimal and binary addition is that, when the sum of two digits
exceeds 9, the result must "carry" over to the next column.
For example:
A decimal adder is typically constructed using binary adders along with additional logic to handle the carry-over
when the sum exceeds 9. It consists of:
1. Binary Full Adders: To add each corresponding pair of decimal digits (and any carry from previous additions).
2. Decimal Adjustment Logic: After adding, if the sum exceeds 9, this logic adjusts the result by adding 6 (i.e., 0110 in
binary) and generating the proper carry.
Decimal Half Adder: It adds two decimal digits without considering any previous carry input. The sum output
is adjusted if the result exceeds 9.
Decimal Full Adder: It adds two decimal digits and includes an input carry from the previous column. It
produces a sum and a carry-out.
Let’s consider a Decimal Full Adder that adds two decimal digits (A, B) and a carry-in (Cin). The output will be a
sum (S) and carry-out (Cout).
0 00 0 0
0 10 1 0
1 00 1 0
1 10 2 0
2 00 2 0
A B Cin Sum (S) Carry-out (Cout)
2 10 3 0
3 00 3 0
3 10 4 0
4 00 4 0
4 10 5 0
5 00 5 0
5 10 6 0
6 00 6 0
6 10 7 0
7 00 7 0
7 10 8 0
8 00 8 0
8 10 9 0
9 00 9 0
9 10 10 1
When the sum exceeds 9, we need to add 6 (binary 0110) and handle the carry:
Example: Adding 7 and 6 results in 13. In binary, 7 is 0111 and 6 is 0110. The sum of 0111 + 0110 = 1101 (13 in
decimal).
o But, since this sum is greater than 9, we need to adjust it by adding 0110 (binary for 6) to get the final sum of
0011 (3) and a carry-out of 1.
The circuit uses AND, OR, and XOR gates to construct the binary addition and additional logic gates for the
adjustment.
Advantages:
Accurate Decimal Operations: Decimal adders allow precise arithmetic operations in decimal form, which is crucial for
human-readable outputs.
Simplifies Human-Computer Interaction: Reduces the need for converting decimal numbers to binary in real-world
applications.
Limitations:
Complexity: Decimal adders are more complex than binary adders due to the need for carry handling and digit
adjustment.
Slower: Because of the extra logic for adjustments, decimal adders may be slower compared to binary adders.
3. Karnaugh Map
The Karnaugh map (K-map) is a graphical method used for simplifying Boolean expressions, making it an essential
tool in digital logic design. It helps in minimizing the number of gates required in a combinational circuit, and thus, it
plays a significant role in optimizing digital circuits. By organizing the truth table into a visual grid, the K-map
provides an easy way to visualize patterns and simplifications that might be difficult to identify algebraically.
A K-map is a diagrammatic tool used to simplify Boolean functions and expressions by grouping the 1's (or 0's) in a
truth table. It’s a simplification technique that minimizes the logical expression and reduces the number of gates in a
logic circuit.
A K-map for n variables has 2n2^n2n cells, where each cell represents one combination of input values.
Adjacent cells differ by only one variable (this is critical for simplification).
The cells are arranged in such a way that it follows the Gray code (where only one variable changes at a time between
adjacent cells).
The number of variables in the Boolean function determines the size of the K-map:
Each cell in the K-map represents a possible combination of the Boolean variables. For example:
In a 3-variable K-map, the cells represent the possible combinations of A,B,A, B,A,B, and CCC.
A 2-variable K-map has 4 cells. The variables AAA and BBB can take four combinations: 00, 01, 11, and 10.
AB 00 01 11 10
0 0 1 1 0
1 1 0 0 1
A 3-variable K-map consists of 8 cells. The three variables A,B,A, B,A,B, and CCC produce the combinations 000,
001, 011, 010, 110, 111, 101, 100.
BC\A 0 1
00 01
01 10
11 00
10 11
BC\A 0 1
A 4-variable K-map contains 16 cells and can be used for simplifications involving four variables. The combinations
of A,B,C,DA, B, C, DA,B,C,D range from 0000 to 1111.
CD\AB 00 01 11 10
00 0 1 1 0
01 0 0 1 1
11 1 0 0 1
10 1 1 0 0
The primary aim of the K-map is to find groups of 1's or 0's that can be combined to simplify the Boolean expression.
Groups must adhere to the following rules:
Example of Grouping:
If a K-map has a 1 in four adjacent cells, you can group those four cells into a single term. The larger the group, the
more simplified the resulting Boolean expression will be.
BC\A 0 1
00 00
01 10
11 11
10 01
Visual Approach: K-map provides an easy-to-visualize method for simplifying Boolean functions compared to algebraic
methods like Boolean algebra.
Minimization of Terms: K-map helps in minimizing the number of logic gates and operations required to implement a
Boolean function.
Time-efficient: It is quicker and easier for simplifying small to medium-sized Boolean functions.
Scalability: K-map becomes cumbersome and hard to manage for Boolean functions with more than 4 or 5 variables. As
the number of variables increases, the K-map becomes more difficult to visualize and manage.
Manual Errors: It requires careful grouping, and human error can occur if the groups are not formed properly.
Complex for Large Functions: For Boolean functions involving more than 6 variables, K-map is not practical, and other
methods (like the Quine-McCluskey algorithm) might be used instead.
While K-maps are easy to work with for up to 4 variables, they become increasingly complex for 5 or more variables.
However, the process remains the same:
In these cases, multiple 4-variable maps are often used, or a computer-based method might be necessary.
4. Binary Adder
A binary adder is a fundamental digital circuit used to perform binary addition. It is a core component of many
digital systems, such as computers and calculators.
0+0=00 + 0 = 00+0=0
0+1=10 + 1 = 10+1=1
1+0=11 + 0 = 11+0=1
1+1=101 + 1 = 101+1=10 (sum = 0, carry = 1)
A. Half Adder
B. Full Adder
C. Multi-Bit Adder
Consists of one XOR gate for SSS and one AND gate for CCC.
4. Full Adder
C. Circuit Design
1. Concept:
o Multiple full adders are connected in series.
o Carry-out of each stage is the carry-in for the next.
2. Design:
o For nnn-bit addition, nnn full adders are used.
o Inputs: A[i],B[i],CinA[i], B[i], C_{in}A[i],B[i],Cin.
o Outputs: S[i],CoutS[i], C_{out}S[i],Cout.
3. Limitations:
o Propagation delay increases linearly with the number of bits.
1. Concept:
o Reduces propagation delay by computing carries in parallel.
o Uses "generate" (GGG) and "propagate" (PPP) signals:
G=A⋅BG = A \cdot BG=A⋅B (carry generated).
P=A⊕BP = A \oplus BP=A⊕B (carry propagated).
2. Advantages:
o Faster than ripple carry adders.
o Suitable for high-speed applications.
6. Key Concepts
A. Propagation Delay
B. Optimization Techniques
Use hierarchical adders like carry look-ahead or carry-save adders to minimize delay.
Parallel computation of intermediate values.
Trade-off between speed (low delay) and hardware complexity (more gates).
Ripple Carry Adder Slow (linear delay) Low Small circuits, low-speed systems
Adder Type Speed Hardware Complexity Use Cases
Binary adders are essential building blocks in digital electronics. Their design ranges from simple single-bit operations
(half and full adders) to sophisticated multi-bit structures (ripple carry and carry look-ahead adders). Understanding
their operation, performance trade-offs, and applications is crucial for designing efficient digital systems.
6. Subtractor
A subtractor is a combinational circuit used to perform binary subtraction. It is an essential component in digital
electronics, forming the basis of arithmetic operations in digital systems.
0−0=00 - 0 = 00−0=0
0−1=10 - 1 = 10−1=1 (borrow = 1)
1−0=11 - 0 = 11−0=1
1−1=01 - 1 = 01−1=0
When subtracting multi-bit numbers, a borrow may propagate to the higher bits.
2. Types of Subtractors
A. Half Subtractor
B. Full Subtractor
C. Multi-Bit Subtractor
4. Full Subtractor
A. Concept
B. Subtraction by Addition
Binary subtraction can be implemented using addition by taking the 2’s complement of the subtrahend:
1. Operation:
o Cascades multiple full subtractors.
o Borrow propagates sequentially.
2. Limitations:
o High propagation delay as borrow cascades through each stage.
1. Operation:
o Reduces delay by computing borrow values in parallel.
o Uses "generate" and "propagate" concepts:
Generate(G)=A‾⋅BGenerate (G) = \overline{A} \cdot BGenerate(G)=A⋅B.
Propagate(P)=A‾⊕BPropagate (P) = \overline{A} \oplus BPropagate(P)=A⊕B.
2. Advantages:
o Faster than ripple borrow subtractors.
7. Key Concepts
A. Propagation Delay
A single adder circuit can perform subtraction using the 2’s complement method.
Modify inputs:
o Minuend remains unchanged.
o Subtrahend is complemented and incremented by 1.
Trade-off between speed (low delay) and hardware complexity (number of gates).
8. Comparisons of Subtractors
Subtractor Type Speed Hardware Complexity Use Cases
Ripple Borrow Subtractor Slow (linear delay) Low Simple, low-speed systems
9. Applications of Subtractors
Subtractor circuits are indispensable for binary arithmetic. They range from simple half subtractors for single-bit
operations to complex multi-bit subtractors optimized for speed and efficiency. Understanding the trade-offs in delay,
complexity, and hardware is key to designing effective digital systems.
7. Magnitude Comparator
A magnitude comparator is a combinational logic circuit that compares the magnitudes of two binary numbers and
determines their relative sizes. It provides outputs indicating whether one number is greater than, less than, or equal to
the other.
The comparator is used to compare two binary numbers AAA and BBB. It evaluates:
A. Single-Bit Comparator
B. Multi-Bit Comparator
5. Multi-Bit Comparator
A. Comparison Logic
Truth Table
7. Design of a 4-Bit Comparator
C. Circuit Design
1. Equality Detection:
o Use XNOR gates for each pair of corresponding bits.
o Combine using AND gates.
2. Greater/Less Detection:
o Use AND, OR gates to evaluate conditions for each bit.
A. Propagation Delay
B. Hardware Complexity
1. Parallel Comparators:
o Use parallel processing to compare bits simultaneously.
2. Hierarchical Comparators:
o Divide inputs into smaller segments and compare hierarchically.
3. Programmable Comparators:
o Allow dynamic configuration of comparison conditions.
Magnitude comparators are versatile components in digital systems used to compare binary numbers. Their design
involves the logical evaluation of individual bits and efficient integration to minimize delay and hardware complexity.
Understanding their operation is fundamental for implementing decision-making processes in digital systems.
[Link]
A decoder is a combinational circuit that converts binary input data into a specific output pattern. It is widely used in
digital electronics to decode information for various applications, such as memory addressing, display systems, and
communication systems.
1. Introduction to Decoders
The decoder activates only one output line corresponding to the binary input, while all other outputs remain inactive.
2. Purpose and Applications of Decoders
Applications
1. Memory Addressing:
o Decoders are used to activate specific memory locations in response to binary addresses.
2. Seven-Segment Displays:
o Decode binary data to display numbers and characters.
3. Instruction Decoding:
o Decoders interpret machine code in CPUs.
4. Data Routing:
o Used in multiplexing and demultiplexing.
5. Error Detection:
o Decoders play a role in detecting and correcting data transmission errors.
2. Logic Representation:
o Outputs are represented using AND gates.
o Inverters may be used to handle logic low (0) inputs.
4. Types of Decoders
B. BCD-to-Decimal Decoder
C. Seven-Segment Decoder
D. Address Decoder
Used in memory systems to enable specific memory blocks based on the input address.
5. Example: 2-to-4 Binary Decoder
A. Truth Table
A. Truth Table
7. Enable Feature in Decoders
A. Seven-Segment Decoder
B. BCD-to-Decimal Decoder
C. Address Decoder
9. Cascading Decoders
Example: A 5-to-32 decoder can be built using two 3-to-8 decoders and one 2-to-4 decoder.
A. Propagation Delay
B. Fan-Out
Functionality Decodes binary to outputs Selects one input Routes input to one output
1. Priority Decoders:
o Prioritize specific inputs when multiple inputs are active.
2. Error Detection:
o Identify and signal invalid inputs.
3. Programmable Decoders:
o Configurable for specific applications.
Decoders are essential circuits in digital electronics, converting binary data into specific output patterns. Their
applications range from simple seven-segment displays to complex memory systems. Understanding their design,
operation, and types is vital for digital system design.
9. Encoder
An encoder is a combinational logic circuit that converts active input signals into a coded binary output. It performs
the reverse operation of a decoder by encoding the information of 2n2^n2n input lines into an nnn-bit output.
1. Introduction to Encoders
Encoders are used to compress data by reducing the number of data lines. They are widely employed in digital
systems for efficient data handling.
Applications
1. Data Compression:
o Reduces multiple inputs into a smaller, encoded binary representation.
2. Multiplexers:
o Helps select data lines for further processing.
3. Keyboards:
o Converts keypresses into binary codes (e.g., ASCII).
4. Priority Systems:
o Encoders with priority (priority encoders) resolve conflicts when multiple inputs are active.
5. Robotics and Automation:
o Used in position sensors for feedback systems.
3. Types of Encoders
A. Basic Encoder
B. Decimal-to-BCD Encoder
D. Rotary Encoder
4. Basic Encoder
B. Truth Table
5. Priority Encoder
A. Definition
A priority encoder outputs the binary code of the highest-priority active input when multiple inputs are active.
B. Example: 4-to-2 Priority Encoder
6. Decimal-to-BCD Encoder
7. Advantages of Encoders
8. Limitations of Encoders
9. Cascading Encoders
1. Propagation Delay:
o The time taken for input changes to reflect in outputs.
o Priority encoders may have slightly higher delays.
2. Fan-In:
o The number of inputs a logic gate can handle affects encoder performance.
Encoders are integral components of digital systems, converting multiple inputs into smaller, coded binary outputs.
They find applications in data compression, communication systems, and control systems. Advanced types, such as
priority encoders and rotary encoders, address specific needs, making encoders versatile and essential in modern
electronics.
10 Multiplexers
A Multiplexer (MUX) is a combinational circuit that selects one of many input signals and forwards the selected
input to a single output line. Multiplexers are also known as data selectors because they allow multiple data sources to
share a single communication line.
1. Introduction to Multiplexers
A MUX uses control signals (selectors) to determine which input should be transmitted to the output.
It acts as a "many-to-one" circuit.
2. Key Features of Multiplexers
Applications
4. Types of Multiplexers
A. 2:1 Multiplexer
Truth Table:
B. 4:1 Multiplexer
C. 8:1 Multiplexer
Logic Expression:
D. 16:1 Multiplexer
5. Cascading Multiplexers
6. Applications of Multiplexers
1. Data Selection:
o Combines multiple inputs and routes the selected input.
2. Communication Systems:
o Reduces the number of transmission lines.
3. Control Systems:
o Selects between different control signals.
4. Function Implementation:
o MUXes can implement Boolean functions.
7. Advantages of Multiplexers
1. Efficiency:
o Reduces hardware requirements.
2. Scalability:
o Easy to expand for more inputs using cascading.
3. Flexibility:
o Can handle different types of signals.
8. Limitations of Multiplexers
1. Propagation Delay:
o Delays can occur in complex MUX designs.
2. Power Consumption:
o Higher for large-scale MUXes.
3. Signal Integrity:
o Signal loss can occur in long-distance transmissions.
10. Comparisons
Feature Multiplexer (MUX) Demultiplexer (DEMUX)
Inputs 2n2^n2n 1
Outputs 1 2n2^n2n
Multiplexers are vital components in digital systems, offering efficient data selection and routing. Their versatility
makes them integral in applications like communication, computation, and control systems.
11. Demultiplexers
A Demultiplexer (DEMUX) is a combinational logic circuit that takes a single input and routes it to one of several
outputs based on select lines. It performs the reverse function of a multiplexer (MUX) and is also called a data
distributor.
1. Introduction to Demultiplexers
A DEMUX has:
o One input line.
o Multiple output lines (2n2^n2n).
o Select lines (nnn) to control which output is active.
It routes data from a single input to one of several outputs.
Applications
The select lines determine which output line receives the input signal.
Only one output is active (logic HIGH) at a time, while others are LOW.
B. 1-to-4 DEMUX
C. 1-to-8 DEMUX
Logic Expressions:
5. Cascading Demultiplexers
6. Applications of Demultiplexers
A. Communication Systems
B. Data Distribution
C. Logic Implementation
D. Display Devices
7. Advantages of Demultiplexers
8. Limitations of Demultiplexers
1. Propagation Delay:
o Can be significant in larger circuits.
2. Signal Degradation:
o Signal quality may reduce over long distances.
3. Synchronization:
o Requires precise control of select lines.
A DEMUX can implement Boolean functions by using select lines as inputs and feeding the desired logic into the
input line.
Example:
Demultiplexers are critical components in digital systems, allowing efficient data distribution and routing. Their
ability to route a single input to multiple outputs makes them indispensable in communication, computation, and
control systems.
Sequential circuits are a fundamental class of digital circuits that depend not only on the current inputs but also on the
past history of inputs. They have memory elements, which store information about previous states.
1. Definition
A Sequential Circuit is a type of digital circuit where the output depends on:
o Present inputs.
o The past sequence of inputs (stored in memory).
Unlike combinational circuits, sequential circuits incorporate feedback loops.
1. Memory: Sequential circuits store past input data using memory elements like flip-flops or latches.
2. State: The stored data determines the circuit's current state.
3. Clock Signals: Most sequential circuits operate synchronously using a clock signal.
4. Feedback: Output signals are fed back to influence future inputs or states.
1. Memory Elements:
o Store state information.
o Examples: Flip-flops (SR, D, JK, T), Latches.
2. Logic Gates:
o Perform logical operations on inputs and feedback to determine the next state.
5. State Representation
0 0 0 0
0 1 1 1
1 0 0 0
1 1 1 1
1. Clock Pulse:
o Determines timing in synchronous circuits.
2. State Transition:
o Depends on inputs and current state.
3. Feedback:
o Enables memory and state retention.
1. Memory:
o Can store information for future use.
2. Complex Operations:
o Suitable for counters, registers, and state machines.
3. Timing Control:
o Synchronous circuits provide precise timing.
1. Complex Design:
o Feedback and timing introduce complexity.
2. Timing Issues:
o Asynchronous circuits are prone to glitches and race conditions.
3. Power Consumption:
o Higher than combinational circuits due to clocking and feedback.
2. Counters:
o Synchronous or asynchronous circuits used for counting events.
3. Shift Registers:
o Used for data storage and movement in serial or parallel formats.
1. Data Storage:
o Used in memory units like RAM and registers.
2. Digital Clocks:
o For timing and counting.
3. Communication Systems:
o Used in encoding, decoding, and error correction.
4. Control Systems:
o Implement controllers in robotics and automation.
5. Computers:
o For processing, control, and data manipulation.
11. Design of Sequential Circuits
1. State Diagram:
o Draw the diagram showing all states and transitions.
2. State Table:
o Create a table mapping current states, inputs, next states, and outputs.
3. Minimize States:
o Simplify the state table to reduce circuit complexity.
4. Choose Memory Elements:
o Select appropriate flip-flops or latches.
5. Circuit Implementation:
o Use combinational logic and memory elements to implement the circuit.
Memory Yes No
1. Glitches:
o Unintended outputs due to timing mismatches.
2. Race Conditions:
o Occur when outputs change unpredictably in asynchronous circuits.
3. Metastability:
o Occurs when a flip-flop's input changes too close to the clock edge.
Sequential circuits form the backbone of digital systems that require memory and state-dependent behavior. Their
ability to store information and handle time-dependent operations makes them essential for modern electronic devices,
ranging from simple timers to complex processors.
Flip-flops are basic memory elements in sequential circuits, capable of storing one bit of information. They are edge-
triggered devices that change their state based on the input and clock signals. Flip-flops are widely used in digital
systems for data storage, synchronization, and state transition.
1. Overview of Flip-Flops
Flip-flops are bistable devices, meaning they have two stable states: 0 and 1.
They change state only on the triggering edge of a clock signal (positive or negative edge).
Key characteristics:
o Set: Forces the output to 1.
o Reset: Forces the output to 0.
o Hold: Retains the current state.
o Toggle: Switches the state.
2. Types of Flip-Flops
1. SR (Set-Reset) Flip-Flop
2. D (Data or Delay) Flip-Flop
3. JK Flip-Flop
4. T (Toggle) Flip-Flop
A. SR Flip-Flop
Operation Table:
0 0 Q (Hold) No change
010 Reset (Q → 0)
101 Set (Q → 1)
Excitation Table:
0 0 00
0 1 10
1 0 01
1 1 00
B. D Flip-Flop
Inputs: D (Data).
Outputs: Q.
Function: Transfers the input DDD to QQQ on the clock edge.
Operation Table:
D Q (Next State) Description
0 0 Reset (Q → 0)
1 1 Set (Q → 1)
Excitation Table:
0 0 0
0 1 1
1 0 0
1 1 1
C. JK Flip-Flop
Inputs: J, K.
Outputs: Q.
Function: Combines the features of SR and T flip-flops. Avoids invalid states.
Operation Table:
0 0 Q (Hold) No change
010 Reset (Q → 0)
101 Set (Q → 1)
Excitation Table:
0 0 0X
0 1 1X
1 0 X1
1 1 X0
D. T Flip-Flop
Inputs: T (Toggle).
Outputs: Q.
Function: Toggles the state when T=1T = 1T=1.
Operation Table:
0Q No change (Hold)
Excitation Table:
0 0 0
0 1 1
1 0 1
1 1 0
4. Applications of Flip-Flops
6. Flip-Flop Conversion
Flip-flops can be converted from one type to another by modifying input equations:
o Example: Convert JK to D flip-flop:
[Link] of Flip-Flops
The triggering of a flip-flop refers to the condition under which the flip-flop changes its state. It depends on the clock
signal and the type of flip-flop. Flip-flops are edge-triggered devices, meaning they change their output only on a
specific edge of the clock signal (rising or falling edge).
1. Types of Triggering
Positive Edge Triggered Flip-Flops change their state on the rising edge of the clock signal, i.e., when the clock signal
transitions from 0 to 1.
On this transition, the inputs to the flip-flop (such as the J, K, D, S, R values) are evaluated, and the output changes
according to the flip-flop's type and its input conditions.
Clock Signal: The flip-flop will only capture the input and change its output on the rising edge of the clock (from 0 to
1).
Characteristics:
o Only the transition from 0 to 1 (rising edge) is used to change the state.
o The flip-flop remains stable during the low (0) and high (1) levels of the clock signal.
Input D is latched on the rising edge of the clock, and Q reflects the value of D at the clock edge.
Negative Edge Triggered Flip-Flops change their state on the falling edge of the clock signal, i.e., when the clock signal
transitions from 1 to 0.
The flip-flop evaluates its inputs and changes its state on the falling edge of the clock.
Clock Signal: The flip-flop will only capture the input and change its output on the falling edge of the clock (from 1
to 0).
Characteristics:
o Only the transition from 1 to 0 (falling edge) triggers the flip-flop to change.
o The flip-flop maintains its output stable during the rising edge and when the clock is either high or low, except
at the falling edge.
The state of the JK flip-flop is updated on the falling edge of the clock, and its output changes according to the J and K
inputs.
4. Clocked vs. Unclocked Flip-Flops
While most modern flip-flops are clocked (dependent on a clock signal for triggering), there are also latches, which
are unclocked memory elements.
Clocked Flip-Flops: Flip-flops that use a clock signal (either positive or negative edge) to trigger state changes.
Unclocked Latches: Change state immediately when the input signal changes (no clock is involved).
Although most flip-flops are edge-triggered, some flip-flops may also operate as level-triggered.
Edge-Triggered Flip-Flops: These flip-flops change state on a specific edge of the clock signal (either rising or falling).
Level-Triggered Flip-Flops: These flip-flops change state as long as the clock is at a specific level (high or low).
A. SR Flip-Flop (Set-Reset)
Typically edge-triggered.
The state of the SR flip-flop changes based on the Set (S) and Reset (R) inputs when the clock signal reaches the
triggering edge.
B. D Flip-Flop
Positive Edge Triggered: The output Q follows the D input at the rising edge of the clock.
Negative Edge Triggered: The output Q follows the D input at the falling edge of the clock.
C. JK Flip-Flop
Positive Edge Triggered: The state of the JK flip-flop changes on the rising edge of the clock. The behavior
depends on the combination of J and K inputs:
o J = 1, K = 0: Set the output to 1.
o J = 0, K = 1: Reset the output to 0.
o J = 1, K = 1: Toggle the output.
Negative Edge Triggered: Similar behavior, but the state change occurs at the falling edge of the clock.
D. T Flip-Flop
Positive Edge Triggered: The output toggles on the rising edge of the clock if T = 1. If T = 0, the output holds its current
state.
Negative Edge Triggered: Similar behavior, but the toggle happens on the falling edge.
A timing diagram is a graphical representation showing how the output of a flip-flop changes in response to the clock
signal and inputs.
↑ 00
Clock D Q (Output)
↑ 11
↑ 00
↑ 11
Here, the Q output follows the D input only on the rising edge (denoted as ↑) of the clock.
Metastability occurs when the input signal changes too close to the clock edge, causing the flip-flop to enter an
uncertain state, resulting in incorrect output. This is especially problematic in asynchronous inputs to synchronous
circuits.
Mitigation: To prevent metastability, ensure that inputs are synchronized before being fed into flip-flops.
Flip-flops are edge-triggered memory elements that change their state based on the clock signal's edge (positive or
negative).
Positive edge triggering (rising edge) and negative edge triggering (falling edge) are the two main triggering
mechanisms.
Flip-flops are essential in synchronous circuits, ensuring that changes in state occur at precise intervals defined by the
clock signal.
The Moore and Mealy models are two types of Finite State Machines (FSMs) that are used to describe sequential
circuits, where the outputs depend on the current state and, in some cases, on the inputs. These two models define how
the output is generated and how state transitions occur in response to inputs.
FSMs can be classified into two types based on how they generate outputs:
1. Moore Machine
2. Mealy Machine
2. Moore Model
In a Moore machine, the outputs depend only on the current state and not directly on the inputs.
Features of Moore Machine:
Consider a Moore machine that generates an output based on detecting a pattern of two consecutive 1's in a binary
input stream.
States:
o S0: No 1’s detected.
o S1: One 1 detected.
o S2: Two consecutive 1’s detected (output = 1).
State Diagram:
scss
Copy code
S0 --(0)--> S0
S0 --(1)--> S1
S1 --(0)--> S0
S1 --(1)--> S2
S2 --(0)--> S0
S2 --(1)--> S2
S0 0 S0 0
S0 1 S1 0
S1 0 S0 0
Current State Input Next State Output
S1 1 S2 0
S2 0 S0 1
S2 1 S2 1
3. Mealy Model
In a Mealy machine, the outputs depend on both the current state and the input. This can make the Mealy machine
more efficient than the Moore machine because fewer states may be needed.
Output is associated with both the current state and the inputs.
State transitions occur based on the inputs, and outputs are generated based on the state and the input values.
The state diagram shows the states, and the output is usually labeled next to the transition arrows between states.
Mealy machines can potentially require fewer states than Moore machines to perform the same function.
Consider a Mealy machine that generates an output (1) when two consecutive 1’s are detected in the input.
States:
o S0: No 1’s detected.
o S1: One 1 detected.
o S2: Two consecutive 1’s detected (output = 1).
State Diagram:
scss
Copy code
S0 --(0/0)--> S0
S0 --(1/0)--> S1
S1 --(0/0)--> S0
S1 --(1/1)--> S2
S2 --(0/0)--> S0
S2 --(1/1)--> S2
Here, the number after the slash indicates the output associated with each transition.
State Transition Table:
Moore Machine: Often used when outputs need to be more stable and predictable, and where it’s acceptable
to have more states for the same functionality (e.g., simple sequential processes like counters and basic control
logic).
Mealy Machine: Useful when you need faster output generation because the output is determined by both the
state and the input. Mealy machines are used in situations where efficiency is important and fewer states are
desirable (e.g., pattern recognition, protocol decoders).
Moore Machines: Outputs are determined solely by the current state. They are simpler in structure but might
require more states to perform the same function as a Mealy machine.
Mealy Machines: Outputs depend on both the current state and the inputs, leading to fewer states but more
complex output generation.
Both models are widely used in digital systems for designing sequential circuits, controllers, and state
machines.
State minimization is an essential process in the design of Finite State Machines (FSMs) where the goal is to reduce
the number of states while maintaining the same functionality. Minimizing the number of states in an FSM can lead to
more efficient circuits with less hardware overhead, making the system simpler and faster.
State minimization is particularly useful for large FSMs, as it helps to make them more manageable and cost-effective.
The main method for state minimization involves identifying equivalent states—states that behave in the same way
for all inputs, transitions, and outputs.
1. Why State Minimization?
Reduced Complexity: Fewer states make the design simpler and more understandable.
Improved Efficiency: Minimizing states reduces the hardware (flip-flops, gates) required to implement the FSM.
Faster Execution: Fewer states result in fewer transitions to be evaluated.
Cost-effective: Fewer states reduce the need for extensive hardware resources, leading to lower cost in practical
implementations.
There are two primary methods used for state minimization in FSMs:
This method is based on identifying equivalent states and grouping them together. The idea is to partition the set of
states into equivalence classes such that:
All states in a class are equivalent (i.e., they behave identically for all inputs).
States in different classes are not equivalent.
1. Initial Partition:
o Split the states into two groups based on their outputs:
Group 1: States that produce the same output.
Group 2: States that produce different outputs.
2. Refinement of Partitions:
o Refine the groups by checking if the transitions of the states in each group lead to states in the same or
different groups. States that behave differently (i.e., transition to different groups for a given input) should be
placed in different groups.
3. Repeat:
o This process of refining partitions is repeated until no further refinement is possible. The final groups represent
the minimized set of states.
4. Merging States:
o Once equivalence classes are formed, each equivalence class can be merged into a single state, and a new state
diagram and state table are created.
This method involves systematically checking pairs of states to determine if they are equivalent.
1. Construct a Table:
o Create a table where the rows and columns represent all pairs of states in the FSM.
o For each pair of states, check if they produce the same output and transition to equivalent states for all inputs.
3. Iterative Refinement:
o Refine the table by iterating through the pairs of states and marking those that behave identically for all inputs.
o Continue until no further changes occur in the table.
4. Final Grouping:
o States that are not marked as non-equivalent are grouped together and merged into a single state.
Let's take a simple example of state minimization to demonstrate the partitioning method.
Assume that the state transitions and outputs for these states are as follows:
S0 S1 S2
S1 S0 S3
S2 S3 S0
S3 S2 S1
First, we group the states based on their output behavior. Since all states have the same output (0) for both inputs, they
are all in the same group.
Since states S0 and S2 transition to different states for both inputs (0 and 1), they cannot be equivalent. Similarly, S1
and S3 transition to different states for both inputs and are not equivalent.
Given the results from the refinement step, we can conclude that:
We now have two distinct states: Group 1 (S0, S2) and Group 2 (S1, S3).
After minimizing, the FSM has two states: S0' and S1'. The new transitions and outputs would be:
This reduced state diagram reflects the minimized FSM with fewer states.
Equivalent States: States are equivalent if, for each input, they transition to the same state and produce the same
output.
Partitioning: The method of splitting the FSM into equivalence classes and iteratively refining those classes until no
further refinement is possible.
State Equivalence Table: A tabular method for determining which states are equivalent by checking their output and
transitions.
State minimization is a critical technique for optimizing FSMs. By grouping equivalent states and merging them, we
can reduce the number of states required to describe the FSM, leading to simpler, more efficient designs. Both the
partitioning method and the state equivalence table method are widely used in practice, with the partitioning method
being the more common approach in digital circuit design.
In digital design, Finite State Machines (FSMs) are often implemented using logic circuits to control various
processes, such as sequential operations or state-driven systems. The goal of circuit implementation is to translate the
abstract behavior of an FSM (as defined by its states, inputs, outputs, and transitions) into a practical, hardware-based
circuit.
1. Overview of FSM Circuit Implementation
Design the FSM: Define the states, transitions, inputs, outputs, and state diagrams/tables.
Choose the type of FSM: Decide whether to use a Moore or Mealy model.
Minimize the FSM (if necessary): Use state minimization techniques to reduce the number of states.
Select appropriate components: Typically, flip-flops (for storing states) and combinational logic gates (for state
transitions and outputs) are used.
Design the state register: Implement the FSM’s states using flip-flops and logic circuits.
Implement output logic: Design the logic that generates outputs based on states (and inputs, in the case of a Mealy
machine).
FSMs use flip-flops to store the state of the machine. The type of flip-flop chosen depends on the design requirements
(e.g., synchronous or asynchronous operation). The most common flip-flops used in FSM design are:
D Flip-Flop (DFF): Stores a single bit of data (state). It's easy to use and widely used in FSM implementations.
T Flip-Flop (TFF): Toggles between states based on the clock input. This is useful when implementing state transitions.
JK Flip-Flop (JKFF): A more flexible flip-flop that can be used to toggle or reset based on inputs.
SR Flip-Flop (SRFF): Used in simple cases, though it's not as commonly used in FSM design due to its limited
functionality.
In many FSM implementations, D flip-flops are used for simplicity and reliability.
1. State Encoding:
o States in an FSM need to be represented using binary values.
o Each state is assigned a unique binary code. For example:
State 1: 00
State 2: 01
State 3: 10
State 4: 11
The state transition table shows how the FSM moves from one state to another based on inputs. It also provides the
corresponding outputs for each state or state-input combination.
For example:
00 0 01 0 0
00 1 10 0 1
Current State Input Next State Output (Moore) Output (Mealy)
01 0 00 0 0
01 1 11 1 0
10 0 11 1 1
10 1 00 0 0
11 0 01 0 1
11 1 10 1 0
The state diagram visually represents the FSM, showing states, transitions, and outputs. Each state is represented by a
circle, and transitions are indicated by arrows between the states, labeled with the input that causes the transition.
For example, the state diagram corresponding to the table above would show:
The next-state logic determines the next state based on the current state and inputs. This logic is typically
implemented using combinational logic circuits such as AND, OR, NOT, and XOR gates.
1. State Register: The current state is stored in flip-flops. For each flip-flop, the next state depends on the current
state and input.
2. Combinational Logic: Based on the state encoding, we derive the next-state logic (using Boolean
expressions). This logic drives the flip-flop inputs.
For example, consider a 2-state FSM with 2 bits of state encoding. You would:
Derive Boolean equations for each bit of the state based on the current state and input.
Implement these equations using AND, OR, and NOT gates.
Example for a 2-bit state (S1 and S0) with inputs (X):
For state transitions, use the current state and the input to derive the next state for each flip-flop (S1 and S0).
F. Implement the Output Logic
1. Output Generation:
o Moore Output Logic: In a Moore machine, the output is only a function of the current state. The output logic is
straightforward: for each state, set the output to the required value.
o Mealy Output Logic: In a Mealy machine, the output depends on both the current state and the input. The
output logic is more complex and typically involves both the current state and the input.
Example:
Moore: The output is directly linked to the current state. If in state 00, output is 0. If in state 01, output is 1.
Mealy: The output might depend on both the state and the input. For example, if in state 00 and input is 1, output
might be 1.
1. States:
o S0: 00
o S1: 01
2. Inputs:
o X: Single input.
3. Outputs:
o Y: Single output (in the case of a Moore machine, the output is only determined by the state).
4. State Transitions:
S0 0 S0 0
S0 1 S1 1
S1 0 S0 0
S1 1 S1 1
2. Next-State Logic:
o Derive the Boolean equations for the next state based on the current state and the input.
For example, the next state equation for a 2-bit state machine with input X might be:
Test for correctness: Ensure that the state transitions and outputs match the desired behavior (verify with simulation
tools like ModelSim or Vivado).
Verify timing constraints: Make sure that the FSM operates correctly within the clock cycles (for synchronous FSMs).
Simulate: Use tools like Verilog, VHDL, or Schematics to simulate and verify the FSM’s behavior.
6. Summary
Registers
Registers are fundamental components in digital systems that store data and control the flow of information. They are
essential building blocks for memory, processing units (like CPUs), and other digital circuits. Registers are
implemented using flip-flops and can store binary data, typically representing multi-bit values.
A register is a small, fast storage device used to store data temporarily in digital systems. A register typically holds a
fixed number of bits (e.g., 8 bits, 16 bits, etc.) and is made up of a collection of flip-flops, which store the individual
bits. Registers are crucial for handling intermediate data during computation or control operations in digital systems,
such as CPUs, microcontrollers, and digital signal processors.
2. Types of Registers
There are different types of registers, each serving a unique purpose. Some of the most commonly used registers are:
Purpose: These registers are used for temporary data storage during computations.
Use case: General-purpose registers are typically used in the CPU for arithmetic, logic operations, and data
manipulation. They are involved in data transfer, calculations, and storing intermediate results.
Example: In a microprocessor, registers like R0, R1, R2, etc., are used for calculations or data storage during
operations.
These registers serve specific functions within a digital system and are not typically used for general computation.
Program Counter (PC):
o Function: Keeps track of the address of the next instruction to be fetched in a processor.
o Use case: The PC points to the memory location from which the next instruction will be read.
Accumulator (ACC):
o Function: A register that stores intermediate results of operations, especially in older or simpler processors.
o Use case: It is often used in arithmetic operations, like adding or multiplying numbers.
3. Register Operations
Registers are used to perform a variety of operations within a digital circuit or processor:
A. Data Transfer
Registers are often used to transfer data between various parts of the system (e.g., between the CPU and memory).
This involves moving data from one register to another or from a register to memory.
Registers are integral to performing arithmetic and logic operations. For example:
Addition/Subtraction: A register can hold a value that is used in mathematical operations, such as adding two
numbers.
AND/OR/XOR: Registers can store the results of logical operations applied to binary data.
Shift Registers: Perform operations like shifting the bits in a register left or right (arithmetic or logical shifts). This
operation is used for multiplication or division by powers of 2 and is also used in serial communication.
Rotate Registers: Bits are shifted left or right, but the bits that "fall off" one end of the register are placed on the
opposite end. This is commonly used in cryptographic algorithms or for circular data storage.
4. Types of Register Groups
Registers are often organized into groups, depending on their function and use in a system. Some common groupings
include:
A. Shift Registers
Function: A shift register is a special type of register that allows binary data to be shifted in or out bit by bit,
usually in one direction (left or right).
Use case: They are widely used in applications like serial-to-parallel conversion, data storage, and
communication systems.
Types of Shift Registers:
o Serial-in, serial-out (SISO): Data is shifted in and out one bit at a time.
o Serial-in, parallel-out (SIPO): Data is shifted in one bit at a time and made available in parallel at the output.
o Parallel-in, serial-out (PISO): Data is loaded in parallel and shifted out one bit at a time.
o Parallel-in, parallel-out (PIPO): Data is loaded and retrieved in parallel.
B. Buffer Registers
Function: A buffer register temporarily holds data while it is being transferred between two systems, such as between a
processor and memory or between a processor and I/O devices.
Use case: Buffer registers help ensure smooth data transfer, particularly in systems with different data rates (e.g., fast
processor vs. slower I/O).
C. Control Registers
Function: These registers are used to control specific functions of a device or system.
Use case: Control registers can control the configuration of the CPU, timing of operations, and access to specific
resources.
Registers are usually implemented with flip-flops and gates. Here’s how registers are designed in digital circuits:
A. Using Flip-Flops
Flip-flops are the basic building blocks of registers. Each flip-flop can store one bit, and multiple flip-flops are
connected together to form multi-bit registers.
D Flip-Flop: Commonly used in register design because of its simplicity and ability to store data on a clock
edge.
B. Clocked Registers
Registers are typically clocked to ensure that they store and update their data synchronously. A clock signal
ensures that data is updated only at specific intervals (usually on the rising or falling edge of the clock pulse).
The behavior of the register is defined by the clock. On each clock cycle, data is either loaded into the register
(from input or memory), or the register holds its value (depending on the design).
C. Register Width
The width of a register refers to the number of bits it can store. A register could be 8 bits, 16 bits, 32 bits, or even
wider. The width determines how much data can be stored in the register at a given time.
6. Register Transfer in the Datapath
In microprocessors, registers are part of the datapath, which is the collection of components that process and transfer
data. The transfer of data between registers happens via multiplexers and buses. Registers control the flow of data
and ensure that the correct values are used during operations.
7. Applications of Registers
CPU: Registers store intermediate results and hold data during processing tasks.
Memory Management: Registers like the MAR (Memory Address Register) and MBR (Memory Buffer Register) help in
managing memory accesses.
Digital Signal Processing (DSP): Registers are used to store coefficients, intermediate results, and control information in
DSP operations.
Communication Systems: Registers store and shift data for serial communication and data buffering.
Registers are vital components in digital circuits, playing an essential role in storing, transferring, and processing data.
They are used in everything from CPUs to communication systems, enabling efficient data manipulation and control
in digital systems. The design and use of registers require careful consideration of the data width, timing control, and
specific functions required by the application.
Counters
A counter is a type of digital circuit used to count the number of occurrences of an event, such as clock pulses, or to
generate specific sequences. Counters are widely used in digital systems for various purposes, including timing,
sequencing, and frequency division.
Counters are built using flip-flops and can count in different ways, such as incrementing or decrementing, and in
various sequences. They are essential components in microprocessors, timers, digital clocks, and other devices where
counting or sequence generation is required.
1. Definition of Counters
A counter is a sequential circuit that has a series of states, with each state representing a specific count. Counters
typically consist of a collection of flip-flops that track the count, and they can be triggered by external signals (such as
clock pulses). The main function of a counter is to store and change its state (count) in a predictable manner based on
these inputs.
Types of Counters:
o Up Counter: Increments the count with each clock pulse.
o Down Counter: Decrements the count with each clock pulse.
o Up/Down Counter: Can either increment or decrement based on the control signal.
o Ring Counter: A special type of counter with a repeating pattern.
o Johnson Counter: A counter where the state is formed by rotating bits in a special pattern.
2. Types of Counters
Counters can be categorized based on several factors, including their counting direction, timing control, and design
structure. Here are the most common types of counters:
A. Synchronous Counters
Definition: In synchronous counters, all flip-flops are driven by the same clock signal. This ensures that each
flip-flop in the counter changes its state simultaneously.
Advantages:
o Faster operation since all flip-flops are synchronized.
o Less chance of errors due to timing mismatches between flip-flops.
Disadvantages:
o Requires more complex wiring and design to synchronize all flip-flops.
Definition: In asynchronous counters, the clock signal is connected only to the first flip-flop. The subsequent
flip-flops are triggered by the output of the preceding flip-flop, creating a "ripple" effect.
Advantages:
o Simple design and fewer components.
o Easier to implement for small counters.
Disadvantages:
o Slower operation due to the ripple effect, as each flip-flop changes state one after another.
o More prone to timing errors due to propagation delays.
C. Up Counters
Definition: These counters increment their count with each clock pulse. The counter increases by one for every
pulse it receives.
Use case: Commonly used in systems that need to track the number of clock cycles or events.
Example: A 3-bit up-counter counts from 000 (0) to 111 (7).
D. Down Counters
Definition: These counters decrement their count with each clock pulse. The counter decreases by one for
every pulse it receives.
Use case: Used in systems where countdowns are required (e.g., timers, countdown clocks).
Example: A 3-bit down-counter counts from 111 (7) to 000 (0).
E. Up/Down Counters
Definition: These counters can either increment or decrement depending on the direction control input.
Use case: Used in systems where bidirectional counting is needed (e.g., in certain microprocessor operations).
Example: A 4-bit up/down counter, which counts up when a control signal is high and counts down when the
control signal is low.
F. Ring Counters
Definition: A ring counter consists of a series of flip-flops connected in a loop. Only one flip-flop holds a
logic high at any given time, and it circulates through all the flip-flops in sequence.
Use case: Used in applications like sequencing or rotating patterns.
Example: A 4-bit ring counter with the states 0001, 0010, 0100, and 1000.
G. Johnson Counters
Definition: A Johnson counter is similar to a ring counter but with a twist. It generates a sequence by shifting
the bits through the flip-flops in a specific way, with feedback from the last flip-flop to the first.
Use case: Useful in generating specific sequences of states and can be used for generating complex timing
signals.
Example: A 4-bit Johnson counter will generate the sequence 0000, 1000, 1100, 1110, 1111, 0111, 0011, and
0001.
3. Counter Design
Each type of counter can be described by its state transition diagram or truth table, showing how the counter moves
from one state to another based on the clock signal and other inputs (like up/down control for an up/down counter).
State Diagram: A graphical representation of the counter's states and the transitions between them based on input
conditions.
Truth Table: A table that shows the current state, input conditions (e.g., clock pulse, up/down control), and next state.
B. Flip-Flop Selection
Counters are typically implemented using flip-flops to store each bit of the counter. The most common types of flip-
flops used in counter design are:
T Flip-Flop (TFF): A toggle flip-flop that changes state with every clock pulse.
JK Flip-Flop (JKFF): A versatile flip-flop that can be configured to toggle, reset, or set based on its inputs.
D Flip-Flop (DFF): A flip-flop where the output is directly controlled by the input.
Synchronous Counters: Typically use JK or T flip-flops because of their simplicity in controlling the state
transitions.
Asynchronous Counters: Can use any type of flip-flop, but T flip-flops are commonly used for their
simplicity in toggling between states.
C. Counting Modulus
The modulus of a counter refers to the number of unique states it can cycle through before it returns to its initial state.
For example:
You can create counters with a smaller modulus by using decoding techniques. For example, an 8-bit counter can be
made to count from 0 to 5 by using logic that resets the counter when it reaches 6.
D. Counter Applications
1. Timers: Counters are used in digital clocks and timers, counting down or up to set time intervals.
2. Frequency Division: Counters can divide the frequency of a clock signal, generating slower clock pulses.
3. Event Counting: Used in applications like pulse counting, measuring the number of events or objects passing a sensor.
4. Sequencing: Counters are used in control systems that require specific sequences of operations.
5. Digital Clocks: In digital clocks, counters count seconds, minutes, and hours.
6. Memory Address Generation: Counters generate memory addresses in sequential memory access systems.
State Diagram: The counter should count from 0000 to 1111 (0 to 15) and then reset to 0000.
Truth Table:
0000 0001 1 0 0 0
0001 0010 1 1 0 0
0010 0011 1 1 1 0
0011 0100 1 1 1 1
0100 0101 1 0 0 0
Logic Design:
o Use T flip-flops for each bit of the counter (T1, T2, T3, T4).
o Design the T inputs using the current state of the flip-flops and logic gates to generate the correct toggling
behavior.
Counters are crucial components in digital systems, with applications ranging from simple timing tasks to complex
sequencing and event counting. They can be implemented using various flip-flops, and they can either be synchronous
or asynchronous depending on the design requirements. By understanding the operation of counters, their state
diagrams, and the flip-flop types used, designers can effectively incorporate counters into systems to perform a wide
range of tasks.
UNIT III COMPUTER FUNDAMENTALS
A digital computer is a machine that performs various operations based on binary data (0s and 1s) and follows a set
of instructions programmed into it. The functional units of a digital computer are the components that work together
to perform tasks such as computation, data storage, control, and communication. These units are typically integrated
into a single system and work in harmony to execute the tasks required by software applications.
Each of these units performs specific roles in the operation of a computer. Let’s look at each in detail.
The CPU is the heart of the computer system and is responsible for executing instructions that make up a program. It
coordinates and controls the operations of the other units.
Control Unit (CU): The control unit orchestrates the execution of instructions. It decodes and directs the flow
of data between different parts of the system, including memory, the ALU, and I/O devices.
Arithmetic and Logic Unit (ALU): This unit performs all arithmetic and logical operations such as addition,
subtraction, multiplication, division, and bitwise operations (AND, OR, NOT, XOR).
Registers: These are small, high-speed storage units inside the CPU used to store intermediate data,
instructions, and memory addresses during processing. Examples include the Program Counter (PC),
Instruction Register (IR), and Accumulator (ACC).
Clock: The clock controls the timing of all operations in the CPU, ensuring that operations happen in sync
with each other.
Instruction Fetching: The CPU fetches instructions from memory, interprets them, and executes them.
Data Processing: The ALU processes data based on the instruction set.
Control and Coordination: The CU directs data and instructions to the appropriate units and ensures that operations
occur in the right sequence.
2. Memory Unit
The Memory Unit is responsible for storing data and instructions that are being processed by the CPU. It is a crucial
component that enables the computer to retrieve and store information efficiently.
Types of Memory:
Primary Memory (Main Memory): This includes RAM (Random Access Memory) and ROM (Read-Only
Memory).
o RAM: Volatile memory that temporarily stores data and instructions that the CPU is currently using. When the
computer is powered off, the data in RAM is lost.
o ROM: Non-volatile memory that stores firmware or essential boot instructions that are not lost when the
computer is powered off.
Secondary Memory (Storage): Includes devices like Hard Disk Drives (HDD), Solid-State Drives (SSD),
Optical Discs (CD/DVD), and Flash Memory. These store data permanently and are slower than primary
memory but provide large capacity.
Cache Memory: A small, high-speed memory located between the CPU and main memory. It stores
frequently accessed data to speed up data retrieval, thus improving performance.
Functions of Memory:
The Input Unit is responsible for accepting data and instructions from external sources and converting them into a
format that the computer can understand and process. This unit allows users and other systems to communicate with
the computer.
4. Output Unit
The Output Unit is responsible for delivering the results of the computer’s processing to the user or to another
system. It takes the processed data from the CPU and converts it into a human-readable or machine-readable format.
Data Conversion: Converts digital data from the CPU into a format suitable for display or physical output (e.g.,
converting digital signals to analog sound for speakers).
Data Presentation: Presents processed data to the user in an understandable form.
Data Transmission: Sends processed data to external devices, like printers or display monitors.
The Control Unit is responsible for directing the operation of the processor and the flow of data between the other
functional units. It acts as the brain of the computer, interpreting the instructions and coordinating the operations of
the CPU.
Instruction Decoding: The CU decodes instructions from memory to determine which operation needs to be
performed.
Control Signals: It generates control signals that manage the operations of other units, such as the ALU, memory, and
I/O devices.
Sequencing: The CU ensures that instructions are executed in the correct sequence and that data flows properly
between the CPU and memory.
Synchronization: It synchronizes the timing of all operations within the computer, ensuring that the system operates
smoothly.
The ALU performs all the mathematical and logical operations in a computer. It is a critical part of the CPU,
executing arithmetic operations like addition, subtraction, multiplication, and division, as well as logical operations
like AND, OR, NOT, and comparisons.
Arithmetic Operations: Performs basic arithmetic operations on binary data (addition, subtraction, etc.).
Logical Operations: Performs operations such as AND, OR, XOR, and NOT.
Comparison: Compares values and generates outputs for equality, greater than, or less than conditions.
Shifting: Executes bitwise shifts (left or right) for data manipulation.
In a computer system, various functional units interact with each other to execute instructions and process data. The
most common ways these units communicate are:
Buses: A bus is a set of physical lines that allow data to travel between various components. The data bus,
address bus, and control bus are the primary buses used to transfer data, addresses, and control signals,
respectively.
o Data Bus: Transfers data between the CPU, memory, and I/O devices.
o Address Bus: Carries the memory addresses to or from which data needs to be fetched or written.
o Control Bus: Carries control signals that manage the operations of the CPU and other units.
Clock: The clock synchronizes operations between different units, ensuring that tasks like instruction fetching,
data processing, and I/O operations occur in a coordinated manner.
The functional units of a digital computer work together to process data and execute instructions efficiently. The CPU
performs computations, the memory unit stores data, the input/output units handle data exchange with external
devices, and the control unit coordinates the operations of the entire system. Together, these units enable the
computer to perform a wide range of tasks, from simple calculations to complex, multi-step processes required for
modern applications. Understanding these units is essential for designing and optimizing digital systems.
The Von Neumann Architecture is a computer architecture model that describes a design for a digital computer. It is
based on a stored-program concept, where both data and instructions are stored in memory and can be accessed and
manipulated in the same way. This architecture was proposed by John von Neumann in 1945 and is the foundation
for most modern computers today.
The Von Neumann architecture consists of several functional components, each with a specific role in the computer
system. These components work together to execute programs and perform computations:
Each of these components is essential for the functioning of a computer based on the Von Neumann architecture.
The CPU is the core component of the Von Neumann architecture and is responsible for executing instructions. The
CPU typically consists of two main units:
The ALU performs all the mathematical and logical operations such as addition, subtraction, multiplication, division,
and logical operations (AND, OR, NOT).
The Control Unit orchestrates the execution of instructions by coordinating the activities of the CPU and other
components.
It fetches instructions from memory, decodes them, and directs the ALU and other units to carry out the necessary
operations.
The CU also generates control signals that dictate the timing of operations in the system.
2. Memory Unit
The Memory Unit is a crucial component of the Von Neumann architecture, as it stores both data and instructions.
In the Von Neumann model, both data and instructions are stored in the same memory. This shared memory is called
the stored-program concept, where the computer program is stored alongside data and can be fetched into the CPU
to be executed.
The Input Unit and Output Unit allow the computer to interact with the outside world. These units enable data to be
received from external devices (input) and results to be sent back (output).
Input Unit: Devices like keyboards, mice, scanners, or sensors are used to input data into the system.
Output Unit: Devices like monitors, printers, and speakers are used to display or communicate the results of
computations.
Both input and output devices are connected to the system through I/O channels. The CPU sends data to the I/O
devices via the control unit, and input devices send data to the CPU.
4. System Bus
A bus is a set of physical connections (electrical pathways) that allow different components of the computer system to
communicate with each other. The Von Neumann architecture typically employs three types of buses:
Data Bus: Carries data between the CPU, memory, and I/O devices.
Address Bus: Carries memory addresses from the CPU to the memory unit to specify where data should be fetched or
stored.
Control Bus: Carries control signals from the control unit to other components to manage and coordinate the
operations of the system (e.g., read/write signals, clock synchronization).
The system bus connects the various components, allowing them to exchange data and instructions.
2. Sequential Execution:
o Instructions are fetched and executed one by one in sequence. The CPU follows the instructions stored in
memory, processing them in order unless explicitly instructed to jump to a different instruction (e.g., via branch
instructions).
3. Fetch-Execute Cycle:
o The CPU continuously performs the fetch-decode-execute cycle, fetching an instruction, decoding it to
understand the operation, and executing it before moving on to the next instruction.
4. Stored-Program Concept:
o Programs are stored in memory, making the system flexible and programmable. This allows new programs to
be loaded and executed without changing the hardware.
One of the limitations of the Von Neumann architecture is the Von Neumann Bottleneck. This term refers to the
limitation in data transfer speeds between the CPU and memory.
1. Instruction Fetch: The CPU fetches an instruction from memory, for example, an instruction to add two
numbers stored in memory locations M1 and M2.
2. Instruction Decode: The control unit decodes the instruction to understand that it is an addition operation.
3. Data Fetch: The control unit sends the addresses M1 and M2 to the memory unit via the address bus, and the
data is fetched from these memory locations.
4. Execution: The ALU adds the two numbers retrieved from memory.
5. Store Result: The result of the addition is stored back into memory or into a register.
1. Simplicity: The architecture is straightforward and easy to implement, as it uses a single memory for both data
and instructions.
2. Flexibility: The stored-program concept allows new programs to be easily loaded into memory, providing
flexibility in program execution.
3. Cost-Effective: Because the same memory is used for both instructions and data, there is no need for separate
memory units, making the system more cost-effective.
Disadvantages of Von Neumann Architecture
1. Von Neumann Bottleneck: The shared memory and bus system create a bottleneck in data transfer, which can
limit the speed and efficiency of the computer.
2. Sequential Execution: The architecture processes instructions one at a time, which can limit performance for
certain types of applications, especially those that could benefit from parallel processing.
The Von Neumann Architecture laid the foundation for modern computing and is still the basis of most general-
purpose computers today. It provides a simple, flexible, and cost-effective way to store and process data and
instructions, making it suitable for a wide range of applications. However, its performance is constrained by the Von
Neumann bottleneck, which has led to innovations in computer architecture such as the use of caches, parallelism,
and Harvard architecture. Despite these limitations, the Von Neumann model remains a key part of the computer
design landscape.
In the context of computer hardware and assembly language programming, instructions are the fundamental
operations that a computer performs to execute a program. These instructions are encoded as machine code that the
central processing unit (CPU) interprets and executes. Every instruction in a computer system generally involves a
combination of operation and operand(s).
Operation (Opcode): Defines what action the instruction performs, such as adding two numbers, moving data, or
jumping to another instruction.
Operands: Specify the data or locations upon which the operation is performed.
2. Operation (Opcode)
The operation (often referred to as the opcode, short for "operation code") is the part of the instruction that specifies
the action to be carried out by the CPU. It defines what kind of operation is being requested and tells the CPU how to
manipulate the data.
Arithmetic Operations:
o ADD: Adds two numbers.
o SUB: Subtracts one number from another.
o MUL: Multiplies two numbers.
o DIV: Divides one number by another.
Logical Operations:
o AND: Performs a logical AND between two operands.
o OR: Performs a logical OR between two operands.
o NOT: Inverts the bits of an operand (bitwise negation).
o XOR: Performs a logical XOR (exclusive OR) between two operands.
Data Movement:
o MOV: Moves data from one location to another.
o LOAD: Loads data from memory into a register.
o STORE: Stores data from a register into memory.
Control Operations:
o JMP: Jumps to a specified address, altering the program's control flow.
o CALL: Calls a subroutine (procedure or function).
o RET: Returns from a subroutine.
o NOP: No operation (used for delays or timing).
Shift Operations:
o SHL: Shift bits left (multiply by powers of 2).
o SHR: Shift bits right (divide by powers of 2).
Input/Output Operations:
o IN: Reads data from an input device (such as a keyboard or I/O port).
o OUT: Sends data to an output device (such as a display or printer).
3. Operands
Operands are the data or references to data that the operation will act upon. These operands can take various forms
and serve different purposes in an instruction. The operands specify the source(s) of data and the destination for the
result of the operation.
Types of Operands:
1. Immediate Operand:
o The operand is a constant value or literal directly embedded within the instruction.
o Example: ADD 5 means "add the value 5 to the contents of a register or memory location".
2. Register Operand:
o The operand refers to a CPU register that holds the data to be used in the operation.
o Example: ADD R1, R2 means "add the contents of register R2 to the contents of register R1".
3. Memory Operand:
o The operand refers to a memory address where the data is stored. This could be a specific location in RAM.
o Example: MOV R1, [1000] means "move the data stored at memory location 1000 into register R1".
4. Indirect Operand:
o The operand refers to a memory location whose address is stored in a register or memory. This type of operand
allows for more dynamic addressing.
o Example: MOV R1, [R2] means "move the data at the memory location stored in register R2 into register R1".
5. Indexed Operand:
o The operand refers to a memory location that is determined by adding an offset to a base address stored in a
register.
o Example: MOV R1, [R2+5] means "move the data from the memory location at address R2 plus 5 into
register R1".
6. Base-Register Operand:
o Similar to indexed operands, but the base address is stored in a register, and an offset is added to it to form the
final memory address.
o Example: MOV R1, [R2 + OFFSET].
7. Displacement Operand:
o An operand that combines immediate data (a displacement value) and a register value to determine a memory
address.
o Example: MOV R1, [R2 + 100] (displacement of 100 added to the address stored in R2).
4. Addressing Modes
The addressing mode is the method used to access operands in memory or in registers. It defines how the operand is
specified within an instruction. Some common addressing modes are:
Immediate Addressing: The operand is a constant value directly given in the instruction.
Register Addressing: The operand is stored in a register.
Direct Addressing: The instruction directly specifies the memory address of the operand.
Indirect Addressing: The operand’s address is specified indirectly via a register or memory.
Indexed Addressing: The operand’s address is determined by adding a constant value (index) to the value in a register.
Base-Register Addressing: A base address is stored in a register, and an offset is added to it to get the operand’s
address.
Relative Addressing: The operand’s address is determined by adding an offset to the current instruction pointer (useful
for branch instructions).
A machine instruction can typically be broken down into several fields, including:
Opcode Field: Contains the operation code (opcode) that specifies the operation to be performed.
Operand Fields: Contain the operands required by the operation, which can be a register, memory location, or
immediate value.
Addressing Mode Field: Specifies which addressing mode is used to determine the operands.
Control Bits: Additional fields may be used to specify conditions like condition flags (zero, carry, etc.) or interrupt
controls.
An example instruction format for an ADD operation could look like this:
mathematica
Copy code
| Opcode | Operand 1 | Operand 2 | Addressing Mode |
| ADD | R1 | R2 | Direct |
The execution cycle refers to the steps the CPU follows to execute an instruction. The basic steps are:
1. Fetch: The CPU fetches the instruction from memory (using the Program Counter to locate the instruction).
2. Decode: The instruction is decoded by the Control Unit to determine the operation and the operands.
3. Execute: The operation is carried out by the Arithmetic and Logic Unit (ALU) or another part of the CPU, based on the
decoded instruction.
4. Store: The result of the operation is stored in a register or memory, depending on the type of operation.
7. Example: Arithmetic Operation Instruction
Consider the instruction ADD R1, R2, R3. This instruction might be decoded as follows:
In summary, the operation (opcode) defines the type of action the CPU should perform, while the operands specify
the data or memory locations that the operation will act on. A well-designed instruction set architecture (ISA) allows
for efficient execution of programs by providing a variety of operations and addressing modes. The operands can be
constants, registers, or memory locations, and the addressing mode determines how the operands are located and
accessed. By understanding how operations and operands work together, computer architects can design systems that
are both efficient and powerful.
The Instruction Set Architecture (ISA) is the interface between software and hardware. It defines the set of
instructions that a processor can execute and how they interact with memory and other hardware components.
Understanding the concepts of memory location, address, and operation is essential to understanding how a
processor executes instructions and accesses data.
The ISA is a critical aspect of computer architecture, specifying how the processor interprets and executes machine-
level instructions. An ISA provides the following key details:
In the context of an ISA, memory location refers to a specific location in memory where data is stored. Address is
the identifier of that location. To effectively understand how a processor interacts with memory, it is important to
distinguish between memory location and address.
Memory Location:
Address:
Physical Address: The actual address in the physical memory (RAM or ROM).
Logical Address: An address used by the program during execution, which may be translated to a physical address by
the Memory Management Unit (MMU).
Example: If a program is working with data stored in memory, it might refer to a specific memory location, such as
memory address 0x00000100, which is the address of a particular variable.
3. Operations (Opcodes)
An operation (or opcode, short for "operation code") is a binary code that specifies which operation the CPU should
perform. The operation defines the action to be taken by the CPU on the given operands, whether they are stored in
registers or memory.
The ISA specifies which operations are available, and how the processor should execute them. Operations can be
grouped into various categories based on their function:
1. Arithmetic Operations:
o ADD: Adds two values.
o SUB: Subtracts one value from another.
o MUL: Multiplies two values.
o DIV: Divides one value by another.
2. Logical Operations:
o AND: Performs a bitwise AND between two operands.
o OR: Performs a bitwise OR.
o XOR: Performs a bitwise exclusive OR.
o NOT: Inverts the bits of an operand.
5. Comparison Operations:
o CMP: Compares two values (sets flags based on the result).
o TEST: Performs a bitwise AND to set flags, but does not store the result.
7. Input/Output Operations:
o IN: Inputs data from an external device (e.g., keyboard, I/O port).
o OUT: Outputs data to an external device (e.g., display, I/O port).
8. Miscellaneous Operations:
o NOP: No operation (used for delays or synchronization).
o HALT: Stops the execution of the program.
4. Instruction Format
An instruction format specifies the layout of the bits in an instruction and determines how the operation and
operands are encoded. The general structure of an instruction includes the following fields:
1. Opcode Field: Contains the binary representation of the operation (opcode) to be executed by the processor.
2. Operand Fields: Contain the operands (e.g., registers, memory addresses, or immediate values) that the operation will
act upon.
3. Addressing Mode Field: Specifies the addressing mode used to access the operands (e.g., direct, indirect, immediate).
4. Control or Flag Fields: Some instructions may include additional fields for control signals or status flags (e.g., condition
flags like Zero, Carry).
In this case:
5. Addressing Modes
Addressing mode refers to the method used to specify the location of an operand in memory or in a register. The
choice of addressing mode is an important feature of the ISA, as it defines how the CPU accesses data.
1. Immediate Addressing:
o The operand is a constant value directly embedded in the instruction itself.
o Example: MOV R1, #5 (Move the constant value 5 into register R1).
2. Register Addressing:
o The operand is stored in a register.
o Example: ADD R1, R2 (Add the contents of R2 to R1).
3. Direct Addressing:
o The operand is located at a specific memory address.
o Example: MOV R1, [1000] (Move the value from memory location 1000 to register R1).
4. Indirect Addressing:
o The operand is located at a memory address pointed to by a register or another memory location.
o Example: MOV R1, [R2] (Move the value from the memory address stored in register R2 into R1).
5. Indexed Addressing:
o The effective address is obtained by adding an index value (offset) to a base address stored in a register.
o Example: MOV R1, [R2 + 5] (Move the value from the memory location at address R2 + 5 into R1).
6. Base-Register Addressing:
o Similar to indexed addressing, but the address is determined by adding a displacement value to a register
holding the base address.
o Example: MOV R1, [R2 + OFFSET].
7. Relative Addressing:
o The operand’s address is calculated by adding an offset to the current value of the program counter (PC). This is
often used in branch instructions.
o Example: JMP [PC + 10] (Jump to an address 10 locations ahead of the current program counter).
The Instruction Set Architecture (ISA) is a crucial part of computer architecture that defines the machine-level
instructions the CPU can execute. The operation (opcode) specifies the action to be performed, while the operand(s)
provide the data or address locations that the operation will act upon. Memory location and address are vital
concepts, as the address specifies where the data resides in memory and allows for the retrieval or manipulation of
data. By understanding these fundamental components, computer architects can design efficient systems, and
programmers can write effective code that interacts directly with hardware.
In computer architecture and assembly programming, the concept of instructions and instruction sequencing is
fundamental to the way a computer executes programs. Instructions are the fundamental operations that a processor
can execute, while instruction sequencing refers to the order in which these instructions are executed.
1. Instructions: Overview
An instruction is a binary-encoded command that tells the computer’s Central Processing Unit (CPU) what
operation to perform. Each instruction is part of a program, which is a set of instructions that together define a task or
series of tasks for the processor to execute.
Components of an Instruction
Opcode (Operation Code): Specifies the operation to be performed (e.g., addition, subtraction, data movement).
Operands: Provide the data or references to data for the operation. This could include:
o Registers: CPU registers holding values.
o Memory addresses: Locations in the computer’s memory.
o Immediate values: Constants directly specified in the instruction.
For example, the instruction MOV R1, R2 means "Move the value from register R2 into register R1".
2. Types of Instructions
Instructions can be classified into different categories based on the operations they perform:
1. Data Movement Instructions: These instructions move data between registers, memory, and I/O devices.
o Example: MOV R1, R2 (Move the value from register R2 to register R1).
3. Logical Instructions: These perform bitwise logical operations (AND, OR, NOT, XOR).
o Example: AND R1, R2, R3 (Perform bitwise AND on the values in R2 and R3, and store the result in R1).
5. Comparison Instructions: These compare two values and set condition flags.
o Example: CMP R1, R2 (Compare the values in R1 and R2, and set flags based on the result).
6. Input/Output Instructions: These perform operations for reading or writing data from external devices.
o Example: IN R1 (Read input into register R1).
7. Shift and Rotate Instructions: These manipulate the bits of a value by shifting or rotating them.
o Example: SHL R1 (Shift the bits in register R1 to the left).
Instruction sequencing refers to the order in which the instructions of a program are executed by the CPU. The CPU
executes instructions sequentially, unless altered by control flow instructions like jumps, branches, or loops.
The Program Counter (PC) is a special register in the CPU that holds the address of the next instruction to be
executed. After an instruction is fetched and executed, the PC is updated to point to the address of the subsequent
instruction in memory.
Normal Sequence: In a typical program, the PC increments sequentially after each instruction, so the next instruction is
always at the next memory address.
Altered Sequence: The flow of instruction sequencing can be altered by control flow instructions, which change the
value of the PC to a different memory address.
Control flow instructions are used to alter the natural sequential execution of instructions. These instructions enable
branching, looping, and subroutine calls, which change the instruction sequence.
Types of Control Flow Instructions:
2. Conditional Branching:
o These instructions cause a jump based on the outcome of a comparison or test (condition flags).
o Example: JZ LABEL (Jump to LABEL if the Zero flag is set, indicating the result of a previous operation was
zero).
3. Subroutine Calls:
o A subroutine call saves the current execution context and jumps to a subroutine (a separate block of code).
o Example: CALL SUBROUTINE (Call the subroutine located at the address SUBROUTINE).
4. Subroutine Return:
o The return instruction restores the program’s state and continues execution from the point after the
subroutine call.
o Example: RET (Return from the current subroutine).
5. Looping:
o Loops are created by combining conditional branches with labels to repeatedly execute a block of instructions.
o Example:
sql
Copy code
LOOP:
ADD R1, R2, R3
DEC R3
JNZ LOOP
6. In this example, the loop executes the ADD instruction and then decrements R3 until R3 becomes zero, at which
point it exits the loop.
The instruction cycle refers to the process through which the CPU fetches, decodes, and executes each instruction.
The cycle is also known as the fetch-decode-execute cycle.
1. Fetch: The CPU fetches the next instruction from memory, using the address stored in the Program Counter
(PC). The instruction is loaded into the Instruction Register (IR).
2. Decode: The Control Unit (CU) decodes the fetched instruction, determining the operation (opcode) and the
required operands. It also identifies the addressing mode.
3. Execute: The instruction is executed by the CPU:
o If it is an arithmetic or logical instruction, the Arithmetic Logic Unit (ALU) performs the required operation.
o If it is a memory operation, data is moved between memory and registers.
o If it is a control instruction, the Program Counter (PC) is updated accordingly.
4. Store: If the instruction involves a result that needs to be saved, the result is stored in a register or memory.
6. Example of Instruction Sequencing
sql
Copy code
MOV R1, 5 ; Load 5 into register R1
MOV R2, 10 ; Load 10 into register R2
ADD R3, R1, R2 ; Add the values in R1 and R2, store the result in R3
JMP END ; Jump to the end of the program
NOP ; No operation (this will be skipped)
END: NOP ; End of the program
Instruction Fetching: The PC starts by fetching the instruction at memory address 0x0000, which is MOV R1, 5.
Execution Sequence:
o MOV R1, 5 is decoded, and the value 5 is moved into register R1.
o The next instruction MOV R2, 10 is executed, loading 10 into register R2.
o Then, the ADD R3, R1, R2 instruction is executed, adding the values in R1 and R2, resulting in 15, which is
stored in R3.
o The JMP END instruction then causes the program to jump to the instruction labeled END, skipping the NOP
instruction.
The program ends with the NOP at the END label.
The Program Counter (PC) is updated throughout this process, initially pointing to the address of the first instruction
and later jumping to the END label.
Instruction sequencing determines the flow of program execution, where the Program Counter (PC) plays a crucial
role in keeping track of the current instruction. While instructions are executed sequentially by default, control flow
instructions like jumps and subroutine calls can alter the natural sequence, allowing for loops, conditionals, and
function calls. Understanding the instruction cycle, how instructions are fetched, decoded, and executed, and how
instruction sequencing works is critical for both hardware designers and software developers.
Addressing Modes
In computer architecture, addressing modes define the methods used by the processor to access operands (data) for an
instruction. The operand could be a value stored in a register, in memory, or even an immediate value specified
directly within the instruction. The addressing mode specifies how the operand is located and fetched from memory or
registers.
Each Instruction Set Architecture (ISA) supports a set of addressing modes, which determine how the CPU
identifies the location of the operand to perform the operation.
Definition: In immediate addressing mode, the operand is directly specified in the instruction. Instead of referring to a
memory location, the value itself is provided as part of the instruction.
Example: MOV R1, #5
This instruction moves the immediate value 5 into register R1.
Usage: Useful when you want to use constant values in operations.
Advantage:
Simple and efficient, as no memory lookup is needed.
Disadvantage:
Limited to small values because of the size of the instruction field that stores the constant.
Definition: In register addressing mode, the operand is located in a register rather than in memory. The instruction
specifies which register holds the operand.
Example: ADD R1, R2
This instruction adds the value in register R2 to the value in register R1.
Usage: Common for operations that involve fast, temporary data stored in CPU registers.
Advantage:
Disadvantage:
Definition: In direct addressing mode, the address of the operand is explicitly specified in the instruction.
Example: MOV R1, [1000]
This instruction moves the data stored at memory address 1000 into register R1.
Usage: Used when you know the exact memory address of the operand at compile time.
Advantage:
Disadvantage:
Less flexible if the operand's memory location changes during program execution.
Definition: In indirect addressing mode, the instruction specifies a memory location that holds the actual address of the
operand. This allows for more flexible memory access.
Example: MOV R1, [R2]
This instruction means that the operand is stored at the memory address held in register R2, and that value is moved
into R1.
Usage: Used for more dynamic memory access, where the address is not known at compile time.
Advantage:
Disadvantage:
Slower access because the processor has to read the address from memory before accessing the operand.
1.5. Indexed Addressing Mode
Definition: In indexed addressing mode, the effective address of the operand is determined by adding a constant value
(an index) to the value stored in a register. This is often used for accessing array elements.
Example: MOV R1, [R2 + 5]
This instruction moves the data from the memory address computed by adding 5 to the value in register R2 into R1.
Usage: Typically used when accessing elements in arrays or tables where the index is stored in a register.
Advantage:
Disadvantage:
The operand's address is not directly specified, requiring an additional calculation (indexing).
Definition: In base-register addressing mode, the effective address is determined by adding a constant displacement
(or offset) to the value stored in a base register.
Example: MOV R1, [R2 + OFFSET]
This instruction accesses the memory address that is the sum of the value in register R2 and the constant OFFSET, and
moves the value at that address into R1.
Usage: Often used in situations involving the use of a base register, like accessing data structures or arrays.
Advantage:
Disadvantage:
Definition: In relative addressing mode, the operand’s address is determined by adding a constant value (displacement)
to the current value of the program counter (PC). This is commonly used for branching operations.
Example: JMP [PC + 10]
This instruction causes a jump to the memory address that is 10 bytes ahead of the current instruction.
Usage: Used for implementing branches, jumps, and loops, where the target address is calculated relative to the
current instruction.
Advantage:
Ideal for control flow instructions like loops and conditional branches.
Disadvantage:
Definition: In register indirect addressing, the instruction specifies a register that holds the address of the operand in
memory. The operand is not directly in the register, but at the address stored in the register.
Example: MOV R1, (R2)
This instruction moves the value from the memory address stored in R2 into register R1.
Usage: Used for indirect access to memory where the address is provided by a register.
Advantage:
Disadvantage:
Indirect addressing typically requires an additional memory fetch, making it slower than direct addressing.
Indirect Operand's memory address is held in a register or memory location. MOV R1, [R2]
Indexed Effective address is the sum of a base address and an offset. MOV R1, [R2 + 5]
Register Indirect Operand's address is located at the address contained in a register. MOV R1, (R2)
Flexibility: Addressing modes like indirect, indexed, and base-register offer more flexibility as they allow the program to
compute operand addresses dynamically at runtime.
Speed: Register addressing modes are the fastest because they involve data stored in the CPU’s registers, avoiding
memory lookups.
Complexity: Some addressing modes, such as indirect and indexed, require extra steps to compute the effective
memory address, which can make the instruction execution slower compared to simpler modes like immediate or
register addressing.
Memory Access: Some addressing modes enable efficient memory access for large data structures like arrays or
dynamically allocated memory, while others are limited to accessing fixed memory locations.
Addressing modes are an essential part of a processor’s instruction set architecture (ISA). They define how the
operands for an instruction are accessed and located, impacting both the flexibility and performance of a system.
Different addressing modes are used depending on the type of operation, the complexity of the data being accessed,
and the underlying hardware architecture. Understanding these modes is crucial for optimizing program execution and
writing efficient code, especially in low-level programming or when working with assembly languages.
In computer architecture, the encoding of machine instructions refers to the process of translating a human-readable
assembly language instruction into a binary representation that the CPU can understand and execute. Machine
instructions are a set of binary-coded operations that the CPU interprets and performs.
Each instruction in a computer's Instruction Set Architecture (ISA) is represented in binary format, often consisting
of several fields, such as the operation code (opcode), operand addresses, and other control information. The encoding
of machine instructions depends on the design of the CPU, the instruction set, and the addressing modes supported.
2. Operands:
o These specify the data or addresses involved in the operation.
o Registers: The operand can be a register (e.g., R1, R2), where the data is stored.
o Memory addresses: The operand can point to a memory address, where data is located.
o Immediate values: Sometimes, the operand can be an immediate constant value specified directly in the
instruction.
3. Addressing Mode:
o This defines how the operand's memory address is calculated, e.g., direct, indirect, register, or indexed
addressing.
o The addressing mode is typically encoded as part of the instruction.
4. Instruction Length:
o The length of an instruction is the number of bits required to represent it. This depends on the CPU
architecture (e.g., 8-bit, 16-bit, 32-bit, or 64-bit processors).
o Common instruction lengths are 16, 32, or 64 bits.
The encoding of machine instructions can vary based on the architecture of the CPU. Some common instruction
formats are:
Definition: In a fixed-length instruction format, each instruction is the same length (e.g., 32 bits or 64 bits), regardless
of the operation or operands.
Example: Many RISC (Reduced Instruction Set Computing) processors use a fixed-length instruction format. In a 32-bit
RISC architecture, every instruction is 32 bits long.
Advantages:
Disadvantages:
Wasteful for some instructions, as operations with fewer operands or simpler formats might use the full instruction
length unnecessarily.
Definition: In variable-length instruction formats, the length of the instruction can vary depending on the complexity of
the operation and the number of operands. For example, instructions in CISC (Complex Instruction Set Computing)
processors often use variable-length encoding.
Example: The x86 architecture uses variable-length instructions. A simple instruction like MOV AL, 5 might use 2
bytes, while a more complex instruction might use more bytes.
Advantages:
Disadvantages:
More complex to decode and process because the instruction length is not fixed.
Slower instruction fetching due to the variable size.
Typical Format:
Typical Format:
Description: Both operands are in memory, and the result is stored in memory.
Example: MOV [1000], [2000]
o Opcode: MOV
o Operand 1: Memory location 1000
o Operand 2: Memory location 2000
Typical Format:
Let’s consider the encoding of a simple ADD instruction in a hypothetical processor. Suppose the instruction set
architecture is 32 bits, and the format is fixed-length. A typical ADD instruction might look like this:
Source Register 5 bits Specifies the first operand register (e.g., R1).
Destination Register 5 bits Specifies the second operand register (e.g., R2).
2. Addressing Modes:
o Encoding operands with different addressing modes (immediate, register, memory, etc.) requires additional
bits to specify how to compute the address.
3. Instruction Complexity:
o The complexity of encoding instructions increases as the number of operands or addressing modes grows. CISC
architectures tend to have more complex instructions, while RISC architectures use simpler, more uniform
instructions.
4. Compatibility:
o As processors evolve, maintaining backward compatibility with older instruction formats while incorporating
new features can be challenging.
The encoding of machine instructions is a critical aspect of processor design and architecture. It defines how human-
readable assembly instructions are converted into binary code that can be executed by the CPU. The design of
instruction formats and the choice of encoding strategies influence the performance, efficiency, and flexibility of the
processor. Different architectures (such as RISC and CISC) adopt different approaches to instruction encoding based
on their design goals, such as simplicity, speed, or functionality. Understanding how machine instructions are encoded
is crucial for low-level programming, optimization, and understanding the inner workings of a CPU.
The interaction between assembly language and high-level languages (HLL) is a crucial topic in computer science
and software engineering, as it explains how software written in high-level languages gets translated into machine
code that a CPU can execute. This interaction involves a multi-step process that includes compilers, assemblers, and
linkers to transform high-level instructions into low-level machine code (or assembly language). Understanding this
process helps in optimizing programs and understanding how software interacts with the hardware.
Assembly Language:
Definition: Assembly language is a low-level programming language that is closely related to machine code. It uses
mnemonics to represent machine-level instructions, which are specific to a particular CPU architecture.
Characteristics:
o Provides control over hardware.
o Each instruction corresponds to a machine code instruction.
o Requires knowledge of the computer's architecture and hardware.
o Less portable as it is designed for specific processors.
High-Level Language (HLL):
Definition: High-level languages, such as C, Java, Python, and JavaScript, are designed to be easier for humans to read
and write. They abstract away the complexities of the underlying hardware and operating system.
Characteristics:
o Portable across different platforms (via compilers or interpreters).
o Uses more abstract constructs like functions, classes, loops, and conditionals.
o Allows for faster development compared to assembly language.
The process of turning a program written in a high-level language into executable machine code involves multiple
stages. High-level language code is converted into assembly language or machine code by a sequence of tools like
compilers, assemblers, and linkers.
Definition: Compilation is the process of translating a high-level language program (such as C, C++, or Java)
into assembly code or intermediate representations (IR), which can then be further converted into machine
code.
1. Lexical Analysis:
The source code is broken down into tokens (keywords, operators, identifiers, etc.).
2. Syntax Analysis:
The syntax of the program is checked, and a syntax tree is created. This tree represents the logical
structure of the program.
3. Semantic Analysis:
Checks for logical errors (type mismatches, undefined variables) and ensures that the syntax tree
follows the semantic rules of the language.
4. Optimization:
The intermediate code is optimized to improve performance (e.g., eliminating redundant
computations).
5. Code Generation:
The optimized intermediate code is translated into assembly code or another low-level language that
corresponds to the machine's architecture.
Output: The compiler generates assembly language instructions specific to the target CPU.
Definition: After the source code is compiled into assembly language, an assembler is used to translate the
assembly code into machine code.
Assembler Process:
o Direct Translation: Assembly language instructions are translated directly into binary machine instructions,
which can be executed by the CPU.
o Symbol Table: The assembler uses a symbol table to manage variables, constants, and labels used in the
assembly code.
o Relocation and Address Resolution: The assembler resolves memory addresses, allowing variables to be
located in specific memory locations.
Output: The assembler produces an object file, which contains machine code (binary code) that the CPU can
execute.
Definition: After individual source files are compiled into object files, a linker is used to combine these object
files into a single executable. The linker also resolves references to external libraries or functions.
Linker Tasks:
1. Symbol Resolution:
The linker resolves symbols, ensuring that all function calls and variable references are connected to
the appropriate code or data.
2. Relocation:
The linker adjusts memory addresses so that all code and data can be placed in the correct memory
locations.
3. Combining Libraries:
If the program uses external libraries, the linker combines them with the program's object code to
create a complete executable.
Output: The linker produces a machine code executable file that can be loaded into memory and run by the
operating system.
While high-level languages and assembly are fundamentally different, they often work together in modern computing.
The following are the key ways in which they interact:
Inline Assembly:
o Some high-level languages allow developers to write assembly code directly within the high-level language
code. This is known as inline assembly.
o Example in C:
c
Copy code
int sum(int a, int b) {
int result;
__asm__ (
"add %1, %2\n\t"
"mov %0, %1"
: "=r"(result)
: "r"(a), "r"(b)
);
return result;
}
This C code uses inline assembly to add two integers a and b directly using assembly language instructions.
Compiler Backends:
o Compilers for high-level languages often generate assembly code as an intermediate representation, before
converting it to machine code. This is particularly common in RISC architectures, where the compiler generates
low-level assembly code to be further optimized and assembled into machine code.
Assembly as Performance Tuning:
o Sometimes performance-critical portions of code are manually written in assembly language to optimize
execution speed or reduce memory usage. These assembly snippets are then combined with the high-level
language code during the compilation and linking phases.
Optimization:
o High-level languages are generally designed for ease of use, but assembly language can be used to optimize
certain performance-critical operations (e.g., loops, bitwise operations).
o Compiler optimization techniques might involve generating more efficient assembly code or even allowing the
programmer to inject assembly code directly.
Portability: Assembly code is typically designed for a specific CPU architecture, making it less portable.
High-level languages are more portable, and using assembly language for optimization can break this
portability.
Complexity: Writing assembly code is more difficult and error-prone than writing in high-level languages.
High-level languages abstract away many of the complexities of machine-level programming.
Performance vs. Maintainability: While assembly can yield better performance in certain cases, it is harder
to maintain. High-level language code, on the other hand, is easier to write, maintain, and understand, but may
not be as optimized.
5. Conclusion
The interaction between assembly language and high-level languages is essential for efficient software development.
While high-level languages offer ease of use and portability, assembly language provides low-level control over
hardware and optimization opportunities. The combination of both approaches allows developers to write portable,
high-level code while ensuring performance in critical sections through assembly language. This interaction,
facilitated by compilers, assemblers, and linkers, forms the backbone of modern software systems and ensures that
software can run efficiently across various hardware architectures.
UNIT IV PROCESSOR
Instruction Execution – Building a Data Path – Designing a Control Unit – Hardwired Control,
Microprogrammed Control – Pipelining – Data Hazard – Control Hazards.
Instruction Execution in Processor
The instruction execution cycle is fundamental to the operation of a computer's central processing unit (CPU). It
refers to the sequence of steps that the CPU follows to execute an instruction retrieved from memory. The process is
critical for transforming program instructions (whether in machine or assembly language) into actions that the CPU
performs.
Instruction execution in a processor is driven by the instruction cycle, which involves fetching, decoding, and
executing instructions. This process involves several stages that are often executed in a specific sequence, frequently
referred to as the fetch-decode-execute cycle.
The instruction execution cycle (also known as the fetch-decode-execute cycle) describes the steps a CPU follows to
execute each instruction in a program. It generally consists of the following stages:
Each of these stages is executed in sequence, and the entire process is repeated for each instruction.
Description: The fetch stage involves retrieving the instruction from memory. The instruction is located using the
program counter (PC), which keeps track of the address of the next instruction to be executed.
Steps in the Fetch Stage:
1. The program counter (PC) contains the address of the next instruction to be executed.
2. The CPU sends the address in the PC to memory.
3. Memory returns the instruction stored at that address.
4. The fetched instruction is loaded into the Instruction Register (IR).
5. The PC is incremented to point to the next instruction.
Description: During the decode stage, the CPU decodes the fetched instruction to determine what action needs to be
performed. This stage typically involves the control unit (CU) and may also involve decoding of operands for the
instruction.
Steps in the Decode Stage:
1. The instruction in the Instruction Register (IR) is examined.
2. The opcode (operation code) is identified from the instruction. The opcode specifies the operation (e.g., ADD,
SUB, MOV).
3. The operands of the instruction (such as registers or memory addresses) are identified. These could be:
Registers: Data directly in CPU registers.
Immediate values: Constant values embedded in the instruction.
Memory locations: Data stored in memory addresses.
4. The control unit (CU) generates control signals to coordinate the execution of the instruction.
2.3. Execute Stage
Description: In the execute stage, the CPU performs the action specified by the decoded instruction. This could involve
arithmetic or logic operations, data transfer, or control flow operations.
Types of operations in the Execute Stage:
o Arithmetic Operations: Addition, subtraction, multiplication, etc. Performed by the Arithmetic Logic Unit
(ALU).
o Logic Operations: AND, OR, NOT, XOR, etc. Performed by the ALU.
o Data Transfer: Moving data from one register to another or from a register to memory.
o Control Operations: Branching instructions that modify the program flow (e.g., jump, conditional branches).
Steps in the Execute Stage:
Description: Some instructions involve reading or writing data from/to memory. In this stage, memory access is
performed.
Steps in the Memory Access Stage:
o If the instruction requires reading from memory (e.g., load instruction), the data is fetched from the memory
location specified by the operand.
o If the instruction requires writing to memory (e.g., store instruction), the data is written to the memory
location.
Description: In this final stage, the result of the operation is written back to a register or memory location, depending
on the instruction.
Steps in the Write-back Stage:
1. If the instruction produces a result (e.g., arithmetic operation), the result is written back into the destination
register or memory.
2. The program counter (PC) is updated for the next instruction to be fetched.
The execution of an instruction can vary based on the type of operation it performs. Here are some typical types of
instructions and how they execute:
Modern processors often implement pipelining, a technique that allows for overlapping instruction execution to
improve performance. In a pipeline, different stages of instruction execution (fetch, decode, execute) occur
simultaneously for different instructions.
For example, while one instruction is being decoded, the next instruction can be fetched, and another instruction can
be executed, creating an assembly line effect. This significantly increases the throughput of instructions, reducing the
overall time to complete programs.
Pipeline Stages:
Hazards: These are situations where the next instruction in the pipeline cannot be executed due to dependencies or
other issues.
o Data Hazards: When an instruction depends on the result of a previous instruction still being processed.
o Control Hazards: When branching instructions alter the flow of the program, causing a delay in fetching
instructions.
1. Fetch: Retrieve the instruction from memory (Program Counter points to the instruction).
2. Decode: Interpret the instruction and generate control signals (Opcode decoding and operand identification).
3. Execute: Perform the required operation (e.g., ALU computation, data transfer).
4. Memory Access: Read from or write to memory (if necessary).
5. Write-back: Store the result into a register or memory.
The instruction execution process is the foundation of how a CPU operates. The fetch-decode-execute cycle ensures
that instructions are processed step-by-step, allowing for the execution of complex tasks. Pipelining improves
instruction throughput by overlapping these stages, enhancing CPU performance. Understanding the steps involved in
instruction execution is essential for low-level programming, optimization, and system design.
A data path is a critical component of a computer processor. It is responsible for performing the actual data
processing operations, such as arithmetic calculations, logic operations, and data transfers. The design of a data path
involves combining hardware components to enable the execution of instructions defined by the processor's
instruction set architecture (ISA).
The data path works alongside the control unit to execute instructions. While the control unit generates signals that
guide the data path, the data path executes the operations on data.
1.1. Registers
Performs arithmetic (addition, subtraction, etc.) and logical (AND, OR, NOT, etc.) operations.
Inputs: Two data values (operands) and control signals specifying the operation.
Output: The result of the operation.
Selects one of several input data sources to be passed to the output, based on control signals.
Used to route data efficiently within the data path.
1.5. Buses
Data bus: Transfers data between components (e.g., memory, registers, ALU).
Address bus: Transfers memory addresses.
Control bus: Carries control signals for synchronization.
Generated by the control unit to direct the flow of data and the operations performed by the ALU.
Building a data path involves a systematic process of identifying the components required and connecting them to
support the processor's instruction set.
Trace how data moves through the processor for each instruction.
Example: For an ADD instruction:
o Fetch operands from registers.
o Send operands to the ALU.
o Perform addition in the ALU.
o Write the result back to a register.
Combine segments for all instruction types into a unified data path.
Use multiplexers to share resources (e.g., ALU, buses) among different instruction types.
There are two main approaches to building a data path: single-cycle and multi-cycle.
Description: Each instruction is executed over multiple clock cycles. Different stages of the instruction cycle (fetch,
decode, execute) occur in separate cycles.
Advantages:
o Efficient use of hardware resources.
o Allows complex instructions to take more time while simple instructions execute faster.
Disadvantages:
o Requires a more complex control unit to manage instruction sequencing.
Instruction Set
1. ADD Rd, Rs, Rt: Add the values in Rs and Rt and store in Rd.
2. LW Rt, offset(Rs): Load a word from memory to register Rt.
3. SW Rt, offset(Rs): Store a word from register Rt to memory.
4. BEQ Rs, Rt, offset: Branch to offset if Rs == Rt.
Components Required
1. Registers:
o General-purpose registers (e.g., Rs, Rt, Rd).
o PC (Program Counter).
2. ALU:
o Performs addition for ADD, address calculation for LW and SW, and comparison for BEQ.
3. Instruction Memory:
o Stores the instructions.
4. Data Memory:
o Stores data accessed by LW and SW.
5. Control Signals:
o Direct the flow of data and operations (e.g., ALU operation, memory read/write).
Fetch Stage:
o Fetch the instruction from Instruction Memory using the PC.
o Increment the PC for the next instruction.
Decode Stage:
o Decode the instruction to determine the operation and operands.
Execute Stage:
o Perform the ALU operation for arithmetic instructions.
o Calculate memory address for load/store instructions.
o Compare values for branch instructions.
Memory Access Stage:
o Access Data Memory for load/store instructions.
Write-back Stage:
o Write the result back to the destination register for arithmetic or load instructions.
Control Signals
ALU control signals: Specify the ALU operation (e.g., addition, comparison).
Memory control signals: Indicate whether to read or write to memory.
Multiplexer control signals: Select appropriate inputs for the ALU and memory.
5. Optimizing the Data Path
Use multiplexers to allow multiple instructions to share the ALU, buses, and memory.
5.2. Pipelining
Handle data hazards (e.g., operand dependencies) and control hazards (e.g., branches) using techniques like
forwarding, stalls, or branch prediction.
The data path, combined with the control unit, forms the backbone of a processor, enabling it to execute instructions
efficiently and effectively.
The control unit (CU) is a fundamental component of a computer processor. It orchestrates the execution of
instructions by generating the necessary control signals to guide the data path components, such as registers, the ALU,
and memory. The design of a control unit ensures that every instruction in the instruction set is executed correctly and
efficiently.
Coordinate Operations: The control unit generates control signals to direct the operation of the data path components.
Interpret Instructions: It decodes instructions fetched from memory to determine the sequence of actions required.
Manage Timing: It synchronizes the sequence of operations using the system clock.
Control Signals:
o Enable data transfer between registers.
o Select ALU operations.
o Activate memory read/write operations.
o Control branching and jumps in program flow.
There are two main types of control units based on how they generate control signals:
Description:
o Control signals are generated using combinational logic circuits.
o The logic is designed using finite state machines (FSMs) to represent the control states.
Characteristics:
o Fast execution: Signals are generated directly through hardware logic.
o Difficult to modify: Changing the control logic requires redesigning the hardware.
Applications: Common in processors requiring high-speed operations with a fixed instruction set.
Design Steps:
Description:
o Control signals are generated using a microprogram, stored in a control memory.
o Each microinstruction specifies the control signals for a particular step in instruction execution.
Characteristics:
o Easier to modify: Changes are made by updating the microprogram.
o Slower execution: Requires fetching and decoding microinstructions.
Applications: Used in complex CPUs with a rich instruction set or in CISC (Complex Instruction Set Computing)
architectures.
Design Steps:
3.3. Sequencer
Understand the instructions supported by the processor and their execution requirements.
Break down each instruction into micro-operations (e.g., fetch, decode, execute).
4.2. Define Control States
Each phase of instruction execution (fetch, decode, execute, memory access, write-back) corresponds to a control
state.
Example for an ADD instruction:
o Fetch: Load the instruction from memory.
o Decode: Determine the operation and operands.
o Execute: Perform addition in the ALU.
o Write-back: Store the result in a register.
Decide between a hardwired or microprogrammed control unit based on performance, complexity, and flexibility
requirements.
Instruction Set
1. ADD Rd, Rs, Rt: Add values in Rs and Rt and store in Rd.
2. LW Rt, offset(Rs): Load a word from memory to register Rt.
3. SW Rt, offset(Rs): Store a word from register Rt to memory.
4. BEQ Rs, Rt, offset: Branch to offset if Rs == Rt.
Control States
1. Fetch:
o Control signals: IR <- Memory[PC], PC <- PC + 1.
2. Decode:
o Control signals: Decode opcode and operands.
3. Execute:
o For ADD: ALU <- Rs + Rt.
o For LW: Memory Address <- Rs + offset.
o For SW: Memory[Address] <- Rt.
o For BEQ: Compare Rs and Rt.
4. Memory Access (if needed):
o Load: Rt <- Memory[Address].
o Store: Memory[Address] <- Rt.
5. Write-back:
o Rd <- ALU Result.
Inputs:
o Opcode (from instruction register).
o Status flags (e.g., zero flag for branching).
Outputs:
o Signals to enable/disable registers, memory, ALU, etc.
Design combinational logic to generate outputs based on inputs.
Microinstruction Format
Control Memory
Advantages of Microprogramming
1. Analyzing the ISA to determine the required operations and control signals.
2. Choosing between hardwired and microprogrammed implementations.
3. Designing the control logic or microprogram to generate control signals.
4. Optimizing the control unit for performance and flexibility.
The control unit ensures smooth and synchronized operation of the processor, enabling it to execute instructions
efficiently and correctly.
Pipelining
Pipelining is a technique used in computer architecture to improve the performance of a processor by overlapping the
execution of instructions. It divides the instruction execution process into multiple stages, each handled by different
hardware components simultaneously.
1. Introduction to Pipelining
Definition: Pipelining is a method of instruction execution where multiple instructions are processed concurrently, with
each instruction at a different stage of execution.
Goal: Increase instruction throughput (number of instructions executed per unit time) without increasing the clock
speed.
Analogy: Similar to an assembly line in a factory, where different workers (stages) perform specific tasks on a product
(instruction) simultaneously.
Non-Pipelined Execution:
Pipelined Execution:
o Instructions are overlapped across stages.
o Execution time is determined by the number of stages and the clock cycle per stage.
Speedup:
o Defined as the ratio of time taken by a non-pipelined processor to time taken by a pipelined processor.
o Speedup=Non-Pipelined TimePipelined Time\text{Speedup} = \frac{\text{Non-Pipelined Time}}{\text{Pipelined
Time}}Speedup=Pipelined TimeNon-Pipelined Time.
o Ideal Speedup = Number of pipeline stages (in practice, less due to overheads).
Throughput:
o Number of instructions completed per unit time.
o Increases as the pipeline processes multiple instructions concurrently.
Latency:
o Time taken to complete a single instruction from start to finish.
o Remains constant or slightly increases due to pipeline overhead.
4. Pipeline Hazards
Pipelining introduces potential conflicts or delays called hazards. These hazards reduce the efficiency of the pipeline.
Cause: Occur when hardware resources are insufficient to support concurrent execution of instructions.
Example: A single memory unit is used for both instruction fetch and data access.
Solution:
o Use separate instruction and data memory (Harvard Architecture).
o Introduce stalls (pipeline bubbles) to resolve resource contention.
o Data Forwarding: Pass the result of one stage directly to another without waiting for the write-back.
o Pipeline Stalls: Delay execution until the hazard is resolved.
Cause: Occur due to changes in the control flow, such as branches or jumps.
Example: The next instruction to fetch is unknown until the branch condition is evaluated.
Solution:
o Branch Prediction: Predict the outcome of a branch and continue execution.
o Delayed Branch: Reorganize instructions to minimize branch penalties.
o Stalls: Wait until the branch decision is known.
5. Pipeline Design
5.3. Superpipelining
Increases the number of pipeline stages by further dividing existing stages into smaller ones.
Enables higher clock speeds but introduces more hazards.
5.4. Superscalar Pipelining
6. Pipeline Optimizations
Data Hazards:
o Implement forwarding paths.
o Use dependency checks to introduce stalls.
Control Hazards:
o Improve branch prediction accuracy using dynamic branch predictors.
o Use speculative execution to guess and execute instructions beyond the branch.
7. Pipeline Challenges
Complex Control Logic: Requires additional logic to handle hazards and optimize performance.
Power Consumption: Increased hardware and clock rates lead to higher power usage.
Latency: Pipelining does not reduce the time for a single instruction; rather, it focuses on increasing throughput.
8. Real-World Applications
Modern Processors: Use deep pipelines (e.g., Intel Core, AMD Ryzen) to achieve high instruction throughput.
Graphics Processing Units (GPUs): Extensively use pipelining for parallel computation in rendering and AI workloads.
Network Routers: Employ pipelining to process network packets at high speeds.
Advantages:
Disadvantages:
Pipelining is a key technique to enhance processor performance by overlapping instruction execution. By addressing
hazards, optimizing control logic, and balancing pipeline stages, modern processors achieve remarkable levels of
instruction throughput. While it introduces complexity, its benefits make it an essential feature in computer
architecture.
In pipelined architectures, hazards are conditions that cause the pipeline to stall or operate inefficiently. Two major
categories of hazards are Data Hazards and Control Hazards. These hazards disrupt the smooth flow of instructions
in a pipeline, reducing overall performance.
1. Data Hazards
Definition: Data hazards occur when instructions in a pipeline depend on the results of previous instructions that have
not yet completed their execution.
Description: Also known as a true dependency, this occurs when an instruction tries to read a value that is being
written by a previous instruction.
Example:
assembly
Copy code
ADD R1, R2, R3 ; Instruction 1: Writes to R1
SUB R4, R1, R5 ; Instruction 2: Reads R1 before Instruction 1 finishes
Solution:
o Data Forwarding: Pass the result directly from one stage to another without waiting for the write-back.
o Stalls: Delay the execution of the dependent instruction until the data is available.
Description: Also known as an anti-dependency, this occurs when a later instruction writes to a register before an
earlier instruction reads it.
Example:
assembly
Copy code
SUB R1, R2, R3 ; Instruction 1: Reads R1
ADD R1, R4, R5 ; Instruction 2: Writes to R1
Description: Also known as an output dependency, this occurs when two instructions write to the same register, and
the order of writes matters.
Example:
assembly
Copy code
ADD R1, R2, R3 ; Instruction 1: Writes to R1
SUB R1, R4, R5 ; Instruction 2: Writes to R1
Solution: Register renaming or delaying one of the instructions to maintain correct order.
2. Pipeline Stalls
o Insert no-operation (NOP) instructions into the pipeline to delay the dependent instruction until the required
data is available.
o Reduces throughput.
3. Instruction Reordering
o Reorganize instructions to separate dependent instructions.
4. Register Renaming
o Use temporary registers to eliminate false dependencies (WAR and WAW).
2. Control Hazards
Definition: Control hazards occur when the pipeline cannot determine the correct sequence of instructions to execute
due to changes in the program flow, such as branches or jumps.
1. Branch Instructions
o Conditional branches (e.g., if statements, loops) may alter the flow of execution.
o The pipeline fetches the next instruction before knowing the branch outcome.
2. Jump Instructions
o Unconditional jumps disrupt the sequential flow of instructions.
3. Branch Delay
o The outcome of a branch (taken or not taken) is determined late in the pipeline, causing delays.
1. Branch Prediction
o Static Prediction: Predicts the branch outcome based on a fixed rule (e.g., always not taken).
o Dynamic Prediction: Uses hardware to track the history of branches and predicts based on past behavior.
2. Delayed Branch
o Rearrange instructions so that useful instructions are executed during the branch delay slot (the time between
branch fetch and resolution).
3. Speculative Execution
o Execute instructions beyond the branch based on a prediction.
o Discard results if the prediction is incorrect, causing minimal delay.
4. Pipeline Flushing
o If a branch prediction is incorrect, flush all partially executed instructions in the pipeline and fetch the correct
instruction sequence.
Effect Delays due to unavailability of data Delays due to incorrect instruction fetch
Given a simple 5-stage pipeline (IF, ID, EX, MEM, WB), consider these instructions:
assembly
Copy code
ADD R1, R2, R3 ; Instruction 1
SUB R4, R1, R5 ; Instruction 2 (Data Hazard: RAW)
BEQ R4, R6, Label ; Instruction 3 (Control Hazard)
Scenario
1. Data Hazard:
o Instruction 2 depends on the result of Instruction 1.
o Without forwarding, Instruction 2 must stall until Instruction 1 writes to R1.
2. Control Hazard:
o The branch instruction (Instruction 3) may alter the sequence of instructions to fetch.
o The pipeline fetches the next sequential instruction before determining the branch outcome.
Resolution
1. Data Hazard: Use data forwarding to pass R1's result from the EX stage of Instruction 1 to the ID stage of Instruction 2.
2. Control Hazard: Apply branch prediction or flush the pipeline if the prediction is incorrect.
Data Hazards
Control Hazards
The memory subsystem is a crucial component of a computer system that stores and retrieves data required for
execution. The design of memory impacts a system's performance, cost, and power consumption. Memory hierarchy is
an organizational structure that balances speed, size, and cost to achieve optimal system performance.
1. Memory Concepts
1. Memory Unit:
o Acts as the storage area for data and instructions.
o Communicates with the processor via a memory bus.
3. Memory Operations:
o Read: Retrieve data from memory.
o Write: Store data into memory.
o Erase: Clear existing data (common in flash memory).
2. Memory Hierarchy
Memory hierarchy organizes memory into levels based on speed, size, cost, and proximity to the CPU. Faster and
smaller memories are closer to the CPU, while larger, slower memories are farther away.
1. Registers:
o Speed: Fastest memory.
o Capacity: Small, typically a few bytes to kilobytes.
o Cost: Highest cost per bit.
o Usage: Stores temporary data and operands for the CPU.
2. Cache Memory:
o Speed: Very fast but slower than registers.
o Capacity: Larger than registers, typically a few KB to several MB.
o Levels:
L1 Cache: Closest to the CPU, smallest, and fastest.
L2 Cache: Larger and slightly slower than L1.
L3 Cache: Shared among cores, largest and slowest of all cache levels.
o Usage: Stores frequently accessed data and instructions to reduce main memory access.
4. Secondary Storage:
o Speed: Slower than main memory.
o Capacity: Very large, typically GBs to TBs.
o Examples:
Hard Disk Drives (HDDs): Magnetic storage with high capacity and lower cost.
Solid State Drives (SSDs): Faster and more reliable than HDDs.
o Usage: Stores data permanently or for long-term use.
5. Tertiary Storage:
o Speed: Slowest memory.
o Capacity: Very large, often petabytes.
o Examples: Tape drives, optical disks (CDs, DVDs).
o Usage: Used for backup and archival purposes.
6. Virtual Memory:
o Concept: Uses part of secondary storage as an extension of main memory.
o Mechanism: The operating system swaps data between RAM and disk storage to provide the illusion of more
memory.
1. Hit Ratio:
o Percentage of memory accesses satisfied by faster levels of the hierarchy.
o Higher hit ratios improve performance.
2. Miss Penalty:
o Time taken to fetch data from a slower memory level when there’s a miss.
o Minimizing miss penalties enhances efficiency.
3. Memory Latency:
o Lower latency improves system responsiveness.
o Techniques like pipelining and prefetching can reduce latency.
4. Memory Bandwidth:
o Higher bandwidth allows more data to be transferred in a given time.
1. Cache Optimization:
o Use of multi-level caches (L1, L2, L3).
o Replacement policies (e.g., Least Recently Used, FIFO).
o Cache prefetching to load anticipated data.
2. Memory Interleaving:
o Splitting memory into multiple modules that can be accessed concurrently to increase bandwidth.
4. Compression:
o Reducing the data footprint to increase effective memory capacity.
1. Consumer Computers:
o CPU with multi-level caches.
o DRAM as main memory.
o SSDs or HDDs for storage.
3. Embedded Systems:
o Smaller, simpler memory hierarchies tailored for specific applications.
2. Integration:
o Increasing integration of memory on CPU dies (e.g., Apple M1).
3. Energy Efficiency:
o Focus on reducing power consumption for mobile and data center applications.
The memory hierarchy is designed to bridge the performance gap between the processor and slower memory units. By
organizing memory into levels with varying speeds, sizes, and costs, it ensures that frequently accessed data is
available at the fastest possible speed while keeping overall costs reasonable. Optimizing memory performance
through techniques like caching, interleaving, and advanced technologies is critical for modern computing systems.
Memory Management
Memory Management refers to the process of efficiently managing a computer's memory resources, including
allocation, deallocation, and protection of memory spaces. It is a core function of an operating system (OS) to ensure
that applications run smoothly while optimizing the utilization of physical memory.
3. Dynamic Allocation:
o Assign memory to processes as needed and reclaim it when processes terminate.
4. Multiprogramming:
o Support the concurrent execution of multiple processes by dividing memory among them.
5. Security:
o Protect sensitive data in memory from unauthorized access.
6. Virtualization:
o Provide an abstraction of more memory than physically available using techniques like virtual memory.
2. Fixed Partitioning:
o Divide memory into fixed-sized partitions.
o Each partition holds one process.
o Advantages:
Simple to implement.
o Disadvantages:
Wastes memory due to internal fragmentation.
3. Dynamic Partitioning:
o Memory is allocated to processes based on their size.
o Advantages:
Reduces internal fragmentation.
o Disadvantages:
Suffers from external fragmentation.
1. Paging:
o Divide physical memory into fixed-sized blocks called frames.
o Divide logical memory into blocks of the same size called pages.
o Pages are loaded into frames, allowing non-contiguous allocation.
o Advantages:
Eliminates external fragmentation.
Simplifies memory management.
o Disadvantages:
Adds overhead for managing page tables.
o Page Table: Maps logical addresses (pages) to physical addresses (frames).
2. Segmentation:
o Divide memory into segments based on logical divisions of a program (e.g., code, data, stack).
o Each segment has its own size and is allocated independently.
o Advantages:
Provides a logical view of memory.
o Disadvantages:
Suffers from external fragmentation.
3. Virtual Memory
Virtual Memory is a memory management technique that allows a system to execute processes that require more
memory than physically available.
1. Key Concepts:
o Logical Address Space: The memory space a process assumes it has access to.
o Physical Address Space: The actual memory available in the system.
2. Mechanism:
o Uses a portion of secondary storage (e.g., HDD or SSD) as an extension of main memory.
o Pages are swapped between RAM and secondary storage as needed.
3. Techniques:
o Demand Paging: Pages are loaded into memory only when accessed.
o Page Replacement Algorithms:
FIFO (First-In, First-Out): Replace the oldest page.
LRU (Least Recently Used): Replace the least recently used page.
Optimal Algorithm: Replace the page that will not be needed for the longest time (theoretical).
4. Advantages:
o Increases effective memory size.
o Allows execution of large programs.
5. Disadvantages:
o Increases latency due to page faults.
o Requires additional hardware (MMU - Memory Management Unit).
4. Fragmentation
1. Internal Fragmentation:
o Unused memory within allocated space (e.g., a process does not fully utilize its allocated block).
2. External Fragmentation:
o Free memory is scattered in small, non-contiguous blocks, making it unusable for larger processes.
3. Solutions:
o Compaction: Rearrange memory to consolidate free space.
o Paging: Avoids external fragmentation.
o Best-Fit/First-Fit Allocation: Allocates memory based on specific strategies to reduce fragmentation.
5. Memory Protection
1. Objective:
o Prevent unauthorized access to memory spaces.
2. Techniques:
o Base and Limit Registers:
Define the range of valid addresses for a process.
o Access Control:
Define permissions for memory regions (e.g., read, write, execute).
o Segmentation and Paging:
Enforce boundaries using segment and page tables.
2. Page Table:
o Maps logical pages to physical frames.
4. Swap Space:
o Dedicated area on secondary storage for virtual memory.
1. Shared Memory:
o Allows multiple processes to access the same memory region.
o Used for inter-process communication.
2. Memory-Mapped I/O:
o Maps hardware device memory into the address space of processes.
4. Garbage Collection:
o Automatically reclaims unused memory in high-level programming languages (e.g., Java, Python).
Memory Management is a critical function of the OS to allocate, protect, and optimize memory usage.
Key Techniques: Paging and segmentation address issues like fragmentation and dynamic allocation.
Virtual Memory provides flexibility and the ability to run large programs.
The efficiency of memory management significantly affects overall system performance.
Cache Memories: Mapping and Replacement Techniques
Cache memory is a high-speed storage layer that bridges the speed gap between the processor and the main memory.
It stores frequently accessed data and instructions to improve overall system performance. Effective management of
cache involves mapping techniques to place data and replacement strategies to manage evictions when the cache is
full.
1. Cache Basics
1. Purpose:
o Reduce memory access time by storing copies of frequently used data.
2. Cache Levels:
o L1 Cache: Closest to the CPU, smallest, and fastest.
o L2 Cache: Larger and slightly slower.
o L3 Cache: Shared among cores, largest, and slowest of the caches.
3. Key Parameters:
o Cache Size: Total amount of data the cache can hold.
o Block Size: Amount of data moved between memory and cache in one operation.
o Associativity: Determines how data is organized in the cache.
o Hit Rate: Percentage of accesses served by the cache.
o Miss Penalty: Time taken to fetch data from main memory after a cache miss.
Mapping techniques determine how main memory blocks are placed in the cache. These techniques directly impact
performance and hardware complexity.
Cache Line=(Memory Block Address)mod (Number of Cache Lines)\text{Cache Line} = (\text{Memory Block Address}) \
mod (\text{Number of Cache Lines})Cache Line=(Memory Block Address)mod(Number of Cache Lines)
Advantages:
o Simple to implement.
o Low-cost hardware.
Disadvantages:
o High conflict misses, as multiple memory blocks can map to the same cache line.
Example:
For a cache with 16 lines and memory block addresses:
o Block 0, 16, 32 all map to cache line 0.
o Block 1, 17, 33 all map to cache line 1.
Disadvantages:
o Complex and expensive hardware.
o Slower due to the need to search all cache lines.
Set Index=(Memory Block Address)mod (Number of Sets)\text{Set Index} = (\text{Memory Block Address}) \mod (\
text{Number of Sets})Set Index=(Memory Block Address)mod(Number of Sets)
Associativity:
o 2-Way Set Associative: 2 lines per set.
o 4-Way Set Associative: 4 lines per set.
Advantages:
o Reduces conflict misses compared to direct mapping.
o Balanced complexity and performance.
Disadvantages:
o Higher cost and complexity than direct mapping.
When a cache is full, and a new block needs to be loaded, a replacement policy decides which block to evict.
Evicts the block that has been in the cache the longest.
Advantages:
o Simple to implement.
Disadvantages:
o Does not consider the frequency or recency of block usage.
Disadvantages:
o Complex to implement, especially in high-associativity caches.
3.3. Random Replacement
Disadvantages:
o Unpredictable performance.
Evicts the block that will not be used for the longest time in the future.
Advantages:
o Provides the best theoretical performance.
Disadvantages:
o Impossible to implement in practice since it requires future knowledge.
Disadvantages:
o Ineffective for workloads with changing access patterns.
4. Performance Metrics
1. Hit Ratio:
2. Miss Ratio:
AMAT=Hit Time+(Miss Rate×Miss Penalty)\text{AMAT} = \text{Hit Time} + (\text{Miss Rate} \times \text{Miss
Penalty})AMAT=Hit Time+(Miss Rate×Miss Penalty)
1. Multi-Level Caches:
o Use L1, L2, and L3 caches to balance speed and size.
2. Prefetching:
o Speculatively load data into the cache before it is accessed.
3. Write Policies:
o Write-Through: Updates both cache and main memory simultaneously.
o Write-Back: Updates only the cache and writes to main memory when the block is evicted.
4. Victim Cache:
o A small buffer to store blocks evicted from the cache.
5. Associativity:
o Increasing associativity reduces conflict misses but increases complexity.
Replacement Policies:
o FIFO, LRU, Random, Optimal, and LFU each have trade-offs in complexity and effectiveness.
Optimization:
o Proper cache design and management, including multi-level caches and efficient replacement policies, are
essential for enhancing system performance.
Direct Memory Access (DMA) is a system feature that allows peripherals (like disk drives, sound cards, or network
adapters) to directly read from or write to memory without involving the CPU for every transaction. It is a critical
method for improving system performance and efficiency.
1. Introduction to DMA
1. Definition:
o DMA is a hardware feature that allows devices to transfer data to/from memory without continuous CPU
intervention.
2. Purpose:
o Reduce the CPU's workload by offloading data transfer tasks to the DMA controller.
o Enable faster and more efficient data transfer between memory and peripherals.
3. Applications:
o Disk-to-memory transfers in storage devices.
o Audio data streaming in sound cards.
o Packet transfers in network cards.
1. Initialization:
o The CPU configures the DMA controller with:
Source address (e.g., peripheral or memory location).
Destination address.
Size of the data block to transfer.
Type of transfer (read/write).
2. Transfer Execution:
o The DMA controller takes control of the bus and executes the data transfer directly between the peripheral
and memory.
3. Completion:
o After the transfer is complete, the DMA controller sends an interrupt to the CPU to notify it.
3. Transparent Mode:
o DMA transfers occur only when the CPU is idle, ensuring no performance degradation for the CPU.
4. Fly-By Mode:
o Data is directly transferred between the peripheral and memory without buffering in the DMA controller.
1. Memory-to-Memory:
o Transfers data between two memory locations.
2. Peripheral-to-Memory:
o Reads data from a peripheral and writes it into memory.
3. Memory-to-Peripheral:
o Reads data from memory and sends it to a peripheral.
5. DMA Controller
1. Structure:
o Contains address registers, counters, and control logic to manage data transfer.
o Common examples include Intel 8257 or modern integrated DMA controllers in microprocessors.
2. Functions:
o Manage addresses for source and destination.
o Keep track of data transfer size.
o Control the data transfer mode (read/write).
Speed Faster due to direct memory access Slower due to CPU involvement
7. Advantages of DMA
1. Improved Performance:
o Offloads data transfer tasks from the CPU, allowing it to perform other operations.
2. High-Speed Transfers:
o DMA transfers data faster than traditional methods like PIO.
8. Disadvantages of DMA
1. Hardware Complexity:
o Requires additional hardware (DMA controller) and configuration.
2. Bus Contention:
o DMA can compete with the CPU for bus access, potentially causing delays.
3. Limited Channels:
o The number of simultaneous DMA transfers is restricted by the available DMA channels.
9. Applications of DMA
1. Disk Drives:
o Used for high-speed data transfers between storage devices and memory.
2. Networking:
o Transferring packets between network interfaces and memory.
4. Graphics Processing:
o Transferring image or texture data in graphics-intensive applications.
2. Scatter-Gather DMA:
o Supports non-contiguous memory regions for flexible data management.
Description
Feature
DMA is essential for efficient system design in modern computing, significantly improving performance by offloading
data-intensive tasks from the CPU to specialized hardware.
Input/Output (I/O)
Input/Output (I/O) in computer systems refers to the communication between a computer and the external world,
which may include hardware devices, peripherals, and other systems. It is a critical component of a computer system,
enabling interaction with users, other computers, and devices.
1. Definition:
o I/O refers to the processes and techniques used by a computer to send and receive data from external devices
or systems.
2. Purpose:
o Facilitate data exchange between the CPU/memory and peripherals.
o Enable user interaction and device communication.
1. I/O Hardware:
o Physical devices like keyboards, monitors, and network cards.
2. I/O Software:
o System software like device drivers and I/O management modules in the operating system.
3. Bus:
o Communication system that transfers data between components.
2. Interrupt-Driven I/O:
o The CPU initiates I/O operations and continues other tasks until interrupted by the device signaling completion.
o More efficient than PIO as it reduces CPU idle time.
5. Port-Mapped I/O:
o Devices use separate address spaces (ports) for I/O operations, accessed via specific instructions.
4. I/O Techniques
1. Polling:
o The CPU continuously checks the device for readiness.
o Simple but inefficient, as it wastes CPU cycles.
2. Interrupts:
o The device notifies the CPU when it is ready, allowing the CPU to perform other tasks in the meantime.
o Efficient for multitasking environments.
3. Buffered I/O:
o Data is temporarily stored in a buffer between the CPU and the device to manage speed mismatches.
1. Device Drivers:
o Interface between the operating system and hardware.
o Abstract device-specific operations into generic commands.
2. Interrupt Handlers:
o Manage interrupts generated by I/O devices.
o Ensure the correct response to device requests.
3. System Calls:
o Provide application programs with access to I/O functions.
4. I/O Scheduler:
o Optimizes the order of I/O operations to improve performance.
1. Throughput:
o Amount of data transferred per unit time.
2. Latency:
o Time taken to complete an I/O request.
3. Bandwidth:
o Maximum data transfer rate supported by the I/O system.
4. Efficiency:
o Ratio of time spent on useful work to total time.
1. Block Devices:
o Store data in fixed-size blocks (e.g., hard drives, SSDs).
o Support random access.
2. Character Devices:
o Transmit data as a stream of characters (e.g., keyboards, serial ports).
o Support sequential access.
3. Network Devices:
o Facilitate data transfer between computers over a network.
1. I/O Scheduling:
o Determines the order of I/O requests to optimize performance.
o Example algorithms:
FCFS (First-Come, First-Served): Simple, but may cause high latency.
SSTF (Shortest Seek Time First): Prioritizes requests closer to the current position.
SCAN and C-SCAN: Elevator algorithms for disk scheduling.
2. Buffering:
o Reduces speed mismatches between the CPU and devices by storing data temporarily.
3. Caching:
o Stores frequently accessed data in faster memory.
4. Error Handling:
o Detects and recovers from device failures or transmission errors.
5. Device Management:
o Allocates and deallocates resources for devices.
o Ensures mutual exclusion to avoid conflicts.
1. Speed Mismatch:
o Devices often operate at different speeds, requiring buffering or caching.
2. Concurrency:
o Managing simultaneous I/O requests efficiently.
3. Fault Tolerance:
o Handling device failures and ensuring data integrity.
4. Scalability:
o Supporting a growing number of devices and higher data volumes.
1. High-Speed Interfaces:
o Examples include USB 4.0, Thunderbolt, and PCIe 5.0.
2. Virtualized I/O:
o Sharing I/O resources among multiple virtual machines.
5. Edge Computing:
o Localized processing closer to the source of data generation.
Aspect Description
Efficient I/O management is crucial for system performance and user experience. Modern advancements in hardware
and software continue to improve the speed, flexibility, and reliability of I/O systems in diverse computing
environments.
When dealing with Input/Output (I/O) in computer systems, data can be transferred between the system and external
devices in two primary ways: Parallel and Serial communication. Both have distinct advantages, limitations, and
areas of application.
I/O Access refers to the method by which data is transferred between the CPU and peripheral devices (e.g., printers,
storage devices, network adapters).
I/O access can be broadly classified into two categories: parallel and serial communication.
2. Parallel Interface
A parallel interface uses multiple data lines to transmit multiple bits of data simultaneously. This type of
communication is often used when high data transfer rates are required over short distances.
Multiple Lines: In parallel communication, each data bit is transmitted on a separate wire or channel.
Simultaneous Transmission: Each bit of a byte (or word) is transmitted at the same time, allowing faster data transfer.
2. Crosstalk:
o In long parallel cables, signals can interfere with each other, causing data corruption.
3. Complex Wiring:
o Requires multiple data lines, making it more complex and costly for longer cable lengths.
4. Limited Scalability:
o As the number of lines increases, the interface becomes cumbersome.
IEEE 1284: A standard for bidirectional parallel communication between computers and peripherals, such as printers.
Centronics Interface: Used for connecting printers to computers.
SCSI (Small Computer System Interface): A faster parallel interface used to connect various peripheral devices (like
hard drives, CD drives).
3. Serial Interface
A serial interface transmits data one bit at a time over a single communication line. While slower in raw data transfer
speeds compared to parallel communication, serial communication has numerous advantages for long-distance
transmission and simpler designs.
One Bit at a Time: Data is transmitted bit by bit over a single wire, making it more efficient for long-distance
communication.
Data Encoding: Data is encoded before transmission to ensure synchronization and error checking.
1. Half-Duplex Communication:
o Data can only flow in one direction at a time.
o Example: Walkie-talkie communication.
2. Full-Duplex Communication:
o Data can flow in both directions simultaneously.
o Example: Telephone lines or Ethernet connections.
1. Simpler Wiring:
o Requires only a few wires (e.g., 2 to 4 for data and clock), making it ideal for long-distance transmission.
2. Less Interference:
o Since fewer wires are involved, the likelihood of crosstalk or signal degradation is lower compared to parallel
communication.
3. Lower Cost:
o Fewer cables and connectors are required, which reduces the overall cost and complexity.
4. Longer Distance:
o Serial communication is less susceptible to signal degradation, allowing for longer transmission distances
compared to parallel.
2. Increased Latency:
o Since only one bit is transmitted at a time, it takes longer to transfer large amounts of data.
1. RS-232:
o One of the oldest standards for serial communication, typically used for short-distance communication (e.g.,
connecting a computer to a modem or mouse).
6. Ethernet:
o A serial communication standard used in networking, where data packets are transmitted over a shared
medium.
Speed Faster for short distances Slower but suitable for long distances
Cable Complexity Requires multiple wires Uses fewer wires (usually 2-4)
Feature Parallel Communication Serial Communication
Cost More expensive (due to more cables and connectors) Less expensive due to fewer wires
Signal Integrity Susceptible to crosstalk and signal degradation Less affected by signal degradation
Distance Limited to shorter distances due to signal degradation Can transmit over longer distances
Examples Printer ports (Centronics), SCSI, IEEE 1284 USB, RS-232, Ethernet, SPI, I2C, SATA
Printers: The traditional parallel ports (IEEE 1284) were widely used for printers before USB became the standard.
Internal Connections: In early computer systems, internal communication between components like memory and
processors often used parallel buses.
Disk Drives (SCSI): Older storage devices, particularly hard drives and CD-ROM drives, used parallel interfaces.
Networking: Ethernet and Wi-Fi are serial communication standards that allow devices to exchange data over large
networks.
Peripherals: Modern devices like printers, cameras, and external hard drives use serial connections (e.g., USB, HDMI).
Embedded Systems: Many microcontrollers and embedded systems use serial communication protocols (I2C, SPI) for
communication between devices.
Both parallel and serial communication have distinct advantages and disadvantages, and the choice between them
depends on the specific requirements of the application. Parallel communication is faster over short distances but is
more complex and prone to signal degradation, while serial communication, though slower, offers simpler wiring and
is better suited for long-distance transmission. Serial communication has become more dominant in modern systems
due to its efficiency, lower cost, and suitability for high-speed interfaces.
Interrupt I/O
Interrupt-driven I/O is an efficient method of handling input and output operations in a computer system. Unlike
traditional programmed I/O, where the CPU must constantly poll a device to check for readiness, interrupt-driven I/O
allows devices to "interrupt" the CPU when they need attention, enabling more efficient and responsive system
operation. This method is widely used in modern computing systems to improve performance and multitasking.
Definition: Interrupt I/O refers to the technique in which the CPU is notified by a hardware device (or
software) when it needs to process data or perform an action. The notification is done through an interrupt
signal.
Purpose: The primary goal is to allow the CPU to perform other tasks while waiting for I/O operations to
complete, reducing idle time and improving overall system efficiency.
3. Interrupt Vector:
o A table or an array that holds the addresses of the interrupt service routines for different types of interrupts.
The CPU uses this table to find the appropriate ISR.
4. Interrupt Controller:
o A device or a circuit that manages multiple interrupts and determines which interrupt should be processed first
if more than one interrupt is pending. Examples: Programmable Interrupt Controller (PIC), Advanced
Programmable Interrupt Controller (APIC).
1. Device Request:
o A peripheral device generates an interrupt to request CPU attention (e.g., a keyboard, disk, or network card
signaling that it is ready for data transfer).
2. Interrupt Signal:
o The device sends an interrupt signal to the CPU through the interrupt line.
4. Interrupt Acknowledgment:
o The CPU acknowledges the interrupt and stops its current execution to process the interrupt.
6. Restoring Context:
o After the ISR completes, the CPU restores the saved context and continues executing the interrupted program
from where it left off.
4. Types of Interrupts
1. Hardware Interrupts:
o Generated by hardware devices to signal that they need attention. Examples include input devices
(keyboard, mouse) or output devices (printer).
o External Hardware Interrupts: Triggered by external devices such as a keyboard, mouse, or network
card.
o Internal Hardware Interrupts: Generated within the processor or hardware system, such as division
by zero, or timer overflow.
2. Software Interrupts:
oInitiated by software or programs to request a service from the operating system, such as system calls
or exception handling.
o System Calls: Software interrupts invoked by programs to request operating system services.
o Trap: A special type of software interrupt that is triggered when an exceptional condition (like an
arithmetic error) occurs during program execution.
3. Maskable Interrupts:
o Interrupts that can be ignored (masked) by the CPU if the CPU is busy with other tasks or if certain conditions
are met. This is typically controlled by setting or clearing an interrupt enable bit.
1. Interrupt Request:
o When a device needs to communicate with the CPU, it sends an interrupt signal through an interrupt request
line.
2. Interrupt Detection:
o The CPU checks for interrupt requests and determines if there is an active interrupt waiting to be processed.
3. Interrupt Acknowledgment:
o If an interrupt is detected, the CPU acknowledges it and begins to process the interrupt by stopping its current
execution.
5. Execution of ISR:
o The CPU executes the ISR to handle the interrupt. This typically involves reading data from or writing data to
the device.
6. Context Saving:
o Before executing the ISR, the CPU saves the context (i.e., the current state of the program) so that it can
resume execution of the interrupted program later.
1. Efficiency:
o The CPU can perform other tasks while waiting for I/O operations to complete, improving overall system
efficiency.
2. Reduced Polling:
o Unlike programmed I/O, which requires constant polling, interrupt I/O only requires the CPU to handle the
interrupt when necessary, thus saving CPU cycles.
3. Immediate Response:
o Interrupts enable immediate response to important events or device requests, ensuring that I/O operations are
handled quickly.
4. Multitasking:
o Interrupt-driven I/O supports multitasking, allowing the CPU to handle multiple I/O devices concurrently
without significant delays.
1. Interrupt Overhead:
o Each interrupt involves saving and restoring context, which can introduce overhead. If interrupts are frequent,
the system may become inefficient.
2. Complexity:
o Interrupt handling requires more complex hardware and software design, particularly when managing multiple
interrupts, as well as determining interrupt priorities.
3. Concurrency Issues:
o Interrupts can cause concurrency problems if not properly synchronized. For example, multiple interrupts
occurring simultaneously may need to be managed correctly to avoid conflicts.
4. Starvation:
o If interrupts are not handled properly (e.g., higher-priority interrupts continuously occurring), lower-priority
interrupts may suffer from starvation and never be processed.
1. Interrupt Priority:
o In systems with multiple interrupts, the CPU needs a method to determine which interrupt should be
handled first. This is done by assigning priorities to interrupts.
o Interrupts with higher priority are serviced before those with lower priority.
2. Nested Interrupts:
o A mechanism where an interrupt service routine (ISR) itself can be interrupted by a higher-priority interrupt.
This requires saving and restoring the state of the ISR and managing multiple levels of interrupt handling.
9. Interrupt Controller
An Interrupt Controller is a hardware component responsible for managing multiple interrupt lines and prioritizing
them. It determines the order in which interrupts are processed and passes the appropriate interrupt signal to the CPU.
Programmable Interrupt Controller (PIC): Used in early systems to handle a limited number of interrupts.
Advanced Programmable Interrupt Controller (APIC): Used in modern systems to handle multiple interrupt lines and
support more advanced features such as priority levels and interrupt masking.
1. Keyboard Input:
o When a key is pressed, the keyboard generates an interrupt to notify the CPU to process the input.
2. Disk I/O:
o When a disk operation is complete (e.g., read/write), the disk controller generates an interrupt to notify the
CPU.
3. Timer Interrupts:
o Used in operating systems to manage tasks, such as time-sharing or scheduling.
4. Network Interfaces:
o Network cards generate interrupts to notify the CPU of incoming data or completion of transmission.
5. Peripheral Devices:
o Devices like printers, mice, or sensors can generate interrupts to notify the CPU of various events or status
changes.
Interrupt I/O is a highly efficient method of handling I/O operations in modern computing systems. By allowing
devices to signal the CPU when attention is required, it frees the CPU to perform other tasks and reduces the need for
constant polling. While the technique introduces complexity in terms of interrupt handling and system design, the
benefits of responsiveness, efficiency, and multitasking make it essential in many systems, from personal computers to
embedded systems.
Interconnection standards define the physical and protocol specifications for connecting devices and peripherals to a
computer system. Among the most widely used interconnection standards are USB (Universal Serial Bus) and SATA
(Serial ATA), both of which are integral for connecting external and internal devices respectively. These standards
are essential for ensuring compatibility, performance, and reliability in data transfer and device communication.
USB (Universal Serial Bus) is a widely used interface standard for connecting external peripherals to a computer or
other host devices.
Initially introduced in 1996, USB was developed to replace a variety of legacy connectors such as serial ports, parallel
ports, and PS/2 connections with a more standardized and universal interface.
USB has undergone several iterations to improve speed, power delivery, and capabilities.
1. USB 1.0/1.1:
o Data Transfer Rate: 12 Mbps (Full Speed).
o Power Delivery: 5V, up to 500mA.
o Connectors: USB-A, USB-B.
2. USB 2.0:
o Data Transfer Rate: 480 Mbps (High Speed).
o Power Delivery: 5V, up to 500mA.
o Backward Compatibility: Supports older USB versions.
o Key Improvement: Faster data transfer compared to USB 1.1.
3. USB 3.0/3.1/3.2:
o Data Transfer Rate:
USB 3.0: 5 Gbps (SuperSpeed).
USB 3.1: 10 Gbps (SuperSpeed+).
USB 3.2: 20 Gbps (SuperSpeed+).
o Power Delivery: 5V, up to 900mA (USB 3.0), and 100W (with USB Power Delivery).
o Connectors: USB-A, USB-B, USB-C.
o Key Improvement: Increased data transfer rate and power delivery capacity.
4. USB4:
o Data Transfer Rate: 40 Gbps.
o Power Delivery: Up to 100W, can support 5K or 8K video output.
o Compatibility: Backward compatible with USB 3.2, 3.1, and USB 2.0.
o Thunderbolt 3 Compatibility: Integrates Thunderbolt 3 functionality.
1. Plug-and-Play: USB allows hot-plugging, meaning devices can be connected or disconnected without powering down
the system.
2. Data Transfer: USB supports both data transfer and power delivery simultaneously.
3. Peripheral Connectivity: USB is used to connect a wide range of devices, including storage devices, printers, cameras,
smartphones, and peripherals.
4. Universal Compatibility: USB ports are commonly found on computers, laptops, smartphones, and many other
electronic devices.
USB Type-A: The standard rectangular connector commonly found on host devices like computers and chargers.
USB Type-B: Used for printers and other peripherals, typically larger in size than Type-A.
USB Mini and Micro: Smaller connectors, often found on older devices like cameras and smartphones.
USB Type-C: The reversible, smaller connector supporting higher data rates and power delivery (adopted widely in
modern laptops, smartphones, and other devices).
External Storage Devices: USB flash drives, external hard drives, and SSDs.
Input Devices: Keyboards, mice, and game controllers.
Networking: USB adapters for network interfaces.
Charging: USB ports are commonly used for charging mobile phones, laptops, and other electronic devices.
SATA (Serial ATA) is a standard interface used to connect internal storage devices, such as hard disk drives (HDDs),
solid-state drives (SSDs), and optical drives (e.g., DVD/Blu-ray drives), to the motherboard of a computer.
SATA was introduced in 2003 as a replacement for the older Parallel ATA (PATA) standard, offering advantages such as
faster data transfer speeds, smaller cables, and improved reliability.
4. SATA Express:
o Data Transfer Rate: 16 Gbps.
o Compatibility: Combines the speed of PCI Express (PCIe) with SATA to improve performance, particularly for
high-end SSDs.
1. Hot-Swapping: SATA supports hot-swapping, which allows storage devices to be connected or disconnected without
powering down the system.
2. Data Integrity: Enhanced error correction and reliability compared to PATA.
3. Lower Power Consumption: Compared to PATA, SATA cables are thinner, reducing power consumption and improving
airflow within the computer case.
4. Point-to-Point Architecture: Each device has a dedicated channel, reducing the risk of conflicts between devices.
Internal Storage Devices: Hard disk drives (HDDs), solid-state drives (SSDs), and optical drives used in desktops,
laptops, and servers.
Enterprise Storage: SATA drives are often used for large-scale storage in data centers due to their cost-effectiveness.
Can connect devices over distances (up to 5 meters Typically limited to short distances (1 meter max for
Distance
for USB 3.0). SATA cables).
Interface Hot-plug, plug-and-play, supports many devices. Primarily for internal use with hard drives and SSDs.
Feature USB SATA
Data Transfer
Serial data transfer. Serial data transfer (point-to-point).
Method
Typical Usage External peripherals, charging, networking. Internal storage connections in computers.
Connector Type USB-A, USB-B, USB-C. 7-pin for data, 15-pin for power.
1. Connecting Peripherals: USB ports are commonly used to connect devices such as printers, external hard drives,
keyboards, mice, and game controllers.
2. Charging Devices: USB ports serve as the standard power supply for smartphones, tablets, and other rechargeable
devices.
3. Data Transfer: USB allows data transfer between devices, including file transfer from smartphones to PCs, connecting
cameras to computers, or using USB flash drives.
1. Internal Storage for Computers: SATA is widely used in desktop PCs, laptops, and servers for connecting hard drives
and SSDs, providing both performance and storage capacity.
2. Storage Devices for Servers: In data centers, SATA-based drives are used for large-scale storage systems, where cost-
effective and reliable storage is required.
3. SSD Storage: SATA SSDs are common in consumer laptops and desktop systems, offering faster performance compared
to traditional HDDs.
USB and SATA are two of the most important interconnection standards in modern computing. USB is primarily used
for connecting external devices, providing high data transfer speeds and power delivery, and ensuring compatibility
with a wide range of peripherals. SATA, on the other hand, is used for connecting internal storage devices, offering
high-speed data transfer and greater reliability for large-scale data storage. Both standards continue to evolve with
newer versions supporting faster speeds, greater power delivery, and better overall performance.
12 Realize XOR gate using only 4 NAND gates. (Dec 2013) Understan
BTL-2 PO1, PO2
ding
13 Realize JK flip flop using D flip flop. (Dec 2013) BTL-1 Rememberi PO1
ng
14 Convert the following hexadecimal numbers BTL-1 Rememberi PO1
into decimal numbers: ( Dec 2012) ng
a)263, b)1C3
15 What is the significance of BCD code. ( Dec 2012) BTL-1 Rememberi PO1
ng
16 Simplify the expression: X = (A’+B)(A+B+D)D’. BTL-1 Rememberi PO1
ng
17 Convert (11001010)2 into gray code. BTL-1 Rememberi PO1
ng
b) Convert a Gray code 11101101 into binary code.
18 State & prove De-Morgan’s theorem. BTL-1 Rememberi PO1
ng
19 Describe the canonical forms of the Boolean function. BTL-1 Rememberi PO1
ng
20 Describe the importance of don’t care conditions. BTL-1 Rememberi PO1
ng
21 What is a prime implicant? BTL-1 Rememberi PO1
ng
22 Define the following: minterm and maxterm? BTL-1 Rememberi PO1
ng
23 Minimize the function using K-map: F=∑m(1,2,3,5,6,7). BTL-1 Rememberi PO1
ng
24 Define Karnaugh map. BTL-1 Rememberi PO1
ng
25 Plot the expression on K-map: F (w,x,y) =∑m (0, 1, 3, 5, BTL-1 Rememberi PO1
6) + d (2, 4). ng
PART B
1 Reduce the expression using Quine McCluskey's method PO1, PO2,
F(x1, x2, x3, x4, x5) = ∑m (0, 2, 4, 5, 6, 7, 8, 10, 14, 17, 18, BTL-6 PO3, PO4
Creating
21, 29, 31) + ∑d (11, 20, 22) (May/June 2016)
3 Simplify the following switching functions using Karnaugh BTL-1 Rememberi PO1
map method and realize expression using gates F(A,B,C,D) ng
= Σ(0,3,5,7,8,9,10,12,15). (Nov/Dec 2015)
4 (a) Express the following function in sum of min-terms and PO1,
product of max-terms F(X,Y,Z)=X+YZ (May 2015) BTL-5 Evaluating PO2, PO3,
(b) convert the following logic system into NAND gates PO4
only. (May 2015)
expression Xyz’+x’yz+z(xy+w).
11 [Link] the Boolean function using QuineMcCluskey method:
PO1,
PO2,
F (A, B, C, D,E) = ∑m (0,1,3,7,13,14,21,26,28) + BTL-5 Evaluating
PO3,
∑d(2,5,9,11,17,24) (Dec 2013) PO4
12 Reduce the following function using K-map technique. (Dec
2012) PO1,
PO2,
BTL-5 Evaluating
i) f (A, B, C) = ∑m (0,1,3,7) + ∑d (2,5) PO3,
PO4
ii) F (w,x,y,z) = ∑m (0,7,8,9,10,12) + ∑d (2,5,13)
13 Simlify the following Boolean function F using Tabulation
method.
i) F (A, B, C, D) = ∑m (0,6,8,13,14) ,d (A, B, C, D)= PO1,
∑m (2,4,10) (Dec 2012) PO2,
BTL-5 Evaluating
PO3,
ii) F (A, B, C, D) = ∑m (1,3,5,7,9,15) ,d (A, B, C, D)= ∑m PO4
(4,6,12,13)
UNIT II
SYNCHRONOUS SEQUENTIAL
LOGIC
Introduction to Sequential Circuits – Flip-Flops – operation and excitation tables, Triggering of FF, Analysis
and design of clocked sequential circuits – Design – Moore/Mealy models, state minimization, state
assignment, circuit implementation - Registers – Counters.
PART – A
CO Mapping : CO202. 2
S. Question Blooms Competence PO
N Taxanom
o. y Level
1 Design the combinational circuit with 3 inputs and 1 BTL-1 Remembering PO1
output. The output is 1 when the binary value of the input
is less than 3. The output is 0 otherwise.
(May/June 2016)
7 Write the data flow description of a 4-bit comparator. BTL-1 Remembering PO1
(May 2015)
8 Implement a full adder with 4×1 multiplexer. (May 2015) BTL-1 Remembering PO1
9 Implement the following Boolean function using 8:1 BTL-1 Remembering PO1
multiplexer F(A,B,C)= ∑m(1,3,5,6)(Dec 2014)
13 Obtain the truth table for BCD to Excess-3 code BTL-1 Remembering PO1
converter. (Dec 2013)
14 Write the stimulus for 2 to 1 line MUX. (June 2012) BTL-1 Remembering PO1
15 Distinguish between a decoder and a demultiplexer. (June BTL-1 Remembering PO1
2012)
16 Design a 2-bit binary to gray code converter. BTL-1 Remembering PO1
17 Draw the 4 bit Gray to Binary code converter. BTL-1 Remembering PO1
18 Draw the 4 bit Binary to Gray code converter. BTL-1 Remembering PO1
19 Distinguish between combinational logic and sequential BTL-1 Remembering PO1
logic.
20 Implement half Adder using NAND Gates. BTL-1 Remembering PO1
22 Give the truth table for half adder and write the PO1,
expression for sum and carry. PO2,
BTL-5 Evaluating
PO3,
PO4
23 Mention the different type of binary codes. BTL-1 Remembering PO1
2 Design a full adder with x, y, z and two outputs S and C. BTL-6 Creating PO1,
The circuits performs x+y+z, z is the input carry, C is the PO2,
output carry and S is the Sum. PO3
(May/June 2016)
Design a code converter thet converts a 8421 to BCD code. PO1,
3 (Nov./Dec. 2015) PO2,
BTL-5 Evaluating
PO3,
PO4
4 (i) Explain the Analysis procedure. Analyze the following
logic diagram. (April/May 2015)
PO1,
PO2,
BTL-5 Evaluating
PO3,
PO4
5 (a) Design 2-bit magnitude comparator and write a verilog BTL-2 Understanding PO1,
HDL code. (Dec 2015) PO2
PART-A
Bloom’s
Q. No. Questions CO
Level
Write the basic functional units of computer? (APR/MAY 2017,NOV/DEC C204. BTL1
2017) 1
2. The basic functional units of a computer are input unit, output unit, memory unit,
ALU unit and control unit.
What is a bus? What are the different buses in a CPU? [ APR/MAY 2011] C204. BTL1
3.
1
A group of lines that serve as a connecting path for several devices is called bus
.The different buses in a CPU are 1] Data bus 2] Address bus 3] Control bus.
List out the methods used to improve system performance. C204. BTL1
1
The methods used to improve system performance are
21 Processor clock
Basic Performance Equation
Pipelining
Clock rate
Instruction set
Compiler
Define addressing modes and its various types.(nov/dec 2017) C204. BTL1
1
The different ways in which the location of a operand is specified in an
22 instruction is referred to as addressing modes. The various types are
Immediate Addressing, Register Addressing, Based or Displacement
Addressing, PC-Relative Addressing, Pseudodirect Addressing.
25
In PC-relative mode addressing, the branch address is the sum of the PC and a
26 constant in the instruction. - In the relative address mode, the effective address is
determined by the index mode by using the program counter in stead of general
purpose processor register. This mode is called relative address mode.
Distinguish pipelining from parallelism APR/MAY 2015 C204. BTL1
1
parallelism means we are using more hardware for the executing the desired
task. in parallel computing more than one processors are running in parallel.
there may be some dedicated hardware running in parallel for doing the
specific task.
while the pipelining is an implementation technique in which multiple
27
instructions are overlapped [Link] increases the performance
but the area also increases.
in case of pipelining the performance and througput increases at the cost of
pipelining registers area pipelining there are different hazards like data
hazards, control hazards etc.
Distinguish between auto increment and auto decrement addressing mode? C204. BTL1
1
MAY/JUNE 2016
A special case of indirect register mode. The register whose number is included in
the instruction code, contains the address of the operand. Autoincrement Mode =
after operand addressing , the contents of the register is incremented. Decrement
Mode = before operand addressing, the contents of the register is decrement. We
denote the autoincrement mode by putting the specified register in parentheses, to
show that the contents of the register are used as the efficient address, followed by
a plus sign to indicate that these contents are to be incremented after the operand is
accessed. Thus, using register R4, the autoincrement mode is written as (R4)+.
In the above example, we could also say that computer B is 1.5 times slower
than computer A, since
means that
Our favorite program runs in 10 seconds on computer A, which has a 2 GHz C204. BTL1
clock. We are trying to help a computer designer build a computer, B, which 1
will run this program in 6 seconds. The designer has determined that a
substantial increase in the clock rate is possible, but this increase will affect
the rest of the CPU design, causing computer B to require 1.2 times as many
clock cycles as computer A for this program. What clock rate should we tell
the designer to target?
33
Let’s first find the number of clock cycles required for the program on A:
CPU time for B can be found using this equation:
To run the program in 6 seconds, B must have twice the clock rate of A.
Suppose we have two implementations of the same instruction set C204. BTL1
architecture. Computer A has a clock cycle time of 250 ps and a CPI of 2.0 for 1
some program, and computer B has a clock cycle time of 500 ps and a CPI of
1.2 for the same program. Which computer is faster for this program and by
how much?
34
We know that each computer executes the same number of instructions for the
program; let’s call this number I. First, find the number of processor clock cycles
for each computer:
Now we can compute the CPU time for each computer:
Likewise, for B:
Clearly, computer A is faster. The amount faster is given by the ratio of the
execution times:
We can conclude that computer A is 1.2 times as fast as computer B for this
program.
Also called CPU time. The actual time the CPU spends computing for a
specific task.
Types:
35
User CPU time
The CPU time spent in the operating system performing tasks on behalf of
the program
D e f i ne r es p o ns e t i C204. BTL1
1
me R es po ns e t i me :
36 Also called execution time. The total time required for the computer to
complete a task, including disk accesses, memory accesses, I/O activities,
operating system overhead, CPU execution time, and so on.
W hat i s T hro ug hp ut ? C204. BTL1
1
Also called bandwidth. Another measure of performance, it is the number
37 of tasks completed per unit time.
Define Clock cycles: C204. BTL1
1
All computers are constructed using a clock that determines when events
38 take place in the hardware. These discrete time intervals are called clock cycles
(or ticks, clock ticks, clock periods, clocks, cycles).
Write Basic performance equation in terms of instruction count (the number C204. BTL1
of instructions executed by the program), CPI, and clock cycle time. 1
39
A[12] = h + A[8];
Answer
44 $t0: lw$t0,32($s3)
# Temporary reg $t0 gets A[8]
add$t0,$s2,$t0
# Temporary reg $t0 gets h + A[8]
sw$t0,48($s3)
# Stores h + A[8] back into A[12]
3.J-type or Jump
What are the types of instruction in MIPS.(APR/MAY2018) C204. BTL1
1
1. Arithmetic instruction
48 2. Data transfer Instruction
3. Logical Instruction
4. Conditional Branch Instruction
5. Unconditional jump Instruction
PART-B
Bloom’s
Q. No. Questions CO
Level
i) Discuss
in detail about Eight great ideas of computer Architecture.(8)
[Link]-13)
C204.
1. Explain in detail about Technologies for Building Processors
ii) BTL5
1
and Memory (8) )([Link]-28)
Explain the various components of computer System with neat diagram (16) C204. BTL5
1
.(NOV/DEC2014,NOV/DEC2015,APR/MAY 2016,NOV/DEC
2. 2016,APR/MAY2018)) ([Link]-17)
Discuss in detail the various measures of performance of a computer(16) C204. BTL6
1
([Link]-40)
3.
Define Addressing mode and explain the different types of basic C204. BTL5
addressing modes with an example 1
([Link]-117)
i) Discuss the Logical operations and control operations of computer (12) C204. BTL6
1
([Link]-89)
5.
ii) Write short notes on Power wall(6)
([Link]-42)
Consider three diff erent processors P1, P2, and P3 executing the same instruction C204. BTL5
set. P1 has 3 GHz clock rate and a CPI of 1.5. P2 has a 2.5 GHz clock rate and a 1
CPI of 1.0. P3 has a 4.0 GHz clock rate and has a CPI of 2.2. (APR/MAY 2018)
c. We are trying to reduce the execution time by 30% but this leads to an
increase
of 20% in the CPI. What clock rate should we have to get this time
reduction?
(Refer Notes)
Explain various instruction format illustrate the same with an example C204. BTL5
7. 1
NOV/DEC2017 ([Link]-86)
Explain direct ,immediate ,relative and indexed addressing modes with C204. BTL5
8. example APR/MAY2018 ([Link]-117) 1
State the CPU performance equation and the factors that affect performance C204. BTL5
(8) 1
9.
(NOV/DEC2014) (Refer Notes)
Explain types of operations and operands with examples.(NOV/DEC 2017) C204. BTL5
12. 1
([Link]-70)
Consider two diff erent implementations of the same instruction C204. BTL5
1
set architecture. Th e instructions can be divided into four classes according
to
their CPI (class A, B, C, and D). P1 with a clock rate of 2.5 GHz and CPIs
of 1, 2, 3,
into classes as follows: 10% class A, 20% class B, 50% class C, and 20%
class D,
(Refer Notes)
(Refer Notes)
Describe the steps that transform a program written in a high-level C204. BTL4
1
language such as C into a representation that is directly executed by
15.
a computer processor.
(Refer Notes)
UNIT IV
PART-A
Bloom’s
Q. No. Questions CO
Level
What is pipelining?
The technique of overlapping the execution of successive instruction for
substantial improvement in performance is called pipelining. C204.
1. BTL1
3
.
What is and precise C204. BTL1
exception? 3
The time required between moving an instruction one step down the pipeline is
a processor cycle.
3.
What is meant by pipeline bubble?(NOV/DEC 2016) C204. BTL1
3
To resolve the hazard the pipeline is stall for 1 clock cycle. A stall is
4. commonly called a pipeline bubble, since it floats through the pipeline taking
space but carrying no useful work.
What is pipeline register delay? C204. BTL1
3
Adding registers between pipeline stages me adding logic between stages and
5 setup and hold times for proper operations. This delay is known as pipeline
register delay.
What are the major characteristics of a pipeline? C204. BTL6
3
The major characteristics of a pipeline are:
The term exception is used to refer to any event that causes an interruption.
15
Interrupt:
An exception that comes from outside of the processor. There are two
types of interrupt.
Why is branch prediction algorithm needed? Differentiate between the C204. BTL1
static and dynamic techniques. (May 2013,APR/MAY 2015,NOV/DEC 15) 3
The branch instruction will introduce branch penalty which would reduce the
gain in performance expected from pipelining. Branch instructions can be
handled in several ways to reduce their negative impact on the rate of
execution of instructions. Thus the branch prediction algorithm is needed.
16 The static branch prediction, assumes that the branch will not take place and to
continue to fetch instructions in sequential address order.
The idea is that the processor hardware assesses the likelihood of a given
branch being taken by keeping track of branch decisions every time that
instruction is executed. The execution history used in predicting the outcome
of a given branch instruction is the result of the most recent execution of that
instruction.
Pipelined processor gives the best throughput for sequenced line instruction. In
branch instruction, as it has to calculate the target address, whether the
18
instruction jump from one memory location to other. In the meantime, before
calculating the larger, the next sequence instructions are got into the pipelines,
which are rolled back, when target is calculated.
What is meant by super scalar processor? C204. BTL1
3
Super scalar processors are designed to exploit more instruction level
parallelism in user programs. This means that multiple functional units are
19 used. With such an arrangement it is possible to start the execution of
several instructions in every clock cycle. This mode of operation is called
super scalar execution.
Define pipeline speedup. [ APR/MAY 2012] ([Link]/DEC 2012) C204. BTL1
3
Speed up is the ratio of the average instruction time without pipelining to
20 the average instruction time with pipelining. Average instruction time
without pipelining Speedup= Average instruction time with pipelining
What is Vectorizer? C204. BTL1
3
The process to replace a block of sequential code by vector instructions
21 is called vectorization. The system software, which generates
parallelism, is called as vectorizing compiler.
What is pipelined computer? C204. BTL1
3
When hardware is divided in to a number of sub units so as to perform the sub
22
operations in an overlapped fashion is called as a pipelined computer.
List the various pipelined processors. C204. BTL1
3
23 8086, 8088, 80286, 80386. STAR 100, CRAY 1 and CYBER 205 etc
25
C204. BTL1
3
Write down the expression for speedup factor in a pipelined architecture.
[MAY/JUNE ‘11]
Branch difficulties → Arises from branch and other instruction that change the
value of PC (Program Counter).
One of the most important methods for finding and exploiting more ILP is
speculation. It is an approach whereby the compiler or processor guesses the
outcome of an instruction to remove it as dependence in executing other
instructions. For example, we might speculate on the outcome of a branch, so
29
that instructions after the branch could be executed earlier.
Precise interrupt
0000 AND
0001 OR
38
0010 add
0110 sub
1100 NOR
40
46
Memory Concepts and Hierarchy – Memory Management – Cache Memories: Mapping and Replacement Techniques – V
PART -A
Bloom’s
Q. No. Questions CO
Level
In memory mapped I/O, there are no specific input or output instructions. The
CPU can manipulate I/O data residing in interface registers with the same
instructions that are used to manipulate memory words
When I/O devices and the memory share the same address space, the
arrangement is called memory mapped I/O. The machine instructions that can
access memory is used to trfer data to or from an I/O device.
SRAMs are simply integrated circuits that are memory arrays with a single
access port that can provide either a read or a write. SRAMs have a fixed access
time to any datum.
SRAMs don’t need to refresh and so the access time is very close to the cycle
time. SRAMs typically use six to eight transistors per bit to prevent the
information from being disturbed when read. SRAM needs only minimal power to
retain the charge in standby mode.
26
C204. BTL1
Pointouthow DMAcan improve I/Ospeed? APRIL/MAY 2015 5
CPU speeds continue to increase, and new CPUs have multiple processing
elements on the same chip.A large amount of data can be processed very quickly
Problem in the transfer of data to CPU or even memory in a reasonable amount of
time so that CPU has some work to do at all time . Without DMA, when the CPU
27
is using programmed input/output, it is typically fully occupied for the entire
duration of the read or write operation, and is thus unavailable to perform other
work. With DMA, the CPU first initiates the transfer, then it does other operations
while the transfer is in progress, and it finally receives an interrupt from the DMA
controller when the operation is done.
C204. BTL1
Whatarethevarious memory Technologies?NOV/DEC 2015 5
Memory Technologies
28
Main memory is implemented from DRAM (dynamic random access memory),
while levels closer to the processor (caches) use SRAM (static random access
memory). DRAM is less costly per bit than SRAM, although it is substantially
slower. The price difference arises because DRAM uses significantly less area per
bit of memory, and DRAMs thus ve larger capacity for the e amount of
ha silicon; sam
C204. BTL1
5
36 Define miss rate.
Miss rate The fraction of memory accesses not found in a level of the memory
hierarchy.
C204. BTL1
5
What are the steps to be taken on an instruction cache miss:
2. Instruct main memory to perform a read and wait for the memory to
40 complete its access.
3. Write the cache entry, putting the data from memory in the data portion of
the entry, writing the upper bits of the address (from the ALU) into the tag
field, and turning the valid bit on.
4. Restart the instruction execution at the first step, which will refetch the
instruction, this time finding it in the cache
C204. BTL1
5
What are the techniques to improve cache performance?
C204. BTL1
Define dirty bit
44 5
dirty bit is commonly used. This status bit indicates whether the block is dirty
(modified while in the cache) or clean (not modified).
What is TLB. C204. BTL1
5
45 Translation-lookaside buffer (TLB)A cache that keeps track of recently used
address mappings to try to avoid an access to the page table.
C204. BTL1
What are the messages transferred in DMA? 5
PART -B
Bloom’s
Q. No. Questions CO
Level
Expain in detail about memory Hierarchy with neat diagram C204. BTL5
2. . 5
( [Link]:-374-378)
Discuss the methods used to measure and improve the performance of the C204. BTL6
4. .
cache.(NOV/DEC 2017) ( [Link]:-398-417) 5
Explain the virtual memory address translation and TLB with necessary C204. BTL5
diagram.(APRIL/MAY2015,NOV/DEC 2015,NOV/DEC 5
5. 2016,APR/MAY2018) ( [Link]:-427-452)
C204. BTL5
5
Draw the typical block diagram of a DMA controller and explain how it is
6.
used for direct data transfer between memory and peripherals. (NOV/DEC
2015,MAY/JUNE 2016,NOV/DEC 2016,MAY/JUN 2018) [Link]:-399-
402)
Describe in detail about programmed Input/Output with neat diagram C204. BTL5
8. 5
(MAY/JUN 2018) (Refer notes)
Draw different memory address layouts and brief about the technique used C204. BTL5
10.
to increase the average rate of fetching words from the main memory 5
(8)(NOV/DEC2014)
(Refer notes)
Explain in detail about any two standard input and output interfaces C204. BTL5
required to connect the I/O devices to the bus.(NOV/DEC2014) 5
11.
([Link]:-438-452)
Explain mapping functions in cache memory in cache memory to determine C204. BTL5
how memory blocks are placed in cache (Nov/Dec 2014) (Refer notes) 5
12.
Explain the various mapping techniques associated with cache memories C204. BTL5
(MAY/JUNE 2016,MAY/JUN 2018) 5
13.
(Refer notes)
Explain virtual memory and the advantages of using virtual memory C204. BTL5
15. 5
([Link]:-427-252)
PART-B
Bloom’s
Q. No. Questions CO
Level
Explain the basic MIPS implementation with binary multiplexers and C204.3 BTL5
1. .
control lines(16) NOV/DEC 15 ([Link]-251)
What is hazards ?Explain the different types of pipeline hazards with C204.3 BTL5
suitable examples.(NOV/DEC2014,APRIL/MAY2015,MAY/JUNE
2. 2016,NOV/DEC2017) ([Link]-324)
Explain how the instruction pipeline works. What are the various situations C204.3 BTL5
where an instruction pipeline can stall? Illustration with an example?
3. NOV/DEC 2015,NOV/DEC 2016.( [Link]-302)
C204.3 BTL3
10. Why is branch prediction algorithm needed?Differentiate between static
and dynamic techniques?NOV/DEC 2016 .( [Link]-323)
Design a simple path with control implementation and explain in C204.3 BTL6
11.
detail(MAY/JUN 2018) ( [Link]-271)
Discuss the limitation in implementing the processor path. Suggest the C204.3 BTL6
12.
methods to overcome them(NOV/DEC 2018) (Refer notes)
When processor designers consider a possible improvement to the processor C204.3 BTL5
the following three problems, assume that we are starting with a datapath
where I-Mem, Add, Mux, ALU, Regs, D-Mem, and Control blocks have
latencies of 400 ps, 100 ps, 30 ps, 120 ps, 200 ps, 350 ps, and 100 ps,
respectively,and costs of 1000, 30, 10, 100, 200, 2000, and 500,
13. [Link] the addition of a multiplier to the ALU. Th is addition
will add 300 ps to the latency of the ALU and will add a cost of 600 to the
ALU. Th e result will be 5% fewer instructions executed since we will no
longer need to emulate the MUL instruction.
1 What is the clock cycle time with and without this improvement?
(Refer notes)
For the problems in this exercise, assume that there are no pipeline stalls C204.3 BTL3
and that the breakdown of executed instructions is as follows:
circuit needed? What is this circuit doing in cycles in which its input is not
needed? (Refer notes)
9. Question and answer bank.
UNIT 1
The basic properties of Boolean algebra are commutative property, associative Property and
distributive property.
De Morgan suggested two theorems that form important part of Boolean algebra. They are,
1) The complement of a product is equal to the sum of the complements. (AB)' = A' + B
2) The complement of a sum term is equal to the product of the complements. (A + B)' = A'B'
=A' + C' + 1
= 1 [A+ 1 =1]
Duality property states that every algebraic expression deducible from the postulates Of Boolean
algebraremains valid if the operators and identity elements are interchanged. If the dual of an
algebraic expression is desired, we simply interchange OR and AND operators and replace 1's by
0's and 0's by 1's.
5. What is a karnaugh map?
A karnaugh map or k map is a pictorial form of truth table, in which the map diagram is made up
ofsquares, with each squares representing one minterm of the function.
The advantages of the K-map method are It is a fast method for simplifying expression up to four
variables. It gives a visual method of logic simplification. Prime implicants and essential prime
implicants are identified fast. Suitable for both SOP and POS forms of reduction. It is more
suitable for class room teachings on logic simplification. The disadvantages of the K-map
method are
i) Generally it is limited to six variable map (i.e) more then six variable involving expression are
not reduced.
ii) The map method is restricted in its capability since they are useful for simplifying only
Boolean expression represented in standard form
In some logic circuits certain input conditions never occur, therefore the Corresponding output
never appears. In such cases the output level is not defined, it can be either high or low. These
output levels are indicated by ‘X’ or‘d’ in the truth tables and are called don’t care conditions or
incompletely specified functions.
When logic gates are connected together to produce a specified output for certain specified
combinationsof input variables, with no storage involved, the resulting circuit is called
combinational logic.
The problem definition determines the number of available input variables & required O/P
variables. Assigning letter symbols to I/O variables Obtain simplified Boolean expression for
each O/P. Obtain the logic diagram.
The logic circuit that performs the addition of two bits is a half adder. The circuit that performs
the addition of three bits is a full adder
The combinational circuit that performs the addition of two bits is called a half-adder
12. What is a full-adder?
The combinational circuit that performs the addition of three bits is called a half-adder.
The combinational circuit that performs the subtraction of two bits is called a half-subtractor.
The combinational circuit that performs the subtraction of three bits is called a half- subtractor.
A binary parallel adder is a digital function that produces the arithmetic sum of two binary
numbers in parallel.
A decoder is a multiple - input multiple output logic circuit that converts coded inputs into coded
outputswhere the input and output codes are different.
A decoder is a combinational circuit that converts binary information from n input lines to a
maximum of2n out puts lines.
An encoder has 2n input lines and n output lines. In encoder the output lines generate the binary
codecorresponding to the input value.
A priority encoder is an encoder circuit that includes the priority function. In priority encoder, if
2 or more inputs are equal to 1 at the same time, the input having the highest priority will take
precedence.
Multiplexer is a digital switch. If allows digital information from several sources to be routed
onto asingle output line
The sum and carry outputs of any stage cannot be produced until the input carry occurs, this
leads to atime delay in the addition process. This delay is knows as carry propagation delay.
A BCD adder is a circuit that addstwo BCD Digits and produces a sum digit also in BCD
Seven segment displays are used to give a visual indication of the outputs states.
PART B
2. i) Find the maxterms for the expression F=AC’+ABC’+A’BC ii) Convert the given expression
in canonical SOPform Y = AC + AB + BC
3. Simplify the function using Karnaugh map and implement using minimum number of logic
gates .F = (2, 9, 10,12, 13) + D (1, 5, 14) what are the limitations of Karnaugh map.
Y’=A’BC’D’+A’BC’D+ABC’D’+ABC’D+AB’CD+A’B’CD’.
6. Simplify the following Boolean expression in (i) Sum-of-product (ii) Product-of-sum using
Karnaugh-map AC′+B′D+A′CD+ABCD
7. Discuss the need and working principle of Carry Look ahead adder.
8. Draw the circuit of a 3 bit binary subtractor and explain its operation with the help of an
example.
9. Design a full/half adder and half/Full Subtractor circuit using NAND gates only
12. i) Use a 8 x 1 MUX to implement the logic function F=∑m (0,1,2,3,4,10,11,14,15) ii)
F(A,B,C,D)= ∑m(1,3,4,11,12,13,14,15)
13. i) Design a 4-bit Binary to Excess-3 code converter. ii) Design a BCD Adder using two 4-bit
parallel binaryadder blocks and additional logic.
14. i) Design a priority encoder and explain its operation. ii) Implement full adder using suitable
decoder and additional logic.
15. Design a BCD to 7 segment decoder and implement it by using basic gates.
UNIT II
In sequential circuits the output variables dependent not only on the present input variables but
they also depend up on the past history of these input variables.
A Synchronous sequential circuit is a system whose behavior can be defined from the knowledge
of its signal at discrete instants of time.
Latch is a simple memory element, which consists of a pair of logic gates with their inputs and
outputs inter connected in a feedback arrangement, which permits a single bit to be stored.
i RS flip-flop
ii D flip-flop
iii T flip-flop
iv JKflip-flop
The state of a flip-flop is switched by a momentary change in the input signal. This momentary
change is called a trigger and the transition it causes is said to trigger the flip-flop.
During the design process we usually know the transition from present state to next state and
wish to find the flip-flop input conditions that will cause the required transition. A table which
lists the required inputs for a given chance of state is called an excitation table.
Qn Qn+1 R S
00X0
0101
1010
110X
In JK flip-flop output is fed back to the input. Therefore change in the output results change in
the input. Due to this in the positive half of the clock pulse if both J and K are high then output
toggles continuously. This condition is called ‘race around condition’.
11. What is counter?
A counter is used to count pulse and give the output in binary form.
In a synchronous counter, the clock pulse is applied simultaneously to all flip- flops. The output
of the flip-flops change state at the same instant. The speed of operation is high compared to an
asynchronous counter
In an Asynchronous counter, the clock pulse is applied to the first flip-flops. The change of state
in the output of this flip-flop serves as a clock pulse to the next flip-flop and so on. Here all the
flip-flops do not change state at the same instant and hence speed is less.
Synchronous counter:
Clock pulse is applied simultaneously Clock pulse is applied to the first flip-flop,
Asynchronous counter:
i) Up counter ii) Down counter iii) Modulo – N counter iv) Up/Down counter
It is a ring counter in which the inverted output is fed into the input. It is also known as a twisted
ring counter.
The basic unit for storage is flip flop. A flip-flop maintains its output state either at1 or 0 until
directed by an input signal to change its state.
18. What is Shift Register?A register capable of shifting its binary data in one or both
directions is known as a shift register. The logical design of a shift register includes a series of
flip-flops, with the output of one flip-flop linked to the input of the next flip-flop.
Types of Shift Register:
Part B
1. Draw the logic circuits and the excitation tables for the T, JK, RS flip-flops.
ii)Why gatedD latch is called transparent latch? Explain with the logic diagram.
6. i) A sequential circuit with two D flip-flops A and B, one input x and one output z is specified
by the following next-state and output equations: A(t+1)= A′+B, B(t+1)=B′x, z=A+B′ (1) Draw
the logic diagram of the circuit (2) Draw the state table (3) Draw the state diagram of the circuit
ii) Explain the difference between a state table, characteristics table and excitation table.
7. Design three bitsynchronous counter with T flip flop and draw the diagram.
11. Design a binary counter using T flip flopsto count in the following sequences: (i) 000,
001,010, 011, 100, 101, 111, 000 (ii) 000, 100, 111, 010, 011, 000
12. Design a sequential circuit using RS flip flop for the state table with minimum flip flop.
UNIT III
The components of a computer system are Input Devices, Output Devices, Memory, CPU or
processor, Network.
In direct addressing mode, the length of the address field is usually less than the word length,
thus limiting the address range. To overcome this, in indirect addressing the address field refer to
the address of a word in memory, which in turn contains a full- length address of the operand.
IR is the part of a CPU's control unit that holds the instruction currently being executed or
decoded. The output of the IR is available to control circuits which generate the timing signals
that control the various processing elements involved in executing the instruction.
The Instruction Set Architecture (ISA) is the part of the processor that is visible to the
programmer or compiler writer. The ISA serves as the boundary between software and
[Link] ISA of a processor can be described using 5 categories:
Operand location
Operations
The PC-relative addressing mode is used to load a register with a value stored in program
memory which is a short distance away from the current instruction. It can be seen as a special
case of the "base plus offset" addressing mode, one that selects the program counter (PC) as the
"base register". Example: JNZ BACK
The control unit co-ordinates and controls the activities among the functional units. The basic
function of control unit is to fetch the instructions stored in the main memory, identify the
operations, the devices involved in it and generate control signals to execute the desired
operations.
In this scheme, high-order byte is stored on the starting address (A) and low-order byteis stored
on the next address (A + 1).
In this scheme, low-order byte is stored on the starting address (A) and high-order byte is stored
on the next address (A + 1).
Word length is typically a multiple of 8 , CPU word length is 8,16,32 and 64 [Link] case of 32
bit word length natural word boundaries occur at addresses 0,4,8.... Words are said to bealigned
in memory if they begin at the natural word boundaries. The address ofsuch words are called
aligned address.
Operation code is the part of a machine code instruction that defines the operation to be
performed.
An effective address is the value which is used by a fetch or store operation to specify which
memory location is to be accessed by the operation from the perspective of the entity (i.e.
process, thread, interrupt handler, kernel component, etc) issuing the operation.
Machine language is a low-level language made up of binary numbers or bits that a computer can
understand. It is also known as machine code or object code and is extremely tough to
comprehend. The only language that the computer understands is machine language.
Compiler is a software that convertsthe source code to the object code. In other words, we can
say that it converts the high-level language to machine/binary language. Moreover, it is
necessary to perform this step to make the program executable. This is because the computer
understands only binary [Link] compilers convert the high-level language to an
assembly language as an intermediate step. Whereas some others convert it directly to machine
code. This process ofconverting the source code into machine code is called compilation.
1. Explain various instruction formats and illustrate the same with an example.
2. Explain with an example about the operations and operands of the computer hardware
3. Explain in detail the various components of computer system with neat diagram.
following sequenceof instructions and explain the addressing modes used and the operation done
in every instruction..
a. Move (R5)+, R0
b. Add (R5)+, R0
d. Move 16(R5), R3
e. Add #40,R5
UNIT IV
Instruction pipeline
Operation pipeline
Multi-issue pipeline
Fetch
Decode
Execute
Memory Access
Write Back
A datapath is a collection of functional units such as arithmetic logic units or multipliers that
perform dataprocessing operations, registers, and buses. It composes the central processing unit
(CPU) along with the control unit.
The cycle time of the processor is reduced and it increases the instruction throughput. If
pipelining is used, the CPU arithmetic logic unit can be designed faster.
Exceptions are internally generated unscheduled events that disrupt program execution and they
are used to detect overflow. Examples for exception are arithmetic overflow, invoking the
operating system from user program and using an undefined instruction.
Any situation that prevents the next instruction in the instruction stream from executing during
its designated cycle is called a hazard. Various types of hazard are: Structural hazard, Data
hazard and Control hazard.
It is a small memory that is indexed by the lower portion of the address of the branch
instruction.
It contains one or more bits indicating whether the branch was recently taken or not.
9. What are R-Type instructions? (April/May 2015)
10. Name the control signals required to perform arithmetic operations. (April/May 2017)
11. Define data hazard. Give an example for data hazard. (April/May 2017)
Data hazards occur when the pipeline changes the order of read/write accesses to operands so
that the order differs from the order seen by sequentially executing instructions on the un-
pipelined machine.
OR R8, R1, R9
Speculation is the technique which is needed to keep the instruction execution at high rate by
using prediction based on program structure and profile. There are two types of speculated
execution of instructions:
Compiler speculation.
Program counter is a register containing the address of the instruction in the program being
executed.
15. What are the units needed to implement MIPS load and store instructions?
Four units that are needed to implement MIPS load and store instruction are
Register file
ALU
Forwarding method is used to resolve the data hazards. It is also called bypassing.
Forwarding is a method of resolving data hazard by retrieving the missing data element from
internal buffers rather than waiting for it to arrive from registers or memory.
Control hazard or branch hazard can be resolved using branch prediction method.
Branch prediction is a method of resolving a branch hazard that assumes a given outcome for
the branch and proceeds from that assumption rather than waiting to ascertain the actual
outcome.
Branch prediction is a method of resolving a branch hazard that assumes a given outcome for the
branch and proceeds from that assumption rather than waiting to ascertain the actual outcome.
Two branch prediction strategies are:
PART B:
1. 1. Explain in detail the operation of the data path and its control. (Nov/Dec 2017)(Nov/Dec
2014)
2. Explain the pipeline hazard in detail. (Nov/Dec 2017)(May/June 2016) (April/May 2015)
(Nov/Dec 2014)(April/May 2017)
3. Explain the basic MIPS implementation with necessary multiplexer and control lines.
(Nov/Dec 2015)
5. Describe How Control signals are generated using Hardwired and Microprogrammed Control
Unit.
Unit :V
The correspondence between the main memory blocks and those in the cache is specified by
address mapping. There are three commonly used methods to translate main memory addresses
to cache memory addresses. They are:
Direct mapping
Associative mapping
Set-associative mapping
A Cache memory is a small and very fast temporary storage memory. It is designed to speed up
the transfer of data and instructions. It is faster than RAM and the data/instructions that are most
recently or most frequently used by CPU are stored in cache.
In computer architecture, the memory hierarchy separates computer storage into a hierarchy
based on response time. Since response time, complexity, and capacity are related, the levels
may also be distinguished by their performance and controlling technologies.
Virtual memory allows processes whose aggregate memory requirement is greater than the
amount of physical memory, as infrequently used pages can reside on the disk
Virtual memory allows speed gain when only a particular segment of the program is required
for the execution of the program
Flash Memory
Magnetic Disk
6. Point out how DMA can improve I/O speed. (April/May 2015)
DMA allow the peripherals to directly communicate with each other using the memory buses,
removing the intervention of the CPU. During DMA the CPU is idle and it has no control over
the memory buses. So, the DMA controller takes control over the buses to manage the transfer
directly between the I/O devices and the memory unit for improving the speed.
Memory interleaving is the technique used to increase the throughput. The memory system is
split into independent banks, which can answer read or write requests independents in parallel.
There are two- address format for memory interleaving the address space. They are:
Interrupts are disabled by changing the control bits in the Processor Status Register.
The device is informed that its request has been recognized, and in response, it deactivates the
interrupt-request signal.
10. What is the purpose of dirty/modified bit in cache memory? (Nov/Dec 2014)
A dirty bit or modified bit is a bit that is associated with a block of computer memory and
indicates whether or not the corresponding block of memory has been modified. Dirty bits are
used by the CPU cache and in the page replacement algorithms of an operating system.
Virtual memory is a memory management technique that is implemented using both hardware
and software and it uses main memory as a cache for secondary storage. Techniques that
automatically move program and data blocks into the physical main memory when they are
required for execution are called virtual memory techniques.
12. How many total bits are required for a direct mapped cache with 16KB of data and 4-
word blocks, assuming a 32bit address? (Nov/Dec 2017)
No. of cache lines= data memory size of cache /data size of 1 cache line
Size of tag memory = No. of tag bits * No. of lines = 18 * 2 12 bits = 72K
Total memory needed for cache = 128 K bits + 72K bits = 200Kbits
The hit ratio is the fraction of accesses which are a hit. The miss ratio is the fraction of accesses
which are a miss. It holds that miss rate = 1 − hit rate. The (hit/miss) latency (also known as
access time) is the time it takes to fetch the data in case of a hit/miss.
The fraction of memory accesses found in a level of the memory hierarchy is called hit rate. The
fraction of memory accesses not found in a level of the memory hierarchy is called miss rate.
Translation Look-aside Buffer (TLB) is a cache that keeps track of recently used address
mapping which tries to avoid an access to the page table.
Reducing the miss rate by reducing the probability that two different memory blocks will
content for the same cache location.
Interrupt is a process that causes a CPU to temporarily transfer control from its current program
to another program. It improves the computer’s IO performance.
PART: B
1. What is cache memory? Discuss Mapping and Replacement Algorithms in detail. (Nov/Dec
2017)(May/June 2016)(Nov/Dec 2014)(April/May 2017)
3. Discuss the steps involved in the address translation of virtual memory with necessary block
diagram. (Nov/Dec 2016)(Nov/Dec 2015)(April/May 2015)(April/May 2017)
2 310823243002 ABINAYAA V 53 52 30 10 10 9 10 10 10 10 10
3 310823243003 ADITHYA R 42 42 32 10 10 0 10 10 10 10 10
4 310823243004 AFREEN R 11 30 34 0 0 0 0 10 10 10 10
8 310823243009 ARUNADEVI S 43 0 44 10 10 9 10 10 10 10 10
9 310823243010 ASMITHA C 30 30 31 10 10 8 10 10 10 10 10
10 310823243011 ATHITHYAN R 16 32 0 0 0 0 10 10 10 10 10
13 310823243014 DEEPIKA M 40 50 34 10 0 9 0 10 10 10 10
14 310823243015 DHARSHINI R 50 54 42 10 10 10 10 10 10 10 10
15 310823243016 DHIVYADHARSHINI J 57 32 40 10 10 9 10 10 10 10 10
18 310823243019 GOWTHAM M 30 41 0 10 10 0 10 10 10 10 10
20 310823243021 HARINI V 53 43 42 10 10 10 10 10 10 10 10
21 310823243022 JOHN VIMAL J 32 25 41 10 0 0 0 10 10 10 10
23 310823243024 JOSHUA S 18 33 14 0 0 0 10 10 10 10 10
25 310823243026 KAVIYARASAN PL 34 30 22 10 10 6 0 10 10 10 10
26 310823243027 KEERTANA T S 40 56 37 10 10 10 10 10 10 10 10
27 310823243028 KEERTHIKA R 50 56 31 10 10 10 10 10 10 10 10
28 310823243029 MATHAVAN V 46 36 26 10 10 10 10 10 10 10 10
29 310823243030 MEEDHUN S 12 4 31 0 0 0 0 10 10 10 10
33 310823243034 PRADHIKSHA E 50 42 34 10 10 10 10 10 10 10 10
34 310823243035 PRATHICSHAA G 54 52 31 10 10 10 10 10 10 10 10
35 310823243036 RAGUL D M 0 3 19 0 0 7 5 10 10 10 10
36 310823243037 RITHIKA V 24 46 38 10 10 0 10 10 10 10 10
37 310823243038 SAKTHI G 21 8 11 0 0 5 5 10 10 10 10
39 310823243040 SANDHIYA C 54 56 49 10 10 9 10 10 10 10 10
40 310823243041 SANJANA J 47 51 48 10 0 9 10 10 10 10 10
41 310823243042 SANJAY B 0 10 10 0 0 0 0 10 10 10 10
42 310823243043 SANJAY K 10 32 18 10 0 0 5 10 10 10 10
44 310823243045 SANTHOSH S 0 0 13 0 0 0 5 10 10 10 10
45 310823243046 SERLIN RIYANSA M 15 54 21 10 10 8 10 10 10 10 10
46 310823243047 SHALINI V 54 52 49 10 10 10 10 10 10 10 10
48 310823243049 SHARUN P 11 0 4 0 10 3 0 10 10 10 10
49 310823243050 SINDHUJA P 0 56 52 10 0 9 10 10 10 10 10
50 310823243051 SREENIDHI S 0 45 35 10 10 10 10 10 10 10 10
51 310823243052 SRINA S 60 57 55 10 10 9 0 10 10 10 10
53 310823243054 STALIN Z A 31 54 26 10 0 7 10 10 10 10 10
54 310823243055 SUKITHA R 46 54 37 10 10 0 10 10 10 10 10
56 310823243057 UDHAYAKUMAR A 31 0 12 0 0 6 10 10 10 10 10
57 310823243058 VISHVA V 0 30 31 10 0 5 10 10 10 10 10
58 310823243059 YUVASRI V 48 50 33 5 10 10 10 10 10 10 10
59 310823243301 KAMALESHWARAN M 37 34 25 10 10 5 10 10 10 10 10
21. CO PO attainment analysis report.
22. Topics covered beyond syllabus.
23. Design of experiments if any
24. Projects done if any.
25. Industry visits arranged related to the subject if any
26. Guest Lectures arranged on the subject if any.
27. University Question paper
28. Feedback on university Question paper
29. University Result
30. Copy of log book duly signed by authorities.