S1.5.3 Hardware or Software

MediumImplement22 minIcarus Verilog · serverReview the topic

One function can be a loop in the program or a block on the chip. Count cycles, then weigh what a late change costs.

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

A function counts the bits of a 32-bit word that are 1. The team can write it as a loop or build it as a block.

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
WayCost of one callAfter the chip is made
Software (code 1)one instruction to set up, then four for each bit; one clock cycle for each instructiona change takes 2 days
Hardware (code 2)one clock cycle to count, and three more to read the result over the busa change needs a new chip: 90 days

The days are exercise numbers.

EntryYour decision
SW_CYCLESHow many clock cycles does one software call take?
HW_CYCLESHow many clock cycles does one hardware call take, with the read?
RATIOHow many times faster is the hardware call? Round down.
AT_BOOTThe function runs once when the chip starts, and its rule may still change. Enter 1 or 2.
EACH_SAMPLEA result is needed within 10 clock cycles of each sample. Enter 1 or 2.
RULE_OPENThe rule is still being argued when the chip goes to the factory. Speed is not a problem. Enter 1 or 2.
SW_FITHow many whole software calls fit in 1000 clock cycles?
HW_FITHow many whole hardware calls fit in 100 clock cycles?
TWENTYTwenty calls are needed in every 1000 clock cycles. Enter 1 or 2.
DAYS_LOSTThe rule changes after the chip is made. How many more days does the hardware choice cost?
MIXEDA mixed design masks the word in software with one instruction, then calls the block. Clock cycles for one call?
CHOICE_AT_CALLSThe function must run CALLS times in every 1000 clock cycles. Enter 1 if the software version fits, or 2 if hardware is needed.

Examples

Example 1

SW CYCLES
Input
How many clock cycles does one software call take?
Output
matches = 1

Four cycles for each of 32 bits, and one to set up.

Example 2

HW CYCLES
Input
How many clock cycles does one hardware call take, with the read?
Output
matches = 1

One to count and three to read the result.

Example 3

RATIO
Input
How many times faster is the hardware call? Round down.
Output
matches = 1

Divide 129 by 4 and drop the fraction.

Constraints and Contract

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

Hints

Hint 1

Work out one call of each way before comparing.

Hint 2

A way that misses the time limit is out.

Hint 3

If the rule may change after the chip is made, keep that part in software.

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

SW CYCLES

Input
How many clock cycles does one software call take?
Expected output
matches = 1

Four cycles for each of 32 bits, and one to set up.

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

Icarus Verilog · server