Question 1 of 5: FPGA/PLD Architecture & Sign-Magnitude to 2’s-Complement Converter
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
National Exams — May 2017 — 04-BS-8 Digital Logic Circuits. Three-hour, closed-book exam (Casio or Sharp approved calculator only; one hand-written 8.5"×11" aid sheet 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, PAL/PLA/FPGA architectures, flip-flop conversion, sequential design, arithmetic circuits; Floyd, Digital Fundamentals (11th ed., Pearson) — decoders, number systems, flip-flop characteristic tables, counters.
Part (a). A PAL/PLA is a fixed two-level AND–OR structure: the AND (product-term) array is fuse- or antifuse-programmable, but the OR array is wired at fabrication, so every output sums a small, fixed set of product terms — cheap and fast, but limited fan-in per output, no routing flexibility, and no sequential resources beyond an optional output flip-flop. An FPGA replaces this with a fine-grained array of small look-up-table (LUT) based logic cells, each paired with its own flip-flop, connected through a rich, field-programmable interconnect fabric. Three features make it versatile where a PLD is not: (1) arbitrary combinational functions per cell — a LUT realizes any function of its (typically 4–6) inputs, not just a sum of fixed-width product terms; (2) a programmable routing fabric that lets thousands of cells be wired into deep, wide, pipelined datapaths, whereas a PLD's AND/OR arrays cannot be chained beyond their own output register; (3) per-cell registers plus embedded blocks (block RAM, multipliers/DSP slices, sometimes hard processor cores) that let an FPGA hold large state machines, memories and arithmetic units on one device — capacity a PLA/PAL, sized for a handful of equations, cannot approach.
Approach (part b). Sign-magnitude splits the word into a sign bit a3 and a 3-bit magnitude a2a1a0 (0–7). For a3=0 the 2’s-complement value equals the magnitude unchanged. For a3=1 the standard 2’s-complement rule applies to the sign-extended magnitude: invert every bit, then add 1. Building the circuit as “conditionally invert, then ripple-increment” (rather than deriving four independent 4-variable K-maps from scratch) is what drives the gate count to the minimum.
Given data
Signal
Meaning
a3
sign bit (0 = positive, 1 = negative)
a2a1a0
3-bit magnitude, 0–7 (value range −7…+7)
Z3Z2Z1Z0
4-bit 2’s-complement representation of the same value
Truth table by inspection. For a3=0, Z = 0 a2 a1 a0 (pass-through — a positive value's 2’s-complement form is itself). For a3=1, Z is the 4-bit 2’s complement of the sign-extended magnitude 0 a2 a1 a0: invert all four bits, then add 1. Conditional inversion of bit i is exactly ci = ai ⊕ a3 (passes ai through unchanged when a3=0, inverts it when a3=1) — and the sign-extension bit inverts to c3 = 0 ⊕ a3 = a3. Adding 1 is then an ordinary ripple carry with carry-in tied to a3 (so the +1 only fires when a3=1):
$$Z_0 = c_0 \oplus a_3,\quad carry_0 = c_0 \cdot a_3$$ $$Z_1 = c_1 \oplus carry_0,\quad carry_1 = c_1 \cdot carry_0$$ $$Z_2 = c_2 \oplus carry_1,\quad carry_2 = c_2 \cdot carry_1$$ $$Z_3 = c_3 \oplus carry_2 = a_3 \oplus carry_2$$ This was brute-force checked against the direct arithmetic definition of Z for all 16 (a3,a2,a1,a0) combinations — it matches exactly.
Simplify Z0 first (K-map not even needed). Substituting c0=a0⊕a3: $$Z_0 = (a_0 \oplus a_3) \oplus a_3 = a_0$$ since XOR-ing twice by the same signal cancels. $$\boxed{Z_0 = a_0}$$ — a direct wire, no gate at all. This makes sense physically: the least-significant bit of a 2’s-complement negation is always unchanged (invert-then-+1 always returns the LSB to its original value).
Z1 — K-map view confirms a 2-gate result. carry0 = c0·a3 = (a0⊕a3)·a3 = a0·a3 (since a3·a3=a3 and the a3=0 rows of the XOR vanish under the AND). So $$Z_1 = c_1 \oplus carry_0 = (a_1 \oplus a_3) \oplus (a_0 \cdot a_3)$$ Plotting Z1 on a 4-variable K-map (a3,a2,a1,a0) shows the 1-cells split cleanly along this same grouping — no further reduction is possible since Z1 depends on all of a3,a1,a0 and no larger adjacent group exists. $$\boxed{Z_1 = a_1 \oplus (a_3 \cdot a_0)}$$ realized as 1 AND + 1 XOR (2 gates).
Z2 and Z3 — continue the ripple. carry1 = c1·carry0, so $$Z_2 = c_2 \oplus carry_1 = (a_2\oplus a_3)\oplus\big[(a_1\oplus a_3)\cdot(a_0\cdot a_3)\big]$$ (1 AND + 1 XOR beyond the shared carry chain). carry2 = c2·carry1 is zero unless a3=1 AND a2=a1=a0=0 (the a3=1,magnitude=0 row, i.e. −0), so $$Z_3 = a_3 \oplus carry_2 = a_3\cdot(a_2+a_1+a_0)$$ which matches the K-map directly: Z3=1 exactly on the eight cells a3=1 with at least one magnitude bit set. $$\boxed{Z_3 = a_3\cdot(a_2+a_1+a_0),\quad Z_2 = c_2\oplus carry_1}$$
Gate count. 3 XOR gates build c0,c1,c2 from a3 and each magnitude bit; the ripple chain adds 3 AND (carry0,carry1,carry2) + 3 XOR (Z1,Z2,Z3); Z0 needs none. $$\boxed{9\text{ two-input gates total}}$$
Fig. Q1(b) — sign-magnitude to 2’s-complement converter: conditional-complement (XOR with a3) then ripple increment (AND/XOR carry chain). 9 gates total; Z0 = a0 needs no gate.