1 / 24 · Concept
Turn an equation into a datapath contract
Specify widths, acceptance events, and valid results alongside the arithmetic.
Lessons are free to read. Enroll to save your learning progress.
Specify what the circuit promises
A datapath stores, selects, and computes values. Its controller decides which values move and when. These are separate design responsibilities, but they are not independently running software tasks. At a clock edge, control signals decide register updates; those register values become inputs to combinational logic during the following cycle. An equation without this timing contract can produce the right number for the wrong transaction.
Our small calculator accepts unsigned eight-bit operands a and b and a two-bit operation. Operation 0 adds, 1 subtracts, 2 computes AND, and 3 computes XOR. Arithmetic returns the low eight bits, with a separate addition carry or subtraction borrow. Later projects also carry a tag. A tag does not change the calculation, but it identifies the input that produced a result, so it must travel with that result.
| Contract item | Choice in this course |
|---|---|
| Operand meaning | Unsigned integers from 0 through 255 |
| Narrowing | Low eight bits, modulo 256 |
| Boundary information | ADD carry and SUB borrow |
| Acceptance | Rising edge with valid and ready both asserted |
| Ordering | Results follow accepted-input order |
| Reset | Discard outstanding work and clear valid state |
For a=250, b=10, and ADD, the mathematical sum is 260. The output is 4 with carry=1. Signed interpretation or saturation would give a different contract. Do not let an accidental language conversion choose the policy. Wrapping arithmetic may suit address counters, while a brightness calculation may require saturation.
- Accept: Capture operands, operation, and tag
- Compute: Apply the specified numeric contract
- Deliver: Transfer result and matching tag
An invalid ALU output may still change electrically; it does not represent a transaction. A valid result with an old tag is also incorrect. Inspect data, tag, and valid together. For every output, answer both what the bits mean and when a consumer may trust them. The cycle models here check functionality and ordering, not physical gate delays. Translate the contract into a reference model before choosing register boundaries for a latency or throughput target.
Try it yourself
Record the eight-bit ADD result and carry for a=250 and b=10. Explain the value 4 and why the tag must be stored with the result.
Read the explanation
260=1×256+4, so data=4 and carry=1. The low-eight-bit contract reduces the sum modulo 256. Store the tag under the same acceptance, stall, and delivery conditions as the data so the result remains associated with its input.