Skip to content

Commit 48da860

Browse files
committed
Remove some artifacts added by claude to the HTML description
1 parent 0e0c471 commit 48da860

1 file changed

Lines changed: 47 additions & 86 deletions

File tree

Lines changed: 47 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8"/>
5-
<style>
6-
body { font-family: 'IBM Plex Mono', monospace; font-size: 13px; max-width: 700px; margin: 2rem auto; padding: 0 1rem; background: #fffdf7; color: #2c3338; line-height: 1.6; }
7-
pre { background: #f3f0e8; border-left: 3px solid #0d6f72; padding: .75rem 1rem; overflow-x: auto; }
8-
code { background: #f3f0e8; padding: 1px 4px; border-radius: 3px; }
9-
blockquote { border-left: 3px solid #d5cbb2; margin: 1rem 0; padding: .5rem 1rem; background: #f9f7f0; color: #4a5560; }
10-
blockquote p { margin: 0; }
11-
dfn { font-style: normal; border-bottom: 1px dashed #0d6f72; cursor: help; }
12-
h2 { border-bottom: 1px solid #d5cbb2; padding-bottom: .3rem; }
13-
.assignment-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
14-
.assignment-table th, .assignment-table td { border: 1px solid #d5cbb2; padding: .5rem .75rem; text-align: left; }
15-
.assignment-table th { background: #f3f0e8; }
16-
.tag-block { color: #9a3a15; font-weight: bold; }
17-
.tag-nba { color: #0a5558; font-weight: bold; }
18-
</style>
19-
</head>
20-
<body>
21-
221
<p><code>always @(event) begin ... end</code> is a block that runs every time a specified event fires.
232
If the event is a clock edge (e.g. <code>posedge clk</code>) we typically use <code>always_ff</code> instead, where "ff" stands for "flip-flop".
243
</p>
254
<svg width="300" height="68" viewBox="0 0 300 68" xmlns="http://www.w3.org/2000/svg" style="display:block;max-width:100%;font-family:'IBM Plex Mono',monospace;font-size:13px;margin:10px auto">
26-
<rect width="300" height="68" rx="4" fill="#fffdf7"/>
27-
<line x1="32" y1="0" x2="32" y2="60" stroke="#d5cbb2" stroke-width="1"/>
28-
<text x="26" y="36" text-anchor="end" fill="#586469">clk</text>
5+
<rect width="300" height="68" rx="4" fill="#fffdf7"/>
6+
<line x1="32" y1="0" x2="32" y2="60" stroke="#d5cbb2" stroke-width="1"/>
7+
<text x="26" y="36" text-anchor="end" fill="#586469">clk</text>
298
<!-- 2 full clock cycles; rising edges (posedge) at x=85 and x=215 -->
30-
<path d="M 36,48 L 85,48 L 85,18 L 150,18 L 150,48 L 215,48 L 215,18 L 280,18 L 280,48"
31-
stroke="#8a9da2" stroke-width="2" fill="none"/>
32-
<line x1="85" y1="14" x2="85" y2="56" stroke="#0d6f72" stroke-width="1.5" stroke-dasharray="3,3"/>
33-
<text x="85" y="65" text-anchor="middle" fill="#0d6f72" font-size="12">posedge</text>
34-
<line x1="215" y1="14" x2="215" y2="56" stroke="#0d6f72" stroke-width="1.5" stroke-dasharray="3,3" opacity="0.4"/>
35-
<text x="215" y="65" text-anchor="middle" fill="#0d6f72" font-size="12" opacity="0.4">posedge</text>
9+
<path d="M 36,48 L 85,48 L 85,18 L 150,18 L 150,48 L 215,48 L 215,18 L 280,18 L 280,48"
10+
stroke="#8a9da2" stroke-width="2" fill="none"/>
11+
<line x1="85" y1="14" x2="85" y2="56" stroke="#0d6f72" stroke-width="1.5" stroke-dasharray="3,3"/>
12+
<text x="85" y="65" text-anchor="middle" fill="#0d6f72" font-size="12">posedge</text>
13+
<line x1="215" y1="14" x2="215" y2="56" stroke="#0d6f72" stroke-width="1.5" stroke-dasharray="3,3" opacity="0.4"/>
14+
<text x="215" y="65" text-anchor="middle" fill="#0d6f72" font-size="12" opacity="0.4">posedge</text>
3615
</svg>
3716
<p>
3817
A flip-flop is a 1-bit memory element that captures its input (d) at a clock edge and holds it until the next edge.
@@ -45,90 +24,72 @@
4524
end // step 2: both mem and out update simultaneously
4625
</pre>
4726
<blockquote><p>
48-
We use <strong><dfn title="Non-blocking assignment (<=) schedules the update to happen after all right-hand sides in the current time step are evaluated. This means two flip-flops can swap values correctly: a <= b; b <= a; works as expected. Blocking assignment (=) takes effect immediately, like a variable assignment in C — correct for combinational logic but causes races in sequential logic.">non-blocking assignment</dfn></strong> (<code>&lt;=</code>) inside <code>always_ff</code>. It works in two steps: first, all right-hand sides are sampled using current values; then all left-hand sides update simultaneously. So <code>out</code> always captures the value <code>mem</code> held <em>before</em> this edge — creating a true one-cycle delay, not a zero-delay pass-through. The same rule is why <code>a &lt;= b; b &lt;= a;</code> correctly swaps two flip-flops.
49-
</p></blockquote>
50-
51-
<h2>Blocking vs. Non-Blocking Assignments</h2>
27+
We use <strong><dfn data-card="Non-blocking assignment (<=) schedules the update to happen after all right-hand sides in the current time step are evaluated. This means two flip-flops can swap values correctly: a <= b; b <= a; works as expected. Blocking assignment (=) takes effect immediately, like a variable assignment in C — correct for combinational logic but causes races in sequential logic.">non-blocking assignment</dfn></strong> (<code>&lt;=</code>) inside <code>always_ff</code>. It works in two steps: first, all right-hand sides are sampled using current values; then all left-hand sides update simultaneously. So <code>out</code> always captures the value <code>mem</code> held <em>before</em> this edge — creating a true one-cycle delay, not a zero-delay pass-through. The same rule is why <code>a &lt;= b; b &lt;= a;</code> correctly swaps two flip-flops.</p></blockquote>
5228

5329
<p>The names describe how each operator behaves in the flow of your procedural code — whether the assignment <strong>blocks</strong> (pauses) execution until it completes.</p>
54-
55-
<p><span class="tag-block">Blocking <code>=</code></span> &mdash; execution stops and waits. The assignment completes immediately, in place, before the next line runs. Think of it like hand-delivering a letter: the recipient has it before you walk away.</p>
56-
30+
<p><strong>Blocking <code>=</code></strong> — execution stops and waits. The assignment completes immediately, in place, before the next line runs. Think of it like hand-delivering a letter: the recipient has it before you walk away.</p>
5731
<pre>
5832
a = b; // a gets b's value RIGHT NOW
5933
c = a; // c sees the new value of a
6034
</pre>
61-
62-
<p><span class="tag-nba">Non-blocking <code>&lt;=</code></span> &mdash; execution continues without waiting. The assignment schedules a write for later and immediately moves on. Think of it like dropping a letter in a mailbox: you keep walking and it gets delivered later, when the NBA update region runs.</p>
63-
35+
<p><strong>Non-blocking <code>&lt;=</code></strong> — execution continues without waiting. The assignment schedules a write for later and immediately moves on. Think of it like dropping a letter in a mailbox: you keep walking and it gets delivered later, when the NBA update region runs.</p>
6436
<pre>
6537
a &lt;= b; // schedules a write to a, but doesn't apply it yet
6638
c &lt;= a; // c gets a's OLD value — the write above hasn't happened yet
6739
</pre>
40+
<p>All right-hand sides are evaluated first, then all writes happen together at the end of the time step. This is what makes <code>always_ff</code> correctly model real hardware, where all flip-flops in a clocked stage sample their inputs and update simultaneously.</p>
6841

69-
<p>All right-hand sides are evaluated first, then all writes happen together at the end of the time step. This is what makes <code>always_ff</code> correctly model real hardware, where all flip-flops in a clocked stage sample their inputs and update their outputs <em>simultaneously</em>.</p>
70-
71-
<table class="assignment-table">
72-
<thead>
73-
<tr><th>Context</th><th>Use <code>&lt;=</code> (non-blocking)?</th><th>Use <code>=</code> (blocking)?</th></tr>
74-
</thead>
75-
<tbody>
76-
<tr><td><code>always_ff</code> / clocked blocks</td><td>✅ Preferred</td><td>⚠️ Avoid</td></tr>
77-
<tr><td>Tasks &amp; functions</td><td>⚠️ Only for static signals</td><td>✅ Correct choice</td></tr>
78-
<tr><td>Automatic task output ports</td><td>❌ Forbidden</td><td>✅ Required</td></tr>
79-
</tbody>
80-
</table>
81-
82-
<p>An SRAM is an array of flip-flops — one per bit — indexed by address.
42+
<p>
43+
An SRAM is an array of flip-flops — one per bit — indexed by address.
8344
We'll need a slightly more advanced pattern to model that array.
8445
We also use a port <code>we</code> (write enable) to control when writes happen, and a separate port <code>rdata</code> for the read result.
8546
</p>
8647
<!-- Timing diagram: write on cycle 1, read request cycle 2, result cycle 3 -->
8748
<svg width="400" height="210" viewBox="0 0 400 210" xmlns="http://www.w3.org/2000/svg" style="display:block;max-width:100%;font-family:'IBM Plex Mono',monospace;font-size:13px;margin:10px auto">
88-
<defs>
89-
<marker id="sff-rarr" markerWidth="7" markerHeight="6" refX="7" refY="3" orient="auto"><path d="M0,0 L7,3 L0,6 Z" fill="#586469"/></marker>
90-
<marker id="sff-larr" markerWidth="7" markerHeight="6" refX="0" refY="3" orient="auto"><path d="M7,0 L0,3 L7,6 Z" fill="#586469"/></marker>
91-
</defs>
92-
<rect width="400" height="210" rx="4" fill="#fffdf7"/>
49+
<defs>
50+
<marker id="sff-rarr" markerWidth="7" markerHeight="6" refX="7" refY="3" orient="auto"><path d="M0,0 L7,3 L0,6 Z" fill="#586469"/></marker>
51+
<marker id="sff-larr" markerWidth="7" markerHeight="6" refX="0" refY="3" orient="auto"><path d="M7,0 L0,3 L7,6 Z" fill="#586469"/></marker>
52+
</defs>
53+
<rect width="400" height="210" rx="4" fill="#fffdf7"/>
9354
<!-- column shading for write/read/result cycles; 3 zones of 108px from x=54 -->
94-
<rect x="54" y="8" width="108" height="162" fill="#fef3e8" opacity="0.5" rx="2"/>
95-
<rect x="162" y="8" width="108" height="162" fill="#e6f5f5" opacity="0.4" rx="2"/>
96-
<rect x="270" y="8" width="108" height="162" fill="#d7f0e3" opacity="0.5" rx="2"/>
55+
<rect x="54" y="8" width="108" height="162" fill="#fef3e8" opacity="0.5" rx="2"/>
56+
<rect x="162" y="8" width="108" height="162" fill="#e6f5f5" opacity="0.4" rx="2"/>
57+
<rect x="270" y="8" width="108" height="162" fill="#d7f0e3" opacity="0.5" rx="2"/>
9758
<!-- cycle labels -->
98-
<text x="108" y="18" text-anchor="middle" fill="#9a3a15" font-size="12" font-weight="bold">WRITE</text>
99-
<text x="216" y="18" text-anchor="middle" fill="#0a5558" font-size="12" font-weight="bold">READ REQ</text>
100-
<text x="324" y="18" text-anchor="middle" fill="#1a5c32" font-size="12" font-weight="bold">READ RESULT</text>
59+
<text x="108" y="18" text-anchor="middle" fill="#9a3a15" font-size="12" font-weight="bold">WRITE</text>
60+
<text x="216" y="18" text-anchor="middle" fill="#0a5558" font-size="12" font-weight="bold">READ REQ</text>
61+
<text x="324" y="18" text-anchor="middle" fill="#1a5c32" font-size="12" font-weight="bold">READ RESULT</text>
10162
<!-- separator line -->
102-
<line x1="52" y1="8" x2="52" y2="172" stroke="#d5cbb2" stroke-width="1"/>
63+
<line x1="52" y1="8" x2="52" y2="172" stroke="#d5cbb2" stroke-width="1"/>
10364
<!-- CLK: 6 half-cycles of 54px from x=54 -->
104-
<text x="46" y="43" text-anchor="end" fill="#586469">clk</text>
105-
<path d="M 54,44 L 108,44 L 108,30 L 162,30 L 162,44 L 216,44 L 216,30 L 270,30 L 270,44 L 324,44 L 324,30 L 378,30 L 378,44" stroke="#8a9da2" stroke-width="1.5" fill="none"/>
65+
<text x="46" y="43" text-anchor="end" fill="#586469">clk</text>
66+
<path d="M 54,44 L 108,44 L 108,30 L 162,30 L 162,44 L 216,44 L 216,30 L 270,30 L 270,44 L 324,44 L 324,30 L 378,30 L 378,44" stroke="#8a9da2" stroke-width="1.5" fill="none"/>
10667
<!-- WE: high during WRITE zone only -->
107-
<text x="46" y="76" text-anchor="end" fill="#586469">we</text>
108-
<path d="M 54,87 L 54,73 L 162,73 L 162,87 L 378,87" stroke="#cc5f2d" stroke-width="2" fill="none"/>
68+
<text x="46" y="76" text-anchor="end" fill="#586469">we</text>
69+
<path d="M 54,87 L 54,73 L 162,73 L 162,87 L 378,87" stroke="#cc5f2d" stroke-width="2" fill="none"/>
10970
<!-- ADDR: bus signal spanning all zones -->
110-
<text x="46" y="112" text-anchor="end" fill="#586469">addr</text>
111-
<rect x="55" y="100" width="322" height="18" rx="2" fill="#e6f5f5" stroke="#0d6f72" stroke-width="1"/>
112-
<text x="216" y="113" text-anchor="middle" fill="#0a5558" font-size="12">addr = 2</text>
71+
<text x="46" y="112" text-anchor="end" fill="#586469">addr</text>
72+
<rect x="55" y="100" width="322" height="18" rx="2" fill="#e6f5f5" stroke="#0d6f72" stroke-width="1"/>
73+
<text x="216" y="113" text-anchor="middle" fill="#0a5558" font-size="12">addr = 2</text>
11374
<!-- WDATA: valid in WRITE zone -->
114-
<text x="46" y="148" text-anchor="end" fill="#586469">wdata</text>
115-
<rect x="55" y="136" width="106" height="18" rx="2" fill="#fef3e8" stroke="#cc5f2d" stroke-width="1"/>
116-
<text x="108" y="149" text-anchor="middle" fill="#9a3a15" font-size="12">0x42</text>
117-
<line x1="162" y1="145" x2="378" y2="145" stroke="#d5cbb2" stroke-width="1.5" stroke-dasharray="4,3"/>
75+
<text x="46" y="148" text-anchor="end" fill="#586469">wdata</text>
76+
<rect x="55" y="136" width="106" height="18" rx="2" fill="#fef3e8" stroke="#cc5f2d" stroke-width="1"/>
77+
<text x="108" y="149" text-anchor="middle" fill="#9a3a15" font-size="12">0x42</text>
78+
<line x1="162" y1="145" x2="378" y2="145" stroke="#d5cbb2" stroke-width="1.5" stroke-dasharray="4,3"/>
11879
<!-- RDATA: valid in READ RESULT zone -->
119-
<text x="46" y="184" text-anchor="end" fill="#586469">rdata</text>
120-
<line x1="54" y1="181" x2="270" y2="181" stroke="#d5cbb2" stroke-width="1.5" stroke-dasharray="4,3"/>
121-
<rect x="271" y="172" width="106" height="18" rx="2" fill="#d7f0e3" stroke="#1a7a3f" stroke-width="1"/>
122-
<text x="324" y="185" text-anchor="middle" fill="#1a5c32" font-size="12">0x42</text>
80+
<text x="46" y="184" text-anchor="end" fill="#586469">rdata</text>
81+
<line x1="54" y1="181" x2="270" y2="181" stroke="#d5cbb2" stroke-width="1.5" stroke-dasharray="4,3"/>
82+
<rect x="271" y="172" width="106" height="18" rx="2" fill="#d7f0e3" stroke="#1a7a3f" stroke-width="1"/>
83+
<text x="324" y="185" text-anchor="middle" fill="#1a5c32" font-size="12">0x42</text>
12384
<!-- 1-cycle latency annotation -->
124-
<line x1="108" y1="196" x2="324" y2="196" stroke="#586469" stroke-width="1.5" marker-start="url(#sff-larr)" marker-end="url(#sff-rarr)" stroke-dasharray="4,3"/>
125-
<text x="216" y="208" text-anchor="middle" fill="#586469" font-size="12">1-cycle read latency</text>
85+
<line x1="108" y1="196" x2="324" y2="196" stroke="#586469" stroke-width="1.5" marker-start="url(#sff-larr)" marker-end="url(#sff-rarr)" stroke-dasharray="4,3"/>
86+
<text x="216" y="208" text-anchor="middle" fill="#586469" font-size="12">1-cycle read latency</text>
12687
</svg>
12788
<p>In <code>sram_core.sv</code> fill in the <code>always_ff</code> body with two statements:</p>
12889
<ul>
129-
<li>When <code>we</code> is high, write <code>wdata</code> into <code>mem[addr]</code></li>
130-
<li>Always register the read: capture <code>mem[addr]</code> into <code>rdata</code></li>
90+
<li>When <code>we</code> is high, write <code>wdata</code> into <code>mem[addr]</code></li>
91+
<li>Always register the read: capture <code>mem[addr]</code> into <code>rdata</code></li>
13192
</ul>
13293
<blockquote><p>The read is <em>registered</em>: drive <code>addr</code> on cycle N and <code>rdata</code> reflects that address on cycle N+1. This is the standard synchronous-read SRAM model.</p></blockquote>
13394
<h2>Testbench</h2>
134-
<p><code>tb.sv</code> writes three values to addresses 2, 7, and 0, then reads them back one cycle later. Each read prints <code>PASS</code> or <code>FAIL</code> — run it before solving to see all three fail, then again after to confirm they all pass. Open the <strong>Waves</strong> tab to see <code>clk</code>, <code>we</code>, <code>addr</code>, <code>wdata</code>, and <code>rdata</code> over time.</p>
95+
<p><code>tb.sv</code> writes three values to addresses 2, 7, and 0, then reads them back one cycle later. Each read prints <code>PASS</code> or <code>FAIL</code> — run it before solving to see all three fail, then again after to confirm they all pass. Open the <strong>Waves</strong> tab to see <code>clk</code>, <code>we</code>, <code>addr</code>, <code>wdata</code>, and <code>rdata</code> over time.</p>

0 commit comments

Comments
 (0)