04-BS-8 · May 2018
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
04-BS-8 Digital Logic Circuits — May 2018
National Exams, 3 hours, closed book (Casio or Sharp approved calculator only; one hand-written 8.5"×11" aid sheet, both sides, permitted). Format: five questions offered, each worth 25 marks (100 total); any four constitute a complete paper and only the first four appearing in the answer book are marked. All five are solved below for completeness.
Reference texts: Mano & Ciletti, Digital Design (6th ed., Pearson) — Boolean minimization, K-maps, PAL/PLA/FPGA architectures, flip-flop conversion, sequential-circuit design, arithmetic circuits; Floyd, Digital Fundamentals (11th ed., Pearson) — logic gates, multiplexers, shift registers, flip-flop characteristic tables.
Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.
The source's own S1=S0=1 example gives Q1=D2 and then, two words later, also gives Q0=D1 — but its S1=S0=0 example (Q0=D0 when shifted 0) and S1=0,S0=1 example (Q0=D3 when shifted 1) both fit the single rule $Q_i=D_{(i-k)\bmod 4}$ for rotate-left-by-$k$ exactly, and that same rule requires $Q_0=D_{(0-3)\bmod4}=D_1$ AND $Q_2=D_{(2-3)\bmod4}=D_3$ at $k=3$ — the source's printed "Q2=D1" repeats the same D1 given for Q0 and is read here as a misprint; the internally-consistent value implied by the source's own $k=0,1$ examples is used instead: $Q_2=D_3$.
(a) A barrel shifter is a combinational circuit that shifts or rotates an $n$-bit word by any amount from 0 to $n-1$ positions in a single clock cycle (one gate-delay pass through a MUX network), instead of one bit-position per cycle the way a shift-register built from cascaded flip-flops would. Three advantages/applications: (1) Single-cycle ALU shift/rotate instructions — every general-purpose CPU's ALU uses a barrel shifter so a "shift left by 5" instruction costs one cycle, not five; (2) Floating-point normalization — aligning a mantissa after addition/subtraction requires shifting by an arbitrary, data-dependent amount, which a barrel shifter does in one step; (3) Cryptographic and CRC/hashing datapaths — algorithms such as AES and many hash functions require fixed, arbitrary bit-rotations of a word on every round, and a barrel shifter performs that rotation with fixed, predictable (data-independent) latency, which is also important for avoiding timing side-channels.
Given. $D_3D_2D_1D_0$ (data), $S_1S_0$ (rotate-left amount $k=0,1,2,3$), $Q_3Q_2Q_1Q_0$ (rotated output); worked examples for $k=0$ and $k=1$ given verbatim in the source.
Find. A minimum-part MSI realization and the complete routing table for all four shift amounts.
Approach. Generalize the source's own two worked examples into the single rule $Q_i=D_{(i-k)\bmod 4}$, tabulate all four columns, then realize each output bit as one 4:1 multiplexer (one MSI package per two outputs) whose four data inputs are wired per that output's column and whose select lines are the shared $S_1S_0$.
| S1 S0 (k) | Q3 | Q2 | Q1 | Q0 |
|---|---|---|---|---|
| 00 (0) | D3 | D2 | D1 | D0 |
| 01 (1) | D2 | D1 | D0 | D3 |
| 10 (2) | D1 | D0 | D3 | D2 |
| 11 (3) | D0 | D3 | D2 | D1 |
| Item | Result |
|---|---|
| Rule | $Q_i=D_{(i-k)\bmod4}$, $k=S_1S_0$ |
| MSI part count | 2× 74LS153 (dual 4:1 MUX), zero discrete gates |
| k=2 row | Q3=D1, Q2=D0, Q1=D3, Q0=D2 |
| k=3 row | Q3=D0, Q2=D3, Q1=D2, Q0=D1 |