V6.1.1 The GPIO Without a Core

MediumImplement30 minap_soc v1.5 · bus seat · serverReview the topic

With no core in the seat, test GPIO's inputs all the way to the core's interrupt pin. Drive the pads from the board, watch the pin, and claim the interrupt yourself. Hidden faulty chips each break one step.

Hardware context: ap_soc v1.5 with a bus manager in the core's seat, watching the interrupt pins. GPIO's inputs taken to the core's pin and claimed by the seat.

The core is out: a bus manager sits in its seat, and your sequence table is the whole test. The board drives pads IO8 to IO14 as GPIO inputs. Write a table that proves two things for each of those seven pads.

First, GPIO IN follows the pad: high when the board drives it high, low when low. Second, a rising edge reaches the core's external interrupt pin. With the pad's bit set in IRQ_ENABLE, the edge must set the pad's bit in STATUS. It must raise the external pin through ap_plic source 2, and a read of the claim register must return 2. Then clear STATUS, complete source 2, and check the pin has fallen.

The good chip must pass. Each of several hidden faulty chips breaks one step of that path, and your table must fail on each.

Full specification
RegisterAddressUse
GPIO IN0x1000_1004Bit n: the level of pad n, two clk_sys cycles late
GPIO IRQ_ENABLE0x1000_1018Bit n: pad n may raise the request
GPIO LEVEL_MODE0x1000_101CBit n = 0: pad n raises on an edge (reset value)
GPIO STATUS0x1000_1024Bit n: an edge seen; write 1 to clear
ap_plic priority of source 20x0C00_0008Non-zero lets source 2 through
ap_plic enable0x0C00_2000Bit 2: source 2
ap_plic claim and complete0x0C20_0004A read claims; writing the source number completes

Board rows: tb gpio_set p level; tb gpio_pulse p cycles. Pin rows: core irq compares the interrupt pins (bit 0 software, 1 timer, 2 external) with mask and expect. A core wait_irq row waits until a pin of mask is high, at most data cycles.

Rows: who op address data mask expect delay repeat (two words, four hex numbers, two decimal numbers). A core r row checks (value & mask) == (expect & mask). Rows core re and core we must answer ERROR. A core poll row reads until the masked value matches, at most data reads. The bench manual lists every row.

Given Files

Read-only files supplied by the bench.

The sequence table · bench manual

One row a line: who op address data mask expect delay repeat. Two words, four hex numbers, two decimal numbers. delay: cycles to wait before the row. repeat: how often the row runs. A line that starts with # is a comment. With +core=bfm the table is the test: the bench writes TB_STATUS = 2 before the first row and the pass or fail word after the last. With +core=cpu a table holds the bench's side of a firmware test.

whoopMeaning
corew wh wbWrite a word, a half, a byte of data at address; the answer must be OKAY
corer rh rbRead; (value & mask) must equal (expect & mask)
corewe reWrite or read that must answer ERROR
corewq rqAs w and r, with the next row's address phase on this row's data phase (back to back)
corepollRead until the masked value is the expected one; data = the most reads (0: 1,000)
coreirqThe interrupt pins now (bit 0 software, 1 timer, 2 external) against mask and expect
corewait_irqWait until a pin of mask is high; data = the most cycles
coreidleEnd a back-to-back run
dmacopyOne job from address to data of mask bytes; STATUS must be expect (2 DONE, 4 FAULT)
jtagidcodeTAP reset, read IDCODE, compare
jtaghalt resume stepDebug control (a halt waits for the core)
jtagrr rwRead or write the register numbered address (0x1000 + n, a CSR, 0x7b0, 0x7b1)
jtagstreamStart background word reads at address A, count D, maximum random gap M, expected word E
tbwait_releaseWait for the system bus and core resets to release. Seat tables also hold each row at dispatch during reset.
tbwatchdogSet the seat stall limit to data system clocks (zero disables it). A stalled request reports its row, address and direction.
tbgapsMaximum random gap D before each seat row, in system cycles (0 disables gaps)
jtagmr mwRead or write a word of memory through the debug manager
jtagarm status"Halt at reset" = data; {halted, error, busy} against mask and expect
jtagcmdCommand number address (0 to 7, facts 27.10) with the word data; its reply against mask and expect
tbuart_sendSend the byte data to the chip
tbuart_expectThe next byte from the chip must be expect; address = the most bit times to wait
tbgpio_set gpio_pulsePad address to level data; a pulse of data cycles of CLK
tbgpio_expectThe sixteen pads against mask and expect
tbreset supplyThe reset pin, or the supply, for data cycles of CLK
tbwait_eventWait until the test writes address to TB_EVENT
tbargDeposit data in TB_ARG
tbwait_statusWait until (TB_STATUS & mask) equals (expect & mask)
tbpoke peekBack-door write of mask bytes (0: 4) of data; back-door read against mask, expect
tbwaitOnly the delay
syma symbol nameBack-door write of data to that C variable, with the symbol's size

