S7.3.2 Hook up the SPI

MediumImplement22 minIcarus Verilog · serverReview the topic

Connect a byte engine to its command register, flash pins and two independent service paths.

Hardware context: ap_soc serial peripherals. Console and flash bring-up

Wire the combinational socket for this exercise controller. run is low during reset. access already means a completed, selected APB transfer. offset is a byte offset inside a 16-byte register bank.

Signals in the Timeline

SignalWidthRole
sample12input of each check
Full specification

When running, launch on a completed write to byte offset 8. The engine handles queueing. While busy and running, drive active-low chip select and pass serial_clk and serial_out to sclk and mosi. Otherwise park both pins low and deselect.

count is receive occupancy from zero through three. While running, request an interrupt for any data if irq_en is set. Request DMA at two or more entries if dma_en is set. Each mask controls only its own request.

Examples

Example 1

Command Acceptance
Input
run=1'h1, access=1'h1, write_en=1'h1, offset=4'h8, busy=1'h0, serial_clk=1'h1, serial_out=1'h1, irq_en=1'h1, dma_en=1'h1, count=2'h0
Output
launch = 1, cs_n = 1, sclk = 0, mosi = 0, rx_irq = 0, dma_req = 0

The command starts while the serial engine is still idle.

Example 2

First Received Byte
Input
run=1'h1, access=1'h0, write_en=1'h0, offset=4'h0, busy=1'h1, serial_clk=1'h1, serial_out=1'h0, irq_en=1'h1, dma_en=1'h1, count=2'h1
Output
launch = 0, cs_n = 0, sclk = 1, mosi = 0, rx_irq = 1, dma_req = 0

The selected device sees its clock and one waiting byte raises the interrupt.

Example 3

Service Watermark
Input
run=1'h1, access=1'h0, write_en=1'h0, offset=4'h0, busy=1'h1, serial_clk=1'h0, serial_out=1'h1, irq_en=1'h0, dma_en=1'h1, count=2'h2
Output
launch = 0, cs_n = 0, sclk = 0, mosi = 1, rx_irq = 0, dma_req = 1

DMA can request service while interrupts are masked.

Constraints and Contract

  • Drive all six outputs for every binary input, including reset while busy.

Hints

Hint 1

Separate register acceptance from engine activity.

Hint 2

Trace chip select through idle and reset.

Hint 3

Check both sides of the receive watermark.

What the grader checks: All 16,384 binary input combinations exercise the command, pins and service requests together.

19 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

Command Acceptance

Input
run=1'h1, access=1'h1, write_en=1'h1, offset=4'h8, busy=1'h0, serial_clk=1'h1, serial_out=1'h1, irq_en=1'h1, dma_en=1'h1, count=2'h0
Expected output
launch = 1, cs_n = 1, sclk = 0, mosi = 0, rx_irq = 0, dma_req = 0

The command starts while the serial engine is still idle.

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

Icarus Verilog · server