S2.16.2 The Reset Vector Tied to Zero

MediumDebug25 minIcarus Verilog · serverReview the topic

A core was wired into its first chip, and the chip came up. The same wiring in the next chip does not. Find what was only right for the first one.

Hardware context: A small model of the core as test code, started at a reset vector with a hart number, running a hello program that writes two words to RAM; the same program runs on the real ap_rv32 with the same reset_vector and hart_id inputs. Integrating a processor core into a chip: what to tie, what to connect and what to observe

A core as an IP block has inputs that give it its place in a chip: where to start, which processor it is, and which interrupt lines are its own. A small block ties them.

The block below worked in the first chip. In the second chip the bring-up program never reaches its end. Repair the block, so that it is right for every chip that sets its two parameters.

Signals in the Timeline

SignalWidthRole
trial10input of each check
Full specification
What the core does with each input
These are the inputs of ap_rv32. The bench runs a model of the core with the values your block gives.
Input of the coreWhat the core does with it
reset_vectorIt fetches its first instruction from this address
hart_idThe CSR mhartid reads this value
irq_externalBit 11 of the CSR mip
irq_timerBit 7 of mip
irq_softwareBit 3 of mip
The bring-up program, in the boot ROM of each chip
The ROM of a chip starts at the address in ROM_BASE. Memory outside the program holds zeros, which are no instruction.
StepWhat it does
1Reads mhartid, adds 72, and writes the sum to the word at 8000_0000
2Reads mip and writes it to the word at 8000_0004
3Stops

How to read a result: program_reached_its_end is 1 when the program stopped by itself. traps counts the traps on the way, up to 15. result_word is the low byte of the word at 8000_0000, in decimal. mip_seen_by_the_program is the word at 8000_0004, in hex.

Examples

Example 1

The First Chip
Input
the first chip: boot ROM at 0, processor 0, no interrupt pending
Output
program_reached_its_end = 1, traps = 0, result_word = 72, mip_seen_by_the_program = 0x0

The program runs from address 0 and writes 72, the letter H, for processor 0. mip reads 0.

Example 2

The Second Chip
Input
the second chip: boot ROM at 200 in hex, processor 0, no interrupt pending
Output
program_reached_its_end = 1, traps = 0, result_word = 72, mip_seen_by_the_program = 0x0

The core must start at 200. The program reaches its end with no trap.

Example 3

A Timer Interrupt Pending
Input
the first chip again, with the timer interrupt pending
Output
program_reached_its_end = 1, traps = 0, result_word = 72, mip_seen_by_the_program = 0x80

The timer line shows as bit 7 of mip: 80 in hex.

Constraints and Contract

  • The block has no clock: every output follows the inputs and the parameters.
  • The bench builds four chips with different parameters. Processor numbers go from 0 to 3.
  • An interrupt line is active high from end to end.
  • A run that executes more than 60 instructions and traps is stopped and refused.

Hints

Hint 1

Run the second public case. The program does not reach its end. Where does the core fetch its first instruction, and what is there?

Hint 2

The first chip had one processor. Which constant in the block is only right for that?

Hint 3

Run the third public case, and compare the bit of mip with the table.

What the grader checks: Four chips: boot ROM at 0, 200, 400 and 800 in hex, processors 0, 0, 1 and 3. Every interrupt line alone, pairs and all three, on several chips. The end of the program, the number of traps, the result word and the value of mip are checked.

14 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 2 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

The First Chip

Input
the first chip: boot ROM at 0, processor 0, no interrupt pending
Expected output
program_reached_its_end = 1, traps = 0, result_word = 72, mip_seen_by_the_program = 0x0

The program runs from address 0 and writes 72, the letter H, for processor 0. mip reads 0.

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

Icarus Verilog · server