<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Midterms | Yao Zheng@UHM</title><link>https://gustybear.github.io/tags/midterms/</link><atom:link href="https://gustybear.github.io/tags/midterms/index.xml" rel="self" type="application/rss+xml"/><description>Midterms</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Fri, 27 Feb 2026 00:00:00 +0000</lastBuildDate><image><url>https://gustybear.github.io/media/logo_hu_d0a0b1783c391ac0.png</url><title>Midterms</title><link>https://gustybear.github.io/tags/midterms/</link></image><item><title>Take-Home Midterm Exam: Combinational Logic and Advanced Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2026_spring/miterm_01_game/</link><pubDate>Fri, 27 Feb 2026 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2026_spring/miterm_01_game/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Number systems, Boolean algebra, multi-level optimization, hazards, arithmetic circuits, encoder/decoder/PLA/ROM, scalable MUX structures, parameterized Verilog&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;/p>
&lt;p>&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show complete derivations and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self-checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include timing and area reasoning (gate depth, gate count, or asymptotic arguments).&lt;/li>
&lt;li>No collaboration. Cite any references consulted.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3--30-pts">Part A — Multiple Choice (10 × 3 = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;p>&lt;strong>Q1.&lt;/strong> Which transformation always preserves functional equivalence but may reduce logic depth?&lt;br>
a) Converting SOP to canonical SOP&lt;br>
b) Algebraic factoring&lt;br>
c) Expanding minterms&lt;br>
d) Adding consensus terms&lt;/p>
&lt;p>&lt;strong>Q2.&lt;/strong> A static-1 hazard occurs when:&lt;br>
a) Output should remain 1 but temporarily glitches to 0&lt;br>
b) Output should remain 0 but glitches to 1&lt;br>
c) Clock frequency is too high&lt;br>
d) Fan-out exceeds limit&lt;/p>
&lt;p>&lt;strong>Q3.&lt;/strong> For an N-bit ripple carry adder, worst-case delay is proportional to:&lt;br>
a) log₂N&lt;br>
b) N&lt;br>
c) √N&lt;br>
d) constant&lt;/p>
&lt;p>&lt;strong>Q4.&lt;/strong> Which gate set is functionally complete?&lt;br>
a) {XOR}&lt;br>
b) {AND, OR}&lt;br>
c) {NAND}&lt;br>
d) {XNOR}&lt;/p>
&lt;p>&lt;strong>Q5.&lt;/strong> In synthesizable combinational Verilog, the safest template is:&lt;br>
a) &lt;code>always @(posedge clk)&lt;/code>&lt;br>
b) &lt;code>always @(*)&lt;/code>&lt;br>
c) &lt;code>initial begin&lt;/code>&lt;br>
d) &lt;code>#5 y = a &amp;amp; b;&lt;/code>&lt;/p>
&lt;p>&lt;strong>Q6.&lt;/strong> A 16→1 multiplexer implemented as a balanced tree of 2→1 MUXes has depth:&lt;br>
a) 4&lt;br>
b) 8&lt;br>
c) 15&lt;br>
d) 16&lt;/p>
&lt;p>&lt;strong>Q7.&lt;/strong> ROM implementation size grows:&lt;br>
a) Linearly with inputs&lt;br>
b) Quadratically with inputs&lt;br>
c) Exponentially with inputs&lt;br>
d) Logarithmically with inputs&lt;/p>
&lt;p>&lt;strong>Q8.&lt;/strong> The consensus term of \(A'B + AC\) is:&lt;br>
a) BC&lt;br>
b) B&amp;rsquo;C&lt;br>
c) AB&lt;br>
d) A&amp;rsquo;C&lt;/p>
&lt;p>&lt;strong>Q9.&lt;/strong> Which operator performs bitwise XNOR in Verilog?&lt;br>
a) &lt;code>~^&lt;/code>&lt;br>
b) &lt;code>^~&lt;/code>&lt;br>
c) Both&lt;br>
d) None&lt;/p>
&lt;p>&lt;strong>Q10.&lt;/strong> A balanced adder tree reduces delay complexity from O(N) to:&lt;br>
a) O(1)&lt;br>
b) O(log N)&lt;br>
c) O(N²)&lt;br>
d) O(N log N)&lt;/p>
&lt;hr>
&lt;h2 id="part-b--design--analysis-10--7--70-pts">Part B — Design &amp;amp; Analysis (10 × 7 = 70 pts)&lt;/h2>
&lt;p>&lt;strong>Problem 1 — Multi-Level Optimization and Cost Analysis&lt;/strong>&lt;br>
Given&lt;br>
\(F(A,B,C,D,E)=\Sigma(1,3,4,7,11,15,16,18,19,23,27,31)\)&lt;/p>
&lt;p>a) Write canonical SOP and POS.&lt;br>
b) Minimize using K-map.&lt;br>
c) Factor to reduce depth.&lt;br>
d) Compare literal count and logic depth between two-level and factored implementations.&lt;/p>
&lt;p>&lt;strong>Problem 2 — Hazard Analysis&lt;/strong>&lt;br>
Given&lt;br>
\(F(A,B,C)=A'B+AC\)&lt;/p>
&lt;p>a) Identify static hazards and show transition causing glitch.&lt;br>
b) Add minimal consensus terms to eliminate hazard.&lt;br>
c) Estimate glitch width assuming uniform 1 ns gate delay.&lt;/p>
&lt;p>&lt;strong>Problem 3 — NAND-Only Realization&lt;/strong>&lt;br>
a) Prove NAND is functionally complete.&lt;br>
b) Implement \(F(A,B,C)=AB+A'C\) using only 2-input NAND gates.&lt;br>
c) Count gates and compute logic depth.&lt;/p>
&lt;p>&lt;strong>Problem 4 — 32→5 Priority Encoder&lt;/strong>&lt;br>
a) Define truth table with D31 highest priority and &lt;code>valid&lt;/code>.&lt;br>
b) Build hierarchically from 4→2 encoders.&lt;br>
c) Structural Verilog implementation.&lt;br>
d) Estimate worst-case delay if each 4→2 block delay = 2 ns.&lt;/p>
&lt;p>&lt;strong>Problem 5 — Shared PLA vs ROM Implementation&lt;/strong>&lt;br>
Given&lt;br>
\(F_1=\Sigma(0,2,5,8,10,13)\)&lt;br>
\(F_2=\Sigma(1,3,6,9,14,15)\)&lt;/p>
&lt;p>a) Minimize jointly and identify shared product terms.&lt;br>
b) Draw PLA matrix (AND plane and OR plane).&lt;br>
c) Determine memory size for equivalent 16×2 ROM.&lt;br>
d) Compare area tradeoffs.&lt;/p>
&lt;p>&lt;strong>Problem 6 — Balanced Adder Tree&lt;/strong>&lt;br>
Sum eight 12-bit numbers.&lt;/p>
&lt;p>a) Serial ripple accumulation: compute depth.&lt;br>
b) Balanced tree: draw structure and compute depth.&lt;br>
c) Determine required output width.&lt;/p>
&lt;p>&lt;strong>Problem 7 — Parameterized ALU&lt;/strong>&lt;/p>
&lt;p>Operations: ADD, SUB, AND, OR, XOR, CMP(==,&amp;gt;,&amp;lt;). Width parameter &lt;code>N&lt;/code>.&lt;/p>
&lt;p>a) Write synthesizable Verilog using &lt;code>unique case&lt;/code>.&lt;br>
b) Implement comparison efficiently (no redundant subtraction).&lt;br>
c) Provide self-checking randomized testbench.&lt;br>
d) Compare resource growth for N=8 and N=32.&lt;/p>
&lt;p>&lt;strong>Problem 8 — Recursive MUX Tree&lt;/strong>&lt;/p>
&lt;p>a) Implement a parameterized &lt;code>mux_tree #(N=16,W=8)&lt;/code> using &lt;code>generate&lt;/code>.&lt;br>
b) Ensure balanced structure.&lt;br>
c) Derive logic depth as function of N.&lt;br>
d) Provide synthesizable code.&lt;/p>
&lt;p>&lt;strong>Problem 9 — Gray/Binary Converters&lt;/strong>&lt;/p>
&lt;p>a) Derive 4-bit Gray→Binary and Binary→Gray equations.&lt;br>
b) Prove composition correctness.&lt;br>
c) Provide parameterized Verilog and exhaustive testbench.&lt;/p>
&lt;p>&lt;strong>Problem 10 — Power-of-Two Detector&lt;/strong>&lt;/p>
&lt;p>Design combinational circuit to detect if a 16-bit input is a power of two.&lt;/p>
&lt;p>a) Derive minimal Boolean condition.&lt;br>
b) Implement structural and behavioral Verilog versions.&lt;br>
c) Compare gate complexity.&lt;/p></description></item><item><title>Take-Home Midterm Exam: Combinational Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_01_game/</link><pubDate>Tue, 30 Sep 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_01_game/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Number systems, Boolean algebra, combinational design, optimization, hazards, MUX/decoder/PLA, Verilog HDL&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3--30-pts">Part A — Multiple Choice (10 × 3 = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;p>&lt;strong>Q1.&lt;/strong> Which of the following is &lt;em>not&lt;/em> a characteristic of combinational logic?&lt;br>
a) Output depends only on present inputs&lt;br>
b) No feedback paths&lt;br>
c) May exhibit propagation delay&lt;br>
d) Requires clock edge to update&lt;/p>
&lt;p>&lt;strong>Q2.&lt;/strong> Which Verilog statement is &lt;em>not&lt;/em> synthesizable in general FPGA/ASIC tools?&lt;br>
a) &lt;code>assign y = a &amp;amp; b;&lt;/code>&lt;br>
b) &lt;code>always @(*) y = a | b;&lt;/code>&lt;br>
c) &lt;code>initial y = 0;&lt;/code>&lt;br>
d) &lt;code>case(sel) y = d0; endcase&lt;/code>&lt;/p>
&lt;p>&lt;strong>Q3.&lt;/strong> The &lt;strong>critical path delay&lt;/strong> in a ripple‑carry adder grows:&lt;br>
a) Linearly with bit‑width&lt;br>
b) Logarithmically with bit‑width&lt;br>
c) Constant with bit‑width&lt;br>
d) Randomly with input values&lt;/p>
&lt;p>&lt;strong>Q4.&lt;/strong> Which gate set is &lt;strong>not&lt;/strong> functionally complete?&lt;br>
a) {NAND}&lt;br>
b) {NOR}&lt;br>
c) {AND, OR}&lt;br>
d) {XOR, AND}&lt;/p>
&lt;p>&lt;strong>Q5.&lt;/strong> In Verilog, &lt;code>reg&lt;/code> and &lt;code>wire&lt;/code> differ because:&lt;br>
a) &lt;code>reg&lt;/code> can only be used in sequential circuits&lt;br>
b) &lt;code>wire&lt;/code> holds values without drivers&lt;br>
c) &lt;code>reg&lt;/code> stores a value until reassigned; &lt;code>wire&lt;/code> reflects drivers continuously&lt;br>
d) &lt;code>wire&lt;/code> is faster than &lt;code>reg&lt;/code>&lt;/p>
&lt;p>&lt;strong>Q6.&lt;/strong> A 32‑to‑1 multiplexer can be implemented most efficiently using:&lt;br>
a) One 32‑input gate&lt;br>
b) A tree of 2‑to‑1 multiplexers&lt;br>
c) A PLA&lt;br>
d) Multiple XOR gates&lt;/p>
&lt;p>&lt;strong>Q7.&lt;/strong> Which optimization reduces &lt;strong>logic depth&lt;/strong> the most?&lt;br>
a) Gate duplication&lt;br>
b) Pipelining&lt;br>
c) Karnaugh map simplification&lt;br>
d) Multi‑level factoring&lt;/p>
&lt;p>&lt;strong>Q8.&lt;/strong> Which Verilog operator performs &lt;strong>bitwise XNOR&lt;/strong>?&lt;br>
a) &lt;code>~^&lt;/code>&lt;br>
b) &lt;code>^~&lt;/code>&lt;br>
c) Both a and b&lt;br>
d) None&lt;/p>
&lt;p>&lt;strong>Q9.&lt;/strong> Main limitation of ROM implementation for logic functions is:&lt;br>
a) Too slow for combinational circuits&lt;br>
b) Size grows exponentially with #inputs&lt;br>
c) Can only implement sequential logic&lt;br>
d) Does not support initialization&lt;/p>
&lt;p>&lt;strong>Q10.&lt;/strong> If two drivers assign conflicting values to a Verilog &lt;code>wire&lt;/code>:&lt;br>
a) Last assignment wins&lt;br>
b) Wire holds 0&lt;br>
c) Wire holds 1&lt;br>
d) Wire becomes unknown (&lt;code>x&lt;/code>)&lt;/p>
&lt;hr>
&lt;h2 id="part-b--design--analysis-10--7--70-pts">Part B — Design &amp;amp; Analysis (10 × 7 = 70 pts)&lt;/h2>
&lt;p>&lt;strong>Problem 1 — Functional Completeness (NAND‑Only)&lt;/strong>&lt;br>
a) Prove {NAND} is functionally complete (construct NOT, AND, OR).&lt;br>
b) Implement \(F(A,B,C)=\Sigma(0,2,5,7)\) using &lt;strong>NAND‑only&lt;/strong>. Show product terms and sharing.&lt;br>
c) Provide synthesizable Verilog for the NAND‑only implementation and compare gate count v.s. SOP using AND/OR/NOT.&lt;/p>
&lt;p>&lt;strong>Problem 2 — Arithmetic: Carry‑Save Adder (CSA)&lt;/strong>&lt;br>
a) Derive a 3‑operand (A,B,C) 4‑bit CSA producing (Sum, Carry).&lt;br>
b) Compare worst‑case delay against 2‑operand ripple add repeated twice.&lt;br>
c) Provide synthesizable Verilog for a parameterized CSA.&lt;/p>
&lt;p>&lt;strong>Problem 3 — 16→4 Priority Encoder&lt;/strong>&lt;br>
a) Specify truth table/priority convention (D\(15\) highest). Include &lt;code>valid&lt;/code>.&lt;br>
b) Build hierarchically from 4×(4→2) encoders + 4→2 encoder.&lt;br>
c) Structural Verilog with module instances.&lt;/p>
&lt;p>&lt;strong>Problem 4 — PLA and ROM Implementations&lt;/strong>&lt;br>
Given:&lt;br>
\(F_1(A,B,C,D)=\Sigma(0,2,5,8,12),\quad F_2(A,B,C,D)=\Sigma(1,3,4,9,15)\)&lt;br>
a) Derive minimized SOPs with shared product terms for a PLA.&lt;br>
b) Sketch a PLA with labeled shared products.&lt;br>
c) Show 16×2 ROM mapping (address=A B C D).&lt;br>
d) Provide generic Verilog: (i) PLA using &lt;code>and&lt;/code> of literals + &lt;code>or&lt;/code> planes; (ii) ROM using &lt;code>case&lt;/code> or packed &lt;code>localparam&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 5 — Scalable MUX&lt;/strong>&lt;br>
a) Build a &lt;strong>16→1&lt;/strong> MUX using only 2→1 MUXes (balanced tree).&lt;br>
b) Count 2→1 cells and tree depth.&lt;br>
c) Write a parameterized &lt;strong>recursive&lt;/strong> Verilog module &lt;code>mux_tree #(N=16,W=1)&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 6 — Comparator (4‑bit)&lt;/strong>&lt;br>
a) Derive equations for &lt;code>GT, EQ, LT&lt;/code>.&lt;br>
b) Show hierarchical design from chained 1‑bit comparators.&lt;br>
c) Provide synthesizable Verilog and a constrained‑random testbench.&lt;/p>
&lt;p>&lt;strong>Problem 7 — Gray/Binary Converters (4‑bit)&lt;/strong>&lt;br>
a) Derive equations: Gray→Bin and Bin→Gray.&lt;br>
b) Compose them in loopback to prove &lt;code>Bin == g2b(b2g(Bin))&lt;/code>.&lt;br>
c) Parameterized Verilog + exhaustive testbench.&lt;/p>
&lt;p>&lt;strong>Problem 8 — Digital Lock&lt;/strong>&lt;br>
Opens for inputs &lt;strong>110101&lt;/strong> or &lt;strong>011110&lt;/strong>.&lt;br>
a) Minimize SOP.&lt;br>
b) Implement via decoder + OR.&lt;br>
c) Verilog (behavioral and structural).&lt;br>
d) Short note: why loose “don’t care” policies are risky for security.&lt;/p>
&lt;p>&lt;strong>Problem 9 — Parameterized ALU&lt;/strong>&lt;br>
Ops: ADD, SUB, AND, OR, XOR, CMP(==,&amp;gt;,&amp;lt;). Width parameter &lt;code>N&lt;/code>.&lt;br>
a) Synthesizable Verilog with &lt;code>unique case&lt;/code>.&lt;br>
b) Self‑checking randomized testbench (seeded).&lt;br>
c) Brief resource discussion for N=8 vs N=32 (qualitative + simple count).&lt;/p>
&lt;p>&lt;strong>Problem 10 — Adder Tree&lt;/strong>&lt;br>
Sum eight 16‑bit numbers with minimal depth.&lt;br>
a) Draw balanced adder tree and give depth.&lt;br>
b) Compare with serial accumulation.&lt;br>
c) Parameterized Verilog using &lt;code>generate&lt;/code> and a reduction tree.&lt;/p></description></item><item><title>Take-Home Midterm Exam Solution: Combinational Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_01_solutions/</link><pubDate>Tue, 30 Sep 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_01_solutions/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Number systems, Boolean algebra, combinational design, optimization, hazards, MUX/decoder/PLA, Verilog HDL&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-keys">Part A — Multiple Choice (Keys)&lt;/h2>
&lt;ol>
&lt;li>d&lt;/li>
&lt;li>c&lt;/li>
&lt;li>a&lt;/li>
&lt;li>c&lt;/li>
&lt;li>c&lt;/li>
&lt;li>b&lt;/li>
&lt;li>d&lt;/li>
&lt;li>c&lt;/li>
&lt;li>b&lt;/li>
&lt;li>d&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="part-b--design--analysis">Part B — Design &amp;amp; Analysis&lt;/h2>
&lt;h3 id="problem-1--functional-completeness-nandonly">Problem 1 — Functional Completeness (NAND‑Only)&lt;/h3>
&lt;p>&lt;strong>a) Constructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>NOT: \( \neg A = A\,\text{NAND}\,A \)&lt;/li>
&lt;li>AND: \( A\land B = (A\,\text{NAND}\,B)\,\text{NAND}\,(A\,\text{NAND}\,B) \)&lt;/li>
&lt;li>OR (by De Morgan): \( A\lor B = (\neg A)\,\text{NAND}\,(\neg B) = (A\,\text{NAND}\,A)\,\text{NAND}\,(B\,\text{NAND}\,B) \)&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>b) Minimal SOP for&lt;/strong> \(F=\Sigma(0,2,5,7)\) &lt;strong>→&lt;/strong> \(F = A' C' + A C\). (Covers 0,2 and 5,7.)&lt;/p>
&lt;p>&lt;strong>c) NAND‑only Verilog&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">module&lt;/span> &lt;span class="n">F_nand_only&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">input&lt;/span> &lt;span class="n">A&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">B&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">C&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="n">F&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="n">nA&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">t1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">t2&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="c1">// B not used after minimization
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">nA&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">A&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">A&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">nC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="n">nA_and_nC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AbarCbar&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">nA_and_nC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nA&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nC&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">AbarCbar&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nA_and_nC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nA_and_nC&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="n">AandC_n&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AandC&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">AandC_n&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">A&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">C&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">AandC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AandC_n&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AandC_n&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="n">nAbarCbar&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nAandC&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">nAbarCbar&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AbarCbar&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AbarCbar&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">nAandC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AandC&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">AandC&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">nand&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">F&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nAbarCbar&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">nAandC&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">endmodule&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Gate count ~7 NANDs.&lt;/p>
&lt;hr>
&lt;h3 id="problem-2--csa">Problem 2 — CSA&lt;/h3>
&lt;p>Sum bits: \(s_i = a_i \oplus b_i \oplus c_i\), carry bits: \(k_i=(a_ib_i)+(b_ic_i)+(a_ic_i)\). Final result = &lt;code>s + (k&amp;lt;&amp;lt;1)&lt;/code> via one CPA. Delay better than two ripples.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">module&lt;/span> &lt;span class="n">csa3&lt;/span> &lt;span class="p">#(&lt;/span>&lt;span class="k">parameter&lt;/span> &lt;span class="n">N&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mh">4&lt;/span>&lt;span class="p">)(&lt;/span>&lt;span class="k">input&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">a&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">c&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">output&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">s&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">k&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">genvar&lt;/span> &lt;span class="n">i&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">generate&lt;/span> &lt;span class="k">for&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="n">N&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">begin&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">g&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">s&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">^&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">^&lt;/span>&lt;span class="n">c&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">];&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">k&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">&amp;amp;&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">])&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">&amp;amp;&lt;/span>&lt;span class="n">c&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">])&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">&amp;amp;&lt;/span>&lt;span class="n">c&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">i&lt;/span>&lt;span class="p">]);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">end&lt;/span> &lt;span class="k">endgenerate&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">endmodule&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="problem-3--164-priority-encoder">Problem 3 — 16→4 Priority Encoder&lt;/h3>
&lt;p>See hierarchical structural solution:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">module&lt;/span> &lt;span class="n">pe4&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">input&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">d&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="n">valid&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">valid&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="o">|&lt;/span>&lt;span class="n">d&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">y&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="o">!&lt;/span>&lt;span class="n">valid&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mb">&amp;#39;b00&lt;/span> &lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mb">&amp;#39;b11&lt;/span> &lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">2&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mb">&amp;#39;b10&lt;/span> &lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mb">&amp;#39;b01&lt;/span> &lt;span class="o">:&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mb">&amp;#39;b00&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">endmodule&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">module&lt;/span> &lt;span class="n">pe16&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">input&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">15&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">d&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="n">valid&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">output&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">v&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="kt">wire&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">y0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">y1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">y2&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">y3&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pe4&lt;/span> &lt;span class="n">u0&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">v&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">y0&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pe4&lt;/span> &lt;span class="n">u1&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">7&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">4&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">v&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">y1&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pe4&lt;/span> &lt;span class="n">u2&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">11&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">8&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">v&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">2&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">y2&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pe4&lt;/span> &lt;span class="n">u3&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">d&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">15&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">12&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">v&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">y3&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pe4&lt;/span> &lt;span class="n">uT&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">v&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">valid&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">2&lt;/span>&lt;span class="p">]);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">reg&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">low&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">case&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">y&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">2&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="mh">2&lt;/span>&lt;span class="mi">&amp;#39;d0&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">low&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">y0&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mi">&amp;#39;d1&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">low&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">y1&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="mh">2&lt;/span>&lt;span class="mi">&amp;#39;d2&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">low&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">y2&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="k">default&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="n">low&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">y3&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">endcase&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">y&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">low&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">endmodule&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h3 id="problem-4--pla--rom">Problem 4 — PLA &amp;amp; ROM&lt;/h3>
&lt;p>One valid sharing (not unique):&lt;/p>
&lt;ul>
&lt;li>\(F_1 = A'B' + C'D' + AD'\)&lt;/li>
&lt;li>\(F_2 = A'CD + AB' + B'D\)&lt;/li>
&lt;/ul>
&lt;p>PLA code shown (shared terms). ROM mapping by full truth table is acceptable (example mapping provided in handout).&lt;/p>
&lt;hr>
&lt;h3 id="problem-5--scalable-mux">Problem 5 — Scalable MUX&lt;/h3>
&lt;p>Uses \(N-1\) 2→1 cells; for 16→1, 15 cells, depth 4. Recursive &lt;code>mux_tree&lt;/code> given in handout; students verify widths and &lt;code>$clog2&lt;/code> correctness with synthesis/sim.&lt;/p>
&lt;hr>
&lt;h3 id="problem-6--comparator">Problem 6 — Comparator&lt;/h3>
&lt;p>Equations:&lt;br>
&lt;code>EQ = Π_i ~(Ai ^ Bi)&lt;/code>&lt;br>
&lt;code>GT = g3 | (eq3&amp;amp;g2) | (eq3&amp;amp;eq2&amp;amp;g1) | (eq3&amp;amp;eq2&amp;amp;eq1&amp;amp;g0)&lt;/code>&lt;br>
&lt;code>LT&lt;/code> mirror. Verilog in handout accepted.&lt;/p>
&lt;hr>
&lt;h3 id="problem-7--graybinary">Problem 7 — Gray/Binary&lt;/h3>
&lt;p>Gray→Bin prefix XOR; Bin→Gray adjacent XOR. Parameterized modules and exhaustive TB as shown.&lt;/p>
&lt;hr>
&lt;h3 id="problem-8--lock">Problem 8 — Lock&lt;/h3>
&lt;p>&lt;code>assign open = (in==6'b110101) || (in==6'b011110);&lt;/code>&lt;br>
Security note: define all unspecified inputs as closed (0); avoid ‘x’ in synthesizable paths.&lt;/p>
&lt;hr>
&lt;h3 id="problem-9--alu">Problem 9 — ALU&lt;/h3>
&lt;p>Reference ALU with &lt;code>unique case&lt;/code>. TB randomizes A,B and compares against high‑level model. Resource: adder dominates; scaling roughly linear with N for ripple implementations.&lt;/p>
&lt;hr>
&lt;h3 id="problem-10--adder-tree">Problem 10 — Adder Tree&lt;/h3>
&lt;p>Balanced tree depth 3 for 8 inputs; serial is 7. Example parameterized module provided; students may generalize to 2^k inputs or pad to nearest power of two.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">module&lt;/span> &lt;span class="n">sum8&lt;/span> &lt;span class="p">#(&lt;/span>&lt;span class="k">parameter&lt;/span> &lt;span class="n">W&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mh">16&lt;/span>&lt;span class="p">)(&lt;/span>&lt;span class="k">input&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">a0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a2&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a3&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a4&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a5&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a6&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">a7&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">output&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="mh">3&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">sum&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="nl">W:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">s0&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">a0&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">a1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">s1&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">a2&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">a3&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">s2&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">a4&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">a5&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">s3&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">a6&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">a7&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kt">wire&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="n">W&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="mh">1&lt;/span>&lt;span class="o">:&lt;/span>&lt;span class="mh">0&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="n">t0&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">s0&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">s1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">t1&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">s2&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="n">s3&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">assign&lt;/span> &lt;span class="n">sum&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">t0&lt;/span> &lt;span class="o">+&lt;/span> &lt;span class="n">t1&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">endmodule&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr></description></item><item><title>Take-Home Midterm Exam: Sequential Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_game/</link><pubDate>Tue, 28 Oct 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_game/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Sequential logic, finite state machines, registers, counters, with Verilog modeling&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;li>Tutorial of Online tools for Verilog simulation can be found
.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3-pts--30-pts">Part A — Multiple Choice (10 × 3 pts = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;p>&lt;strong>Q1.&lt;/strong> A positive-level D latch is best described as:&lt;/p>
&lt;ul>
&lt;li>A. Sampling on rising edges only&lt;/li>
&lt;li>B. Transparent when clock=1 and opaque when clock=0&lt;/li>
&lt;li>C. Triggered on both edges&lt;/li>
&lt;li>D. Metastability-free by design&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q2.&lt;/strong> The parameter that primarily limits f_max is:&lt;/p>
&lt;ul>
&lt;li>A. Hold time&lt;/li>
&lt;li>B. Recovery time&lt;/li>
&lt;li>C. t_clk-q + t_comb + t_setup&lt;/li>
&lt;li>D. Clock duty cycle&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q3.&lt;/strong> A T flip-flop divides the clock by two because it:&lt;/p>
&lt;ul>
&lt;li>A. Filters every other edge by delay&lt;/li>
&lt;li>B. Toggles its output at each active edge&lt;/li>
&lt;li>C. Samples input twice per cycle&lt;/li>
&lt;li>D. Has J=0, K=1&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q4.&lt;/strong> A ripple counter differs from a synchronous counter because:&lt;/p>
&lt;ul>
&lt;li>A. It uses fewer flip-flops&lt;/li>
&lt;li>B. Its stages are clocked by preceding stage outputs&lt;/li>
&lt;li>C. It is immune to propagation delay&lt;/li>
&lt;li>D. It is always faster&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q5.&lt;/strong> In a Moore machine, outputs depend on:&lt;/p>
&lt;ul>
&lt;li>A. Current input only&lt;/li>
&lt;li>B. Current state only&lt;/li>
&lt;li>C. Next state only&lt;/li>
&lt;li>D. Current and previous inputs&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q6.&lt;/strong> In a Mealy machine:&lt;/p>
&lt;ul>
&lt;li>A. Outputs change only at clock edges&lt;/li>
&lt;li>B. Outputs depend on state and inputs&lt;/li>
&lt;li>C. It needs more states than Moore always&lt;/li>
&lt;li>D. It cannot be coded in Verilog&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q7.&lt;/strong> A 4-bit shift register with serial input 1101 after four clocks contains (MSB..LSB):&lt;/p>
&lt;ul>
&lt;li>A. 1011&lt;/li>
&lt;li>B. 1101&lt;/li>
&lt;li>C. 0110&lt;/li>
&lt;li>D. 1110&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q8.&lt;/strong> A hold-time violation can be mitigated by:&lt;/p>
&lt;ul>
&lt;li>A. Adding delay to data path&lt;/li>
&lt;li>B. Increasing clock frequency&lt;/li>
&lt;li>C. Reducing setup time&lt;/li>
&lt;li>D. Removing all registers&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q9.&lt;/strong> One-hot encoding of an N-state FSM uses:&lt;/p>
&lt;ul>
&lt;li>A. log2(N) flip-flops&lt;/li>
&lt;li>B. N flip-flops&lt;/li>
&lt;li>C. N-1 flip-flops&lt;/li>
&lt;li>D. 2N flip-flops&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q10.&lt;/strong> Pipeline registers primarily:&lt;/p>
&lt;ul>
&lt;li>A. Reduce combinational delay per stage&lt;/li>
&lt;li>B. Store only final outputs&lt;/li>
&lt;li>C. Remove all hazards&lt;/li>
&lt;li>D. Reduce setup time of FFs&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-b--design--analysis-10--7--70-pts">Part B — Design &amp;amp; Analysis (10 × 7 = 70 pts)&lt;/h2>
&lt;p>For each problem, complete the Verilog template in the
and verify using the provided self‑checking testbench.
Name your top‑level modules exactly as specified.&lt;/p>
&lt;p>&lt;strong>Files provided (in the questions zip):&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Templates: &lt;code>*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Testbenches: &lt;code>tb_*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Timescale: &lt;code>1ns/1ps&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problems:&lt;/strong>&lt;/p>
&lt;p>&lt;strong>Problem 1 — Synchronizer + Edge Detect (&lt;code>sync_edge&lt;/code>)&lt;/strong>&lt;br>
Synchronize asynchronous &lt;code>btn_async&lt;/code> into &lt;code>clk&lt;/code> with a two‑FF synchronizer; output &lt;code>btn_sync&lt;/code> level and one‑cycle &lt;code>btn_pulse&lt;/code> on rising edges. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 2 — Dual‑Edge Capture (&lt;code>ddr_reg&lt;/code>)&lt;/strong>&lt;br>
Capture &lt;code>D&lt;/code> on posedge into &lt;code>Q_pos&lt;/code> and on negedge into &lt;code>Q_neg&lt;/code>. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 3 — Mealy Sequence Detector “11010” (&lt;code>seq_11010_mealy&lt;/code>)&lt;/strong>&lt;br>
Detect the overlapping pattern and assert &lt;code>Z&lt;/code> on the final bit. Use a minimal FSM.&lt;/p>
&lt;p>&lt;strong>Problem 4 — Mod‑6 Up/Down Counter with Enable (&lt;code>mod6_counter&lt;/code>)&lt;/strong>&lt;br>
3‑bit counter over 0..5. &lt;code>En&lt;/code> gates counting; &lt;code>Dir=1&lt;/code> up, &lt;code>0&lt;/code> down. Synchronous reset to 0.&lt;/p>
&lt;p>&lt;strong>Problem 5 — 4×4 Serial Multiplier Controller (&lt;code>mul4_ctrl&lt;/code>)&lt;/strong>&lt;br>
Shift‑add controller with signals &lt;code>LdA,LdB,ClrP,Add,Shift,Done&lt;/code>. Start with &lt;code>start=1&lt;/code>. Iterate 4 times.&lt;/p>
&lt;p>&lt;strong>Problem 6 — 2‑Stage Pipeline &lt;code>(A+B)*C&lt;/code> with Valid/Ready (&lt;code>pipe_add_mul&lt;/code>)&lt;/strong>&lt;br>
Implement a two‑stage pipeline (add then multiply) with back‑pressure (&lt;code>in_valid/in_ready&lt;/code>, &lt;code>out_valid/out_ready&lt;/code>).&lt;/p>
&lt;p>&lt;strong>Problem 7 — CDC Bridge 1 MHz → 100 MHz (&lt;code>cdc_bridge&lt;/code>)&lt;/strong>&lt;br>
Use a &lt;code>req/ack&lt;/code> handshake and 2FF synchronizers both directions to transfer an 8‑bit word reliably.&lt;/p>
&lt;p>&lt;strong>Problem 8 — Moore FSM with Registered Output (&lt;code>moore_safe&lt;/code>)&lt;/strong>&lt;br>
Provide both combinational output &lt;code>Zc&lt;/code> and registered &lt;code>Zr&lt;/code> (hazard‑free).&lt;/p>
&lt;p>&lt;strong>Problem 9 — Sequential 4‑bit ALU (&lt;code>seq_alu4&lt;/code>)&lt;/strong>&lt;br>
Opcode: 00=ADD, 01=AND, 10=XOR, 11=SHL. Registered outputs &lt;code>Y&lt;/code> and &lt;code>Cout&lt;/code> with synchronous reset.&lt;/p>
&lt;p>&lt;strong>Problem 10 — Traffic Lights with Pedestrian Preempt (&lt;code>traffic_ped&lt;/code>)&lt;/strong>&lt;br>
Main: G×3, Y×1; Side: G×2, Y×1. Insert &lt;code>WALK&lt;/code>×4 at a safe point when &lt;code>ped_req=1&lt;/code>; resume correctly.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Deliverables:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>PDF with answers to Section A and brief design notes for Section B.&lt;/li>
&lt;li>Verilog sources for all 10 designs.&lt;/li>
&lt;li>Simulation logs/screenshots demonstrating passing testbenches.&lt;/li>
&lt;/ul></description></item><item><title>Take-Home Midterm Exam: Sequential Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_solutions/</link><pubDate>Tue, 28 Oct 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_solutions/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Sequential logic, finite state machines, registers, counters, with Verilog modeling&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;li>Tutorial of Online tools for Verilog simulation can be found
.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3-pts--30-pts">Part A — Multiple Choice (10 × 3 pts = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;h2 id="part-a--multiple-choice-keys">Part A — Multiple Choice (Keys)&lt;/h2>
&lt;ol>
&lt;li>b&lt;/li>
&lt;li>c&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>a&lt;/li>
&lt;li>b&lt;/li>
&lt;li>a&lt;/li>
&lt;/ol>
&lt;h2 id="part-a-mp--multiple-choice-keys">Part A (MP) — Multiple Choice (Keys)&lt;/h2>
&lt;ol>
&lt;li>b&lt;/li>
&lt;li>c&lt;/li>
&lt;li>b&lt;/li>
&lt;li>c&lt;/li>
&lt;li>c&lt;/li>
&lt;li>c&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>b&lt;/li>
&lt;li>d&lt;/li>
&lt;/ol>
&lt;hr>
&lt;h2 id="part-b--design--analysis-10--7--70-pts">Part B — Design &amp;amp; Analysis (10 × 7 = 70 pts)&lt;/h2>
&lt;p>Download solutions
.&lt;/p>
&lt;p>&lt;strong>Files provided (in the questions zip):&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Templates: &lt;code>*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Testbenches: &lt;code>tb_*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Timescale: &lt;code>1ns/1ps&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problems:&lt;/strong>&lt;/p>
&lt;p>&lt;strong>Problem 1 — Synchronizer + Edge Detect (&lt;code>sync_edge&lt;/code>)&lt;/strong>&lt;br>
Synchronize asynchronous &lt;code>btn_async&lt;/code> into &lt;code>clk&lt;/code> with a two‑FF synchronizer; output &lt;code>btn_sync&lt;/code> level and one‑cycle &lt;code>btn_pulse&lt;/code> on rising edges. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 2 — Dual‑Edge Capture (&lt;code>ddr_reg&lt;/code>)&lt;/strong>&lt;br>
Capture &lt;code>D&lt;/code> on posedge into &lt;code>Q_pos&lt;/code> and on negedge into &lt;code>Q_neg&lt;/code>. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 3 — Mealy Sequence Detector “11010” (&lt;code>seq_11010_mealy&lt;/code>)&lt;/strong>&lt;br>
Detect the overlapping pattern and assert &lt;code>Z&lt;/code> on the final bit. Use a minimal FSM.&lt;/p>
&lt;p>&lt;strong>Problem 4 — Mod‑6 Up/Down Counter with Enable (&lt;code>mod6_counter&lt;/code>)&lt;/strong>&lt;br>
3‑bit counter over 0..5. &lt;code>En&lt;/code> gates counting; &lt;code>Dir=1&lt;/code> up, &lt;code>0&lt;/code> down. Synchronous reset to 0.&lt;/p>
&lt;p>&lt;strong>Problem 5 — 4×4 Serial Multiplier Controller (&lt;code>mul4_ctrl&lt;/code>)&lt;/strong>&lt;br>
Shift‑add controller with signals &lt;code>LdA,LdB,ClrP,Add,Shift,Done&lt;/code>. Start with &lt;code>start=1&lt;/code>. Iterate 4 times.&lt;/p>
&lt;p>&lt;strong>Problem 6 — 2‑Stage Pipeline &lt;code>(A+B)*C&lt;/code> with Valid/Ready (&lt;code>pipe_add_mul&lt;/code>)&lt;/strong>&lt;br>
Implement a two‑stage pipeline (add then multiply) with back‑pressure (&lt;code>in_valid/in_ready&lt;/code>, &lt;code>out_valid/out_ready&lt;/code>).&lt;/p>
&lt;p>&lt;strong>Problem 7 — CDC Bridge 1 MHz → 100 MHz (&lt;code>cdc_bridge&lt;/code>)&lt;/strong>&lt;br>
Use a &lt;code>req/ack&lt;/code> handshake and 2FF synchronizers both directions to transfer an 8‑bit word reliably.&lt;/p>
&lt;p>&lt;strong>Problem 8 — Moore FSM with Registered Output (&lt;code>moore_safe&lt;/code>)&lt;/strong>&lt;br>
Provide both combinational output &lt;code>Zc&lt;/code> and registered &lt;code>Zr&lt;/code> (hazard‑free).&lt;/p>
&lt;p>&lt;strong>Problem 9 — Sequential 4‑bit ALU (&lt;code>seq_alu4&lt;/code>)&lt;/strong>&lt;br>
Opcode: 00=ADD, 01=AND, 10=XOR, 11=SHL. Registered outputs &lt;code>Y&lt;/code> and &lt;code>Cout&lt;/code> with synchronous reset.&lt;/p>
&lt;p>&lt;strong>Problem 10 — Traffic Lights with Pedestrian Preempt (&lt;code>traffic_ped&lt;/code>)&lt;/strong>&lt;br>
Main: G×3, Y×1; Side: G×2, Y×1. Insert &lt;code>WALK&lt;/code>×4 at a safe point when &lt;code>ped_req=1&lt;/code>; resume correctly.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Deliverables:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>PDF with answers to Section A and brief design notes for Section B.&lt;/li>
&lt;li>Verilog sources for all 10 designs.&lt;/li>
&lt;li>Simulation logs/screenshots demonstrating passing testbenches.&lt;/li>
&lt;/ul></description></item><item><title>Take-Home Midterm Exam: Sequential Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2026_spring/miterm_02_game/</link><pubDate>Tue, 28 Oct 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2026_spring/miterm_02_game/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Sequential logic, finite state machines, registers, counters, with Verilog modeling&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;li>Tutorial of Online tools for Verilog simulation can be found
.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3-pts--30-pts">Part A — Multiple Choice (10 × 3 pts = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;p>&lt;strong>Q1.&lt;/strong> Why are &lt;strong>edge-triggered flip-flops&lt;/strong> preferred over level-sensitive latches in synchronous systems?&lt;br>
A. They reduce power consumption&lt;br>
B. They eliminate race-through conditions&lt;br>
C. They operate at higher frequency inherently&lt;br>
D. They require fewer transistors&lt;/p>
&lt;p>&lt;strong>Q2.&lt;/strong> A setup time violation occurs when:&lt;br>
A. Data arrives too early before the clock edge&lt;br>
B. Data arrives too late before the clock edge&lt;br>
C. Data changes too slowly&lt;br>
D. Clock period is too long&lt;/p>
&lt;p>&lt;strong>Q3.&lt;/strong> Which of the following circuits is most prone to &lt;strong>metastability&lt;/strong>?&lt;br>
A. Combinational logic&lt;br>
B. Single flip-flop sampling asynchronous input&lt;br>
C. Synchronous counter&lt;br>
D. Registered pipeline&lt;/p>
&lt;p>&lt;strong>Q4.&lt;/strong> In a synchronous design, increasing combinational delay between registers will:&lt;br>
A. Increase hold margin&lt;br>
B. Reduce maximum clock frequency&lt;br>
C. Improve timing robustness&lt;br>
D. Eliminate hazards&lt;/p>
&lt;p>&lt;strong>Q5.&lt;/strong> A Moore FSM is generally more stable than a Mealy FSM because:&lt;br>
A. It uses fewer states&lt;br>
B. Outputs depend only on registered state&lt;br>
C. It requires no combinational logic&lt;br>
D. It runs at lower frequency&lt;/p>
&lt;p>&lt;strong>Q6.&lt;/strong> Which condition most directly causes a &lt;strong>hold time violation&lt;/strong>?&lt;br>
A. Data path too slow&lt;br>
B. Data path too fast&lt;br>
C. Clock period too long&lt;br>
D. Setup time too large&lt;/p>
&lt;p>&lt;strong>Q7.&lt;/strong> Consider the Verilog snippet:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="k">posedge&lt;/span> &lt;span class="n">clk&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">begin&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">q&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">d&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">end&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>What is the main issue?&lt;br>
A. Non-synthesizable&lt;br>
B. Blocking assignment may cause incorrect sequential behavior&lt;br>
C. Missing sensitivity list&lt;br>
D. No issue&lt;/p>
&lt;p>&lt;strong>Q8.&lt;/strong> Consider:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="k">posedge&lt;/span> &lt;span class="n">clk&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">begin&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">en&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">q&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="n">d&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">end&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If en = 0, what happens to q?&lt;br>
A. Becomes 0&lt;br>
B. Becomes unknown&lt;br>
C. Holds previous value&lt;br>
D. Toggles&lt;/p>
&lt;p>&lt;strong>Q9.&lt;/strong> Which Verilog construct correctly models a synchronous reset flip-flop?&lt;br>
A.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="k">posedge&lt;/span> &lt;span class="n">clk&lt;/span> &lt;span class="k">or&lt;/span> &lt;span class="k">posedge&lt;/span> &lt;span class="n">rst&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>B.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="k">posedge&lt;/span> &lt;span class="n">clk&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>C.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-verilog" data-lang="verilog">&lt;span class="line">&lt;span class="cl">&lt;span class="k">always&lt;/span> &lt;span class="p">@(&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>D. Both A and B&lt;/p>
&lt;p>&lt;strong>Q10.&lt;/strong> In FSM coding, separating state register and next-state logic helps:&lt;br>
A. Reduce power only&lt;br>
B. Improve readability and avoid unintended latches&lt;br>
C. Increase clock frequency directly&lt;br>
D. Eliminate combinational logic&lt;/p>
&lt;hr>
&lt;h2 id="part-b--sequential-design-analysis-and-schematic-10--7--70-pts">Part B — Sequential Design, Analysis, and Schematic (10 × 7 = 70 pts)&lt;/h2>
&lt;p>&lt;strong>Problem 1 — Hazard Propagation into Sequential Logic&lt;/strong>&lt;/p>
&lt;p>Given combinational logic feeding a flip-flop:&lt;/p>
&lt;p>\(F = A'B + AB'\)&lt;/p>
&lt;p>a) Determine whether a &lt;strong>static-1 hazard&lt;/strong> exists. Justify using Boolean reasoning&lt;br>
b) Draw a timing diagram where input transitions cause a glitch&lt;br>
c) Explain how this glitch can be &lt;strong>captured by a flip-flop&lt;/strong>&lt;br>
d) Modify the logic to eliminate the hazard and draw the corrected schematic&lt;br>
e) Explain why hazard removal is critical in synchronous pipelines&lt;/p>
&lt;p>&lt;strong>Problem 2 — Multi-Cycle Pulse Generator&lt;/strong>&lt;/p>
&lt;p>Design a synchronous circuit that generates an output pulse of &lt;strong>exactly 4 clock cycles&lt;/strong> upon detecting a rising edge on input &lt;code>x&lt;/code>.&lt;/p>
&lt;p>a) Define the required states and draw the FSM diagram&lt;br>
b) Provide a complete state transition table&lt;br>
c) Derive next-state equations&lt;br>
d) Draw the full schematic (flip-flops + combinational logic)&lt;br>
e) Describe behavior if &lt;code>x&lt;/code> is asserted again during the active pulse&lt;/p>
&lt;p>&lt;strong>Problem 3 — Self-Correcting Mod-6 Counter&lt;/strong>&lt;/p>
&lt;p>Design a synchronous &lt;strong>mod-6 counter (0–5)&lt;/strong> that &lt;strong>recovers automatically from invalid states&lt;/strong>.&lt;/p>
&lt;p>a) Draw the state transition diagram including invalid states&lt;br>
b) Specify recovery transitions&lt;br>
c) Choose a state encoding and justify&lt;br>
d) Derive next-state logic equations&lt;br>
e) Draw the complete schematic&lt;br>
f) Explain why self-correction is important in real hardware&lt;/p>
&lt;p>&lt;strong>Problem 4 — Sequence Detector with Overlap and Reset&lt;/strong>&lt;/p>
&lt;p>Design an FSM that detects the sequence &lt;code>1101&lt;/code> with overlap allowed.&lt;/p>
&lt;p>a) Draw the state diagram (minimal states)&lt;br>
b) Provide the state transition table&lt;br>
c) Derive output logic for a Mealy implementation&lt;br>
d) Convert to a Moore implementation&lt;br>
e) Compare:&lt;/p>
&lt;ul>
&lt;li>output timing&lt;/li>
&lt;li>number of states&lt;br>
f) Add a synchronous reset and explain its effect&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problem 5 — Timing Closure and Pipeline Insertion&lt;/strong>&lt;/p>
&lt;p>A sequential circuit has:&lt;/p>
&lt;ul>
&lt;li>t_clk-q = 1 ns&lt;/li>
&lt;li>t_comb = 10 ns&lt;/li>
&lt;li>t_setup = 2 ns&lt;/li>
&lt;/ul>
&lt;p>a) Compute the minimum clock period and maximum frequency&lt;br>
b) Determine if the design meets a 100 MHz requirement&lt;br>
c) Insert one pipeline stage and redraw the system&lt;br>
d) Recompute timing after pipelining&lt;br>
e) Discuss:&lt;/p>
&lt;ul>
&lt;li>latency increase&lt;/li>
&lt;li>throughput improvement&lt;/li>
&lt;li>design tradeoffs&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problem 6 — Serial Pattern Detection: Architecture Comparison&lt;/strong>&lt;/p>
&lt;p>Design a system to detect &lt;strong>five consecutive 1s&lt;/strong> in a serial bitstream.&lt;/p>
&lt;p>a) Implement using a &lt;strong>shift register approach&lt;/strong> (block diagram)&lt;br>
b) Implement using an &lt;strong>FSM approach&lt;/strong> (state diagram)&lt;br>
c) Compare:&lt;/p>
&lt;ul>
&lt;li>hardware cost&lt;/li>
&lt;li>detection latency&lt;/li>
&lt;li>scalability for longer patterns&lt;br>
d) Explain which design is preferred in ASIC vs FPGA contexts&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problem 7 — Reliable Clock Domain Crossing (CDC)&lt;/strong>&lt;/p>
&lt;p>Design a system to safely transfer an &lt;strong>8-bit data word&lt;/strong> between two clock domains.&lt;/p>
&lt;p>a) Explain why a simple 2-FF synchronizer is insufficient&lt;br>
b) Draw a &lt;strong>handshake-based CDC architecture&lt;/strong>&lt;br>
c) Provide a timing diagram showing req/ack interaction&lt;br>
d) Explain how data integrity and ordering are preserved&lt;br>
e) Discuss limitations of this approach&lt;/p>
&lt;p>&lt;strong>Problem 8 — Glitch-Free Output Design&lt;/strong>&lt;/p>
&lt;p>An FSM controls a critical signal that must &lt;strong>never glitch&lt;/strong>.&lt;/p>
&lt;p>a) Explain why Mealy outputs may produce glitches&lt;br>
b) Convert a Mealy FSM into a glitch-free Moore FSM&lt;br>
c) Draw schematic with registered outputs&lt;br>
d) Analyze timing impact (one-cycle delay, stability)&lt;br>
e) Discuss when Mealy design is still preferred&lt;/p>
&lt;p>&lt;strong>Problem 9 — Sequential Resource Sharing&lt;/strong>&lt;/p>
&lt;p>Design a system to compute:&lt;/p>
&lt;p>\(Y = A + B + C + D\)&lt;/p>
&lt;p>using a &lt;strong>single adder reused over multiple cycles&lt;/strong>.&lt;/p>
&lt;p>a) Draw the datapath (registers, muxes, adder)&lt;br>
b) Design the control FSM (states and transitions)&lt;br>
c) Provide a cycle-by-cycle execution table&lt;br>
d) Compare with parallel implementation:&lt;/p>
&lt;ul>
&lt;li>area&lt;/li>
&lt;li>latency&lt;/li>
&lt;li>throughput&lt;br>
e) Explain when sequential reuse is advantageous&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problem 10 — Fair Traffic Controller with Priority and Starvation Avoidance&lt;/strong>&lt;/p>
&lt;p>Design a traffic controller with:&lt;/p>
&lt;ul>
&lt;li>Main road (high priority)&lt;/li>
&lt;li>Side road (low priority)&lt;/li>
&lt;li>Pedestrian request input&lt;/li>
&lt;/ul>
&lt;p>a) Define system states and timing requirements&lt;br>
b) Draw FSM diagram&lt;br>
c) Explain how priority is enforced for main road&lt;br>
d) Design a mechanism to prevent starvation of side road and pedestrians&lt;br>
e) Ensure all transitions are safe (no conflicting greens)&lt;br>
f) Discuss how the design can scale to more lanes or intersections&lt;/p>
&lt;hr></description></item><item><title>Take-Home Midterm Exam (Makeup): Sequential Circuits and Verilog</title><link>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_game_mp/</link><pubDate>Tue, 25 Nov 2025 00:00:00 +0000</pubDate><guid>https://gustybear.github.io/docs/exams/course_ece260_2025_fall/miterm_02_game_mp/</guid><description>&lt;p>&lt;strong>Scope:&lt;/strong> Sequential logic, finite state machines, registers, counters, with Verilog modeling&lt;br>
&lt;strong>Duration:&lt;/strong> 48 hours&lt;br>
&lt;strong>Instructions&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Attempt &lt;strong>all&lt;/strong> questions. Show reasoning, derivations, and clearly state assumptions.&lt;/li>
&lt;li>Provide &lt;strong>commented, synthesizable Verilog&lt;/strong> and a &lt;strong>self‑checking testbench&lt;/strong> where requested.&lt;/li>
&lt;li>Include brief timing/area reasoning (big‑O style or gate/count estimates).&lt;/li>
&lt;li>No collaboration. Cite any external references you consulted.&lt;/li>
&lt;li>Tutorial of Online tools for Verilog simulation can be found
.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-a--multiple-choice-10--3-pts--30-pts">Part A — Multiple Choice (10 × 3 pts = 30 pts)&lt;/h2>
&lt;p>Select the &lt;strong>best&lt;/strong> answer.&lt;/p>
&lt;p>&lt;strong>Q1.&lt;/strong> The primary reason metastability cannot be completely eliminated in synchronous systems is:&lt;/p>
&lt;ul>
&lt;li>A. Setup and hold times are always zero in practice&lt;/li>
&lt;li>B. Flip-flops rely on analog behavior near threshold regions&lt;/li>
&lt;li>C. Clocks in synchronous systems naturally drift&lt;/li>
&lt;li>D. Combinational gates inherently produce glitches&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q2.&lt;/strong> A level-sensitive latch used inside a two-phase latch pipeline must satisfy which condition to avoid races?&lt;/p>
&lt;ul>
&lt;li>A. Both latches must be transparent at the same time&lt;/li>
&lt;li>B. The two clocks must overlap for reliable data transfer&lt;/li>
&lt;li>C. The two clocks must be non-overlapping&lt;/li>
&lt;li>D. Both latches must be opaque for half the cycle&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q3.&lt;/strong> A master–slave flip-flop is functionally equivalent to:&lt;/p>
&lt;ul>
&lt;li>A. Two positive-edge-triggered flip-flops in series&lt;/li>
&lt;li>B. A positive-level latch feeding a negative-level latch&lt;/li>
&lt;li>C. A single negative-level latch&lt;/li>
&lt;li>D. A pair of asynchronous SR latches&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q4.&lt;/strong> The &lt;em>maximum&lt;/em> safe operating frequency of a synchronous sequential circuit is limited by:&lt;/p>
&lt;ul>
&lt;li>A. Clock skew plus the hold time requirement&lt;/li>
&lt;li>B. The minimum propagation delay of the flip-flop&lt;/li>
&lt;li>C. The longest register-to-register combinational path plus setup time&lt;/li>
&lt;li>D. The number of flip-flops in the design&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q5.&lt;/strong> A state machine experiences a transient illegal state during power-up but self-recovers within two cycles. This is most likely due to:&lt;/p>
&lt;ul>
&lt;li>A. Bad next-state logic&lt;/li>
&lt;li>B. Incomplete state encoding causing metastability&lt;/li>
&lt;li>C. Lack of synchronous reset initialization&lt;/li>
&lt;li>D. Excessive gate fan-out in the critical path&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q6.&lt;/strong> A Mealy FSM can produce output glitches primarily because:&lt;/p>
&lt;ul>
&lt;li>A. Its outputs change only on clock edges&lt;/li>
&lt;li>B. It depends directly on asynchronous inputs&lt;/li>
&lt;li>C. Its outputs are combinational functions of both state and inputs&lt;/li>
&lt;li>D. It always requires one extra pipeline stage&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q7.&lt;/strong> Gray-coded counters are often used in multi-clock systems because:&lt;/p>
&lt;ul>
&lt;li>A. They require fewer flip-flops than binary counters&lt;/li>
&lt;li>B. Only one bit changes per transition, minimizing sampling hazards&lt;/li>
&lt;li>C. They operate at higher maximum clock frequencies&lt;/li>
&lt;li>D. They automatically synchronize across domains&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q8.&lt;/strong> In a synchronizer chain for CDC (clock-domain crossing), increasing the number of flip-flops:&lt;/p>
&lt;ul>
&lt;li>A. Eliminates metastability completely&lt;/li>
&lt;li>B. Reduces metastability probability exponentially&lt;/li>
&lt;li>C. Increases metastability probability linearly&lt;/li>
&lt;li>D. Has no effect on metastability at all&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q9.&lt;/strong> Which Verilog description is most likely to unintentionally infer a latch?&lt;/p>
&lt;ul>
&lt;li>A. &lt;code>always @(posedge clk)&lt;/code> with full assignment&lt;/li>
&lt;li>B. &lt;code>always @(*)&lt;/code> missing an &lt;code>else&lt;/code> assignment&lt;/li>
&lt;li>C. A continuous assignment with XOR logic&lt;/li>
&lt;li>D. A blocking assignment inside a clocked block&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Q10.&lt;/strong> A multi-port register file supporting simultaneous read and write must ensure:&lt;/p>
&lt;ul>
&lt;li>A. Writes occur asynchronously to avoid data hazards&lt;/li>
&lt;li>B. Read ports are implemented with edge-triggered flip-flops&lt;/li>
&lt;li>C. Write operations are synchronized and typically prioritized over reads&lt;/li>
&lt;li>D. Read-after-write data hazards are resolved with bypass logic or forwarding&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-b--design--analysis-10--7--70-pts">Part B — Design &amp;amp; Analysis (10 × 7 = 70 pts)&lt;/h2>
&lt;p>For each problem, complete the Verilog template in the
and verify using the provided self‑checking testbench.
Name your top‑level modules exactly as specified.&lt;/p>
&lt;p>&lt;strong>Files provided (in the questions zip):&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Templates: &lt;code>*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Testbenches: &lt;code>tb_*.v&lt;/code> (one per problem)&lt;/li>
&lt;li>Timescale: &lt;code>1ns/1ps&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Problems:&lt;/strong>&lt;/p>
&lt;p>&lt;strong>Problem 1 — Synchronizer + Edge Detect (&lt;code>sync_edge&lt;/code>)&lt;/strong>&lt;br>
Synchronize asynchronous &lt;code>btn_async&lt;/code> into &lt;code>clk&lt;/code> with a two‑FF synchronizer; output &lt;code>btn_sync&lt;/code> level and one‑cycle &lt;code>btn_pulse&lt;/code> on rising edges. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 2 — Dual‑Edge Capture (&lt;code>ddr_reg&lt;/code>)&lt;/strong>&lt;br>
Capture &lt;code>D&lt;/code> on posedge into &lt;code>Q_pos&lt;/code> and on negedge into &lt;code>Q_neg&lt;/code>. Active‑low &lt;code>rst_n&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Problem 3 — Mealy Sequence Detector “11010” (&lt;code>seq_11010_mealy&lt;/code>)&lt;/strong>&lt;br>
Detect the overlapping pattern and assert &lt;code>Z&lt;/code> on the final bit. Use a minimal FSM.&lt;/p>
&lt;p>&lt;strong>Problem 4 — Mod‑6 Up/Down Counter with Enable (&lt;code>mod6_counter&lt;/code>)&lt;/strong>&lt;br>
3‑bit counter over 0..5. &lt;code>En&lt;/code> gates counting; &lt;code>Dir=1&lt;/code> up, &lt;code>0&lt;/code> down. Synchronous reset to 0.&lt;/p>
&lt;p>&lt;strong>Problem 5 — 4×4 Serial Multiplier Controller (&lt;code>mul4_ctrl&lt;/code>)&lt;/strong>&lt;br>
Shift‑add controller with signals &lt;code>LdA,LdB,ClrP,Add,Shift,Done&lt;/code>. Start with &lt;code>start=1&lt;/code>. Iterate 4 times.&lt;/p>
&lt;p>&lt;strong>Problem 6 — 2‑Stage Pipeline &lt;code>(A+B)*C&lt;/code> with Valid/Ready (&lt;code>pipe_add_mul&lt;/code>)&lt;/strong>&lt;br>
Implement a two‑stage pipeline (add then multiply) with back‑pressure (&lt;code>in_valid/in_ready&lt;/code>, &lt;code>out_valid/out_ready&lt;/code>).&lt;/p>
&lt;p>&lt;strong>Problem 7 — CDC Bridge 1 MHz → 100 MHz (&lt;code>cdc_bridge&lt;/code>)&lt;/strong>&lt;br>
Use a &lt;code>req/ack&lt;/code> handshake and 2FF synchronizers both directions to transfer an 8‑bit word reliably.&lt;/p>
&lt;p>&lt;strong>Problem 8 — Moore FSM with Registered Output (&lt;code>moore_safe&lt;/code>)&lt;/strong>&lt;br>
Provide both combinational output &lt;code>Zc&lt;/code> and registered &lt;code>Zr&lt;/code> (hazard‑free).&lt;/p>
&lt;p>&lt;strong>Problem 9 — Sequential 4‑bit ALU (&lt;code>seq_alu4&lt;/code>)&lt;/strong>&lt;br>
Opcode: 00=ADD, 01=AND, 10=XOR, 11=SHL. Registered outputs &lt;code>Y&lt;/code> and &lt;code>Cout&lt;/code> with synchronous reset.&lt;/p>
&lt;p>&lt;strong>Problem 10 — Traffic Lights with Pedestrian Preempt (&lt;code>traffic_ped&lt;/code>)&lt;/strong>&lt;br>
Main: G×3, Y×1; Side: G×2, Y×1. Insert &lt;code>WALK&lt;/code>×4 at a safe point when &lt;code>ped_req=1&lt;/code>; resume correctly.&lt;/p>
&lt;hr>
&lt;p>&lt;strong>Deliverables:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>PDF with answers to Section A and brief design notes for Section B.&lt;/li>
&lt;li>Verilog sources for all 10 designs.&lt;/li>
&lt;li>Simulation logs/screenshots demonstrating passing testbenches.&lt;/li>
&lt;/ul></description></item></channel></rss>