Show description
Microprocessor Mastery
Microprocessor Mastery
The Complete Microprocessor
Architecture, Logic, and Troubleshooting Review
1. The Ecosystem: How Files Connect
In this lab, you moved between visual design (Digital) and hardware description code (Verilog). Understanding how these files talk to each other is crucial.
.dig File
(Visual Schematic)
➡
microprocessor.v
(Hardware Code)
+
micro_stim.v
(The Test Bench)
rom_vals.hex
(The Dictionary)
↘
iverilog / vvp
(The Compiler)
↙
ram_vals.txt
(The Script/Program)
Key Takeaways:
Digital is the Generator: When you click "Export," Digital overwrites microprocessor.v. Any manual hacks in the code are lost unless you update the .dig file.
Hardcoded vs. Dynamic: ROM values are baked into the chip (hardcoded in .v). RAM values are read dynamically at startup ($readmemh).
2. Component Glossary
The microprocessor is built of three main subsystems. Here is what every part does.
The Address Generator (The Navigator)
PC (Program Counter)
Holds the address of the next instruction. It usually counts up by 1 (0, 1, 2...) to step through your program sequentially.
MAR (Memory Address Register)
Holds a specific address we want to look at. Unlike the PC (which just counts), the MAR can hold any random address (e.g., 9) to save or retrieve data.
Mux (Multiplexer)
The "Traffic Cop." It decides which address goes to Memory: the PC (for instructions) or the MAR (for data).
The Controller (The Brain)
IR (Instruction Register)
Holds the current command (Opcode) being executed (e.g., "STORE" or "ADD"). It tells the ROM what row to look at.
Step Register
Counts the micro-steps inside a single instruction. (e.g., Step 0: Fetch, Step 1: Execute).
ROM (Read-Only Memory)
The "Lookup Table." It takes the Instruction + Step and outputs a 14-bit binary code that controls every wire in the machine.
The Datapath / Brainless CPU (The Muscle)
ALU (Arithmetic Logic Unit)
The calculator. It performs math (ADD, SUB) and logic (AND) on the data.
Accumulator
The "Short-term Memory." It holds the result of the last calculation.
RAM (Random Access Memory)
The "Long-term Memory." It stores your program instructions AND your data variables.
3.…
Microprocessor Mastery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Microprocessor Mastery</title>
<style>
:root {
--bg-color: #e3f2fd; /* Light Blue */
--card-bg: #ffffff;
--text-color: #212121; /* Black/Dark Grey */
--accent-color: #f57c00; /* Orange */
--highlight-blue: #bbdefb;
--code-bg: #263238;
--code-text: #eceff1;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
margin: 0;
padding: 0;
line-height: 1.6;
}
header {
background-color: var(--accent-color);
color: white;
padding: 2rem;
text-align: center;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
h1 { margin: 0; font-size: 2.5rem; }
h2 { color: var(--accent-color); border-bottom: 2px solid var(--accent-color); padding-bottom: 0.5rem; margin-top: 2rem;}
h3 { color: #333; }
.container {
max-width: 1000px;
margin: 2rem auto;
padding: 0 1rem;
}
.card {
background: var(--card-bg);
border-radius: 8px;
padding: 2rem;
margin-bottom: 2rem;
box-shadow: 0 2px 5px rgba(0,0,0,0.05);
border-left: 5px solid var(--accent-color);
}
/* File Relationship Diagram Styling */
.flow-container {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
align-items: center;
margin: 2rem 0;
}
.file-box {
background-color: var(--highlight-blue);
border: 2px solid var(--accent-color);
padding: 1rem;
border-radius: 8px;
font-weight: bold;
text-align: center;
width: 180px;
}
.arrow {
font-size: 2rem;
color: var(--accent-color);
}
/* Glossary Styling */
.glossary-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 1.5rem;
}
.term-card {
border: 1px solid #ddd;
padding: 1rem;
border-radius: 6px;
background-color: #fafafa;
}
.term-title {
color: var(--accent-color);
font-weight: bold;
font-size: 1.1rem;
margin-bottom: 0.5rem;
display: block;
}
code {
background-color: #eee;
padding: 2px 5px;
border-radius: 4px;
font-family: monospace;
color: #d84315;
}
.debugging-section {
background-color: #fff3e0; /* Very light orange */
border-left-color: #d84315;
}
footer {
text-align: center;
padding: 2rem;
background-color: #333;
color: white;
margin-top: 3rem;
}
</style>
</head>
<body>
<header>
<h1>The Complete Microprocessor</h1>
<p>Architecture, Logic, and Troubleshooting Review</p>
</header>
<div class="container">
<div class="card">
<h2>1. The Ecosystem: How Files Connect</h2>
<p>In this lab, you moved between visual design (Digital) and hardware description code (Verilog). Understanding how these files talk to each other is crucial.</p>
<div class="flow-container">
<div class="file-box">
.dig File<br>
<span style="font-size:0.8em; font-weight:normal;">(Visual Schematic)</span>
</div>
<div class="arrow">➡</div>
<div class="file-box">
microprocessor.v<br>
<span style="font-size:0.8em; font-weight:normal;">(Hardware Code)</span>
</div>
<div class="arrow">+</div>
<div class="file-box">
micro_stim.v<br>
<span style="font-size:0.8em; font-weight:normal;">(The Test Bench)</span>
</div>
</div>
<div class="flow-container">
<div class="file-box">
rom_vals.hex<br>
<span style="font-size:0.8em; font-weight:normal;">(The Dictionary)</span>
</div>
<div class="arrow">↘</div>
<div class="file-box">
iverilog / vvp<br>
<span style="font-size:0.8em; font-weight:normal;">(The Compiler)</span>
</div>
<div class="arrow">↙</div>
<div class="file-box">
ram_vals.txt<br>
<span style="font-size:0.8em; font-weight:normal;">(The Script/Program)</span>
</div>
</div>
<h3>Key Takeaways:</h3>
<ul>
<li><strong>Digital is the Generator:</strong> When you click "Export," Digital overwrites <code>microprocessor.v</code>. Any manual hacks in the code are lost unless you update the .dig file.</li>
<li><strong>Hardcoded vs. Dynamic:</strong> ROM values are baked <em>into</em> the chip (hardcoded in .v). RAM values are read <em>dynamically</em> at startup ($readmemh).</li>
</ul>
</div>
<div class="card">
<h2>2. Component Glossary</h2>
<p>The microprocessor is built of three main subsystems. Here is what every part does.</p>
<h3>The Address Generator (The Navigator)</h3>
<div class="glossary-grid">
<div class="term-card">
<span class="term-title">PC (Program Counter)</span>
Holds the address of the <em>next</em> instruction. It usually counts up by 1 (0, 1, 2...) to step through your program sequentially.
</div>
<div class="term-card">
<span class="term-title">MAR (Memory Address Register)</span>
Holds a specific address we want to look at. Unlike the PC (which just counts), the MAR can hold any random address (e.g., 9) to save or retrieve data.
</div>
<div class="term-card">
<span class="term-title">Mux (Multiplexer)</span>
The "Traffic Cop." It decides which address goes to Memory: the PC (for instructions) or the MAR (for data).
</div>
</div>
<h3>The Controller (The Brain)</h3>
<div class="glossary-grid">
<div class="term-card">
<span class="term-title">IR (Instruction Register)</span>
Holds the current command (Opcode) being executed (e.g., "STORE" or "ADD"). It tells the ROM what row to look at.
</div>
<div class="term-card">
<span class="term-title">Step Register</span>
Counts the micro-steps inside a single instruction. (e.g., Step 0: Fetch, Step 1: Execute).
</div>
<div class="term-card">
<span class="term-title">ROM (Read-Only Memory)</span>
The "Lookup Table." It takes the Instruction + Step and outputs a 14-bit binary code that controls every wire in the machine.
</div>
</div>
<h3>The Datapath / Brainless CPU (The Muscle)</h3>
<div class="glossary-grid">
<div class="term-card">
<span class="term-title">ALU (Arithmetic Logic Unit)</span>
The calculator. It performs math (ADD, SUB) and logic (AND) on the data.
</div>
<div class="term-card">
<span class="term-title">Accumulator</span>
The "Short-term Memory." It holds the result of the last calculation.
</div>
<div class="term-card">
<span class="term-title">RAM (Random Access Memory)</span>
The "Long-term Memory." It stores your program instructions AND your data variables.
</div>
</div>
</div>
<div class="card">
<h2>3. Key Logic Concepts</h2>
<h3>Microcode (The "Puppet Strings")</h3>
<p>You learned that a single assembly instruction (like <code>STORE</code>) is actually a sequence of smaller hardware events.</p>
<ul>
<li><strong>Fetch (Step 0):</strong> The CPU reads RAM to find out what to do.</li>
<li><strong>Execute (Step 1+):</strong> The ROM turns on specific wires (like <code>load_mar</code> or <code>arith</code>) to move data around.</li>
</ul>
<h3>Control Signals</h3>
<p>The 14-bit HEX codes (e.g., <code>0098</code>) you wrote are just compressed switches:</p>
<ul>
<li><code>arith=1</code>: Tell ALU to add.</li>
<li><code>load_acc=1</code>: Open the door to the Accumulator.</li>
<li><code>write=1</code>: Tell RAM to save the data on the bus.</li>
</ul>
</div>
<div class="card debugging-section">
<h2>4. Debugging Lessons Learned</h2>
<p>The real learning happened when things broke. Here is what you solved:</p>
<h3>Problem: The Infinite Loop</h3>
<p><strong>Symptom:</strong> The <code>write</code> signal never turned on. The simulation stalled.<br>
<strong>Cause:</strong> The ROM code for STORE (Step 1) told the controller to go to "Step 1" next. This created a circle.<br>
<strong>Solution:</strong> Changing the hex from <code>1304</code> to <code>2304</code> changed the "Next Step" bits to 2, allowing the program to advance.</p>
<h3>Problem: Red Waveforms</h3>
<p><strong>Symptom:</strong> Red lines in GTKWave.<br>
<strong>Cause:</strong> The hardware expected 16 lines of RAM, but the text file only had 12. The simulator filled the gap with "Undefined" (X).<br>
<strong>Solution:</strong> Padding the text file with zeros matched the hardware expectation.</p>
<h3>Problem: The "Safe" Zero</h3>
<p><strong>Lesson:</strong> Originally, ZERO was done by subtraction. This was risky because it relied on external inputs. We changed it to <code>0010</code> which performs an <strong>AND with 0</strong>. This is a robust engineering choice: ensure the result is 0 regardless of external noise.</p>
</div>
</div>
<footer>
<p>You Are Now Prepared</p>
</footer>
</body>
</html>