S1.5.1 CPU Time from Three Numbers

EasyImplement12 minIcarus Verilog · serverReview the topic

Work out CPU time from the instruction count, the cycles for each instruction and the clock period.

Hardware context: A job in two parts, one of them a slow unit that can be made faster. Architecture trade-off studies

Every entry uses one equation. CPU time is the instruction count, times the CPI, times the clock period. CPI is the average number of clock cycles for one instruction.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification

Times are in nanoseconds (ns). A clock of 1000 MHz has a period of 1 ns. A clock of 100 MHz has a period of 10 ns.

EntryYour decision
PERIODThe clock is 100 MHz. What is the period in ns?
CYCLESA program runs 20 instructions with a CPI of 2. How many clock cycles?
TIMEThose 40 cycles run with a period of 5 ns. CPU time in ns?
TIME_ADesign A: 10 instructions, CPI 2, period 10 ns. CPU time in ns?
TIME_BDesign B halves the period to 5 ns, and its CPI rises to 3. The same 10 instructions. CPU time in ns?
WINNERWhich design finishes the program sooner? Enter 1 for A or 2 for B.
CPI_TIMES_10A program of 30 instructions took 45 cycles. What is the CPI, times 10?
FASTER_CLOCKA run takes 240 ns with a period of 10 ns. The period becomes 8 ns and nothing else changes. New time in ns?
FEWERA rewritten program needs a quarter fewer than 40 instructions. The CPI is 2 and the period is 3 ns. CPU time in ns?
FREQUENCYThe period is 20 ns. What is the clock frequency in MHz?
TIME_CA program runs 12 instructions with a CPI of 3 and a period of 4 ns. CPU time in ns?
TIME_AT_CPIA program runs 25 instructions with a clock period of 1 ns. Each instruction takes CPI clock cycles. CPU time in ns?

Examples

Example 1

PERIOD
Input
The clock is 100 MHz. What is the period in ns?
Output
matches = 1

One thousand divided by 100 gives 10 ns.

Example 2

CYCLES
Input
A program runs 20 instructions with a CPI of 2. How many clock cycles?
Output
matches = 1

Twenty instructions, two cycles each.

Example 3

TIME
Input
Those 40 cycles run with a period of 5 ns. CPU time in ns?
Output
matches = 1

Forty cycles of 5 ns each.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For TIME_AT_CPI, enter a constant expression using CPI. Only this entry changes with the parameter. The supported integer range is 1 through 8, inclusive.

Hints

Hint 1

Instruction count, CPI and period. Find any that is missing first.

Hint 2

Count times CPI gives cycles. Cycles times period gives time.

Hint 3

A faster clock can lose to a lower CPI, and the other way round.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

12 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 3 problems on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

PERIOD

Input
The clock is 100 MHz. What is the period in ns?
Expected output
matches = 1

One thousand divided by 100 gives 10 ns.

Run samples executes all 3 public checks. Check all tests runs 12 checks on the server.

Icarus Verilog · server