OpenHW CVE2 on ALINX PI-AR035-F1-1 - Episode 04: peripheral bus matrix ====================================================================== What it does ------------ CVE2 gets a memory-mapped peripheral bus: GPIO, SPI (QSPI Flash + TF card), I2C EEPROM, four PWM channels, bus-error reporting and a five-source interrupt aggregator. The design is verified without a scope or signal generator: PWM is measured by CH0's on-chip capture counter, SPI by Flash JEDEC and TF CMD0, I2C by EEPROM ACK, and unmapped accesses by RISC-V load/store access faults. Verified result (2026-11-20) ---------------------------- ALINX AR035 CVE2 Peripheral Bus EP04 BOOT CAUSE=POR/EXT GPIO TEST=PASS FLASH ID=00c84018 OK EEPROM DATA=00000074 ACK SD R1=00000001 OK PWM PERIOD=0000c350 HIGH=000061a9 FREQ=1000 DUTY=500/1000 PWM TEST=PASS BUSERR TEST=PASS IRQ TEST START IRQ COUNT=00000001 IRQ TEST=PASS KEY1=0 KEY2=0 BUS TXN=00434418 RD=002e2c51 WR=001539d2 WAIT=00000000 ERR=00000002 LAST=00003044 IRQ STATUS=00000000 ENABLE=00000000 COUNT=1 READY EEPROM is accepted at ACK level. The returned byte is board content and is not compared against a fixed value; content integrity is NOT claimed. Resources / timing ------------------ LUT 4,103 (19.73%), FF 3,559 (8.56%), BRAM 8 (16.00%), DSP 11 (12.22%), IOB 25 (10.00%) WNS 1.285 ns / WHS 0.052 ns; 0 failing endpoints. Bitstream 2,192,137 B, SHA-256 5940ddfc502c5ecb29e09493dc0d5fae0d3de177c3b194c57c56549ced681145. Build ----- cd sw && make clean && make vivado -mode batch -source build_ep04.tcl vivado -mode batch -source program_ep04.tcl # hw_server on TCP:127.0.0.1:3122 Pitfalls -------- 1. PWM period register was overwritten by duty/CTRL writes; period writes now require data_addr[3:0]==0. Before the fix the period became 1, which also caused an interrupt storm once PWM interrupts were enabled. 2. The IRQ vector at 0x12C jumped straight to irq_handler without saving t0-t3. It now jumps to trap_handler so the common prologue runs. 3. I2C changed SDA while SCL was high; phase0 now keeps SCL low, phase1 raises it. 4. I2C ACK/data were sampled on the cycle SCL rose, before the synchronizer saw the slave. They are now sampled at the end of the high phase. 5. Firmware i2c_wait_done returned on the previous transfer's sticky done before busy asserted. It now waits for busy to assert, then clear, then done. License ------- Upstream CVE2 is Apache-2.0. See LICENSE.