- 2069 Bhadra · 8 marks
Design LCM single-purpose processor
Short answer
Method: maintain X = multiples of a, Y = multiples of b; if X<Y, X = X+a else Y = Y+b until X=Y. Datapath: registers A(a), B(b), X, Y; adders with muxes to load or add; comparator generates eq/lt flags. Controller: FSM with states S0 (wait), S1 (compare), S2 (X add), S3 (Y add), S4 (output).
Design a processor that calculates the LCM of two numbers. Show the design of data path only and construct the diagram of controller.
The design uses the additive LCM method: keep two running multiples, X (of a) and Y (of b), and repeatedly add to the smaller one until they become equal. That common value is the LCM. (Inputs a and b are positive integers.)
Algorithm
LCM(a, b):
X = a; Y = b
while (X != Y):
if (X < Y) X = X + a
else Y = Y + b
output X
Example a = 4, b = 6: (X, Y) = (4,6) -> (8,6) -> (8,12) -> (12,12). LCM = 12.
FSMD
| State | Condition | Actions | Next |
|---|---|---|---|
| S0 wait | start = 0 | done = 0 | S0 |
| S0 | start = 1 | A = a, B = b, X = a, Y = b | S1 |
| S1 compare | X = Y | none | S4 |
| S1 | X < Y | none | S2 |
| S1 | X > Y | none | S3 |
| S2 | always | X = X + A | S1 |
| S3 | always | Y = Y + B | S1 |
| S4 output | always | out = X, done = 1 | S0 |
Datapath (only)
a -> [A] [B] <- b
| X+A | Y+B
v v
+--> [adder] [adder] <--+
| | | |
| mux(a,X+A) mux(b,Y+B)
| v v |
+----- [X] [Y] ----+
| \ / |
| [comparator]--> eq, lt (to controller)
v
out = X
Components: registers A, B, X, Y (X and Y are 16 bits, since the LCM of two 8-bit numbers can need up to 16 bits), two adders (or one shared adder with a mux), two 2:1 multiplexers (load the input or the add result), one comparator giving eq (X = Y) and lt (X < Y), and an output buffer. Control inputs to the datapath: loadA/B, X_sel, X_ld, Y_sel, Y_ld, out_en.
Controller (FSM)
Inputs: start, eq, lt. Outputs: X_ld, Y_ld, selects, done. Five states, 3-bit state register.
start, status flags --> +-------------+ +-----------+
(from datapath) | Next-state |-->| State |
| logic | | register |
+------^------+ +-----+-----+
| current state |
+-----------------+
v
+-------------+
| Output logic|--> control
+-------------+ signals
| State | Control signals asserted |
|---|---|
| S0 | none (waiting) |
| S1 | none (comparison only) |
| S2 | X_sel = add, X_ld = 1 |
| S3 | Y_sel = add, Y_ld = 1 |
| S4 | out_en = 1, done = 1 |
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- LCM processor with state table · Embedded System, chapter 2
- Factorial single-purpose processor · Embedded System, chapter 2
- Single-purpose processor for power · Embedded System, chapter 2 · asked 2×
- Dual-purpose processor: median and variance · Embedded System, chapter 2
- Fibonacci single-purpose processor · Embedded System, chapter 2 · asked 2×
- LCM processor algorithm and VHDL · Embedded System, chapter 9 · asked 2×
- Single-phase AC voltage controller with R load · Power Electronics, chapter 6 · asked 6×
- DMA controller block diagram and transfer · Computer Organization and Architecture, chapter 7 · asked 6×
- Digital PD controller design for plant 1/s² · Digital Control System, chapter 4 · asked 2×
- Derivative feedback controller: block diagram and effect · Control Systems, chapter 7 · asked 2×