S6.16.2 Three Bring-Up Failures

HardFix45 minIcarus Verilog · serverReview the topic

A receive program gets nothing from UART0. It holds three faults, and each hides the next. Find and repair all three.

Hardware context: Four bring-up programs on a small processor model in front of ap_plic and the ap_clint timer, checked against the real ap_rv32. First firmware on a new chip or board

On a new board, steps 1 and 2 of the bring-up pass: the chip prints, and the timer ticks. Step 3 fails. The program below should take COUNT bytes from UART0 by interrupt and keep them in SRAM. It takes none.

The program holds three faults. Repair them. The structure of the program is right: every fault is in one or two rows.

Signals in the Timeline

SignalWidthRole
trial8input of each check
Full specification
What the program must do
ItemValue
The count of bytesthe word at 0x8000_0000; it ends at COUNT
Byte number n, from 0the word at 0x8000_0040 + 4 times n
Interrupts takenone for each byte
At the endinterrupts off, and a jump to itself
UART0 transmitnothing is sent
The devices
AddressNameWhat it does
0x1000_000CUART0 RXDATARead: the oldest received byte. The read removes it.
UART0 requestinterrupt source 1It is 1 while a received byte waits.
0x0C00_0000 + 4 times IDap_plic priority0 to 7. A source with priority 0 never competes.
0x0C00_2000ap_plic enableBit number = ID.
0x0C20_0000ap_plic thresholdThe wire to the processor rises only for a priority above it.
0x0C20_0004ap_plic claim and completeRead: the ID of the winner; its pending bit clears. Write: that ID, when the handler is done. Until then the source cannot request again.
miebit 11 external, bit 7 timer, bit 3 softwareThe enable bits of the processor.
mstatus, bit 3MIEThe global enable.
A row
CSR names: MSTATUS, MIE, MTVEC, MSCRATCH, MEPC, MCAUSE, MIP. Also available: ANDI, ORI, SLLI, SRLI, ADD, SUB, AND, OR. Row n is at address 4 times n.
FormMeaning
i(LUI, a, 0, c)x[a] = c shifted left by 12. c has at most 20 bits.
i(ADDI, a, b, c)x[a] = x[b] + c. c is from -2048 to 2047.
i(LW, a, b, c) and i(SW, a, b, c)load x[a] from, or store x[a] to, the address x[b] + c
i(BEQ, a, b, c), BNE, BLT, BGEcompare x[a] with x[b]; if true, go to address c
i(JAL, a, 0, c) and i(JALR, a, b, c)x[a] = the address of the next row; go to c, or to x[b] + c
i(CSRR, a, 0, name), i(CSRW, a, 0, name)read a CSR into x[a]; write x[a] to a CSR
i(CSRS, a, 0, name), i(CSRC, a, 0, name)set, or clear, the bits of a CSR that are 1 in x[a]
i(MRET, 0, 0, 0)return from a handler
at(address)the rows that follow start at this address

Examples

Example 1

Four Bytes, Far Apart
Input
COUNT = 4; the bytes 0x41 at tick 300, 0x42 at tick 500, 0x43 at tick 700, 0x44 at tick 900
Output
program_stops = 1, no_exception = 1, count = 1, buffer = 1, one_interrupt_per_byte = 1, nothing_else_written = 1

Four bytes arrive 200 ticks apart. Each causes one interrupt.

Example 2

Six Bytes, Far Apart
Input
COUNT = 6; the bytes 0x41 at tick 300, 0x42 at tick 500, 0x43 at tick 700, 0x44 at tick 900, 0x45 at tick 1100, 0x46 at tick 1300
Output
program_stops = 1, no_exception = 1, count = 1, buffer = 1, one_interrupt_per_byte = 1, nothing_else_written = 1

With COUNT at 6 the program waits for six bytes.

Example 3

Bytes in Pairs
Input
COUNT = 4; the bytes 0x61 at tick 300, 0x01 at tick 304, 0x00 at tick 800, 0x7f at tick 803
Output
program_stops = 1, no_exception = 1, count = 1, buffer = 1, one_interrupt_per_byte = 1, nothing_else_written = 1

Two bytes arrive four ticks apart: the second waits while the handler serves the first.

Constraints and Contract

  • Keep module my_receive, its parameter and the declarations below the task. Change only the rows of the_program.
  • Use COUNT. The bench builds the module twice, with different values. At most 128 rows.

Hints

Hint 1

Walk the path of a request: device, pending bit, priority, enable, threshold, the wire, mie, mstatus. The first break stops everything.

Hint 2

After the first repair, expect the same symptom. Go on along the path.

Hint 3

When one byte arrives and no more, look at what ends the handler.

What the grader checks: Each trial sends COUNT bytes at planned ticks and runs the model until the program stops. It checks the count, every buffer word, the number of interrupts and the word after the buffer. Plans include bytes four ticks apart, the values 0 and 1, and values drawn for each submission.

9 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

Four Bytes, Far Apart

Input
COUNT = 4; the bytes 0x41 at tick 300, 0x42 at tick 500, 0x43 at tick 700, 0x44 at tick 900
Expected output
program_stops = 1, no_exception = 1, count = 1, buffer = 1, one_interrupt_per_byte = 1, nothing_else_written = 1

Four bytes arrive 200 ticks apart. Each causes one interrupt.

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

Icarus Verilog · server