S9.8.1 Attach the Accelerator

MediumImplement35 minIcarus Verilog · serverReview the topic

Give the CRC engine of S9.8 its registers on APB and its own read port. Then it fetches a buffer by itself, reports DONE and raises an interrupt.

Hardware context: A CRC engine of ap_soc attached as a register-mapped subordinate, a stream fed by the DMA and a bus manager, beside the real ap_rv32. Accelerator integration and offload decisions

The engine of S9.8 computes a CRC one word at a time. Here it becomes a block of ap_soc. Software programs it through APB, and then the engine reads the buffer itself, as a bus manager.

APB writes take effect on the rising clk edge of their access phase (psel and penable both 1). pready is always 1. rst_n is a synchronous reset, active low, that clears every register to 0.

Signals in the Timeline

SignalWidthRole
sample10input of each check
Full specification
OffsetRegisterMeaning
0x00SRCAddress of the first word. Bits 1:0 always read 0. A write while BUSY is ignored.
0x04LENWords to read, in bits 15:0. Bits 31:16 read 0. A write while BUSY is ignored.
0x08CTRLWrite: bit 0 = START (reads 0), bit 1 = IE, the interrupt enable (reads back).
0x0CSTATUSBit 0 BUSY, bit 1 DONE, bit 2 ERROR. Write 1 to bit 1 or bit 2 to clear that bit; 0 leaves it.
0x10RESULTThe CRC of the last finished run. It changes only when a run finishes.

START while idle with LEN not 0 begins a run. BUSY becomes 1 and DONE 0. The CRC is set to FFFF_FFFF, the address to SRC and the count to LEN. START while idle with LEN = 0 sets ERROR and starts nothing. START while BUSY is ignored.

While BUSY, rd_req is 1 and rd_addr is the address of the next word. In a cycle with rd_ack = 1 that word is taken. The CRC takes rd_data (use crc_word), the address grows by 4, and the count falls by 1. When the last word is taken, BUSY falls, DONE rises and RESULT gets the final CRC, all on that edge.

If software clears DONE on the same edge on which a run finishes, DONE is 1 after the edge.

irq = DONE and IE. prdata shows the register at paddr while psel is 1, and 0 otherwise. A transfer to any other offset gets pslverr = 1 in its access phase, and prdata 0.

Examples

Example 1

Reset
Input
Reset
Output
prdata = 0x0, pslverr = 0, pready = 1, rd_addr = 0x0, rd_req = 0, irq = 0

Every register is 0, so the read port is idle and prdata is 0.

Example 2

The Setup Edge
Input
Setup edge of a write of 8000_0043 to SRC
Output
prdata = 0x0, pslverr = 0, pready = 1, rd_addr = 0x0, rd_req = 0, irq = 0

psel is 1 and penable is 0: nothing is written yet, and SRC still reads 0.

Example 3

The Access Edge
Input
Access edge of that write: SRC keeps 8000_0040
Output
prdata = 0x80000040, pslverr = 0, pready = 1, rd_addr = 0x0, rd_req = 0, irq = 0

SRC takes the address with bits 1:0 cleared: 8000_0040.

Constraints and Contract

  • Implement module crc_accel with the given ports. Keep the function crc_word. rd_req, rd_addr, irq, pready, pslverr and prdata depend only on the registers and the APB inputs.
  • Use only your ports. Force, release, defparam, bind and hierarchical names are refused.

Hints

Hint 1

Write the register file first, and read every register back before you add the run.

Hint 2

A run has three counters of state: the CRC, the address and the words left. Which edge changes each of them?

Hint 3

Two things can happen to DONE on one edge. The brief says which wins.

What the grader checks: Every register is read and written in both APB phases, with random memory acks. The runs include one word, twelve words with sparse acks, and back-to-back runs. The bench also writes and starts while busy, and starts with LEN = 0. It uses unknown offsets and turns IE off and on. It clears DONE as a run ends, and resets in a run.

348 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

Reset

Input
Reset
Expected output
prdata = 0x0, pslverr = 0, pready = 1, rd_addr = 0x0, rd_req = 0, irq = 0

Every register is 0, so the read port is idle and prdata is 0.

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

Icarus Verilog · server