D101 of 13
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D10 · Lesson 1 · Concurrency in hardware

Why a hardware description is not a program, every assignment as its own circuit running all the time, signals settling through levels of gates, the order of statements not mattering, and the throughput that comes from doing thousands of operations in every clock cycle

Verilog looks like a programming language, which is the first trap it sets. A program runs one statement after another on one processor. A Verilog description has no "after": each assign describes a separate piece of circuitry, and all of them work at once, continuously, from the moment power is applied. Change an input and every gate that depends on it starts changing within picoseconds, in parallel. That's what lets an FPGA do a thousand multiplications in the time a processor does one, and it's why thinking in hardware feels so different from thinking in software.

  • Three assignments: A = X & Y, B = X | Y and C = A ^ B, each gate with a delay of one tick. Flip X and Y, or watch the scripted changes in the timing diagram.
  • A and B respond together, one tick after the inputs change; C responds one tick after that, because it depends on them. The order the lines are written in makes no difference.
  • The time for C to settle is set by the number of gate levels between it and the inputs: the critical path.

Predict

A processor at 3 GHz does one addition per cycle. An FPGA at 300 MHz has 1000 adders working side by side. How many additions per second does each manage?

Name it

Concurrent statements

In Verilog, each assign and each always block describes hardware that exists and operates independently. Their textual order is irrelevant: assign C = A ^ B; can come before the lines that define A and B. Simulators model this with events: when a signal changes, every statement that reads it is scheduled to update after its delay.

Settling time

A combinational output settles after the delay of the slowest path from the inputs to it. With n levels of gates of delay tg each, that's ntg, and a clocked design can run no faster than about 1/(ntg) plus the flip-flops' overhead (lesson 8). Until it settles, an output may show glitches: brief wrong values as faster paths arrive before slower ones.

Throughput from parallelism

Hardware throughput is the number of operations done per cycle times the clock rate. A processor executes a few operations per cycle at gigahertz rates; an FPGA or ASIC can lay down thousands of operators side by side at hundreds of megahertz. Hardware design is the art of finding that parallelism in a problem and laying it out in space.

Worked example

A path passes through 6 levels of gates, each taking 80 ps. How long does it take to settle, and what clock rate does that allow?

Show the solution
  1. Settling time. Each of the 6 levels takes 80 ps: t=6×80ps=480ps
  2. Clock rate. The clock period must be at least 480 ps plus flip-flop overhead, so the clock must stay below about 1480ps=2.08GHz
  3. Fewer levels. Halving the levels would double the rate.

Answer the path settles in 480 ps, which allows a clock below about 2.08 GHz.

Worked example

A video filter must process 1920 × 1080 pixels at 60 frames per second, with 25 multiplications per pixel. How many multipliers does it need at 150 MHz?

Show the solution
  1. Multiplications per second. 1920×1080×60×25=3.11×109per second
  2. Divide by one multiplier's rate. Each multiplier does 1.5×108 a second: 3.11×1091.5×108=20.7
  3. Round up. 20.7 rounds up to 21 multipliers working in parallel.

Answer 21 multipliers working in parallel.

Worked example

1024 numbers must be summed. How many adder delays does a processor adding one at a time need, and how many does a tree of adders in hardware need?

Show the solution
  1. One at a time. A processor needs 1023 additions in sequence, so 1023 adder delays.
  2. A tree of adders. A tree adds pairs in parallel, halving the count at each level: log2⁡1024=10levels using 1023 adders in all.
  3. Speed for area. Hardware buys speed with area, here a hundredfold.

Answer 1023 adder delays one at a time, against 10 for a tree of 1023 adders.

Check

An FPGA design has 256 operators each finishing one operation per clock at 100 MHz. How many billion operations per second does it perform?

Check

A logic path has 6 levels of gates, each with a delay of 50 ps. Ignoring flip-flop overhead, what's the fastest clock it allows?

Write units the way you normally would: 1.5 GHz, 1500 MHz and 0.0015 THz are the same answer.

Check

A filter needs 25 multiplications per pixel on 1920 × 480 video at 60 frames per second. How many multipliers running at 150 MHz does it need?

Check

In a timing simulation, an output sits 4 gate levels from the inputs, and each gate takes 2 ticks. How many ticks after an input changes does the output settle?

Check

A path passes through 8 levels of gates of 40 ps each.

(a)

How long does it take to settle?

Write units the way you normally would: 1.5 ps and 0.0015 ns are the same answer.

(b)

What clock rate does that allow, ignoring flip-flop overhead?

Check

1024 numbers are summed.

(a)

How many additions in sequence does one adder need?

(b)

How many levels does an adder tree need?

Explain why

Why doesn't the order of assign statements matter in Verilog?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.