Which technique handles control hazards by predicting the outcome before it's resolved?
A. Speculative execution
B. Delayed branching
C. Forwarding
D. Scoreboarding
Assistant
The correct answer is: A. Speculative execution
Explanation:
Control hazards (also known as branch hazards) occur when the processor doesn't know which instruction to fetch next because it's waiting to determine the outcome of a branch (e.g., an if or goto statement in programming).
Here’s how the techniques relate to control hazards:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
A. Speculative execution:
This technique predicts the outcome of a branch before it's actually resolved. The processor continues to execute instructions along the predicted path. If the prediction is correct, time is saved; if it’s incorrect, speculatively executed instructions are discarded. 💡 This directly handles control hazards.
B. Delayed branching:
Reorders instructions to fill the delay slot after a branch but doesn't predict branch outcomes. It mitigates but does not predict.
C. Forwarding (or bypassing):
Used to resolve data hazards, not control hazards.
D. Scoreboarding:
A technique to dynamically schedule instructions to handle structural and data hazards, not control hazards.
✅ Correct Answer: A. Speculative execution
User
Which logic circuit is used to implement decision-making operations in a CPU?
A. Decoder
B. Multiplexer
C. ALU
D. Control Unit
Assistant
The correct answer is: C. ALU
🚀 Explanation:
Decision-making operations in a CPU typically involve comparing values and determining outcomes based on conditions (e.g., is one number greater than another, are two numbers equal, etc.). These operations are a key function of the:
Example: Determining if A > B, A == B — these are decision-making tasks handled by the ALU.
These decisions often set condition flags (e.g., Zero, Negative, Carry) used for branching decisions.
❌ Incorrect Options:
A. Decoder: Converts binary input into one of many outputs; used for instruction decoding or memory access—not decision-making.
B. Multiplexer: Selects one of several input signals based on control signals; it's a data routing circuit, not used directly for decision-making.
D. Control Unit: Directs the operation of the processor (fetch, decode, execute), but it does not perform the actual decision-making—it uses results from the ALU to make control flow decisions.
✅ Final Answer: C. ALU
User
The number of bits used to represent an instruction is called:
A. Instruction length
B. Opcode
C. Operand
D. Instruction cycle
Assistant
The correct answer is: A. Instruction length
✅ Explanation:
Instruction length refers to the number of bits used to represent a full machine instruction in a computer’s instruction set architecture (ISA).
It determines how much information an instruction can contain, including:
The opcode
The operands
Any addressing mode information
❌ Let’s look at the incorrect options:
B. Opcode:
This is the part of the instruction that specifies the operation to perform (like ADD, LOAD, JUMP), but not the total size of the instruction.
C. Operand:
This is the data (or the reference to data) that the instruction uses — again, it's a part of the instruction, not its total length.
D. Instruction cycle:
Refers to the process of fetching, decoding, and executing an instruction — it's not related to the bit length of the instruction.
✅ Final Answer: A. Instruction length
User
A DMA controller has burst mode and cycle-stealing mode. Which of the following is true about burst mode?
A. CPU accesses memory during transfer
B. DMA transfers one byte per CPU cycle
C. DMA locks the bus for multiple transfers
D. DMA interrupts CPU after each byte
Assistant
The correct answer is: C. DMA locks the bus for multiple transfers
✅ Explanation:
Burst mode in Direct Memory Access (DMA) allows the DMA controller to take control of the system bus and transfer a block of data (multiple bytes or words) in one continuous burst without releasing the bus back to the CPU after each byte or word.
In this mode, the CPU is temporarily halted, as the DMA "locks" the bus to transfer data as quickly and efficiently as possible.
Let’s analyze each option:
A. CPU accesses memory during transfer
❌ Incorrect — In burst mode, the CPU cannot access memory during the DMA transfer because the DMA holds the bus exclusively.
B. DMA transfers one byte per CPU cycle
❌ Incorrect — That describes cycle-stealing mode more closely, where the DMA takes control of the bus one cycle at a time, usually for transferring a single byte or word.
C. DMA locks the bus for multiple transfers
✅ Correct — This is exactly how burst mode works, allowing fast data transfer at the expense of CPU access.
D. DMA interrupts CPU after each byte
❌ Incorrect — While DMA can interrupt the CPU, it does not do so after each byte in burst mode. It typically only raises an interrupt after the entire block transfer is complete.
✅ Final Answer: C. DMA locks the bus for multiple transfers
User
A pipeline has five stages: IF, ID, EX, MEM, WB. An instruction sequence includes a data dependency between a LOAD and a following ADD. Which kind of hazard will this cause?
A. Structural hazard
B. Control hazard
C. Data hazard - RAW
D. Data hazard - WAW
Assistant
The correct answer is: C. Data hazard - RAW (Read After Write)
✅ Explanation:
You are given a 5-stage instruction pipeline:
IF – Instruction Fetch
ID – Instruction Decode / Operand Fetch
EX – Execute
MEM – Memory Access
WB – Write Back
📌 Situation:
A LOAD instruction is followed by an ADD instruction.
The ADD uses the result loaded by the previous LOAD.
Example:
assembly
LOAD R1, 0(R2) ; Load value from memory into R1
ADD R3, R1, R4 ; Use R1 value to perform addition
Here:
The ADD reads from register R1, which is yet to be written by the LOAD.
This creates a Read After Write (RAW) dependency — the most common data hazard.
🔍 Breakdown of the Hazard:
The LOAD writes to R1 during the WB stage (5th stage).
The ADD reads R1 during the ID stage (2nd stage).
Therefore, if ADD starts immediately after LOAD, it will read a stale value — causing a RAW data hazard.
❌ Incorrect Options:
A. Structural hazard: Happens when hardware resources are insufficient (e.g. 1 memory unit shared by instructions); not the case here.
B. Control hazard: Caused by branches or jumps — not relevant here.
D. Data hazard - WAW (Write After Write): Occurs when two instructions write to the same register, and the second writes before the first — not the case here.
✅ Final Answer: C. Data hazard - RAW (Read After Write)
User
Which of the following is true about vectored interrupts?
A. Fixed ISR for all devices
B. ISR determined by polling
C. ISR address provided by device
D. Requires DMA
Assistant
The correct answer is: C. ISR address provided by device
✅ Explanation:
Vectored interrupts are a type of interrupt handling technique where:
The interrupting device provides the address of the Interrupt Service Routine (ISR) directly to the processor.
This allows faster interrupt handling because the processor can immediately jump to the correct ISR without needing to poll devices or use fixed addresses.
❌ Let's examine the incorrect options:
A. Fixed ISR for all devices
❌ Incorrect — This describes non-vectored interrupts, where all devices share a common ISR entry point.
B. ISR determined by polling
❌ Incorrect — Polling interrupts involve the CPU checking each device one by one to identify the source. Vectored interrupts bypass polling by having the device specify the ISR address.
D. Requires DMA
❌ Incorrect — DMA (Direct Memory Access) is unrelated to vectored interrupts. They handle data transfer, not interrupt vectoring.
✅ Final Answer: C. ISR address provided by device
User
A program has 50% data hazards that each cause 2 stall cycles, and 10% branches with a 40% misprediction rate (each misprediction flushes 3 instructions). For a program of 1000 instructions, how many total stall cycles occur?
A. 500
B. 600
C. 640
D. 700
Assistant
To solve this, we'll calculate the total stall cycles caused by:
Data hazards
Branch mispredictions
🔹 Given:
Program size = 1000 instructions
50% data hazards, each causes 2 stall cycles
10% branches, with 40% misprediction rate
Each misprediction flushes 3 instructions (⇒ counts as 3 stall cycles per misprediction)
Total stall cycles = Data hazard stalls + Branch misprediction stalls
= 1000 + 120
= 1120
Wait! But the question asks:
How many total stall cycles occur?
But the options are:
A. 500
B. 600
C. 640
D. 700
Hmm... our total is 1120 stall cycles, but that's not one of the options.
Let’s re-read the question carefully.
A program has 50% data hazards that each cause 2 stall cycles,
and 10% branches with a 40% misprediction rate (each misprediction flushes 3 instructions).
For a program of 1000 instructions, how many total stall cycles occur?
User
Which of the following hazards cannot be resolved using forwarding (bypassing) alone?
A. RAW
B. WAR
C. WAW
D. Control hazards
Assistant
The correct answer is: D. Control hazards
✅ Explanation:
Let's break each option down in the context of pipeline hazards and forwarding (bypassing):
🔹 What is Forwarding (Bypassing)?
Forwarding is a hardware technique used to resolve data hazards—specifically when an instruction needs the result of a previous instruction that hasn’t yet written it back to the register file, but has computed it (e.g., in the EX or MEM stage). Forwarding allows the result to be directly passed between stages instead of waiting.
Now, examine each option:
A. RAW (Read After Write)
Type: Data hazard
Occurs when: An instruction tries to read a value before a previous instruction writes it
🔄 Can be resolved with forwarding ✅
Example:
code
ADD R1, R2, R3
SUB R4, R1, R5 ; Depends on result of previous ADD
Without forwarding → stall
With forwarding → R1’s value is sent directly from execution pipeline
B. WAR (Write After Read)
Type: Name dependency hazard, typically in out-of-order execution
Occurs when: A later instruction writes to a register before an earlier instruction has read it
❌ Forwarding can't help here
⚠️ Usually not present in basic instruction pipelines that execute in order
Requires special techniques like register renaming in out-of-order processors
C. WAW (Write After Write)
Type: Name dependency hazard (again, in out-of-order scenarios)
Occurs when: Two instructions write to the same register and incorrectly swap their order
❌ Forwarding can’t fix this
Needs mechanisms like register renaming
D. Control hazards
Type: Arises from branch instructions
Occurs when: The next instruction address is unknown due to a conditional or unconditional branch
❌ Forwarding cannot resolve control hazards
Requires:
Branch prediction
Delayed branching
Branch target buffers, etc.
✅ Final Answer: D. Control hazards
Because forwarding only helps with data hazards, specifically RAW, and control hazards involve program flow—not data—it cannot be resolved by forwarding.
User
In a daisy-chaining priority scheme for handling multiple interrupt requests, which of the following is true?
A. All devices have equal priority
B. The device nearest to the CPU has the lowest priority
C. The CPU selects the highest-priority device by polling
D. The interrupt acknowledge signal is propagated serially through devices
Assistant
The correct answer is: D. The interrupt acknowledge signal is propagated serially through devices
✅ Explanation:
In a daisy-chaining priority scheme for interrupt handling, multiple devices are connected in series (a chain). When multiple devices raise interrupt requests simultaneously, the system must decide which device gets serviced first.
🔹 What actually happens in daisy-chaining:
All devices share a common interrupt request line to the CPU.
When an interrupt occurs, the CPU sends an interrupt acknowledge (INTA) signal.
This INTA signal is passed serially from one device to the next in the chain.
The first device in the chain that has raised a request captures the acknowledge signal and responds.
Devices further down the chain only see the acknowledge signal if earlier devices pass it on, i.e., they don’t have an active interrupt.
👉 Therefore, in this scheme:
Devices nearer to the CPU (earlier in the chain) have higher priority.
The INTA signal travels serially through devices until it is claimed or reaches the end.
❌ Incorrect Options:
A. All devices have equal priority
❌ Wrong — Daisy-chaining explicitly introduces priority based on position in the chain.
B. The device nearest to the CPU has the lowest priority
❌ Opposite of correct — it's the highest priority.
C. The CPU selects the highest-priority device by polling
❌ Wrong — there’s no software or hardware polling by the CPU in this approach. Priority is determined by physical position in the chain.
✅ Final Answer: D. The interrupt acknowledge signal is propagated serially through devices
User
Which mapping technique requires the most comparator hardware for tag checking?
A. Direct mapped
B. Fully associative
C. Set-associative (2-way)
D. Set-associative (4-way
Assistant
The correct answer is: B. Fully associative
✅ Explanation:
To understand this, let's quickly review the types of cache mapping techniques and their tag comparison requirements.
🔹 1. Direct Mapped Cache
Each block of memory maps to exactly one cache line.
So, when searching for a block, only one tag needs to be compared.
✅ Requires only 1 comparator.
✅ Least hardware complexity.
🔹 2. Set-Associative Cache (2-way, 4-way, etc.)
Memory blocks map to a set (not a single line), and each set has multiple lines (ways).
For:
2-way set-associative: you need 2 comparators.
4-way set-associative: you need 4 comparators.
Each tag in the set must be simultaneously compared.
🔹 3. Fully Associative Cache
A memory block can be placed anywhere in the cache — not restricted to a set or line.
Therefore, every single cache line must be checked simultaneously.
This means:
You need one comparator per cache line.
If the cache has N lines, you'll need N comparators.
❗️ Requires the most comparator hardware of all techniques.
✅ Summary of comparator requirements:
Cache Type
Number of Comparators
Direct Mapped
1
2-way Set-Associative
2
4-way Set-Associative
4
Fully Associative
N (one for each line)
✅ Correct Answer: B. Fully associative
User
What is the tag size for a 64KB cache with 64B blocks and 4-way associativity in a 32-bit address
system?
A. 20 bits
B. 16 bits
C. 18 bits
D. 22 bits
Assistant
To find the tag size in a cache system, we need to analyze how a 32-bit memory address is divided into three components in a set-associative cache:
This is the number of bits used in the address to represent the tag field in this cache configuration.
User
In a 3-address instruction format, which of the following is true about instruction size and hardware complexity?
A. Smaller instruction size, simpler hardware
B. Larger instruction size, reduced execution time
C. Larger instruction size, increased memory utilization
D. Simplified control logic with fewer operands
Assistant
The correct answer is: B. Larger instruction size, reduced execution time
✅ Explanation:
In a 3-address instruction format, each instruction explicitly specifies:
Two source operands
One destination operand
📌 Example:
assembly
ADD R1, R2, R3 ; R1 = R2 + R3
This means the instruction tells the CPU:
Use R2 and R3 as input
Store the result in R1
🔍 Implications of this format:
🔸 Instruction size:
Each operand (e.g., register) must be encoded in the instruction.
More operands → more bits to represent them → larger instruction size.
🔸 Execution time and performance:
Since all operands are specified directly:
No need for implied operands or multiple instructions to fetch operands.
Reduces the number of instructions required to perform an operation.
Leads to faster execution time because fewer instructions are needed.
🔸 Hardware complexity:
Slightly increased, because more operands have to be decoded.
But modern CPUs are optimized for such decoding.
🔸 Memory utilization:
Larger instructions = more memory per instruction,
But possibly fewer instructions needed in total.
✅ Why B. Larger instruction size, reduced execution time is correct:
It accurately captures the trade-off in 3-address formats:
More bits per instruction (larger size),
But fewer total instructions needed to perform tasks,
Resulting in better performance and reduced execution time overall.
❌ Incorrect options:
A. Smaller instruction size, simpler hardware
→ Opposite is true: 3-address format has larger instruction size.
C. Larger instruction size, increased memory utilization
→ Only partially true — but doesn't reflect the performance benefit, which is more relevant here.
D. Simplified control logic with fewer operands
→ Incorrect — 3-address format has more operands, and the control logic must handle them.
✅ Final Answer: B. Larger instruction size, reduced execution time
User
A basic CPU uses the following instruction: ADD R1, R2. If the CPU has a single ALU and one accumulator,
what is a valid sequence of micro-operations?
A. AC R1, R2 AC + R2
B. AC R1, AC AC R2, R1 AC
C. R1 R1 + R2, AC R1
D. R2 R1 + R2, AC R2
Assistant
The correct answer is: D. R2 → AC; R1 + R2 → AC
Let’s break this down step by step.
🧠 Understanding the Scenario
Instruction:ADD R1, R2
This format likely implies: Add the contents of R2 to R1 (i.e., R1 = R1 + R2)
CPU Type:
Has a single ALU
Has one accumulator (AC) — used as central operand for arithmetic operations
Since there's only one accumulator, all arithmetic operations must go through it.
🔬 Required Micro-operation Sequence
We want to implement:
[
\text{R1} = \text{R1} + \text{R2}
]
With these limitations:
Data must flow through the accumulator (AC) to perform the addition
ALU uses AC and one operand to compute the result
Then result can be stored back into R1
✅ Valid sequence (Option D):
Let's interpret what D is specifying:
code
R2 → AC; R1 + R2 → AC
Load R2 into AC:
[
AC \leftarrow R2
]
Add R1 to AC (which contains R2):
[
AC \leftarrow R1 + AC = R1 + R2
]
At this point, AC has R1 + R2, the correct result.
✅ Now we can store it back to R1 (not explicitly mentioned, but implied):
[
R1 \leftarrow AC
]
So the full sequence would be:
AC ← R2
AC ← R1 + AC → this is R1 + R2
R1 ← AC (to write the result back)
❌ Why other options are incorrect:
A. AC R1, R2 AC + R2
❌ Unclear syntax, and assumes ALU operates directly on R1 & R2 without AC.
B. AC R1, AC AC R2, R1 AC
❌ Unclear and disorganized; repeating AC assignments doesn't reflect a valid ALU op.
C. R1 R1 + R2, AC R1
❌ Implies R1 can be an ALU operand directly, which isn't allowed with only one accumulator.
✅ Final Answer: D. R2 → AC; R1 + R2 → AC
🔍 A-ha! Key insight:
Loading or flushing instructions removes instructions from the original 1000, so perhaps stall cycles should be computed based on stalls added, not total flushed or inserted.
But no — that doesn’t reduce the stall cycles. Stalls are extra cycles, the processor takes in addition to instruction execution. So our earlier calculations for stall cycles are valid.
➡️ However, the discrepancy must be due to a different interpretation:
Maybe the data hazards and mispredictions aren’t overlapping?
Wait — Let's reread carefully again.
The question says:
A program has 50% data hazards that each cause 2 stall cycles, and10% branches with a 40% misprediction rate (each misprediction flushes 3 instructions).
So:
50% of instructions (500 instructions) cause 2 stalls each ⇒ 500 × 2 = 1000 stalls
10% of instructions are branches = 100 instructions
40 of them mispredicted ⇒ 40 × 3 = 120 stalls
👉 This adds up to:
code
Total stall cycles = 1000 (from data hazards) + 120 (from mispredictions) = 1120
So again, correct calculation = 1120 stall cycles, but that's not among the answer options.
Now look again — maybe we misread "50% data hazards".
🔁 Wait — The phrasing says:
"A program has 50% data hazards that each cause 2 stall cycles"
Does this mean:
50% of all instructions are affected by data hazards?
Or does it mean: 50% of the total instructions are involved, but not every one causes a hazard?
🥇 Best interpretation matching the answer options:
Assume:
50% of instructions = 500 instructions are involved in data hazards
⇒ But only those 500 cause stalls (each 2 cycles)
→ So: 500 × 2 = 1000 stall cycles
BUT — let's consider that maybe the stalls caused by data hazards mean "50% of instructions have a data hazard", but only those that depend on previous ones — maybe the number of actual hazards is 25% (half of the 50%)? Could be a trap in wording.
🟨 Alternative interpretation:
What if:
Of the 1000 instructions, 50% have a data hazard, and these are the ones that require 2 stall cycles
So, total data hazard stalls = 0.50 × 1000 × 2 = 1000
Branches: 10% → 100 branch instructions
40% mispredicted → 100 × 0.40 = 40 mispredicted
Each misprediction = 3 stalls ⇒ 40 × 3 = 120
Again, Total = 1120
Still not matching options.
🟥 Conclusion: The correct number of stall cycles is 1120, but your options only go up to 700.
This strongly suggests either a typo in the options, or the intent is different.
BUT:
💡 What if the question isn't asking for stall cycles, but number of pipeline stalls (i.e., bubbles) — and flushing 3 instructions is not equal to 3 stall cycles?
According to common interpretation:
A branch misprediction that flushes 3 instructions reflects a pipeline with 3 stages affected — **equivalent to 3 **cycles lost.
So flushing 3 ≈ 3 stall cycles.
Therefore:
✅Final reaffirmed answer: 1120 stall cycles
But since none of the choices match, likely the question wants one of:
Data hazard: 50% of instructions are dependent on previous ones ⇒ 500 instructions
Each causes 1 stall instead of 2 — are we using 1 stall?
🔄 Try assuming each data hazard causes 1 stall, not 2:
50% × 1000 = 500 hazards × 1 stall = 500
Mispredictions = 100 × 0.40 = 40 ⇒ 40 × 3 = 120
➡️ Total = 500 + 120 = 620 — still not in the options.
🔄 Assumption: Only 50% of LOADs cause 2 stalls?
Wait — question says:
"An instruction sequence includes a data dependency between a LOAD and a following ADD."
This means only LOAD-to-use dependencies cause stall cycles.
Maybe of 1000 instructions:
Only 20% are LOADS, and 50% of those are followed by dependent ADDs
⇒ Not enough info
✅ Final Summary
With the exact data given:
1000 instructions
50% data hazards, each causes 2 stall cycles
→ 500 × 2 = 1000