core and dma rows need +core=bfm. soc-rows.mjs turns a list of core and tb rows into both forms: a table for the seat, or a table in SRAM for an interpreter in ROM, with a hand-shake wherever the list goes from one side to the other.

GPIO · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000DIR15:0valuerw0x0000regs1 turns the output driver of that pin on. One bit for each pin.
0x004IN15:0valueroblockThe pin levels, after two sampling flip-flops. One bit for each pin.
0x008OUT15:0valuerw0x0000regsThe saved output value. One bit for each pin.
0x00CSET15:0valuew1sacts on OUT.valueA 1 sets that bit of OUT. One bit for each pin.
0x010CLR15:0valuew1cacts on OUT.valueA 1 clears that bit of OUT. One bit for each pin.
0x014TGL15:0valuew1tacts on OUT.valueA 1 inverts that bit of OUT. One bit for each pin.
0x018IRQ_ENABLE15:0valuerw0x0000regsA 1 lets that pin's status bit raise interrupt source 2. One bit for each pin.
0x01CLEVEL_MODE15:0valuerw0x0000regs1: the pin is a level cause. 0: an edge cause. One bit for each pin.
0x020ACTIVE_HIGH15:0valuerw0xFFFFregs1: a high level, or a rising edge, is the event. One bit for each pin.
0x024STATUS15:0valuew1cblockRaw status. A written 1 clears the saved edge flag of that pin. One bit for each pin.
0x028MASKED_STATUS15:0valueroblockSTATUS AND IRQ_ENABLE. One bit for each pin.
ap_plic · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x004 + 4 × (n − 1), n = 1 to 16PRIORITY2:0levelrw0x0blockPriority of source n, 0 to 7. 0 never competes. Priority.
0x001000PENDING16:1sourcesroblockPending bits; bit number = source ID. One bit for each source.
0x002000ENABLE16:1sourcesrw0x0000blockEnable bits; bit number = source ID. One bit for each source.
0x200000THRESHOLD2:0levelrw0x0blockThe core sees a request only above this priority. Threshold.
0x200004CLAIM4:0idrw0x00blockRead: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID.

Examples

Example 1

The Good Chip
Input
your table
Output
pass

Every input follows its pad, and every edge reaches the pin and is claimed as source 2.

Example 2

A Hidden Faulty Chip
Input
your table on a faulty chip
Output
fail: a row did not get its expected answer

Each hidden chip breaks one step between a pad and the pin; one of your rows must notice.

Example 3

What Does Not Count
Input
a table that only reads STATUS
Output
refused

A request can set STATUS and still never reach the pin.

Constraints and Contract

  • At most 160 rows, only rows of the bench manual.
  • The good chip must pass. Each hidden faulty chip must fail one of your rows.

Hints

Hint 1

A rising edge on a pad whose IRQ_ENABLE bit is clear sets nothing. Set the bit first.

Hint 2

A source stays claimed until it is completed: claim, clear STATUS, then complete, or the next pad's claim returns 0.

Hint 3

Which pads did you test all the way to the pin, and not only to STATUS?

What the grader checks: Your table runs on the pre-built ap_soc v1.5 bench with +core=bfm, on the good chip and on several hidden faulty chips. The good chip must pass with no bench error. The grader cannot see which of your rows caught a faulty chip. The Timeline of a sample run shows the first 256 cycles of the good chip.

1 checks on ap_soc v1.5 · bus seat · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your text only; the chip, the bench and the hidden checks stay on the server. 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 Sequence tableSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

The Good Chip

Input
your table
Expected output
pass

Every input follows its pad, and every edge reaches the pin and is claimed as source 2.

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

ap_soc v1.5 · bus seat · server