- Asked 2/19
- 2072 Asoj · 8 marks
- 2075 Baisakh · 8 marks
Fibonacci single-purpose processor
Short answer
The processor initializes a=0, b=1, then loops outputting a, computing next = a+b, updating a=b, b=next until count=n. The FSMD has states wait, test, output, update. Datapath includes registers A, B, T, I, an adder for next, incrementer for count, and comparator; controller sequences loads and outputs.
Design a single-purpose processor that outputs Fibonacci numbers up to 'n' places. Start with a function computing the desired result, translate it into a state diagram and sketch a probable datapath.
Assumption: the processor takes an input n and outputs the first n Fibonacci numbers (0, 1, 1, 2, 3, 5, ...), one per output, with a start input and a done output.
Step 1: Function (algorithm)
Fibonacci(n):
a = 0; b = 1; i = 0
while (i < n) {
output a
t = a + b
a = b
b = t
i = i + 1
}
Step 2: State diagram (FSMD)
start=0 (loop)
+---+
v | start=1
+----------+ a=0,b=1,i=0 +---------+
| S0 wait |------------->| S1 test |
+----------+ +---------+
^ i<n | | i>=n
| v v
| done=1 +--------+ +----+ +------+
+----------| S4 done| | S2 | (to S4)
+--------+ |out=a, t=a+b|
+-----+------+
v
+-----------+
| S3 a=b |
| b=t,i=i+1 |--> S1
+-----------+
Simplified state table:
| State | Condition | Actions | Next |
|---|---|---|---|
| S0 (wait) | start = 0 | done = 0 | S0 |
| S0 | start = 1 | a = 0, b = 1, i = 0 | S1 |
| S1 (test) | i < n | none | S2 |
| S1 | i >= n | done = 1 | S4 |
| S2 (output) | always | out = a, valid = 1, t = a + b | S3 |
| S3 (update) | always | a = b, b = t, i = i + 1 | S1 |
| S4 (finish) | always | done = 1 | S0 |
Step 3: Probable datapath
n --------------------+
v
+---+ +---+ +---+ +------+ i<n (status)
| A | | B | | T | | < |-----------> to controller
+-+-+ +-+-+ +-+-+ +--^---+
| \ | / ^ |
| +-->[ + ]----+ +-+-+
| adder | I |<-[+1]
v +---+
out (a)
Components: registers A, B, T (data) and I (counter), an adder (a + b), an incrementer (i + 1), a comparator (i < n), muxes in front of A (0 or B) and B (1 or T) and output register. Control signals from the controller: load/clear A, B, T, I; mux selects; output enable. Status to controller: i < n.
Controller
A 5-state FSM (3 flip-flops, binary encoded) that generates the loads shown in the table and receives start and i<n. Example n = 5 outputs 0, 1, 1, 2, 3.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Factorial single-purpose processor · Embedded System, chapter 2
- Single-purpose processor for power · Embedded System, chapter 2 · asked 2×
- Design LCM single-purpose processor · Embedded System, chapter 2
- Sum of digits processor · Embedded System, chapter 2
- Dual-purpose processor: median and variance · Embedded System, chapter 2
- LCM processor with state table · Embedded System, chapter 2