GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - deuskane/asylum-soc-picosoc: Minimal SoC based on Picoblaze clone or RISCV academic processor

BranchesTags
Open more actions menu

Latest commit

 

History

522 Commits
522 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
boards
boards
 
 
doc
doc
 
 
esw
esw
 
 
hdl
hdl
 
 
mk
mk
 
 
sim
sim
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
PicoSoC.core
PicoSoC.core
 
 
README.md
README.md
 
 

Repository files navigation

Version License

CI lint sim syn

PicoSoC

A small SoC in VHDL around OpenBlaze8 or WardRV CPUs: switches, LEDs, UART, SPI, I2C, PWM, GIC, timer, CRC, spinlock, mailbox and RAMs, with multi-core, lock-step / TMR safety, a supervisor and JTAG debug, programmed in C.

Part of the Asylum project, a collection of small IP cores, written to be read and learned from.

Table of Contents

  1. Overview
  2. Features
  3. Block Diagram
  4. Getting Started
  5. Hardware Interfaces
  6. Configuration
  7. Memory Map
  8. Resources
  9. Theory of Operation
  10. Programmer's Guide
  11. Design Verification
  12. Dependencies and Related IPs
  13. License

Overview

PicoSoC is the reference system of the Asylum project: it connects the Asylum IPs around a CPU and runs C firmware on them. The CPU is chosen at build time with CPU_MODEL: OpenBlaze8 (8-bit, a PicoBlaze-3 clone) or WardRV_fsm (RV32I). Every peripheral sits on the SBI bus (the simple bus of Asylum: 8-bit address, 8-bit data).

The SoC has two parts:

  • the user SoC (PicoSoC_user): 1 to USER_NB_CPU CPU clusters (CPU, program ROM, local interconnect, GIC and RAM) sharing the peripherals through a global interconnect;
  • the supervisor SoC (PicoSoC_supervisor, optional): one CPU that watches the differences between the redundant user CPUs (lock-step or TMR) and resets the user SoC on an error.

The top level PicoSoC_top adds the board side: reset resynchronization, clock divider, input polarities, the pads (PicoSoC_pads: SPI, I2C, and the UART pads shared by the user UART, the UART of the logic analyzer, the JTAG pins of the JTAG chain and JTAG over the UART, selected by debug_mux_sel_i), with DEBUG_ENABLE a logic analyzer (HWLA) on the bus of the user CPU (its captures on a UART, or read through the JTAG chain with HWLA_LINK = "jtag") and a JTAG TAP of fault injection and status. The JTAG chain also goes through the user and supervisor SoCs, where the WardRV CPUs can have their RISC-V debug unit (in cpu_wrapper). The firmware in esw/ is compiled by FuseSoC generators into the ROMs at build time; the targets run it on GHDL testbenches or on a NanoXplore NG-MEDIUM board.

Features

  • CPU per build: OpenBlaze8 or WardRV_fsm (cpu_wrapper), same SoC and same C drivers
  • Multi-core user SoC: USER_NB_CPU clusters, each with its own ROM, GIC and local RAM; mhartid = cluster index (WardRV); spinlock, mailbox and shared RAM for the inter-CPU communication
  • CPU safety (cpu_safety): none, lock-step (CPU1 runs USER_LOCK_STEP_DEPTH cycles after CPU0 and is compared with it) or tmr (3 CPUs, majority vote); sticky difference flags
  • Fault injection: one instruction bit of each redundant CPU flipped from a pin (inject_error_i) or the JTAG TAP; a request, even of one cycle, is trapped until the compare flags the copy
  • Supervisor SoC: resets the user SoC on a difference and counts the errors on led_diff_o; with TMR, a first error is only masked
  • Peripherals: switches and 2 LED banks (sbi_GPIO_irq), UART with CTS/RTS, SPI master with pads, I2C master and slave with open-drain pads, PWM output, GIC, timer, CRC16 (Modbus polynomial), spinlock, mailbox, RAMs
  • Interrupts: user button (it_user_i, resynchronized in the GIC), UART, timer, mailbox "data available", switch edges
  • Firmware in C (and one assembler example): switch / LED identity, full peripheral test with UART output, Modbus RTU server, multi-core hello with spinlock, supervisor
  • Debug (DEBUG_ENABLE): HWLA logic analyzer on the bus of the user CPU and the difference flags, triggered by the error injection (push buttons or TAP, every safety configuration), captures sent on debug_uart_tx_o (HWLA_LINK = "uart", the default: UART, HWLA_BAUD_RATE, 115200 baud by default) or read through a TAP of the JTAG chain (HWLA_LINK = "jtag": jtag_axis, OpenOCD picosoc_hwla_dump); JTAG TAP of fault injection (ORed with inject_error_i) and status (LEDs, switches, resets, flags of the HWLA)
  • UART pads shared by 4 functions (jtag_pad_mux of asylum-debug-jtag), selected by debug_mux_sel_i: user UART, UART of the HWLA, JTAG chain on the JTAG pinout of an FTDI cable (FT232R USB-UART cable with the OpenOCD ft232r driver, or FT232H / FT2232H MPSSE cable: one cable is the UART and the JTAG probe), JTAG over the UART (jtag_bitbang: OpenOCD remote_bitbang through any USB-UART cable, JTAG_BAUD_RATE)
  • JTAG chain: RISC-V debug units (WardRV_debug in cpu_wrapper, Debug Specification 1.0, for OpenOCD + GDB) of the user CPUs (one TAP per cluster, USER_CPU_DEBUG_ENABLE) and of the supervisor CPU (SUPERVISOR_CPU_DEBUG_ENABLE), then the injection / status TAP; the JTAG pins reach every redundant copy of the CPU, whose TDO is compared or voted; an OpenBlaze8 (or a CPU without debug unit) is a wire in the chain (TDO = TDI)
  • Host tools: OpenOCD configurations of the board in tools/openocd (adapters FT232R, FT232H and remote_bitbang, JTAG chain discovered or given and riscv targets, discovery of the chain), Modbus scripts in tools/modbus
  • Self-checking UVVM testbenches driven by the firmware, with an SPI flash model, and NG-MEDIUM board targets

Block Diagram

Block diagram of PicoSoC

Supervisor SoC (top) and user SoC (bottom) with their address maps. The dashed box is the CPU cluster, replicated USER_NB_CPU times; ICN2 and the peripherals are shared. The led0_o GPIO of the supervisor is the reset of the user SoC, the three difference flags of the user CPUs are the supervisor GIC inputs. Source: doc/picosoc.drawio, pages overview, cpu_safety-lock_step and cpu_safety-TMR (see CPU safety).

PicoSoC_top (not drawn on this page) takes its clock and resets from PicoSoC_clkrst (resynchronization of arst_i, division of clk_i by FSYS/FSYS_INT), inverts it_user_i / inject_error_i when they are active low (active_high of PicoSoC_pkg), puts IO buffers on the SPI and I2C signals (PicoSoC_pads) and, with DEBUG_ENABLE, instantiates the HWLA and its link (PicoSoC_hwla: its UART, or the TAP of jtag_axis in the JTAG chain with HWLA_LINK = "jtag", see Debug: HWLA).

UART pads and JTAG chain of PicoSoC_top

Page jtag of the same file: the UART pads and their multiplexer (PicoSoC_pads), and the JTAG chain of PicoSoC_top: user CPUs, supervisor CPU, HWLA (HWLA_LINK = "jtag"), injection / status TAP (see UART pads and JTAG).

Getting Started

The cores of the Asylum IPs are published in the FuseSoC library asylum-cores (with UVVM and the flash models used by the testbenches). The firmware is compiled at the setup of each target by the generators of asylum-utils-generators: pbcc_gen (SDCC with the PicoBlaze back-end and picoasm) for OpenBlaze8, rvcc_gen (riscv64-unknown-elf-gcc) for WardRV. GHDL, FuseSoC, UVVM, Yosys and both toolchains are in the asylum-env image used by the CI.

Simulation

pip install fusesoc
fusesoc library add https://github.com/deuskane/asylum-cores
fusesoc run --target sim_soc1_wardrv_fsm_c_user_uart asylum:soc:PicoSoC   # GHDL + RISC-V toolchain

From a clone of asylum-project, in ip/asylum-soc-picosoc: make help, make sim_soc3_openblaze8_fault_c_user, make nonreg_sim (see How to Run).

Firmware

A target names its firmware with its generate entries (see PicoSoC.core): for example gen_rv32i_user_c_uart_921600 compiles esw/demo/user.c with -DHAVE_UART -DCLOCK_FREQ=12500000 -DBAUD_RATE=921600 into the entity ROM_user, and gen_rv32i_supervisor_c_tmr compiles esw/system/supervisor.c with -DSAFETY_TMR into ROM_supervisor. To run another program, add a generator entry with its file and flags and a target that uses it. CLOCK_FREQ and BAUD_RATE of the firmware must match FSYS_INT and USER_BAUD_RATE of the target. The integration firmwares esw/test/test_<ip>.c are short examples of each peripheral driven from C.

Board

The emu_ng_medium_* targets build the SoC for the NanoXplore NG-MEDIUM kit (DK625V0) with NXmap and program it (program: True); pads in boards/NanoXplore-DK625V0/pads.py: 25 MHz clock, 4 user switches (S1 to S4, USER_NB_SWITCH = 4) and 2 switches for debug_mux_sel_i (S5, S6), push buttons on arst_i, it_user_i and inject_error_i (active low), 8 + 8 + 3 LEDs, UART, SPI flash (USER_SPI_NB_IO = 2), I2C (i2c_scl_io, i2c_sda_io, weak pull-ups of the pads) and pwm_o on spare pads of Bank0, the 4 UART pads and debug_uart_tx_o on spare pads of Bank0 (3.3V, test point TP2: pin 1 GND, pins 2 to 5 RX, TX, CTS*, RTS*, pin 7 debug_uart_tx_o; weak pull-ups on TDI and TMS; CTS* has the default pull-up of the pads, the NG-MEDIUM has no pull-down: see UART pads and JTAG), for a 3.3V USB-UART or FTDI cable. Bank5 (TP5) is supplied at 2.5V by the HSMC supply and Bank12 at 2.5V: the bank voltages of pads.py follow the DK625 user guide. The emu_ng_medium_* targets set the three UARTs of the UART pads to 9600 baud (USER_BAUD_RATE, HWLA_BAUD_RATE, JTAG_BAUD_RATE): the terminal keeps its setting when debug_mux_sel_i changes. They set DEBUG_ENABLE = false (no HWLA, debug_uart_tx_o at '1', no injection / status TAP): set it to true in a target to get the captures of the HWLA and the injection / status TAP. emu_ng_medium_soc3_wardrv_fsm_fault_debug (and _debug_hwla_jtag, the HWLA captures read through JTAG) has the HWLA, the injection / status TAP and both CPU debuggers. emu_ng_medium_soc1_wardrv_fsm has the debugger of the user CPU (USER_CPU_DEBUG_ENABLE = true, the only TAP of its JTAG chain, IDCODE 0x10001001): OpenOCD + GDB through the UART pads with debug_mux_sel_i 10 (FT232R or FTDI MPSSE cable) or 11 (any USB-UART cable, 9600 baud; see OpenOCD and GDB on the board); the other targets have no TAP (the JTAG mode of the UART pads drives no pad).

Switches of the board: S1 to S4 are the user switches (switch_i); S5 and S6 (left to right on the board) are debug_mux_sel_i(1) and debug_mux_sel_i(0) (pads IOB10_D09N / NA09 and IOB10_D04N / NA04 of pads.py, DK625 user guide), the function of the UART pads (see UART pads and JTAG): read left to right, S5 S6 is the value of debug_mux_sel_i:

debug_mux_sel_i S5 S6 Function Pads Cable and host tool
00 0 0 User UART (sbi_UART, USER_BAUD_RATE) RX, TX, CTS*, RTS* Any 3.3V USB-UART cable: a terminal at 9600 baud (tools/uart/uart.sh: screen in an xterm), or the Modbus scripts with the Modbus firmware
01 0 1 UART of the HWLA (HWLA_BAUD_RATE), with DEBUG_ENABLE and HWLA_LINK = "uart" only TX Any USB-UART cable: tools/hwla/hwla_capture.sh saves the captures, then hwla2vcd.py of asylum-debug-hwla (see Debug: HWLA)
10 1 0 JTAG pins of the JTAG chain TCK, TDI, TDO, TMS FT232R cable (ft232r.cfg) or FTDI MPSSE cable (ft232h.cfg): OpenOCD (see OpenOCD and GDB on the board)
11 1 1 JTAG over the UART (JTAG_BAUD_RATE) RX, TX Any USB-UART cable: socat and OpenOCD (remote_bitbang.cfg)

The WardRV_fsm board targets run esw/demo/user_loop.c (LED0 = switches and, in mode 00, one line per iteration at 9600 baud, Loop <loop number> <pseudo random number>: the same sequence after every reset, so a wrong line shows an error), but the SPI flash (emu_ng_medium_soc1_wardrv_fsm, emu_ng_medium_soc4_wardrv_fsm_fault_spi) and Modbus builds; the OpenBlaze8 board targets run esw/demo/user.c (a banner, the echo and a loop line at every iteration). The Basys1 pad file (boards/Digilent-Basys1/pads.ucf) has no pin for the UART, SPI, I2C and PWM, nor for debug_mux_sel_i. NXmap is not in the asylum-env image: these targets are not run by the CI.

make emu_ng_medium_soc4_wardrv_fsm_fault      # TOOL=nxmap (mk/defs.mk)

tools/modbus/modbus_server.py and tools/modbus/modbus_server_debug.py talk to the Modbus firmware on the board through the serial port:

  • UART pads in mode 00, /dev/ttyUSB0 at 9600 baud, slave 0x5A (set in the scripts);
  • base addresses from tools/modbus/addrmap_user.hjson, read next to the scripts (any working directory);
  • Python packages: hjson, pyserial, and pymodbus 2.x for modbus_server.py (pymodbus.client.sync).

To use PicoSoC in another design, instantiate PicoSoC_top (library asylum, component in asylum.PicoSoC_pkg) and generate the two ROMs as the targets do (ROM_user_pkg is used by PicoSoC_pkg):

library asylum;
use     asylum.PicoSoC_pkg.all;

  ins_soc : PicoSoC_top
    generic map
    (FSYS                 => 25_000_000
    ,FSYS_INT             => 12_500_000
    ,CPU_MODEL            => "WardRV_fsm"
    ,USER_BAUD_RATE       => 9600
    ,USER_SAFETY          => "tmr"
    ,USER_FAULT_INJECTION => true
    ,SUPERVISOR           => true
    )
    port map
    (clk_i            => clk
    ,arst_i           => arst_b
    ,switch_i         => switch
    ,led0_o           => led0
    ,led1_o           => led1
    ,led_diff_o       => led_diff
    ,it_user_i        => button_b
    ,debug_mux_sel_i  => mux_sel          -- UART pads : 00 UART, 01 HWLA, 10 JTAG, 11 JTAG over the UART
    ,uart_rx_i        => uart_rx          -- RX   / TCK
    ,uart_tx_io       => uart_tx          -- TX   / TDI (inout)
    ,uart_cts_b_io    => uart_cts_b       -- CTS* / TDO (inout)
    ,uart_rts_b_io    => uart_rts_b       -- RTS* / TMS (inout)
    ,spi_sclk_io      => spi_sclk
    ,spi_cs_b_io      => spi_cs_b
    ,spi_io_io        => spi_io           -- (7 downto 0)
    ,i2c_scl_io       => i2c_scl          -- open drain : pull-up on the board
    ,i2c_sda_io       => i2c_sda
    ,pwm_o            => pwm
    ,inject_error_i   => inject_error_b
    ,debug_uart_tx_o  => debug_tx         -- HWLA captures, UART 115200 8N1
    );

Hardware Interfaces

Top-level entity: PicoSoC_top (hdl/PicoSoC_top.vhd), component in asylum.PicoSoC_pkg. It is the DUT of the testbenches and the toplevel of the lint_*, syn_* and emu_* targets.

Clock and Reset

Name Direction Type Description
clk_i in std_logic Board clock (FSYS), divided by FSYS/FSYS_INT for the SoC
arst_i in std_logic Asynchronous reset, active level RESET_POLARITY, resynchronized inside

Switches, LEDs and Interrupt

Name Direction Type Description
switch_i in std_logic_vector(USER_NB_SWITCH-1 downto 0) Switches (user GPIO SWITCH, resynchronized in the GPIO)
led0_o out std_logic_vector(USER_NB_LED0-1 downto 0) User GPIO LED0
led1_o out std_logic_vector(USER_NB_LED1-1 downto 0) User GPIO LED1
led_diff_o out std_logic_vector(2 downto 0) Supervisor GPIO LED_DIFF (error counter of esw/system/supervisor.c); without supervisor, the difference flags
it_user_i in std_logic User interrupt (user GIC source 0, resynchronized in the GIC), active level USER_IT_POLARITY

UART and JTAG

The 4 UART pads, shared by the user UART, the UART of the HWLA, the JTAG chain and JTAG over the UART (debug_mux_sel_i, see UART pads and JTAG), in the order of the pins AD0 to AD3 of an FTDI MPSSE cable:

Name Direction Type Description
debug_mux_sel_i in std_logic_vector(1 downto 0) Function of the UART pads: 00 user UART, 01 UART of the HWLA, 10 JTAG, 11 JTAG over the UART (asynchronous, synchronized inside)
uart_rx_i in std_logic UART receive / JTAG TCK / receive of JTAG over the UART
uart_tx_io inout std_logic UART transmit (output) / JTAG TDI (input) / transmit of JTAG over the UART (output)
uart_cts_b_io inout std_logic UART Clear To Send, active low (input) / JTAG TDO (output while the TAPs shift, 'Z' otherwise)
uart_rts_b_io inout std_logic UART Request To Send, active low (output) / JTAG TMS (input)

SPI

Name Direction Type Description
spi_sclk_io inout std_logic SPI clock (obuf with output enable)
spi_cs_b_io inout std_logic Chip select, active low (obuf)
spi_io_io inout std_logic_vector(USER_SPI_NB_IO-1 downto 0) Data lanes (iobuf): 0 = MOSI, 1 = MISO, 2 = WP#, 3 = HOLD# in single mode; the SPI inputs without pad read 0

I2C

Name Direction Type Description
i2c_scl_io inout std_logic I2C clock, open drain (iobuf): driven to 0 when the output enable of the I2C is set, 'Z' otherwise; pull-up on the board
i2c_sda_io inout std_logic I2C data, open drain, as i2c_scl_io

PWM

Name Direction Type Description
pwm_o out std_logic PWM output, low while the PWM is disabled

Safety

Name Direction Type Description
inject_error_i in std_logic_vector(2 downto 0) Bit i requests an error in CPU i of every cluster (USER_FAULT_INJECTION; resynchronized, trapped until the difference is flagged, see CPU safety), active level USER_FAULT_POLARITY

Debug

Name Direction Type Description
debug_uart_tx_o out std_logic Captures of the HWLA (DEBUG_ENABLE = true, HWLA_LINK = "uart"): UART HWLA_BAUD_RATE baud (115200 by default), 8 data bits, no parity, 1 stop bit (see Debug: HWLA); '1' (idle) otherwise

Configuration

Generics of PicoSoC_top:

Name Type Default Description
FSYS positive 50_000_000 Frequency of clk_i (Hz)
FSYS_INT positive 50_000_000 Frequency of the SoC (Hz): clock divider ratio FSYS/FSYS_INT, UART clock
RESET_POLARITY string "low" Active level of arst_i: "high" / "low"
DEBUG_ENABLE boolean True HWLA on the bus of the user CPU, captures on debug_uart_tx_o or through JTAG (HWLA_LINK, see Debug: HWLA); JTAG TAP of fault injection and status, last TAP of the JTAG chain
USER_CPU_DEBUG_ENABLE boolean False RISC-V debug unit (WardRV_debug, in cpu_wrapper) of the user CPU of every cluster: one TAP per cluster, first TAPs of the JTAG chain; CPU_MODEL = "WardRV_fsm" only
SUPERVISOR_CPU_DEBUG_ENABLE boolean False RISC-V debug unit of the supervisor CPU, TAP after the user CPU ones; CPU_MODEL = "WardRV_fsm" and SUPERVISOR only
HWLA_BAUD_RATE integer 115200 Baud rate of the UART of the HWLA captures (debug_uart_tx_o, DEBUG_ENABLE): a bit every FSYS_INT/HWLA_BAUD_RATE SoC clock cycles
HWLA_DEPTH positive 64 Samples of a capture of the HWLA, a power of 2 (DEBUG_ENABLE): the RAM of the HWLA is HWLA_DEPTH x (probes + timestamp) bits
HWLA_PRE_TRIGGER natural 32 Samples of the HWLA before the trigger sample, 0 to HWLA_DEPTH - 1 (DEBUG_ENABLE)
HWLA_TIMESTAMP_WIDTH natural 16 Width of the timestamp of a sample of the HWLA, in SoC clock cycles (DEBUG_ENABLE; 0: no timestamp)
HWLA_LINK string "uart" Link of the HWLA captures (DEBUG_ENABLE): "uart" (debug_uart_tx_o and the UART pads in mode 01, HWLA_BAUD_RATE) or "jtag" (TX FIFO of jtag_axis, read through its TAP in the JTAG chain, IDCODE 0x10004001; debug_uart_tx_o idle); any other value: assertion failure
JTAG_BAUD_RATE integer 115200 Baud rate of JTAG over the UART pads (debug_mux_sel_i 11, jtag_bitbang): a bit every FSYS_INT/JTAG_BAUD_RATE SoC clock cycles
CPU_MODEL string "OpenBlaze8" "OpenBlaze8" or "WardRV_fsm", for the user and supervisor CPUs; the ROMs of the target must be built for this CPU
USER_NB_CPU natural 1 Number of CPU clusters of the user SoC
USER_ICN_TARGET_SEL string "or" Response selection of the user interconnects: "or" / "mux"
USER_ICN_MASTER_SEL string "fix" Arbitration of ICN2 between the clusters: "fix" / "roundrobin"
USER_RAM1_DEPTH natural 128 Local RAM1 of each cluster (bytes, up to 128)
USER_RAM2_DEPTH natural 64 Shared RAM2 (bytes, up to 64)
USER_NB_SWITCH positive 8 Width of switch_i (4 on the NG-MEDIUM board)
USER_NB_LED0 positive 8 Width of led0_o (1 to 8)
USER_NB_LED1 positive 8 Width of led1_o (1 to 8)
USER_BAUD_RATE integer 115200 UART baud rate (reset value of the baud counter)
USER_UART_DEPTH_TX / _RX natural 0 UART FIFO depths
USER_SPI_DEPTH_CMD / _TX / _RX natural 0 SPI FIFO depths
USER_SPI_NB_IO natural 8 SPI data pads (up to 8)
USER_SAFETY string "lock-step" "none" / "lock-step" / "tmr"
USER_LOCK_STEP_DEPTH natural 2 Delay of CPU1 behind CPU0 in lock-step (cycles)
USER_FAULT_INJECTION boolean True Connect inject_error_i
USER_FAULT_POLARITY string "low" Active level of inject_error_i
USER_IT_POLARITY string "low" Active level of it_user_i
USER_MAILBOX_FIFO0_DEPTH_TX / _RX, USER_MAILBOX_FIFO1_DEPTH_TX / _RX natural 4 Mailbox FIFO depths
SUPERVISOR boolean True Instantiate the supervisor SoC
SUPERVISOR_ICN_TARGET_SEL / _MASTER_SEL string "or" / "fix" Supervisor interconnect
SUPERVISOR_RAM_DEPTH natural 128 Supervisor RAM (bytes, up to 128)

The configurations used by the targets are named after their safety: soc1 = no supervisor, no safety; soc2 = lock-step without supervisor; soc3 = supervisor and lock-step; soc4 = supervisor and TMR; soc5 = TMR without supervisor (WardRV_fsm, led_diff_o shows the difference flags); _fault = with fault injection; socKxN = N user CPU clusters (each with the safety of socK).

Memory Map

PicoSoC has no register of its own: the software sees the registers of its peripherals at the base addresses of hdl/PicoSoC_pkg.vhd (PICOSOC_USER_*_BA, PICOSOC_SUPERVISOR_*_BA), mirrored in esw/include/addrmap_user.h and esw/include/addrmap_supervisor.h. Address encoding "binary": a target answers to its base address and its own address bits.

User SoC

Address Target Instance Interconnect Registers
0x00-0x01 GIC (one per cluster) sbi_GIC ICN1 GIC_csr.md
0x02-0x03 Spinlock sbi_spinlock ICN2 spinlock_csr.md
0x04-0x07 SWITCH sbi_GPIO_irq (inputs) ICN2 GPIO_irq_csr.md
0x08-0x0B LED0 sbi_GPIO_irq (outputs) ICN2 GPIO_irq_csr.md
0x0C-0x0F LED1 sbi_GPIO_irq (outputs) ICN2 GPIO_irq_csr.md
0x10-0x13 CRC sbi_crc (CRC16, polynomial 0xA001, LSB first) ICN2 crc_csr.md
0x14-0x17 Mailbox sbi_mailbox ICN2 mailbox_csr.md
0x18-0x1B SPI sbi_spi (software prescaler, WP# / HOLD# handled) ICN2 SPI_csr.md
0x20-0x27 UART sbi_uart ICN2 UART_csr.md
0x28-0x2F Timer sbi_timer ICN2 timer_csr.md
0x30-0x33 I2C sbi_I2C (master and slave, FIFOs of depth 0, prescaler reset value CLOCK_FREQ/400000-1: SCL at 100 kHz) ICN2 I2C_csr.md
0x34-0x37 PWM sbi_PWM (default generics: prescaler reset value 0xC2) ICN2 PWM_csr.md
0x38-0x3F (unmapped) default slave of ICN2: a write is ignored, a read returns 0 ICN2 -
0x40-0x7F RAM2 (shared) sbi_ram, USER_RAM2_DEPTH bytes ICN2 -
0x80-0xFF RAM1 (one per cluster) sbi_ram, USER_RAM1_DEPTH bytes ICN1 -

Interrupt sources of the user GIC (the same vector on the GIC of every cluster):

GIC source Source HDL constant C mask
0 it_user_i (resynchronized: ITS_SYNC_ENABLE bit 0) PICOSOC_USER_GIC_IT_USER GIC_IT_USER_MSK (0x01)
1 UART it_o PICOSOC_USER_GIC_UART GIC_UART_MSK (0x02)
2 Timer it_o PICOSOC_USER_GIC_TIMER GIC_TIMER_MSK (0x04)
3 Mailbox fifo0 not empty (level) PICOSOC_USER_GIC_MAILBOX0 GIC_MAILBOX0_MSK (0x08)
4 Mailbox fifo1 not empty (level) PICOSOC_USER_GIC_MAILBOX1 GIC_MAILBOX1_MSK (0x10)
5 SWITCH GPIO it_o (edge on a switch) PICOSOC_USER_GIC_SWITCH GIC_SWITCH_MSK (0x20)

Supervisor SoC

Address Target Instance Registers
0x10-0x13 RST (GPIO USER_ARST): reset of the user SoC, active low sbi_GPIO_irq GPIO_irq_csr.md
0x20-0x23 LED (GPIO LED_DIFF): led_diff_o sbi_GPIO_irq GPIO_irq_csr.md
0x40-0x41 GIC, sources = difference flags (0 CPU0 vs CPU1, 1 CPU1 vs CPU2, 2 CPU2 vs CPU0) sbi_GIC GIC_csr.md
0x80-0xFF RAM sbi_ram, SUPERVISOR_RAM_DEPTH bytes -

tools/modbus/addrmap_user.hjson (read by the Modbus tools) repeats the user base addresses: keep it aligned with PicoSoC_pkg and addrmap_user.h.

Resources

Figures of the syn_* targets (make nonreg_syn, see Targets): PicoSoC_top with the generics of each configuration, synthesized by Yosys and its GHDL plugin; the reports are in the build directory of each target. The user ROM holds esw/demo/user_identity.c (the firmware of lint_ghdl), the supervisor ROM esw/system/dummy.c: a bigger program needs a bigger ROM. soc1: no supervisor, no safety, default FIFOs (0); soc4_ng_medium: supervisor, TMR (3 user CPUs) and fault injection with the generics of the NG-MEDIUM board (FSYS 25 MHz, 4 switches, FIFOs of 4, 2 SPI pads, the user UART, the UART of the HWLA and JTAG over the UART at 9600 baud). The syn_* targets set DEBUG_ENABLE = false (no HWLA, no injection / status TAP), but syn_wardrv_soc4_ng_medium_debug: DEBUG_ENABLE (HWLA_LINK = "uart", the default) and both CPU debuggers.

Configuration LUT¹ LUTRAM¹ FF¹ CARRY4¹ MUXF7/F8¹ BRAM¹ DSP¹ TBUF¹ Area² (µm²) kGE³
syn_soc1 (OpenBlaze8) 1332 108 788 64 183 0.5 0 13 189116.38 50.383
syn_soc4_ng_medium (OpenBlaze8) 1986 304 1010 132 63 1 0 7 494152.68 131.648
syn_wardrv_soc1 (WardRV_fsm) 2136 104 1069 58 198 1 0 13 164245.02 43.757
syn_wardrv_soc4_ng_medium (WardRV_fsm) 5380 304 2141 108 645 2 0 7 380690.11 101.420
syn_wardrv_soc4_ng_medium_debug (WardRV_fsm, DEBUG_ENABLE, both CPU debuggers) 9644 304 4444 165 1194 4.5 0 7 3839610⁴ 1022.914

With the HWLA (Debug: HWLA) and the injection / status TAP: the same configurations with DEBUG_ENABLE = true (fusesoc --cores-root . run --target syn_soc1 asylum:soc:PicoSoC --DEBUG_ENABLE=true):

Configuration, DEBUG_ENABLE = true LUT¹ LUTRAM¹ FF¹ CARRY4¹ MUXF7/F8¹ BRAM¹ DSP¹ TBUF¹ Area² (µm²) kGE³
syn_soc1 (OpenBlaze8) 1769 208 1267 89 97 0.5 0 13 374194⁴ 99.689
syn_soc4_ng_medium (OpenBlaze8) 2509 304 1494 161 88 3.5 0 7 3258380⁴ 868.068
syn_wardrv_soc1 (WardRV_fsm) 2638 220 1590 83 191 1 0 13 382695⁴ 101.954
syn_wardrv_soc4_ng_medium (WardRV_fsm) 5948 304 2653 137 817 4.5 0 7 3712791⁴ 989.128

DEBUG_ENABLE (the second table against the first) costs, with the default HWLA_* generics (syn_soc1, syn_wardrv_soc1: 64 samples), 437 or 502 LUTs, 100 (OpenBlaze8) or 116 (WardRV_fsm) LUTRAM, 479 or 521 flip-flops and 25 CARRY4 on Artix-7, and 185000 or 218000 µm² (49 or 58 kGE) in sky130: the RAM of the HWLA, 64 x 76 or 90 bits (probes and 16-bit timestamp), is the LUTRAM and becomes flip-flops in sky130. With the NG-MEDIUM generics (syn_soc4_ng_medium, syn_wardrv_soc4_ng_medium: HWLA_DEPTH = 1024) it costs 523 or 568 LUTs, 484 or 512 flip-flops, 29 CARRY4 and 2.5 BRAM (the RAM of 1024 x 76 or 90 bits goes to block RAM, no LUTRAM), but 736 or 888 kGE in sky130, where the 92000 bits of the RAM become flip-flops (a memory macro would replace them in a real chip). The cost covers the HWLA and its UART (PicoSoC_hwla), the injection / status TAP (its IDCODE, IR and TDR shift registers, the INJECT register of 16 bits, its 15 synchronizers and the 12 pulses of the injection inside the CPUs, the STATUS fields with the flags of the HWLA) and JTAG over the UART (jtag_bitbang and its uart_core, only with a TAP in the chain). The CPU debug units (syn_wardrv_soc4_ng_medium_debug against syn_wardrv_soc4_ng_medium with DEBUG_ENABLE) cost 3696 LUTs, 1791 flip-flops and 28 CARRY4 (34 kGE): a debug unit (TAP, DTM, Debug Module) in each of the 4 WardRV_fsm (3 user copies in TMR and the supervisor) and their debug logic. HWLA_LINK = "jtag" (jtag_axis: its TAP, TDRs and a TX FIFO of 4 bytes, in place of the uart_core of the HWLA; the syn_* targets do not expose HWLA_LINK, measured with copies of the targets that add HWLA_LINK=jtag): syn_soc1 with DEBUG_ENABLE 1820 LUT, 216 LUTRAM, 1334 FF, 87 CARRY4, 93 MUXF7/F8, 379231 µm², 101.031 kGE (+51 LUT, +8 LUTRAM, +67 FF, -2 CARRY4, +1.3 kGE); syn_wardrv_soc4_ng_medium_debug 9520 LUT, 312 LUTRAM, 4512 FF, 163 CARRY4, 1040 MUXF7/F8, 3850792 µm², 1025.893 kGE (-124 LUT, +8 LUTRAM, +68 FF, -2 CARRY4, +3.0 kGE). The DSP and TBUF counts do not change with DEBUG_ENABLE or HWLA_LINK, nor the BRAM count with HWLA_LINK.

¹ Xilinx Artix-7 (LUT6), Yosys 0.33 synth_xilinx -flatten -noiopad -noclkbuf, before place and route: every cell of the netlist is counted, Vivado may differ. An INV counts as a LUT1. The user ROM goes to BRAM (a RAMB18E1 counts 0.5), the RAMs and FIFOs mostly to LUTRAM. TBUF: tristate pad buffers (the OBUFT / IOBUF of the I/O blocks, not logic, never in LUT), one per pad whose output enable is not constant: the SPI data lanes (8 in soc1, 2 with the NG-MEDIUM generics; SCLK and CS* are plain outputs), I2C SCL and SDA, and the 3 inout UART pads (TX / TDI, CTS* / TDO, RTS* / TMS). The logic that drives the pads (data and output enables, TDO of the JTAG chain) is counted. These figures need asylum:utils:yosys_synth >= 1.1.0: older versions lost the logic behind the inout pads of component instances (a GHDL synthesis issue) and rejected the tristate buffers.

² SkyWater sky130 sky130_fd_sc_hd, typical corner (tt, 25 °C, 1.80 V), Yosys 0.33 synth + dfflibmap + abc -liberty: standard-cell area only, no timing constraint, no buffering, clock tree or placement (the tristate pad buffers are I/O cells: no area); the ROMs, RAMs and FIFOs become flip-flops and logic (no ROM or SRAM macro), which explains most of the area.

³ Area in thousands of NAND2 gate equivalents (sky130_fd_sc_hd__nand2_1 = 3.7536 µm²).

⁴ Measured with 4.8.5 (the difference flags in the probes of the HWLA, HWLA_DEPTH = 1024 with the NG-MEDIUM generics, 4 bits of injection inside each CPU copy): the area is the kGE times 3.7536 µm², rounded (yosys_synth prints 6 significant digits).

The NG-MEDIUM board targets (emu_ng_medium_*) need NXmap, which is not in the asylum-env image: no figure for this FPGA (about 32000 4-input LUTs and 32000 flip-flops: the 9.5k LUT6 and 4.5k flip-flops of the largest configuration, with the CPU debuggers (9.6k and 4.5k with HWLA_LINK = "jtag"), are expected to fit, not checked with NXmap).

Theory of Operation

Hierarchy

File Unit Role
hdl/PicoSoC_top.vhd PicoSoC_top Top level, wiring only: clock and resets (PicoSoC_clkrst), polarities of the inputs (active_high), user and supervisor SoCs, pads (PicoSoC_pads), JTAG chain (user SoC, supervisor SoC, HWLA (HWLA_LINK = "jtag"), injection / status TAP PicoSoC_tap), error injection (PicoSoC_inject), HWLA (PicoSoC_hwla, DEBUG_ENABLE), JTAG over the UART (PicoSoC_jtag_over_uart, when the chain has a TAP)
hdl/PicoSoC_clkrst.vhd PicoSoC_clkrst Clock and resets of the top: polarity of arst_i and its resynchronizers, clock divider, reset of the supervisor domain (debug units, board modules), of the supervisor SoC (and ndmreset of its debugger), of the user SoC (from the supervisor or ndmreset of its debugger, resynchronized)
hdl/PicoSoC_pads.vhd PicoSoC_pads Pads: UART pads shared by the user UART, the HWLA UART, the JTAG chain and JTAG over the UART (jtag_pad_mux, debug_mux_sel_i synchronizers and select; the JTAG chain driven by the pads or by jtag_bitbang), SPI pads (obuf, iobuf), I2C open-drain pads
hdl/PicoSoC_hwla.vhd PicoSoC_hwla HWLA of the top: hwla on the probes (unconstrained probe_i: the width comes from the actual) and the trigger, its captures on the link HWLA_LINK: a UART 8N1 at HWLA_BAUD_RATE (uart_core, transmitter only; its JTAG stage a wire) or the TX FIFO of jtag_axis (its TAP a stage of the JTAG chain); its flags (status_o: arm, armed, triggered, sending)
hdl/PicoSoC_jtag_over_uart.vhd PicoSoC_jtag_over_uart JTAG over the UART pads (debug_mux_sel_i 11): uart_core (receiver and transmitter, JTAG_BAUD_RATE, RX synchronizer inside) and jtag_bitbang; its JTAG pins drive the chain, the TDO of the chain comes back
hdl/PicoSoC_tap.vhd PicoSoC_tap Injection / status TAP of the top (DEBUG_ENABLE): jtag_tap, the instruction decoder, the INJECT (jtag_tdr_inout, read diff) and STATUS (jtag_tdr_in, unconstrained status_i) registers, the synchronizers of the injection; one stage of the JTAG chain (the top chains the stages)
hdl/PicoSoC_inject.vhd PicoSoC_inject Error injection of the top: the push buttons resynchronized, ORed with the INJECT requests of the TAP, one trap per copy of the CPU (set by a request, cleared by a rising edge of a difference flag of the copy or a 1 -> 0 of the TAP request), power-on reset
hdl/PicoSoC_user.vhd PicoSoC_user User SoC: CPU clusters (cpu_safety, ROM_user, ICN1, GIC, RAM1), ICN2 and the shared peripherals
hdl/PicoSoC_supervisor.vhd PicoSoC_supervisor Supervisor SoC: CPU (TCK of its debug unit resynchronized), ROM_supervisor, ICN, 2 GPIO, GIC, RAM
hdl/cpu_safety.vhd cpu_safety 1, 2 or 3 copies of the CPU (one generate; records of the inputs and of the outputs of a copy), lock-step delay line and compare, TMR vote, fault injection, JTAG pins of the copies (TCK already resynchronized by PicoSoC_top)
hdl/cpu_wrapper.vhd cpu_wrapper sbi_OpenBlaze8 or sbi_WardRV_fsm from CPU_MODEL; with DEBUG_ENABLE (WardRV_fsm) its debug unit WardRV_debug, else TDO = TDI
hdl/PicoSoC_pkg.vhd PicoSoC_pkg Address maps, GIC source indexes, JTAG IDCODEs and instructions, debug records, active_high (polarity of an input), components
(generated) ROM_user, ROM_supervisor Program ROMs built from esw/ by pbcc_gen / rvcc_gen

Clock and boot

In PicoSoC_clkrst, arst_i (after its polarity) goes through two sync2dffrn resynchronizers: the first one, on clk_i, resets the clock divider; the second one, on the divided clock, resets the supervisor SoC. The reset of the user SoC is this one without supervisor, or the RST GPIO of the supervisor: esw/system/supervisor.c sets up its GIC, then writes 1 to it. A third sync2dffrn on the divided clock resynchronizes it: 2 more cycles of reset with a running clock, so that the registers without reset of the user SoC (input stages of the GPIOs) are loaded before the reset release.

Every CPU starts at address 0 of its ROM: the firmware sets up the GPIO directions, the UART baud rate, the GIC masks and the CPU interrupt, then runs its main loop.

Interconnect

Each cluster has a local interconnect ICN1 (one master): GIC at 0x00, RAM1 at 0x80, every other address forwarded to ICN2. ICN2 has USER_NB_CPU masters (arbitration USER_ICN_MASTER_SEL) and the shared targets; its internal default slave answers to an unmapped address. Code is not on the bus: each CPU fetches from its own ROM.

Interrupts

The user GIC of each cluster collects the 6 sources of the table above and drives the interrupt of its CPU. it_user_i comes from a pad: the GIC resynchronizes it (ITS_SYNC_ENABLE). The mailbox sources are levels: a channel with data sets its isr bit again after a clear, so the firmware pops the channel before clearing the bit. The interrupt routine reads isr, serves the sources and clears them (write 1). The edges of the switches are recorded in the isr register of the SWITCH GPIO, whose it_o is source 5 (esw/test/test_gpio.c); the interrupt outputs of LED0 and LED1 are not connected, the I2C and the PWM have no interrupt (the firmware polls the I2C status). The supervisor GIC receives the 3 difference flags.

Multi-core

With USER_NB_CPU > 1, the clusters run the same ROM content and share ICN2. WardRV gives each one its index in mhartid (cpu_hartid() of cpu.h): esw/demo/user_hello.c uses it, the spinlock for mutual exclusion (lock 0 for the shared data, lock 1 to elect the CPU that sets up the SoC) and RAM2 for the shared loop counter. Neither the spinlock nor the ICN arbitration is fair: the firmware backs off a random time after releasing the lock.

Safety and multi-core combine: the redundancy is inside each cluster (its cpu_safety holds the 2 or 3 copies of the cluster CPU, compared or voted together), the clusters are different harts. Every copy of a cluster gets the same HARTID, so the copies read the same mhartid and stay equal; the difference flags of all clusters are ORed for the supervisor.

CPU safety

cpu_safety lock-step

Lock-step: CPU0 drives the SoC. Its inputs (reset, instruction, bus response, interrupt, JTAG pins of the debug unit) go through USER_LOCK_STEP_DEPTH registers to CPU1; the outputs of CPU1 (ics, iaddr, interrupt acknowledge, bus request, TDO and ndmreset of the debug unit) are compared with the delayed outputs of CPU0. The bus requests are compared with the "/=" of sbi_pkg: the address only when cs = '1', the data only when we = '1'. A difference sets diff_o(0) until the reset.

In hdl/cpu_safety.vhd, the inputs and the outputs of a copy are records (cpu_in_t, cpu_out_t with its "/=" and its vote); the lock-step delay line is an array of these records, one generate instantiates the enabled copies, and the difference i compares the copy i with the copy i+1 mod 3 (lock-step: CPU0 of the last stage of the delay line with CPU1).

cpu_safety TMR

TMR: 3 CPUs get the same inputs; ics, iaddr, the bus request, the interrupt acknowledge, TDO and ndmreset are majority-voted bit by bit. diff_o bits 0, 1, 2 latch the differences CPU0 / CPU1, CPU1 / CPU2 and CPU2 / CPU0.

Fault injection: inject_error(i) XORs one instruction bit of CPU i (bit 17 / 16 / 15 for OpenBlaze8, bit 7 / 8 / 9 for WardRV) of every cluster. The bits are chosen so that the program goes wrong even when nothing detects the error: for WardRV they are the low bits of the rd field, so the instruction writes the wrong register (an rd of x0 becomes a real register), or a store or a branch gets another immediate (the low bits of the opcode, used before 4.8.3, give an unknown opcode that WardRV_fsm runs as a no-operation: the program often went on). The difference flags of all clusters are ORed into PicoSoC_user.diff_o.

inject_error comes from PicoSoC_inject (in PicoSoC_top), one trap per copy, so that a request is never lost (a request of one cycle may fall on a cycle where the CPU does not read its instruction):

  • Request: inject_error_i after its polarity, resynchronized on the SoC clock (sync2dffrn), ORed with the INJECT register of the injection / status TAP (already synchronized in PicoSoC_tap).
  • Set: a request sets the trap of its copy, even for one cycle; the trap flips the instruction bit until it is cleared.
  • Clear by the detection: a rising edge (0 -> 1) of any registered (sticky) difference flag of the copy: CPU0 diff(0) or diff(2), CPU1 diff(0) or diff(1), CPU2 diff(1) or diff(2). The same rule for lock-step (only diff(0) exists: it clears CPU0 and CPU1) and TMR. The edge, not the level: in TMR the supervisor masks a first error without a reset, its flags stay set, and they also involve the other copies; on the level they would keep every trap clear, on the edge they clear the traps once and a second error can be injected (fault_tmr). Without safety, no flag: only the TAP clears a trap.
  • Clear by the TAP: a 1 -> 0 of INJECT bit i (picosoc_inject 0x1 then picosoc_inject 0x0).
  • Priority: clear wins over set in the same cycle, the cycle of the edge only. A request that stays active (button held, INJECT bit at 1) sets the trap again on the next cycle: a held request keeps injecting, as a continuous error. A trap set after the edge (a request held past the detection, or made while the flags of its copy are already set) waits for the next edge: a 1 -> 0 of INJECT clears it, else it stays until the reset of the user SoC clears the flags and its error is detected again after the reset.
  • Reset: the power-on reset of the supervisor domain (as the TAPs), not the reset of the user SoC: a trap set while the supervisor holds the user SoC in reset waits for the CPU to run.

Supervisor

esw/system/supervisor.c enables the 3 sources of its GIC, then releases the user SoC. On an interrupt:

  • lock-step (default build): it holds the user SoC in reset (RST = 0), clears its GIC, increments LED (led_diff_o) and releases the reset;
  • TMR (-DSAFETY_TMR): on the first error (all sources still enabled) it only masks the sources that fired: the voter already hides the faulty CPU. On a second error (an unmasked pair differs) it resets the user SoC as above, unmasks every source and increments LED.

The user SoC restarts from its reset: the firmware runs its setup again.

Debug: HWLA

With DEBUG_ENABLE = true, PicoSoC_top instantiates PicoSoC_hwla (hdl/PicoSoC_hwla.vhd): hwla, the logic analyzer of asylum-debug-hwla, and its link (a UART, or a TAP of the JTAG chain: HWLA_LINK), on the bus of the user CPU of cluster 0 (the CPU that drives the SoC, after the lock-step / TMR logic). With DEBUG_ENABLE = false nothing is added and debug_uart_tx_o stays at '1'.

  • Probes: the data bus and the instruction bus of the CPU (cpu_* fields of PicoSoC_user_debug_t) and the difference flags (diff, MSB), 60 probes with OpenBlaze8, 74 with WardRV_fsm:

    Probes Signal Name in tools/hwla/*.args
    0, 1, 2, 3 Data bus cs, re, we, ready dcs, dre, dwe, dready
    11:4 Data bus address daddr
    19:12 Data bus write data dwdata
    27:20 Data bus read data drdata
    28 Instruction fetch strobe ics (enable of the ROM: the instruction of the next cycle is the ROM word at the address) ics
    38:29 Instruction address (address of the ROM word) iaddr
    56:39 (OpenBlaze8), 70:39 (WardRV_fsm) Instruction (output of the ROM) idata
    59:57 (OpenBlaze8), 73:71 (WardRV_fsm) Difference flags diff of the user SoC (bit 0 CPU0 vs CPU1, 1 CPU1 vs CPU2, 2 CPU2 vs CPU0; sticky until the reset of the user SoC; 000 with USER_SAFETY = "none") diff
  • Trigger: the error injection that reaches the CPUs, whatever its source (push buttons inject_error_i or INJECT of the injection / status TAP): the rising edge of the OR of the 3 traps of PicoSoC_inject (USER_FAULT_INJECTION) and of the pulses of the injection inside the CPUs (INJECT [7:4], [11:8], [15:12], the 4 bits of each copy), registered in PicoSoC_top; only the copies present (USER_SAFETY) count. The trap, not the request: a request of one cycle sets a trap, which flips the instruction bit from its next cycle, so the trigger sample is the first cycle of the error; the edge, not the level: one capture per injection, also while a trap stays set (USER_SAFETY = "none": no difference flag clears it). The HWLA works in every safety configuration; the field diff of the capture shows whether and when the compare saw the error (lock-step, TMR: a few to about 60 clock cycles after the trigger in the simulations; none: never).

  • Capture: HWLA_DEPTH stored samples (64 by default; 1024 on the NG-MEDIUM targets), HWLA_PRE_TRIGGER before the trigger sample (32 by default; 16 on the NG-MEDIUM targets: the capture is mostly after the error), a HWLA_TIMESTAMP_WIDTH-bit timestamp (16, cycles of the SoC clock), changes only: a sample is stored when a probe changes (and for the first sample, the trigger sample and the timestamp 0), so a capture of 64 samples covers about 70 (OpenBlaze8) to 130 (WardRV_fsm) clock cycles of the main loop of esw/demo/user.c (tens of instructions), 1024 samples about 1000 to 2000 cycles. arm_i is tied to 1: a new capture starts after each extraction, and waits for the next injection.

  • Clock and reset: the SoC clock for both domains of the HWLA, and the reset of the supervisor SoC: a capture goes on while the supervisor resets the user SoC.

  • Output: the bytes of the capture (TDATA_WIDTH = 8; with a 16-bit timestamp, a sample is 10 bytes (OpenBlaze8: 60 probes and the timestamp, 76 bits) or 12 bytes (WardRV_fsm: 74 probes, 90 bits), from the LSB; a capture is 640 or 768 bytes with the default generics, 10240 or 12288 bytes on the NG-MEDIUM targets) go to the link chosen by HWLA_LINK:

    • "uart" (default): uart_core of asylum-communication-uart, transmitter only (RX_ENABLE = false), without CSR: HWLA_BAUD_RATE baud, 115200 by default (a bit every FSYS_INT/HWLA_BAUD_RATE cycles, 108 cycles at 12.5 MHz: 115741 baud, + 0.5 %), 8 data bits, no parity, 1 stop bit, CTS ignored, on debug_uart_tx_o and on the TX pad in mode 01; a capture of 12288 bytes (WardRV_fsm, NG-MEDIUM) takes about 12.8 s at 9600 baud (the baud rate of the NG-MEDIUM targets), 1.07 s at 115200 baud. The TAP stage of PicoSoC_hwla is a wire.
    • "jtag": jtag_axis of asylum-debug-jtag (>= 1.3.0), TX only (RX_ENABLE = false), 8-bit words, DEPTH_TX = 4: the bytes go into its TX FIFO (fifo_async: written on the SoC clock, read on TCK) and the debugger reads them through its TAP, a stage of the JTAG chain between the supervisor CPU and the injection / status TAP (IDCODE 0x10004001, see UART pads and JTAG): instruction TX, one DR scan of 9 bits per byte, {byte, valid} (bit 0: valid, the byte is removed from the FIFO in Update-DR); instruction CONFIG (16 bits: TX enable, TX empty / full, RX enable, DATA_WIDTH). Back-pressure: the HWLA sends faster than any debugger reads; while the FIFO is full (tready = 0) the extraction of the HWLA waits with its byte held, so the capture stays in the RAM of the HWLA until it is read, nothing is lost and there is no overflow; the next capture starts after the last byte of this one is in the FIFO (a FIFO of a whole capture would only cost RAM). The TAP has no TRST* pin (its trst_n tied to 1): it is reset by the reset of the supervisor (power-on) and by 5 TCK with TMS = 1, like the other TAPs, and takes the TCK of the chain resynchronized on the SoC clock (the FIFO accepts any TCK). debug_uart_tx_o stays at '1' and the mode 01 of the UART pads sends nothing. A byte costs about 16 TCK (9 bits, a BYPASS bit per other TAP, the moves of TMS): with the FT232R at 1 MHz (adapter speed 1000 of ft232r.cfg) about 60 kbyte/s on the wire, a capture of 12288 bytes in about 0.2 s, in practice more: the USB round trips of the scans of the bitbang driver dominate; through JTAG over the UART at 9600 baud, 3 bytes of 10 bits per scanned bit, about 20 captured bytes/s (a capture of 12288 bytes in about 10 minutes: prefer the UART link or the JTAG pins for the 1024-sample captures). These speeds are estimates, not measured on the board.
  • Flags: status_o of PicoSoC_hwla, read in the register STATUS of the injection / status TAP (above its other fields, see the injection / status TAP in UART pads and JTAG): arm (arm_i of hwla, tied to 1: the HWLA is armed from the reset and again after each extraction, so there is no "not armed" state to read), armed (capture started, trigger not yet seen), triggered (trigger seen, capture not yet extracted: post-trigger samples, then the extraction), sending (m_axis_tvalid of hwla: a byte of the capture offered to the link, held while the link is busy). The link itself has no other flag (no overflow); with HWLA_LINK = "jtag" the CONFIG of jtag_axis tells whether a capture is waiting (TX not empty).

To read a capture on the host, rebuild a VCD file from its bytes with tools/hwla2vcd.py of asylum-debug-hwla (>= 3.1.0: --signal, comments in the argument files) and the argument file of the CPU of tools/hwla. Both are in the build directory of every target, in hwla/ of its work root: asylum-debug-hwla copies hwla2vcd.py there (fileset tools of its default target), PicoSoC copies its argument files next to it (files_hdl); for the bitstream of an NG-MEDIUM target, build/asylum_soc_PicoSoC_<version>/<target>-nxmap/hwla/ (for example build/asylum_soc_PicoSoC_4.8.0/emu_ng_medium_soc3_wardrv_fsm_fault_debug-nxmap/hwla/). The argument files: hwla_wardrv_fsm.args or hwla_openblaze8.args, the generics of the HWLA of the NG-MEDIUM targets (-n 74 or 60 probes, -d 1024 -p 16 -t 16 -w 8) and the period of their SoC clock (--period 80, FSYS_INT = 12.5 MHz; another configuration: change these lines, or give the options after the file, which override them, as the hook of sim_soc3_wardrv_fsm_fault_c_user_openocd_hwla does with -d 64 -p 32), then one --signal=<name>=<msb>:<lsb> per field of the probes (the names of the table above: only these signals and trigger are in the VCD file).

With HWLA_LINK = "uart", the bytes of debug_uart_tx_o (or of the TX pad in mode 01): saved by tools/hwla/hwla_capture.sh [-d device] [-b baud] [-o file] [-s bytes] [-n captures] (the serial port set raw at HWLA_BAUD_RATE, the bytes appended to the file, the number of bytes and of complete captures shown as they arrive; 12288 bytes per capture by default: WardRV_fsm with the HWLA_* generics of the NG-MEDIUM targets; -s 10240 for OpenBlaze8), then decoded, or read by hwla2vcd.py on the serial port directly:

H=build/asylum_soc_PicoSoC_4.8.0/emu_ng_medium_soc3_wardrv_fsm_fault_debug-nxmap/hwla
tools/hwla/hwla_capture.sh -d /dev/ttyUSB1 -n 1                    # S5 S6 = 01 : capture.bin
python3 $H/hwla2vcd.py capture.bin --args-file $H/hwla_wardrv_fsm.args -o capture.vcd
# or directly on the serial port
python3 $H/hwla2vcd.py --port /dev/ttyUSB1 --baudrate 9600 --captures 1 \
        --args-file $H/hwla_wardrv_fsm.args -o capture.vcd
gtkwave capture.vcd

With HWLA_LINK = "jtag" (make emu_ng_medium_soc3_wardrv_fsm_fault_debug_hwla_jtag), OpenOCD with picosoc.cfg (see OpenOCD and GDB on the board: mode 10 with an FTDI cable or mode 11 through any USB-UART cable), then in its telnet console (port 4444) or with monitor in GDB:

tools/openocd/openocd.sh ft232r                    # S5 S6 = 10 ; the chain discovered, picosoc.hwla named
telnet localhost 4444
> picosoc_hwla_status                              # flags of the HWLA, CONFIG of its TAP : nothing to read
> picosoc_inject 0x2                               # an error in CPU1 (or the push button) : the HWLA triggers
> picosoc_inject 0x0
> picosoc_hwla_status                              # triggered, sending : a capture is waiting
> picosoc_hwla_dump capture.bin                    # one capture of 12288 bytes (WardRV_fsm, NG-MEDIUM) in capture.bin
H=build/asylum_soc_PicoSoC_4.8.0/emu_ng_medium_soc3_wardrv_fsm_fault_debug_hwla_jtag-nxmap/hwla
python3 $H/hwla2vcd.py capture.bin --args-file $H/hwla_wardrv_fsm.args -o capture.vcd

Several captures in one file (hwla_capture.sh -n <captures>, picosoc_hwla_dump <file> <captures>): hwla2vcd.py writes one VCD file per capture, or with --merge all of them in one VCD file (placed from their timestamps, a capture variable; asylum-debug-hwla 3.1.0).

picosoc_hwla_dump <file> [captures [capture_bytes [timeout]]] reads the bytes of the TX FIFO (jtag_axis_pop), waiting for the trigger, until captures x capture_bytes bytes are read (capture_bytes = HWLA_DEPTH x the bytes of a sample: 12288 by default, the WardRV_fsm bitstreams of the NG-MEDIUM targets (1024 samples of 12 bytes); 10240 with OpenBlaze8), and writes them raw to <file> (relative to the directory of OpenOCD): the same bytes as the UART, so hwla2vcd.py reads both the same way. It stops with a warning when no byte comes for timeout seconds (10). One capture per injection: the next one waits for the next injection. picosoc_hwla_status [nb_switch [nb_led0 [nb_led1]]] prints the flags of the HWLA (from STATUS, the widths of the bitstream as for picosoc_status) and the CONFIG of the TAP of jtag_axis with the state, for example hwla_arm=0x1 hwla_armed=0x0 hwla_triggered=0x1 hwla_sending=0x1 tx_enable=1 tx_empty=0 tx_full=1 rx_enable=0 data_width=8 : a capture is waiting; without the TAP of the HWLA (HWLA_LINK = "uart") it prints the flags only. Both use the procedures of tools/openocd/jtag_axis.tcl, a copy of tools/openocd/jtag_axis.tcl of asylum-debug-jtag 1.3.0 (keep the two files identical), sourced by picosoc.cfg from its own directory. The file is raw bytes; it is a text of hexadecimal bytes (16 per line, hwla2vcd.py --format hex) when its name ends with .hex, or when the Tcl of the OpenOCD build has no command binary (some xPack builds: picosoc_hwla_dump then warns).

The trigger wire of the VCD file is high during the clock cycle of the trigger sample. Cost of the HWLA: see Resources.

A capture of the scenario hwla (WardRV_fsm, lock-step, SoC clock 1.152 MHz), decoded by hwla2vcd.py from the bytes received on debug_uart_tx_o, around the trigger: an error is injected in CPU1 just after the firmware writes the new switches 0x96 to LED0 (daddr 0A); the CPU fetches an instruction when ics is high, the ROM gives it the next cycle (idata); the difference of the two copies of the CPU triggers the capture (trigger, one cycle) while the main loop reads the switches again (daddr 06):

HWLA capture around a fault

UART pads and JTAG

The 4 UART pads go through jtag_pad_mux (in PicoSoC_pads) of asylum-debug-jtag: debug_mux_sel_i (synchronized on the SoC clock by two sync2dffrn) gives them to one function:

debug_mux_sel_i Function Pads
00 user UART (sbi_UART) RX, TX, CTS*, RTS*
01 UART of the HWLA (TX only): the captures, also on debug_uart_tx_o; '1' (idle) without DEBUG_ENABLE or with HWLA_LINK = "jtag"; no JTAG (nothing for OpenOCD) TX
10 JTAG chain on the JTAG pins (no TRST*) TCK, TDI, TDO, TMS
11 JTAG over the UART: the UART of jtag_bitbang (OpenOCD remote_bitbang), which drives the JTAG chain (see JTAG over the UART) RX, TX

The pinout is the one of an FTDI MPSSE cable (FT232H, channel A of an FT2232H): the same cable is the UART (virtual COM port, modes 00 and 11) and the JTAG probe (OpenOCD ftdi, mode 10) without rewiring. It is also the UART pinout of an FT232R cable (TXD, RXD, RTS#, CTS#): the OpenOCD ft232r driver drives these 4 pins in synchronous bitbang mode, so a plain FT232R USB-UART cable is the JTAG probe of mode 10 too.

Pad FTDI pin UART mode (00) JTAG mode (10) JTAG over the UART (11) NG-MEDIUM pad
uart_rx_i AD0 (TXD / TCK) RX, input TCK, input RX, input IOB0_D06N (TP2 pin 2)
uart_tx_io AD1 (RXD / TDI) TX, output TDI, input TX, output IOB0_D07N (TP2 pin 3), weak pull-up
uart_cts_b_io AD2 (RTS# / TDO) CTS*, input TDO, output in Shift-IR / Shift-DR, 'Z' otherwise not used, 'Z' IOB0_D05N (TP2 pin 4), default pull-up (no pull-down on the NG-MEDIUM: CTS* inactive without a cable)
uart_rts_b_io AD3 (CTS# / TMS) RTS*, output TMS, input not used, 'Z' IOB0_D09N (TP2 pin 5), weak pull-up

The functions that do not own the pads see PAD_IN_DEFAULT: RX idle ('1'), CTS* active ('0': the user UART keeps sending into nothing and its firmware never waits, so the program goes on while the pads are given to JTAG), TDI '1', TMS '1' (the TAPs stay in Test-Logic-Reset); TCK reads the RX default ('1', no clock edge). The pad mapping is in the PAD_* constants and in one assignment block of PicoSoC_pads, which also gives the JTAG chain its pins: those of the pads in mode 10, those of jtag_bitbang in mode 11.

Switch the mode of the FPGA before starting the terminal or OpenOCD on the cable: in the wrong mode, two outputs drive the same wire (TX of the SoC and TDI of the probe, RTS* of the SoC and TMS of the probe). Series resistors (about 330 Ω) on these wires limit the current of such a contention. The multiplexer has no clock: change debug_mux_sel_i while the functions are idle; a change of mode while a probe is active (a scan cut in the middle, a byte half received) is not supported: stop the terminal or OpenOCD, change debug_mux_sel_i, start again.

JTAG chain. TDI → user SoC (the TAP of the CPU of each cluster, cluster 0 first) → supervisor SoC (the TAP of its CPU) → HWLA (the TAP of jtag_axis, HWLA_LINK = "jtag") → injection / status TAP → TDO. The TAPs share TCK and TMS (they are always in the same state); TDO comes from the last stage, its enable is the OR of the enables of the stages. A CPU without debug unit (OpenBlaze8, or *_CPU_DEBUG_ENABLE = false) and an absent TAP are wires (TDO = TDI, TDO never driven), so the chain has 0 to USER_NB_CPU + 3 TAPs. Since a wire stage passes the TDO of the stages before it with the OR of their enables, the last real TAP drives the TDO pad whatever wires follow it (checked by the scenario jtag_last, with the TAP of the user CPU only, as on the NG-MEDIUM board). Without any TAP (DEBUG_ENABLE and both CPU debuggers off), nothing drives TDO: in mode 10 the pad stays 'Z' and the probe reads the pull level of the pad (the default 30 kΩ pull-up of the NG-MEDIUM pads, which have no pull-down: ones); in mode 11, jtag_bitbang answers '1' to every 'R', as a pull-up. Every TAP has a 5-bit IR; they are reset by the reset of the supervisor (power-on) and by 5 TCK with TMS = 1.

Position from TDI TAP Present with IDCODE Instructions
1st to USER_NB_CPU-th WardRV_debug of the user CPU of cluster i USER_CPU_DEBUG_ENABLE 0x10001001 + i x 0x10000 IDCODE 00001, DTMCS 10000, DMI 10001, BYPASS
next WardRV_debug of the supervisor CPU SUPERVISOR_CPU_DEBUG_ENABLE 0x10002001 same
next jtag_axis of asylum-debug-jtag, HWLA captures (TX only, 8-bit words) DEBUG_ENABLE and HWLA_LINK = "jtag" 0x10004001 IDCODE 00001, CONFIG 00010, TX 00011, BYPASS (every other opcode, RX 00100 included)
last jtag_tap, injection / status DEBUG_ENABLE 0x10003001 IDCODE 00001, INJECT 00010, STATUS 00011, BYPASS (every other opcode)

The IDCODEs (PICOSOC_JTAG_IDCODE_* of PicoSoC_pkg) are version 1, manufacturer 0, part number 0x0001 + 0x10 x i for the user CPU of cluster i, 2 for the supervisor CPU, 3 for the injection / status TAP, 4 for the TAP of the HWLA captures (the same whatever the number of CPUs).

Injection / status TAP (DEBUG_ENABLE, PicoSoC_tap in hdl/PicoSoC_tap.vhd): a jtag_tap with its instruction decoder and two test data registers, in the TCK domain (the TCK resynchronized on the SoC clock by PicoSoC_top, see JTAG timing below):

Instruction TDR Bits (from the LSB, first shifted out)
INJECT 00010 jtag_tdr_inout, 16 bits written, nibble aligned: [2:0] error injection outside the CPUs, bit i in CPU i (as inject_error_i, active high: the instruction bit SEU_BIT; trapped, a 1 -> 0 clears the trap of CPU i); [3] reserved (0); [7:4], [11:8], [15:12] error injection inside the CPU copy 0, 1, 2, bit 4+4*i+k = request k of copy i (for example bits 1:0 the copies of a TMR register, bits 3:2 1 or 2 bits of a word of the register file): a pulse of one SoC clock cycle on bit k of inject_i (4 bits) of the cpu_wrapper of copy i (inject_cpu_i of cpu_safety, 3 x 4 bits, every cluster) for each 0 -> 1 of the bit, so one error per write; unused by the reference CPUs: free for a hardened CPU, connected to its own injection. A write sets the 16 bits: writing the bits inside the CPUs also writes [2:0]. Read: diff of the user SoC in [2:0] (0 CPU0 vs CPU1, 1 CPU1 vs CPU2, 2 CPU2 vs CPU0, sticky until the reset of the user SoC), 0 in [15:3]
STATUS 00011 jtag_tdr_in, USER_NB_LED0 + USER_NB_LED1 + 3 + USER_NB_SWITCH + 2 + 4 bits (33 with the defaults) led0_o, led1_o, led_diff_o, switch_i, the resets: user SoC, supervisor SoC (1: running), then the flags of the HWLA (status_o of PicoSoC_hwla): arm (arm_i, tied to 1), armed (capture started, trigger not yet seen), triggered (trigger seen, capture not yet extracted), sending (a byte of the capture offered to its link)

The injection written by an Update-DR (falling edge of TCK) goes through a sync2dffrn per bit to the SoC clock. The 12 bits inside the CPUs then go through a register and give a pulse on the rising edge of each bit (inject_cpu of PicoSoC_top to PicoSoC_user, cpu_safety and cpu_wrapper, gated by USER_FAULT_INJECTION in cpu_safety; it is also a trigger of the HWLA). [2:0] is ORed with inject_error_i after its polarity (USER_FAULT_POLARITY) and resynchronized, in PicoSoC_inject: either sets the trap of the copy (see CPU safety). The written value stays until the next scan of INJECT, a Test-Logic-Reset or the power-on reset; a bit written back to 0 clears the trap of its copy (the way to stop an error without safety, where no difference flag clears it). The read values are quasi-static (LEDs, switches, sticky difference flags, resets) or single flags (HWLA): they are loaded in Capture-DR without synchronizer, a bit that changes during the capture may be read old or new.

CPU debug units (USER_CPU_DEBUG_ENABLE, SUPERVISOR_CPU_DEBUG_ENABLE, CPU_MODEL = "WardRV_fsm"): each cpu_wrapper with DEBUG_ENABLE instantiates WardRV_debug of asylum-processor-WardRV (TAP, DTM, Debug Module with a program buffer of 2 words and 2 data registers, no system bus access, no TRST*) next to its sbi_WardRV_fsm: the halt requests and the debug memory stay inside cpu_wrapper, which only has the JTAG pins, the power-on reset of the debug unit and ndmreset. With lock-step or TMR, every copy of the CPU has its debug unit: cpu_safety receives a TCK already resynchronized on the SoC clock (by PicoSoC_top, see JTAG timing below) and gives the JTAG pins to every copy like their other inputs (to CPU1 through the lock-step delay line), and checks their TDO and ndmreset like their other outputs (compared with CPU0, which drives them, in lock-step; voted in TMR). So a halted, stepped or resumed CPU stays in lock-step: no difference flag. The supervisor CPU has no copy: PicoSoC_supervisor gives the JTAG pins to its debug unit. The debug units are reset by the reset of the supervisor (power-on), not by a reset of the user SoC; ndmreset of a debug unit resets the SoC of its CPU (the supervisor SoC holds the user SoC in reset).

JTAG timing. One sync2dffrn in PicoSoC_top resynchronizes TCK on the SoC clock for the whole chain, reset by the reset of the supervisor (power-on). It is after the pad multiplexer of PicoSoC_pads, so it serves both modes (the TCK pad in mode 10, tck_r of jtag_bitbang in mode 11): one place, the same path in both modes, and a glitch of the multiplexer when the mode changes is filtered too. Every TAP (the user CPU debug units in cpu_safety, the supervisor CPU debug unit, the injection / status TAP) gets this TCK: no TAP is clocked by the TCK pad, they all see the same TCK, 2 to 3 SoC clock cycles after the pad, and move on the same SoC clock edge. Only TCK is resynchronized: TMS and TDI go straight to the TAPs. This is not a protocol change (IEEE 1149.1 behaviour unchanged, the probes change TMS and TDI on the falling edge of TCK and sample TDO on the rising edge), but a limit on TCK:

Parameter Value
TCK frequency below about FSYS_INT / 8 (1.5 MHz at 12.5 MHz); TCK high and low each more than 3 SoC clock cycles
TMS, TDI hold after the rising edge of TCK about 3 SoC clock cycles (the edge is seen up to 3 cycles later)
TDO valid after the falling edge of TCK about 3 SoC clock cycles

A probe faster than this limit can miss TCK pulses (the scans then fail). Along the chain, a TAP changes its TDO on the falling edge of the resynchronized TCK and the next TAP (its TDI) samples it on the rising edge of the same TCK, half a TCK period later (more than 3 SoC clock cycles): every TAP is on the same TCK, there is no skew between them. TMS and TDI, changed by the probe on the falling edge of the pad, are sampled on the rising edge of the resynchronized TCK, 2 to 3 SoC clock cycles after the rising edge of the pad: they must hold that long (the line above), which a TCK high time of more than 3 SoC clock cycles gives. The last TDO reaches the probe about 3 SoC clock cycles after the falling edge of the pad, before the next rising edge where the probe samples it.

Why a resynchronized TCK for every TAP: a TAP clocked by the TCK pad takes every glitch or ringing of the TCK wire as an edge, and an edge too close to a change of TMS may be taken with the old TMS. The synchronizer samples the pad once per SoC clock cycle, so a bounce on an edge shorter than a SoC clock period gives one edge, and TMS and TDI are sampled 2 to 3 cycles after the edge of the pad. Why one synchronizer: every TAP sees exactly the same edges (with one synchronizer per TAP, an edge in the metastable window could be seen one SoC clock cycle apart by two TAPs), there is one place to read, and cpu_safety, rewritten by the students, only receives a TCK already on the SoC clock. On the NG-MEDIUM board (emu_ng_medium_soc3_wardrv_fsm_fault_debug, FT232R in synchronous bitbang at 10 kHz, mode 10), the injection / status TAP, then clocked by the pad like the supervisor CPU debug unit (only the user CPU debug units resynchronized TCK, in cpu_safety), lost its state: the 3 IDCODEs were read, then OpenOCD failed from time to time (auto0.tap IR capture error on this TAP only, Unsupported DTM version 9: the STATUS of this TAP read instead of dtmcs, picosoc_status all zeros) until a reset of the board, while JTAG over the UART (mode 11, TCK made inside the FPGA on the SoC clock) always worked. The scenario jtag_glitch reads the IDCODEs of the chain with a bounce on every TCK edge of the scan: it passes with the resynchronized TCK and fails without the synchronizer of PicoSoC_top.

The testbench uses TCK = 1 µs; the co-simulation with OpenOCD runs at the limit (TCK = FSYS_INT / 8, see Co-simulation with OpenOCD and GDB). JTAG over the UART (mode 11) is always far below this limit: a TCK edge per command byte, at least 10 bit times.

On the host, OpenOCD and GDB use the files of tools/openocd: see OpenOCD and GDB on the board.

Halt and resume of the user CPU through the JTAG pads, from the simulation of the scenario jtag_cpu_user (WardRV_fsm, lock-step): the DMI write of haltreq sets the halt request of the Debug Module, the CPU enters debug mode (halted) and leaves the user ROM (cpu_ics low: it runs the park loop of the Debug Module, at the addresses 0x201 to 0x206), LED0 no longer follows the switches; resumereq brings it back to the program:

Halt and resume of the user CPU through the JTAG pads

JTAG over the UART

With the switches 11, the UART pads carry a UART (PicoSoC_jtag_over_uart: uart_core of asylum-communication-uart, receiver and transmitter, RX resynchronized inside uart_core, 8 data bits, no parity, 1 stop bit, JTAG_BAUD_RATE, 115200 by default) to jtag_bitbang of asylum-debug-jtag: a JTAG master driven by the byte stream of the OpenOCD remote_bitbang adapter. Its JTAG pins drive the same JTAG chain as the pads of mode 10 (the selection is in PicoSoC_pads), the TDO of the chain comes back to it. Any USB-UART cable is the probe: no JTAG adapter, no extra pin; the FTDI MPSSE cable of mode 10 works too, as a plain serial port (AD0 TXD to uart_rx_i, AD1 RXD from uart_tx_io).

Byte jtag_bitbang in PicoSoC
'0' to '7' TCK, TMS, TDI = bits 2, 1, 0 of the byte
'R' answer '0' / '1' on uart_tx_io: TDO of the chain, '1' when no TAP drives it
'r', 's', 't', 'u' TRST, SRST: no effect. SRST (srst_o of jtag_bitbang) is not connected: a CPU is reset by ndmreset of its debug unit (Debug Module); TRST reaches the TAPs, which have no TRST* (ignored)
'B', 'b', any other byte LED of OpenOCD (not connected: no free LED), ignored
  • Clock and reset: jtag_bitbang and its UART run on the SoC clock with the reset of the supervisor (power-on): a reset of the user SoC (by the supervisor or ndmreset) keeps the link. They exist only when the JTAG chain has at least one TAP (DEBUG_ENABLE, USER_CPU_DEBUG_ENABLE or SUPERVISOR_CPU_DEBUG_ENABLE); without TAP, the code 11 drives the TX pad idle ('1') and ignores RX.
  • TCK: in mode 11, TCK is the register tck_r of jtag_bitbang, clocked by the SoC clock, with a TCK edge per command byte. Every TAP resynchronizes it on the SoC clock as the TCK of the pads (see JTAG timing in UART pads and JTAG): nothing changes for them. Neither the TCK pad nor tck_r clocks a register: each is the input of the synchronizers (false path, as every sync2dffrn input), and the TAPs are clocked by the outputs of the synchronizers (registers of the SoC clock): no clock to declare for TCK. OpenOCD changes TMS and TDI a byte before the rising edge of TCK and reads TDO a byte after its falling edge.
  • Speed: a scanned bit read by OpenOCD costs 3 bytes (TCK low with TMS and TDI, 'R', TCK high), a TMS move 2 bytes. At 115200 baud (11520 bytes/s), TCK is about 3.8 kHz during the scans (about 320 Hz at 9600 baud, the baud rate of the NG-MEDIUM targets): the IDCODE of a TAP (about 110 bytes) takes about 10 ms, a DMI access of a CPU debug unit (two DR scans of 41 bits and the BYPASS bits of the other TAPs, about 310 bytes) about 27 ms. The speed scales with JTAG_BAUD_RATE (the testbench uses 921600 baud); adapter speed of OpenOCD has no effect.

On the host, tools/openocd/remote_bitbang_setup.sh (socat) links the TCP port 9824 of the OpenOCD adapter remote_bitbang (tools/openocd/remote_bitbang.cfg, the adapter of the co-simulation) to the serial port: see OpenOCD and GDB on the board.

The same halt and resume through JTAG over the UART, from the simulation of the scenario bitbang_cpu (921600 baud): each step is a DMI access, two DR scans of 43 bits (the target and the BYPASS bits of the 2 other TAPs), 3 command bytes per bit:

Halt and resume of the user CPU through JTAG over the UART

The first bytes of such a scan, one column per byte (TCK low then high around each 'R', the answer comes back on uart_tx_io while the next commands arrive):

remote_bitbang bytes of a DR scan

OpenOCD and GDB on the board

OpenOCD takes an adapter file (the cable), then a chain file (the TAPs), both in tools/openocd; any adapter goes with any chain file:

openocd -f tools/openocd/<adapter>.cfg -f tools/openocd/<chain>.cfg

tools/openocd/openocd.sh checks the host, then runs this command: tools/openocd/openocd.sh <adapter> [picosoc|discover] [OpenOCD options] (adapter ft232r, ft232h or remote_bitbang; chain picosoc by default).

  • OpenOCD >= 0.11 (OPENOCD=<path> for another binary than openocd).
  • ft232r, ft232h: the cable on USB (lsusb, VID:PID 0403:6001 / 0403:6014); without access to its USB device, OpenOCD runs with sudo (the udev rules contrib/60-openocd.rules of OpenOCD avoid it); ft232r: a warning when a terminal still holds a /dev/ttyUSB*.
  • remote_bitbang: remote_bitbang_setup.sh listens on the TCP port 9824.
  • The ports 3333, 4444 and 6666 are free (no other OpenOCD running).
Adapter file Cable OpenOCD driver debug_mux_sel_i TCK
ft232r.cfg USB-UART cable with an FT232R (TXD, RXD, RTS#, CTS#, 3.3V; for example DSD TECH SH-U09G), vid_pid 0x0403 0x6001 ft232r, synchronous bitbang (the ftdi driver needs an MPSSE chip, the FT232R has none) 10 adapter speed 1000 (kHz: 1 MHz checked on the NG-MEDIUM board with an SH-U09G, TCK resynchronized on the SoC clock; the bitbang clock of the FT232R is not the one asked: keep a margin below FSYS_INT / 8, 1.56 MHz with the NG-MEDIUM generics)
ft232h.cfg FTDI MPSSE cable: FT232H, vid_pid 0x0403 0x6014 (FT2232H: 0x0403 0x6010, channel A) ftdi, layout_init 0x0008 0x000b 10 adapter speed 500 (kHz)
remote_bitbang.cfg Any USB-UART cable, through socat (TCP port 9824 to the serial port) remote_bitbang (also the adapter of the co-simulations) 11 A TCK edge per byte: the baud rate of the serial port (JTAG_BAUD_RATE, 9600 on the NG-MEDIUM targets); adapter speed has no effect

In mode 10, TCK stays below FSYS_INT / 8 (1.5 MHz on the NG-MEDIUM targets, see JTAG timing in UART pads and JTAG). Both cables keep the wiring of the UART modes (NG-MEDIUM: TP2 pins 2 to 5):

Cable pin (FT232R / FT232H) Pad TP2 pin Mode 10
TXD / AD0 uart_rx_i 2 TCK, input of the FPGA
RXD / AD1 uart_tx_io 3 TDI, input of the FPGA
RTS# / AD2 uart_cts_b_io 4 TDO, output of the FPGA
CTS# / AD3 uart_rts_b_io 5 TMS, input of the FPGA

With ft232r, RXD and CTS# are outputs of the cable and RTS# an input (ft232r jtag_nums TXD CTS RXD RTS, in the order TCK, TMS, TDI, TDO); ft232r restore_serial 0x0015 gives the cable back to the serial driver when OpenOCD quits (else unplug and plug the cable).

Chain file Role
picosoc.cfg The JTAG chain (the list picosoc_chain: chip, TAP and IDCODE of each TAP, from TDO), a riscv target for each CPU TAP (GDB ports 3333, 3334 ... in the order of the chain), the commands picosoc_inject <errors> (INJECT of the injection / status TAP, raw 16 bits: [2:0] outside the CPUs, [7:4], [11:8], [15:12] inside the CPU copy 0, 1, 2), picosoc_inject_cpu <copy> <mask> (one injection inside the CPU copy, mask of 4 bits; writes mask << (4 + 4 * copy), then 0, [2:0] at 0), picosoc_status (its STATUS), picosoc_hwla_status and picosoc_hwla_dump (the HWLA, see Debug: HWLA; with the procedures of jtag_axis.tcl, a copy of the one of asylum-debug-jtag), then init. Any PicoSoC bitstream, no argument: see the two modes below
picosoc_cmds.tcl Short commands of the telnet session, sourced by picosoc.cfg (picosoc_help): status (state and pc of every CPU), select <cpu>, stop / run (one CPU or stop_all / run_all), stepi, halt_cause, pc, regs, read_reg / write_reg, read_mem / write_mem (32 bits) and read_byte / write_byte (8 bits: the peripheral registers), bp_add / bp_del. A CPU is given by its name (user.cpu0, supervisor.cpu), a short name (user, user1, sup) or its index in status. Without System Bus Access, memory is accessed by the CPU itself (program buffer), only while it is halted: read_mem / write_mem halt a running CPU for the access, then resume it. Checked by the co-simulation sim_soc3x2_wardrv_fsm_c_user_openocd_generic
discover.cfg Declares no TAP and no target: picosoc_discover probes and prints the chain, then the file prints the line set picosoc_chain {...} (the chain to give to picosoc.cfg) and quits (shutdown)
discover.tcl Sourced by picosoc.cfg and discover.cfg (one copy of the discovery): picosoc_discover runs jtag init in the configuration stage: the adapter starts and OpenOCD probes the chain after Test-Logic-Reset (autoprobe: TAPs auto0.tap, auto1.tap ... from TDO, IR length from the Capture-IR value); it reads the IDCODEs from scan_chain (jtag cget <tap> -idcode needs the exec stage), prints the number of TAPs and the IDCODE and PicoSoC name of each TAP (picosoc_tap, table below), and returns the chain as a picosoc_chain list
picosoc.cfg mode TAPs riscv targets Checks
picosoc_chain not set (default) Discovered: picosoc_discover prints the chain; the TAPs keep the names of the OpenOCD autoprobe (auto<k>.tap) One per CPU TAP, named from its IDCODE (supervisor.cpu, user.cpu<i>); a TAP of unknown IDCODE stays in the chain without target (Warn : TAP auto<k>.tap (IDCODE ...) : not a PicoSoC TAP, no target) None: the chain is the one found
picosoc_chain set before the file (-c "set picosoc_chain {...}", the line printed by discover.cfg) Declared: <chip>.<tap>, 5-bit IR, -expected-id One per TAP named cpu*, named <chip>.<tap> init checks each IDCODE against its -expected-id

Names given by picosoc_tap of discover.tcl (the IDCODEs of UART pads and JTAG):

IDCODE TAP In picosoc_chain (riscv target)
0x10001001 + i x 0x10000 WardRV_debug of the user CPU of cluster i user cpu<i> (user.cpu<i>)
0x10002001 WardRV_debug of the supervisor CPU supervisor cpu (supervisor.cpu)
0x10003001 Injection / status TAP picosoc inject (no target)
0x10004001 jtag_axis of the HWLA captures (HWLA_LINK = "jtag") picosoc hwla (no target; picosoc_hwla_status, picosoc_hwla_dump)
Any other value Not a PicoSoC TAP: no target (given in picosoc_chain, picosoc.cfg declares it with a 5-bit IR) unknown tap<k>

Steps (an FT232R cable in mode 10; with the FTDI MPSSE cable use ft232h.cfg):

  1. Build and program a bitstream with at least one TAP: make emu_ng_medium_soc1_wardrv_fsm (the debugger of the user CPU, the only TAP of its chain) or make emu_ng_medium_soc3_wardrv_fsm_fault_debug (lock-step, HWLA, chain of 3 TAPs: injection / status, supervisor CPU, user CPU) or make emu_ng_medium_soc3_wardrv_fsm_fault_debug_hwla_jtag (the same with the HWLA captures read through JTAG: chain of 4 TAPs, from TDO injection / status, HWLA, supervisor CPU, user CPU); the other emu_ng_medium_* targets have no TAP.
  2. Stop the terminal on the cable, then set S5 S6 to 10 (S5 1, S6 0; see Board).
  3. Start OpenOCD with the adapter file and picosoc.cfg, no argument: it discovers the chain, prints it, creates the riscv targets and starts a GDB server per CPU.
  4. Connect GDB to the GDB port of the CPU (3333 for the first CPU of the chain, from TDO).
  5. Quit GDB and OpenOCD, set S5 S6 back to 00 for the user UART.

After a reset of the board (button S11, which also resets the TAPs and the CPU debug units), the TAPs are back in Test-Logic-Reset while OpenOCD still believes them in Run-Test/Idle: its next scans are shifted and read garbage. Restart OpenOCD (the CPUs are examined again), or at least run jtag arp_init (telnet port 4444, or monitor jtag arp_init in GDB): Test-Logic-Reset through TMS, then the IDCODEs of the chain checked again.

make emu_ng_medium_soc1_wardrv_fsm                                  # TOOL=nxmap
tools/openocd/openocd.sh ft232r                                     # S5 S6 = 10
gdb-multiarch -ex "set architecture riscv:rv32" -ex "mem 0x80000040 0x80000100 rw" -ex "target extended-remote localhost:3333"

For the chain of emu_ng_medium_soc1_wardrv_fsm, picosoc.cfg prints (lines of the co-simulation sim_soc1_wardrv_fsm_c_user_openocd_generic, the same command on remote_bitbang.cfg):

Info : JTAG tap: auto0.tap tap/device found: 0x10001001 (mfg: 0x000 (<invalid>), part: 0x0001, ver: 0x1)
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 0x10001001"
PicoSoC JTAG chain : 1 TAP(s), from TDO
TAP 0 : IDCODE 0x10001001 : user.cpu0
Info : JTAG tap: auto0.tap tap/device found: 0x10001001 (mfg: 0x000 (<invalid>), part: 0x0001, ver: 0x1)
Info : Examined RISC-V core; found 1 harts
Info : starting gdb server for user.cpu0 on 3333

The chain can also be given, its IDCODEs then checked by init (-expected-id): discover.cfg prints the chain and its picosoc_chain line (here set picosoc_chain {user cpu0 0x10001001}, lines of sim_soc1_wardrv_fsm_c_user_openocd_discover), then quits; give that line before picosoc.cfg:

openocd -f tools/openocd/ft232r.cfg -f tools/openocd/discover.cfg
openocd -f tools/openocd/ft232r.cfg -c "set picosoc_chain {user cpu0 0x10001001}" -f tools/openocd/picosoc.cfg

JTAG over the UART (mode 11, any USB-UART cable): tools/openocd/remote_bitbang_setup.sh links the TCP port 9824 of remote_bitbang.cfg to the serial port, at the baud rate of the bitstream (JTAG_BAUD_RATE); the rest is the same:

tools/openocd/remote_bitbang_setup.sh /dev/ttyUSB0 9600   # S5 S6 = 11 ; Ctrl-C to stop
tools/openocd/openocd.sh remote_bitbang                                     # in another terminal
  • The script sets the serial port with stty (raw, 8N1, no flow control) and runs socat without termios option: some socat versions fail with Inappropriate ioctl for device on the options raw,echo=0,b9600 of a serial port.
  • The link stays for the next OpenOCD session (fork).
  • Without read / write access to the serial port, the script runs stty and socat with sudo. To avoid it, add the user to the group of the port: sudo usermod -aG dialout $USER, then log out and in.

With the injection / status TAP in the chain (DEBUG_ENABLE), GDB drives it through OpenOCD:

(gdb) monitor picosoc_inject 0x1          # inject an error in CPU0 (INJECT, trapped until diff), prints the difference flags
(gdb) monitor picosoc_inject 0x0          # end of the injection : the 1 -> 0 clears the trap
(gdb) monitor picosoc_inject_cpu 1 0x8    # request 3 inside the CPU copy 1 (INJECT [11:8] = 1000, then 0) : for a hardened CPU
(gdb) monitor picosoc_status              # STATUS : led0, led1, led_diff, switch, user / supervisor SoC running

picosoc_status [nb_switch [nb_led0 [nb_led1]]] reads the register STATUS (IR 0x03) of the injection / status TAP and prints its fields, for example led0=0x9 led1=0x0 led_diff=0x2 switch=0x9 user_running=0x1 supervisor_running=0x1 hwla_arm=0x1 hwla_armed=0x1 hwla_triggered=0x0 hwla_sending=0x0:

Field Bits (from the LSB) Signal
led0 USER_NB_LED0 led0_o (the firmware user.c copies the switches)
led1 USER_NB_LED1 led1_o (count of it_user_i in user.c)
led_diff 3 led_diff_o: LEDs of the supervisor (its count of the resets of the user SoC)
switch USER_NB_SWITCH switch_i
user_running 1 reset of the user SoC released (1: running)
supervisor_running 1 reset of the supervisor SoC released (1: running)
hwla_arm, hwla_armed, hwla_triggered, hwla_sending 1 each flags of the HWLA (see Debug: HWLA): arm (tied to 1), armed, triggered, sending; 0 with a bitstream before 4.8.0 (its STATUS is 4 bits shorter: these bits are the zeros shifted in by the scan)

The widths are the generics of the bitstream: the default arguments (4 switches, 8 + 8 LEDs) are those of the NG-MEDIUM targets.

  • GDB reads the memory of the RAM of the firmware only (mem, the data RAM of the rvcc_gen link script): without it, GDB reads the code around pc through the data bus of the hart, where the user ROM is not, so these reads reach the peripherals (a spinlock taken, a FIFO popped; in a co-simulation, a read that never ended left the abstract command busy).
  • Several riscv targets in one chain work with OpenOCD 0.12: the co-simulations sim_soc3x2_wardrv_fsm_c_user_openocd_chain (chain given) and sim_soc3x2_wardrv_fsm_c_user_openocd_generic (chain discovered) examine, halt and resume the 3 CPUs of a chain of 4 TAPs.
  • A discovered chain keeps the TAP names of the autoprobe (auto<k>.tap): OpenOCD 0.12 can neither rename nor remove a TAP, and a jtag newtap after the probe adds a TAP after them (checked in a co-simulation of the chain of 1 TAP: user.cpu0 declared after jtag init is a second TAP at init, UNEXPECTED: 0xffffffff, IR capture error, the target is not examined). The targets carry the PicoSoC names, and picosoc_inject uses the TAP of IDCODE 0x10003001.
  • picosoc_inject and picosoc_status are defined even when the chain has no injection / status TAP: they then fail in OpenOCD. picosoc_status is checked on its decoding only (OpenOCD 0.12); the register STATUS itself by the scenario jtag_status of tb_PicoSoC on main.
  • A bitstream without TAP: nothing drives TDO. TDO at one (mode 10: the default pull-up of the NG-MEDIUM pad; mode 11: jtag_bitbang answers '1') gives JTAG scan chain interrogation failed: all ones and the discovery prints 0 TAP(s) and a line No TAP : ... (checked with a co-simulation without TAP, TDO pulled up); picosoc.cfg then creates no target. TDO at zero (an adapter or a board that pulls TDO down) is read by the OpenOCD autoprobe as a chain of TAPs without IDCODE, unknown with 0x00000000 (seen with the OpenOCD dummy adapter, whose TDO is 0): picosoc.cfg warns for each one and creates no target.

Install on the host:

  • OpenOCD >= 0.11 (the ft232r driver and the RISC-V target), for example xPack OpenOCD 0.12 on CentOS 8; the co-simulations use OpenOCD 0.12 of the asylum-env image.
  • A RISC-V GDB: gdb-multiarch (asylum-env image) or riscv-none-elf-gdb.
  • socat for JTAG over the UART (remote_bitbang_setup.sh).
  • Access to the cables without sudo (USB device for OpenOCD, serial port for screen, socat and the HWLA captures), once: tools/udev/install.sh installs tools/udev/60-picosoc.rules in /etc/udev/rules.d (FTDI FT232R 0403:6001, FT2232H 0403:6010, FT232H 0403:6014: group dialout, mode 0660, kept when the cable is plugged again or re-enumerated, e.g. after OpenOCD or by the USB passthrough of a virtual machine) and adds the user to the group dialout; log out and in once (tools/udev/install.sh --uninstall removes the rules).

Programmer's Guide

Firmware structure

esw/ has one folder per group of firmwares: system/ (supervisor, empty program), demo/ (demonstrations of the boards and of most simulation targets), protocol/ (servers of a protocol on the UART), test/ (integration firmwares); include/ holds the drivers and the address maps (-Iesw/include of every generator).

File Description
esw/system/supervisor.c Supervisor (see Supervisor)
esw/system/dummy.c Empty program (supervisor ROM when the SoC has no supervisor)
esw/demo/user_identity.c, esw/demo/user_identity.psm Copies the switches into LED0 (C, and assembler for OpenBlaze8); -DINVERT_SWITCH inverts them
esw/demo/user.c Peripheral test: LED0 = switches, LED1 counts the it_user_i interrupts, UART echo in the interrupt routine; one UART line per loop with the loop counter, the switches, an SPI byte (loopback or flash, HAVE_SPI / HAVE_SPI_MEMORY), a spinlock test and a mailbox test that also checks the mailbox sources of the GIC (prints KO and stops on a mismatch; on hart 0 only: with several clusters, the others share the mailbox and its GIC sources and skip it)
esw/demo/user_loop.c LED0 = switches and one UART line per iteration, Loop <loop number> <pseudo random number>, both in 8 hexadecimal digits; the numbers come from the xorwow generator of Marsaglia (5 x 32-bit xorshift state and a Weyl counter d += 362437: shifts, xor and additions, no multiply on RV32I), fixed seed (Loop 00000000 0EB70507, Loop 00000001 DBF10AA0 ...): the same lines after every reset, a wrong or missing line shows an error (WardRV)
esw/demo/user_hello.c Multi-core test (WardRV): each CPU prints CPU <hartid> - Loop <counter> under the spinlock, shows the shared counter on LED0 and the CPUs seen on LED1
esw/protocol/user_modbus_rtu.c Modbus RTU server on the UART (slave id 0x5A, functions 0x03 read and 0x06 write of a SoC address, CRC16 by the CRC IP)
esw/test/test_<ip>.c Integration firmwares, see below

Integration firmwares

One small firmware per peripheral of the user SoC, the reference example of its use from C: registers through the driver of esw/include/ at the base address of addrmap_user.h, the path to the pins (seen by the testbench) and the interrupt through the user GIC. Each step is one test_check(step, condition) of esw/include/test.h; the firmware prints PASS on the UART, or FAIL <step> and stops. Each one has its scenario test_<ip> in tb_PicoSoC (see Scenarios).

Firmware What it checks
esw/test/test_gpio.c GPIO: reset directions and values, LED0 / LED1 registers read back and seen on the pins, switches set by the testbench read back, their rising / falling edges recorded in the isr of SWITCH and taken by interrupt (SWITCH -> GIC source 5 -> CPU), direction register (an input reads its pin)
esw/test/test_uart.c UART: reset values (disabled, baud rate of the generics), setup read back, TX (every line), RX polled on the "RX FIFO not empty" source, RX by interrupt (UART source -> GIC source 1 -> CPU)
esw/test/test_spi.c SPI with the flash model of the testbench: reset values, prescaler and configuration read back, flash status register (write enable latch set / cleared), read of 4 bytes, page program of 2 bytes polled on the write-in-progress bit, read back
esw/test/test_timer.c Timer: reset values, 32-bit initial value read back, periodic interrupt (autostart, GIC source 2) counted on LED0, period of 2000 SoC cycles measured by the testbench, no interrupt after the timer is stopped
esw/test/test_crc.c CRC: reset value, seed read back, CRC16 of 123456789 (0x4B37), of a Modbus request (C5 CD) and of the request with its CRC (0)
esw/test/test_spinlock.c Spinlock from one CPU: test-and-set on read, 2 independent locks, release by a write of 0, a write never takes a lock (several CPUs: esw/demo/user_hello.c)
esw/test/test_gic.c GIC: reset values, mask read back, it_user_i pulse recorded while masked (no interrupt), taken when unmasked, taken at once when unmasked before
esw/test/test_ram.c RAM2 (64 bytes) and the lower half of RAM1 (WardRV keeps its stack in the upper half): address in the data then its complement (aliasing, every data bit), the unmapped addresses 0x38-0x3F answered by the default slave of ICN2 (write ignored, read 0)
esw/test/test_i2c.c I2C with the UVVM I2C BFM of the testbench: reset values (disabled, prescaler for 100 kHz), prescaler and configuration read back; master: write of 2 bytes to the BFM slave and read back, every byte acknowledged, NACK on an address without slave; slave (polling of the status, no interrupt): 2 bytes written by the BFM master read and checked, then sent back to it
esw/test/test_pwm.c PWM: reset values, prescaler / period / duty read back; steps on LED0, acknowledged by the testbench on the switches: pwm_o low while disabled, period and high phase measured by the testbench for 2 duties, low again once disabled
esw/test/test_mailbox.c Mailbox between 2 clusters: the CPU that takes lock 1 is the requester; reset status, FIFO order and full / empty flags, then 4 requests in fifo0 answered in fifo1, each one through the "data available" source of the GIC of the other cluster

The interconnects and the clock divider have no firmware of their own: every integration firmware reaches its peripheral through ICN1 and ICN2 at its base address (a decoding error fails it), test_ram checks the RAM ranges and the default slave, test_mailbox runs with 2 masters on ICN2, and the timer period and the UART bit time measured by the testbench are counted in cycles of the divided clock (FSYS_INT).

The firmwares are portable C (the drivers support both CPUs), with one restriction: test_ram is built for WardRV only, as pbcc (SDCC 3.0.1, OpenBlaze8) miscompiles the variable port address of PORT_WR(base, i, ...) in a loop (it uses the high byte of base + i). Two other pbcc limits shape the code of the integration firmwares: a function that ends with an infinite loop breaks the register saves of the next function (the stop loops of test.h are in macros), a register saved inside a branch is restored on every path (the interrupt routine of test_mailbox.c calls one function per source), and a register is saved at its first use, also inside a polling loop of main, where it would be saved at each iteration (test_i2c.c has no local variable and tests a status bit before its first loop).

Drivers

The drivers in esw/include/ are macros on PORT_WR(base, offset, data) / PORT_RD(base, offset) (8-bit accesses, cpu/picoblaze.h or cpu/riscv.h from cpu.h) and on the register offsets of the regtool headers of each peripheral (<X>_csr.h, on the include path of the generators): gpio.h, uart.h (putchar, puthex, getchar, empty without HAVE_UART), spi.h (flash commands), i2c.h (master commands, slave data), pwm.h, gic.h, timer.h, crc.h, spinlock.h, mailbox.h, modbus_rtu.h. cpu.h also gives ISR_FCT (the interrupt routine isr), interrupt_setup, interrupt_enable / interrupt_disable, cpu_nop and cpu_hartid (mhartid on WardRV, 0 on OpenBlaze8). The base addresses are those of addrmap_user.h / addrmap_supervisor.h.

Example: switches to LEDs, interrupt counter

#include <stdint.h>
#include "addrmap_user.h"

// Interruption routine : count the it_user_i interruptions on LED1
ISR_FCT
{
  if (gic_isr(GIC) & GIC_IT_USER_MSK)
    {
      gpio_wr(LED1, gpio_rd(LED1)+1);
      gic_clr(GIC, GIC_IT_USER_MSK);     // acknowledge (rw1c)
    }
}

void main()
{
  gpio_setup(SWITCH, INPUT);
  gpio_setup(LED0  , OUTPUT);
  gpio_setup(LED1  , OUTPUT);
  gpio_wr   (LED1  , 0);

  gic_clr      (GIC, GIC_IT_USER_MSK);   // old events : the ISR also records the masked sources
  gic_it_enable(GIC, GIC_IT_USER_MSK);
  interrupt_setup(isr);
  interrupt_enable();

  while (1)
    gpio_wr(LED0, gpio_rd(SWITCH));      // LED0 = switches
}

Clear the old events of a GIC source before unmasking it: the isr register also records the masked sources.

Design Verification

Testbenches

File DUT Description
sim/picosoc/tb_PicoSoC.vhd PicoSoC_top Self-checking UVVM testbench driven by the firmware of the target: drives the switches, debug_mux_sel_i, it_user_i and inject_error_i, checks LED0, LED1, led_diff_o, pwm_o, the UART lines (UART VIP) and the captures of the HWLA on debug_uart_tx_o (UART VIP) or through the TAP of jtag_axis (JTAG BFM, HWLA_LINK = "jtag"), with a copy of the user ROM ROM_user as the reference of the instruction bus; the I2C bus has pull-ups and the UVVM I2C BFM (slave or master of the SoC). The UART pads have pull-ups (a pad driven by nobody reads 'H') and a model of the FTDI cable: RX and CTS* driven by the testbench in the UART modes, TCK, TDI and TMS by the JTAG BFM jtag_bfm_pkg of asylum-verification-uvvm in the JTAG mode (debug_mux_sel_i 10, TCK 1 µs), TDO read on uart_cts_b_io; the monitor jtag_ir_capture_monitor of the BFM checks the Capture-IR value of the whole chain (00001 per TAP) at each IR scan. tb_PicoSoC_jtag_pkg gives the BFM configuration of a TAP of the chain (jtag_config(cfg, tap): the chain fields head_ir, tail_ir, head_dr, tail_dr, the other TAPs in BYPASS) and holds the DTM / DMI accesses of a debugger (as WardRV_vips of WardRV). In the mode 11 (JTAG over the UART), the cable is a UART: the remote_bitbang BFM rbb_bfm_pkg of asylum-verification-uvvm sends the bytes of the OpenOCD remote_bitbang adapter as UART frames on uart_rx_i (JTAG_BAUD_RATE), as the bitbang driver of OpenOCD 0.12 (TMS moves, IR / DR scans of a TAP of the chain with the same JTAG BFM configuration), and its monitor rbb_uart_monitor receives the answers to 'R' on uart_tx_io; tb_PicoSoC_bitbang_pkg holds the PicoSoC part: the BFM configuration of the testbench (rbb_config), one BFM call per helper and the DMI accesses of a debugger (bitbang_dmi). Generics: the DUT configuration (CPU, clusters, safety, polarities), TESTS_LIST, FIRMWARE (program of the user ROM: identity, user, user_uart, user_uart_spi, user_uart_spi_mem, hello or an integration firmware test_<ip>; it selects the scenarios that apply), TB_WATCHDOG (timeout of each wait, in clk_i cycles), SPI_MODEL (m25p40 / s25fl512s flash model preloaded with sim/mem/memory.mem) and TB_INJECT_CPU (scenario inject_cpu: the mask of 4 bits written in INJECT [7:4]). Scenarios in tb_PicoSoC_<name>_pkg, names, applicability and dispatch in tb_PicoSoC_tests_pkg, helpers in tb_PicoSoC_bfm_pkg. With an integration firmware, a UART console logs every line and stops on FAIL <step>, whatever the scenario waits for
sim/modbus_rtu/tb_PicoSoC_modbus_rtu.vhd PicoSoC_top UVVM testbench of esw/protocol/user_modbus_rtu.c: the UART VIP is the Modbus RTU master (CRC16 computed by the bench) and reads / writes the SoC addresses. Scenarios in tb_PicoSoC_modbus_rtu_<name>_pkg, dispatch in tb_PicoSoC_modbus_rtu_tests_pkg, Modbus frames in tb_PicoSoC_modbus_rtu_bfm_pkg
sim/openocd/tb_PicoSoC_openocd.vhd PicoSoC_top OpenOCD + GDB co-simulation (see Co-simulation with OpenOCD and GDB): OpenOCD drives the JTAG chain through the UART pads, with the entities of the co-simulation kit asylum:verification:openocd of asylum-verification-uvvm: rbb_jtag on the JTAG pins (DEBUG_MUX_SEL 10), or rbb_axis and a UART bridge (UART VIP, JTAG_BAUD_RATE) for JTAG over the UART (11); GDB runs sim/openocd/picosoc.py. Before OpenOCD the firmware runs (LED0 = switches); after OpenOCD quits, led_diff_o shows the error injected by the scenario (with USER_FAULT_INJECTION; else no difference flag) and LED0 follows new switches. Generics: the DUT configuration (with USER_NB_CPU), DEBUG_MUX_SEL; the scenario is the hook of the target (picosoc.py, chain.cfg or discover_check.cfg); the chain of the generics is written in cosim.cfg (PICOSOC_CHAIN, read by discover_check.cfg)
sim/tap/tb_PicoSoC_tap.vhd PicoSoC_tap The injection / status TAP alone, with the JTAG BFM on its pins (TCK resynchronized on clk_i by two flip-flops, as in PicoSoC_top) and a count of the pulses of inject_cpu_o (rising edges and cycles at 1 per bit). Scenarios in tb_PicoSoC_tap_pkg: inject ([2:0] written 010: inject_error_o = 010 until a write of 0, no pulse; the capture reads diff_i in [2:0], 0 in [15:3]) and inject_cpu (for each copy i and bit k, the bit 4+4*i+k alone: exactly one pulse of one clk_i cycle on inject_cpu_o(4*i+k) (bit 3 of each copy included), none on the other bits nor on inject_error_o; the same value again and 0: no pulse; the 12 bits together: one pulse on each; the reserved bit [3]: no pulse)

Waveform setups: sim/wave/waves.gtkw, sim/wave/cpus.gtkw.

Scenarios (TESTS_LIST)

The scenarios are chosen at run time with the generic TESTS_LIST: names separated by , without space, a name may be repeated. The sequencer first checks every name (an unknown name, or a scenario that does not apply to the firmware and the configuration, is a TB_ERROR before any scenario runs), then for each scenario puts the inputs to their inactive level, drives a reset pulse, logs TEST <i>/<N> : <name> and runs it: each scenario starts from reset, so the firmware runs its setup again. The empty list only compiles and elaborates the testbench. Checks are counted as the => OK lines of the log; for an integration scenario, (+ n) is the number of test_check steps of its firmware, summed up by its PASS line.

tb_PicoSoC:

Name Checks Applies to Description
switch 11 every firmware but hello Switches set one by one from bit 7 to bit 0, then 0x5A and 0xA5: LED0 follows; led_diff_o = 0 (no difference between the redundant CPUs)
it_user 10 user* The loop also prints its line and runs the spinlock / mailbox code: two short it_user_i pulses give exactly one interrupt each (LED1 + 1), a long pulse at least one, LED1 stable without interrupt; LED0 still follows the switches afterwards
uart 10 user_uart* Banner Welcome Back, Commander; CTS* held from the CR of the banner (the line is quiet), a byte sent on uart_rx_i is echoed by the interrupt routine (UART source of the GIC) in the first Loop line; 6 Loop lines checked character by character (counter from 0, switches: 00 for the first two lines, then 0xA5; SPI byte of the loopback or of the flash, spinlock, mailbox); one it_user_i pulse during the lines
sequence 10 user_loop Switches 0x5A, then 3 lines; 0xA5, then 3 more: the 6 lines are the reference lines of the loops 0 to 5 (Loop <n> <xorwow>, the xorwow sequence computed by the testbench from the seed of the firmware, tb_PicoSoC_sequence_pkg, with a UART line receiver that returns on a silent line); LED0 = the switches after each run of lines; led_diff_o stable at 0
inject_cpu 15 user_loop, fault injection, DEBUG_ENABLE For the labs that harden WardRV (inject_i of cpu_wrapper): switches 0x3C, the Loop lines of the loops 0 and 1; then the UART pads to the JTAG pins (mode 10), the HWLA armed (STATUS), INJECT written with TB_INJECT_CPU in [7:4] (inside the CPU copy 0: one pulse per bit of the mask on inject_i), then 0; the HWLA triggered (the injection reached the CPUs: a mask of 0 would not trigger it); the UART pads back to the user UART: the next complete line is a reference line of a loop number >= 2 (the lines of the JTAG time are lost, no restart from the loop 0), then 3 more reference lines; LED0 = switches, led_diff_o stable at 000 (no reset of the user SoC). The reference CPU ignores inject_i: it passes. A hardened CPU passes when it corrects the error (one copy of a TMR PC, one bit of an ECC word) and fails when it reports it (parity, two TMR copies, two bits of an ECC word: the supervisor resets the user SoC, the lines restart from the loop 0). About 2 ms of simulated time, 1 min of run
fault_lock_step 13 user*, supervisor, lock-step, fault injection Errors in CPU0, CPU1, CPU0: after each one the user SoC is reset (LED0 = 0, then the switches again) and led_diff_o counts the errors; one reset per error
fault_tmr 29 user*, supervisor (-DSAFETY_TMR), TMR, fault injection Requests of one SoC clock cycle (the trap keeps the error until a difference flag of the copy rises). Errors in CPU0 (voted out: no reset, LED0 stable, then LED0 follows new switches: the two correct copies drive the buses), CPU1 (second error: reset, led_diff_o = 1), CPU2 (voted out), CPU2 again (its flags already set: no edge, the trap stays pending, no reset), CPU1 (reset, 2; the pending error of CPU2 fires after the reset: voted out, no reset), CPU0 (second error after the reset: reset, 3, which proves the pending error of CPU2 was delivered), CPU1 (voted out: no trap left pending). No TAP in the TMR configurations: the pending trap is checked by its error after the reset, not by a 1 -> 0 of INJECT
fault_diff 4 user*, no supervisor, lock-step or TMR, fault injection Without supervisor led_diff_o shows the difference flags: an error in CPU0 sets them (lock-step 001, TMR 101) and they stay set
hwla 11 (HWLA_LINK = "uart"), 15 ("jtag") user*, no supervisor, fault injection, DEBUG_ENABLE (every safety) UART pads in mode 10 from the start (both links: the same stimulus times; TCK of 10 SoC clock cycles: the limit of the resynchronized TCK at 1.152 MHz). Switches 0x5A then 0x96 (LED0 follows), debug_uart_tx_o idle until the error; just after LED0 changes, a request of one SoC clock cycle on inject_error_i (the push button) for CPU1 (CPU0 with USER_SAFETY = "none"); the capture is received on debug_uart_tx_o with the UART VIP at 115200 baud, or with HWLA_LINK = "jtag" read through the TAP of jtag_axis (Test-Logic-Reset, instruction TX, one 9-bit DR scan per byte until its valid bit), and checked: the write of the new switches to LED0 is in the samples before the trigger; the trigger sample is the sample HWLA_PRE_TRIGGER, its timestamp the one of the write of LED0 plus the clock cycles from the change of LED0 to the request plus 4 (resynchronization 2, trap 1, input stage of the HWLA 1): the time of the injection; the field diff is 000 up to the trigger sample, then the flags of CPU1 appear after it and stay (lock-step 001, TMR 011; 3 to 60 cycles after the trigger in these runs) or stay 000 (none); the timestamps increase and the probes change from a sample to the next (but the trigger sample); the instruction of each sample follows the fetch strobe ics of the previous sample (a copy of ROM_user in the testbench); one capture per injection (no other byte during 2000 SoC clock cycles: TX FIFO of jtag_axis empty, or debug_uart_tx_o idle); with HWLA_LINK = "jtag" also the Capture-IR of the chain, the CONFIG of jtag_axis (TX enabled, RX disabled with its flags empty and full, 8-bit words) and debug_uart_tx_o idle all along. The samples of the capture are the same on both links (the HWLA sample <i> lines of the logs of sim_soc2_<cpu>_fault_c_user_hwla and _hwla_jtag are identical)
hwla_tap 13 ("uart"), 17 ("jtag") as hwla The same with the error injected by INJECT of the injection / status TAP (the instruction selected before the new switches, the DR scan just after the change of LED0, INJECT left at 1 until the Test-Logic-Reset): the trigger timestamp lies within the DR scan of INJECT (from its start to its end plus 6 cycles); the diff read during the scan is 000. With HWLA_LINK = "jtag" the chain has one more TAP (jtag_axis), so the injection comes one TCK later than with the UART link
pad_mux 26 (22 without DEBUG_ENABLE or fault injection, or with HWLA_LINK = "jtag") user_uart* Each code of debug_mux_sel_i (switches with the MSBs 00: they no longer select the pads): 00 banner and echo (CTS* held from the CR of the banner, the echo in the first loop line), RTS* driven, CTS* not driven by the SoC; 11 TX pad driven by the UART of jtag_bitbang (idle), RTS* and CTS* not driven, the firmware does not wait; 01 the loop lines of the firmware do not reach the TX pad, idle ('1'), CTS* and RTS* not driven, the firmware does not wait (LED0 follows the switches); 10 TDI, TMS and TDO pads not driven by the SoC out of a scan, the firmware does not wait; back to 00: a quiet line (CTS* held two characters), the end of the current line, then a complete Loop line; with DEBUG_ENABLE and fault injection, 01 again: an error in CPU0 triggers the HWLA, its capture is on the TX pad, bit by bit equal to debug_uart_tx_o during 3 bytes
jtag_chain 6 + 2 x TAPs (8 to 12) user*, at least one TAP JTAG mode, LED0 = switches (also with several clusters: user.c runs its mailbox test on hart 0 only); TDO not driven out of a scan; after Test-Logic-Reset one DR scan reads the IDCODE of every TAP in the chain order; every TAP in BYPASS: a DR scan is delayed by one bit per TAP; IDCODE of each TAP alone, the others in BYPASS; Capture-IR of the whole chain by the monitor
jtag_inject 9 (no supervisor), 11 (supervisor) user*, DEBUG_ENABLE, fault injection, no supervisor or lock-step An error injected in CPU1 through INJECT (written 010; the scan reads diff = 000 before); no supervisor: led_diff_o = flags of CPU1 (001 lock-step, 011 TMR), read back through INJECT, sticky (read again); supervisor: the user SoC is reset and led_diff_o counts, diff 001 read during the injection, after it the firmware runs again, no more reset, diff 000
jtag_inject_cpu 16 user*, DEBUG_ENABLE Injection inside the CPUs in the whole SoC: with fault injection the HWLA, armed before (flags of STATUS), is triggered by the bit 3 of the copy 0 alone (INJECT [7], then 0); then for each copy i, INJECT written with its 4 bits (4+4*i to 7+4*i), then 0: INJECT reads diff = 000 and 0 in [15:3]; [2:0] stayed 0: no difference flag, and the firmware still follows the switches (the reference CPUs do not use inject_i). The pulses themselves are checked on PicoSoC_tap by tb_PicoSoC_tap (GHDL 6.0.0 crashes at the elaboration of an external name to inject_cpu_i of cpu_safety)
jtag_status 8 (no supervisor), 10 (supervisor), 14 (supervisor, HWLA_LINK = "jtag") user*, DEBUG_ENABLE STATUS read after reset, after new switches (0x05) and an it_user_i pulse (LED1 = 1), and with fault injection after an error in CPU0, a request of one cycle trapped until the difference flag (the UART writes of the loop line stall the fetches of the CPU) (led_diff_o); compared with the pins, resets 11; the flags of the HWLA above them: armed (0011: arm, armed) after reset, triggered and sending (1101) after the error (read until they change, at most 100 scans: the HWLA moves on the SoC clock); with HWLA_LINK = "jtag" and a supervisor, the capture is then read through the TAP of jtag_axis until its TX FIFO is empty (the bytes of one capture, 704 with the default generics) and the HWLA is armed again (the reset of the user SoC cleared the difference flag). arm_i is tied to 1, so there is no state before arm to read; with the UART link the end of the capture (60 ms) is not waited for
jtag_cpu_user 27 (lock-step, with the injection TAP), 25 (TMR, without) user*, USER_CPU_DEBUG_ENABLE Debugger of the user CPU through the chain: dtmcs 0x00005071, dmactive, dmstatus running, havereset acknowledged; haltreq: allhalted; halted, LED0 does not follow the switches; resumereq: allresumeack, allrunning, LED0 follows again; led_diff_o stays 0 (lock-step: no reset counted by the supervisor; TMR: no difference flag): the copies of the CPU halt and resume together; ndmreset: the user SoC in reset (LED0 = 0, STATUS resets 10 with the injection TAP), then the firmware runs again
jtag_cpu_supervisor 26 user*, SUPERVISOR_CPU_DEBUG_ENABLE Debugger of the supervisor CPU: as above; halted, an error (inject_error_i) is not handled (led_diff_o = 0); resumed, the user SoC is reset and the error counted; ndmreset: the supervisor SoC in reset holds the user SoC in reset (STATUS resets 00), then both run again
bitbang_chain 3 + TAPs (4 to 6) user*, at least one TAP JTAG over the UART (debug_mux_sel_i 11, remote_bitbang bytes on uart_rx_i, answers on uart_tx_io): after Test-Logic-Reset one DR scan reads the IDCODE of every TAP in the chain order; every TAP in BYPASS: one bit per TAP; IDCODE of each TAP alone, the others in BYPASS
bitbang_inject 7 user*, DEBUG_ENABLE, fault injection, supervisor, lock-step JTAG over the UART: INJECT written 010 (diff read 000 before), the supervisor resets the user SoC; diff read while the injection lasts: 001; injection stopped (000): the firmware runs again, diff 000
bitbang_cpu 7 user*, USER_CPU_DEBUG_ENABLE JTAG over the UART, debugger of the user CPU: dtmcs 0x00005071; dmactive, haltreq: allhalted; halted, LED0 does not follow the switches; resumereq: allresumeack, allrunning, LED0 follows again
jtag_last 10 user*, USER_CPU_DEBUG_ENABLE The chain ends with stages without TAP (the configuration of the board: no supervisor, no DEBUG_ENABLE): JTAG pads, TDO not driven out of a scan, the IDCODEs of the chain with every TDO bit driven by the SoC (no 'H' of the pull-up), dmactive and dmstatus (allrunning) through the DMI; JTAG over the UART: the IDCODEs and dmstatus
jtag_glitch 4 user*, at least one TAP JTAG mode, LED0 = switches; after Test-Logic-Reset, one DR scan of the IDCODE of every TAP where both edges of TCK bounce on every shifted bit but the last (TCK back to its old level, then to the new one, each step a quarter of a SoC clock period): the IDCODEs are read in the chain order; then, without bounce, an IR scan (Capture-IR of the whole chain by the monitor) and a DR scan read the IDCODEs again: every TAP kept its state. A TAP clocked by the TCK pad sees two edges per bounce and fails it
trap_cpu0, trap_cpu1 12 user*, supervisor, lock-step, fault injection Twice: a request of one SoC clock cycle on inject_error_i (CPU0 or CPU1) is trapped until the compare flags it (diff(0) for both copies): the supervisor resets the user SoC once (LED0 = 0, then the switches again, led_diff_o + 1); the trap is then cleared: no other reset (LED0 and led_diff_o stable)
trap_reset 11 user*, supervisor, lock-step, fault injection, SUPERVISOR_CPU_DEBUG_ENABLE ndmreset of the supervisor debugger: the supervisor SoC in reset holds the user SoC in reset (LED0 = 0); a request of one cycle in CPU1 waits (no fetch, no flag); ndmreset released: the supervisor releases the user SoC, the trapped error is flagged, one reset (led_diff_o = 1), then no other: a reset of the user SoC does not clear a trap
trap_tap 14 user*, no safety, fault injection, DEBUG_ENABLE, USER_CPU_DEBUG_ENABLE Without compare: a request of one cycle in CPU0 is trapped, the firmware stops (LED0 does not follow the switches); ndmreset of the user CPU debugger (reset of the user SoC): the trap stays (LED0 = 0); INJECT written 001 then 000: the 1 -> 0 clears the trap, after a new ndmreset the firmware runs again; led_diff_o stays 0
hello 4 x USER_NB_CPU + 4 hello The first 4 x USER_NB_CPU UART lines are CPU <id> - Loop <counter> with a valid id and the counter 0, 1, 2, ... (mutual exclusion, shared counter in RAM2); every CPU takes the lock (LED1) and the counter progresses (LED0); led_diff_o stays 0 during the whole scenario: with lock-step or TMR, the copies of every cluster read the same mhartid (no difference flag, no error counted by the supervisor)
test_gpio 5 (+ 16 in the firmware) test_gpio LED0 = 0xA5 and LED1 = 0x5A on the pins, switches 0x3C (rising edges) copied into LED0, then 0x00 (falling edges); PASS; LED1 pins unchanged while the firmware reads LED1 as an input
test_uart 3 (+ 11) test_uart On each prompt >, a byte sent on uart_rx_i: 0x5A read by polling, 0xA5 read by the interrupt routine; PASS; LED0 = 0xA5, LED1 = one interrupt
test_spi 1 (+ 16) test_spi (SPI_MODEL = m25p40) PASS: the firmware checks the answers of the flash model
test_timer 9 (+ 10) test_timer LED0 counts the timer interrupts: 3 periods of 2000 SoC cycles (± 10); PASS; LED0 stays at 4 for 2 more periods (timer stopped)
test_crc 1 (+ 10) test_crc PASS: the firmware checks the CRC values
test_spinlock 1 (+ 9) test_spinlock PASS: the firmware checks the lock values
test_gic 5 (+ 9) test_gic One it_user_i pulse on each request of the firmware (LED0 = 1, 2, 3); PASS; LED1 = 2 interrupts (pulses 2 and 3)
test_ram 1 (+ 6) test_ram PASS: the firmware checks the RAM bytes and the unmapped addresses
test_i2c 25 (+ 14) test_i2c BFM slave at 0x50: write of A5 5A by the SoC, read back (ACK, then NACK of the last byte); write of the SoC to 0x51 (no slave): address byte sampled, SCL period 95 to 100 kHz; once LED0 = 1, BFM master: write of 3C C3 to the slave of the SoC at 0x3A, read back; end of the read acknowledged on the switches; PASS; SCL and SDA released
test_pwm 21 (+ 9) test_pwm Steps of the firmware on LED0, acknowledged on the switches: pwm_o low since the reset while disabled; period of 10 ticks of 4 SoC cycles and high phase of 3, then 7 ticks; pwm_o low once disabled, until PASS
test_mailbox 7 (+ 6) test_mailbox, USER_NB_CPU = 2 LED1 counts the 4 answers of the other cluster; PASS; LED0 = last answer 0xBB

tb_PicoSoC_modbus_rtu:

Name Checks Applies to Description
basic 58 every configuration LED0 written and read back (data and output enable), switches read (0x5A, 0x3C), a frame to another slave id is ignored (no answer, LED0 unchanged), broadcast write
fault_lock_step 23 supervisor, lock-step, fault injection Errors in CPU0 then CPU1: LED0 written by Modbus, then back to 0 after the reset of the user SoC; led_diff_o counts the resets
fault_tmr 64 supervisor, TMR, fault injection Errors CPU0 (voted out, LED0 kept and still writable), CPU1 (reset), CPU2 (voted out), CPU0 (reset), CPU1 (voted out), CPU2 (reset); led_diff_o counts the resets
sequence 128 every configuration Each switch alone, bits 0 to 7: read through Modbus, then written into LED0

Co-simulation with OpenOCD and GDB

The debug modes of the UART pads are also checked with the real debugger: OpenOCD 0.12 (adapter remote_bitbang) and GDB (gdb-multiarch) drive tb_PicoSoC_openocd through the OpenOCD co-simulation kit asylum:verification:openocd of asylum-verification-uvvm: its TCP server rbb_server.c, called by the testbench through VHPIDIRECT, its testbench entities rbb_jtag / rbb_axis and its hooks rbb/cosim.sh (build librbb.so; start OpenOCD with openocd/gdb.cfg or openocd/generic.cfg, then GDB with openocd/picosoc.py on the GDB port 3333, or OpenOCD alone with openocd/chain.cfg, openocd/discover_check.cfg or openocd/generic_check.cfg; at the end, print the logs and fail without the line SCENARIO PASS). The OpenOCD files of tools/openocd are the ones of the board (see OpenOCD and GDB on the board); the core copies them with the scenarios of sim/openocd into openocd/ of the work root:

File Role
tools/openocd/picosoc.cfg JTAG chain given by picosoc_chain (from TDO, -expected-id) or, without it, discovered (discover.tcl); a riscv target for each CPU TAP (GDB ports from 3333); picosoc_inject <errors>: INJECT of the injection / status TAP (errors injected, bit i in CPU i), returns the difference flags
tools/openocd/discover.tcl picosoc_discover: discovery of the chain, shared by picosoc.cfg and discover.cfg
tools/openocd/remote_bitbang.cfg Adapter remote_bitbang on 127.0.0.1:9824 (the port of the kit), adapter only
sim/openocd/gdb.cfg OpenOCD configuration of the GDB targets of soc2: picosoc_chain given (picosoc inject 0x10003001, user cpu0 0x10001001), then remote_bitbang.cfg and picosoc.cfg (the hook of the kit takes one file)
sim/openocd/generic.cfg OpenOCD configuration of the GDB target on a discovered chain: remote_bitbang.cfg, then picosoc.cfg without picosoc_chain (the board command)
sim/openocd/picosoc.py GDB scenario (the chain of the testbench read from PICOSOC_CHAIN), on the GDB helpers gdb_lib.py of asylum-processor-WardRV (>= 1.5.0: its default target copies it to openocd/ of the work root)
sim/openocd/chain.cfg OpenOCD script of the chain of 4 TAPs, no GDB: picosoc_chain of the 4 TAPs, then remote_bitbang.cfg and picosoc.cfg; checks with check / scenario_end of rbb/check.tcl of the kit (see below)
tools/openocd/discover.cfg Discovery of the chain, no TAP declared (see OpenOCD and GDB on the board)
sim/openocd/discover_check.cfg OpenOCD script of the discovery targets, no GDB: remote_bitbang.cfg, then discover.cfg with its printed lines captured (capture, its shutdown made a no-op while it runs), checked against PICOSOC_CHAIN (see below)
sim/openocd/generic_check.cfg OpenOCD script of the chain of 4 TAPs discovered, no GDB: generic.cfg, then the TAPs and targets checked against PICOSOC_CHAIN (see below)
sim/openocd/hwla_check.cfg OpenOCD script of the HWLA captures over JTAG, no GDB: generic.cfg, then picosoc_hwla_status, picosoc_inject, picosoc_hwla_dump checked (see below)
sim/openocd/hwla_vcd.sh Hook of sim_soc3_wardrv_fsm_fault_c_user_openocd_hwla: vcd (post_run) decodes hwla.bin with hwla/hwla2vcd.py (copied by asylum-debug-hwla) and hwla/hwla_wardrv_fsm.args (copied from tools/hwla) and checks the named signals of the VCD file
debug_mux_sel_i Target Kit Path of the JTAG commands
10 sim_soc2_wardrv_fsm_fault_c_user_openocd_jtag rbb_jtag (PIN mode: the commands of OpenOCD decoded in C, one pin change every 8 clk_i cycles) JTAG pins of the UART pads: TCK uart_rx_i, TDI uart_tx_io, TMS uart_rts_b_io, TDO uart_cts_b_io (pull-up out of the shifts); TCK = FSYS_INT / 8, the limit of JTAG timing
11 _sim_soc2_wardrv_fsm_fault_c_user_openocd_bitbang (by hand, not in the CI) rbb_axis (BYTE mode: the bytes of OpenOCD) JTAG over the UART: a UART bridge of the testbench (UART VIP, 921600 baud) sends the bytes of OpenOCD on uart_rx_i and returns the answers to 'R' received on uart_tx_io; jtag_bitbang of the SoC decodes them. An unknown TDO bit ('U' of a data read that no target answers, or of a stack word never written) is sent to OpenOCD as 1 by rbb_axis, with a warning, as with rbb_jtag; any other answer than '0' / '1' is an error
10 sim_soc3x2_wardrv_fsm_c_user_openocd_chain rbb_jtag (PIN mode) Same pins, the chain of 4 TAPs and chain.cfg (see below)
10 sim_soc3x2_wardrv_fsm_c_user_openocd_discover, sim_soc1_wardrv_fsm_c_user_openocd_discover rbb_jtag (PIN mode) Same pins, discover_check.cfg on the chain of 4 TAPs and on the chain of 1 TAP of emu_ng_medium_soc1_wardrv_fsm (see below)
10 sim_soc1_wardrv_fsm_c_user_openocd_generic, sim_soc3x2_wardrv_fsm_c_user_openocd_generic rbb_jtag (PIN mode) Same pins, picosoc.cfg without picosoc_chain: GDB scenario on the chain of 1 TAP, generic_check.cfg on the chain of 4 TAPs (see below)
10 sim_soc3_wardrv_fsm_fault_c_user_openocd_hwla rbb_jtag (PIN mode) Same pins, HWLA_LINK = "jtag", hwla_check.cfg (see below)
01 none none UART of the HWLA, no JTAG: nothing for OpenOCD (the captures are checked by the scenario hwla)

The two GDB targets of soc2 give their chain to picosoc.cfg (gdb.cfg) and use the configuration soc2 with the CPU debugger: WardRV_fsm, no supervisor, lock-step, fault injection, DEBUG_ENABLE and USER_CPU_DEBUG_ENABLE (a chain of 2 TAPs), firmware esw/demo/user.c without UART (LED0 = switches). Without the supervisor, an error injected through INJECT leaves the difference flag set (sticky) and the user SoC running on CPU0; with it, the supervisor would reset the user SoC, the hart under the debugger and the flag. The TAP of the supervisor CPU is the same WardRV_debug (checked by the scenario jtag_cpu_supervisor), and a second riscv target would double the work of OpenOCD (it is checked without GDB by the chain target below).

Step Checks
testbench Before OpenOCD: LED0 = switches 0x5A, led_diff_o = 000
step_chain For each TAP of PICOSOC_CHAIN, OpenOCD found its IDCODE: JTAG tap: picosoc.inject tap/device found: 0x10003001 and user.cpu0 0x10001001 with the chain given, the line TAP <k> : IDCODE <idcode> : <chip>.<tap> of a discovered chain; no unexpected IDCODE, the RISC-V core examined
step_halt GDB, limited to the RAM of the firmware (mem), connects (the user hart halts): pc in the user ROM, dcsr.cause = halt request, sp in the stack of the firmware
step_resume monitor resume: dmstatus allrunning and anyrunning
step_inject Only with the injection / status TAP in PICOSOC_CHAIN: picosoc_inject 0x2 (error in CPU1): diff 000 before; again after runtest 100 until CPU1 differs: 001; picosoc_inject 0x0 (end of the injection): 001, sticky
testbench After OpenOCD quits: led_diff_o = 001, LED0 follows the new switches 0xA5 (the firmware runs after the session)

Each GDB target prints 4 => OK (testbench) and 11 GDB ok lines. Run times (asylum-env image, build included): _openocd_jtag about 80 to 110 s (15 ms of simulated time), _openocd_bitbang 18 to 34 minutes (650 ms of simulated time; 921600 baud: 3 bytes of 10 bits per scanned bit, against 16 clk_i cycles with the pins). The mode 11 target is too long for the CI: its name starts with _, so it has no CI job and is not in make nonreg_sim; run it by hand with make _sim_soc2_wardrv_fsm_fault_c_user_openocd_bitbang. They need gcc, openocd and gdb-multiarch (in the asylum-env image) and the free TCP ports 9824, 3333 and 6666 (one co-simulation at a time per host; a container has its own network). A fault that leaves OpenOCD waiting for an answer of the simulation (BYTE mode) is ended by the timeouts of the kit (COSIM_TIMEOUT, 1800 s, of OpenOCD and of GDB) or of the testbench (10 s of simulated time).

JTAG chain of 4 TAPs (sim_soc3x2_wardrv_fsm_c_user_openocd_chain, no GDB): the configuration soc3x2 (WardRV_fsm, 2 user clusters, supervisor, lock-step in each cluster, no fault injection) with DEBUG_ENABLE, USER_CPU_DEBUG_ENABLE and SUPERVISOR_CPU_DEBUG_ENABLE, firmwares user.c and supervisor.c, debug_mux_sel_i 10. Without fault injection the supervisor never resets the user SoC during the session (an error injected through INJECT would). The chain, from TDI: user CPU of cluster 0 (0x10001001), of cluster 1 (0x10011001), supervisor CPU (0x10002001), injection / status TAP (0x10003001); chain.cfg declares it from TDO (picosoc.inject, supervisor.cpu, user.cpu1, user.cpu0, each with -expected-id) and a riscv target for each CPU, then OpenOCD runs:

Step Checks
testbench Before OpenOCD: LED0 = switches 0x5A, led_diff_o = 000
init The scan of the chain after Test-Logic-Reset, then the examination of the 3 riscv targets (Examined RISC-V core, GDB ports 3333 supervisor.cpu, 3334 user.cpu1, 3335 user.cpu0)
IDCODE of the scan of the chain For each TAP of scan_chain: the IDCODE read by init is its -expected-id (4 checks)
IDCODE instruction For each TAP, the others in BYPASS: irscan IDCODE, a 32-bit DR scan reads its -expected-id (4 checks)
riscv targets Each target examined, halted (halt, curstate halted), resumed (resume, running) (9 checks)
testbench After OpenOCD quits: led_diff_o = 000, LED0 follows the new switches 0xA5

It prints 4 => OK (testbench) and 17 OpenOCD OK : lines, then SCENARIO PASS; about 2 to 3 minutes (asylum-env image, build included; 21 ms of simulated time). OpenOCD 0.12 handles the 3 riscv targets of one chain: init examines them in turn and each one is halted and resumed through its own TAP, the others in BYPASS; as with picosoc_inject, the IR and DR scans of chain.cfg run with the poll of the targets off.

Discovery of the JTAG chain (sim_soc3x2_wardrv_fsm_c_user_openocd_discover, sim_soc1_wardrv_fsm_c_user_openocd_discover, no GDB): discover.cfg of the board on two chains, debug_mux_sel_i 10:

  • soc3x2, the chain of 4 TAPs above (same configuration as sim_soc3x2_wardrv_fsm_c_user_openocd_chain);
  • the chain of 1 TAP of emu_ng_medium_soc1_wardrv_fsm: WardRV_fsm, no supervisor, no safety, no fault injection, no DEBUG_ENABLE, USER_CPU_DEBUG_ENABLE.

The testbench writes the chain of its generics in cosim.cfg (PICOSOC_CHAIN: chip, TAP and IDCODE of each TAP from TDO, as discover.cfg prints it; the hooks of the kit export it to OpenOCD). discover_check.cfg runs discover.cfg with its printed lines captured, then checks them:

Step Checks
testbench Before OpenOCD: LED0 = switches 0x5A, led_diff_o = 000
discover.cfg jtag init with no TAP declared: the OpenOCD autoprobe finds each TAP (auto<k>.tap, IR length 5); the lines are printed
number of TAPs Line PicoSoC JTAG chain : <n> TAP(s): n is the number of TAPs of PICOSOC_CHAIN
IDCODEs Line TAP <k> : IDCODE <idcode> of each TAP: the IDCODE of the k-th TAP of PICOSOC_CHAIN
picosoc_chain The printed line set picosoc_chain {...} is PICOSOC_CHAIN (names included)
testbench After OpenOCD quits: led_diff_o = 000, LED0 follows the new switches 0xA5

The 4-TAP target prints 4 => OK (testbench) and 6 OpenOCD OK : lines, the 1-TAP target 4 and 3, then SCENARIO PASS; about 90 to 120 s each (asylum-env image, build included; OpenOCD quits at 0.71 ms and 0.63 ms of simulated time). Lines of the 4-TAP target:

Info : JTAG tap: auto0.tap tap/device found: 0x10003001 (mfg: 0x000 (<invalid>), part: 0x0003, ver: 0x1)
Info : JTAG tap: auto1.tap tap/device found: 0x10002001 (mfg: 0x000 (<invalid>), part: 0x0002, ver: 0x1)
Info : JTAG tap: auto2.tap tap/device found: 0x10011001 (mfg: 0x000 (<invalid>), part: 0x0011, ver: 0x1)
Info : JTAG tap: auto3.tap tap/device found: 0x10001001 (mfg: 0x000 (<invalid>), part: 0x0001, ver: 0x1)
PicoSoC JTAG chain : 4 TAP(s), from TDO
TAP 0 : IDCODE 0x10003001 : picosoc.inject
TAP 1 : IDCODE 0x10002001 : supervisor.cpu
TAP 2 : IDCODE 0x10011001 : user.cpu1
TAP 3 : IDCODE 0x10001001 : user.cpu0
set picosoc_chain {picosoc inject 0x10003001 supervisor cpu 0x10002001 user cpu1 0x10011001 user cpu0 0x10001001}

The printed picosoc_chain of the 4-TAP target is the list of chain.cfg.

picosoc.cfg on a discovered chain (sim_soc1_wardrv_fsm_c_user_openocd_generic with GDB, sim_soc3x2_wardrv_fsm_c_user_openocd_generic without GDB): picosoc.cfg without picosoc_chain, as on the board, on the two chains of the discovery targets, debug_mux_sel_i 10. jtag init of picosoc_discover probes the chain in the configuration stage, the targets are created on the TAPs of the autoprobe, then init scans the chain again and examines them.

  • Chain of 1 TAP (soc1, the chain of emu_ng_medium_soc1_wardrv_fsm): generic.cfg, then the GDB scenario picosoc.py on the target user.cpu0 (port 3333): step_chain (the printed line TAP 0 : IDCODE 0x10001001 : user.cpu0), step_halt, step_resume; no step_inject (no injection / status TAP). It prints 4 => OK (testbench) and 7 GDB ok lines, then SCENARIO PASS; about 2 minutes (12 ms of simulated time).
  • Chain of 4 TAPs (soc3x2): generic_check.cfg runs generic.cfg, then checks against PICOSOC_CHAIN:
Step Checks
testbench Before OpenOCD: LED0 = switches 0x5A, led_diff_o = 000
TAPs Number of TAPs of jtag names, then the IDCODE of each TAP (jtag cget <tap> -idcode), from TDO (5 checks)
riscv targets Number of targets, then each target named <chip>.<tap> of its CPU TAP and on that TAP (-chain-position), in the order of the chain (4 checks)
halt / resume Each target examined, halted (halt, curstate halted), resumed (resume, running) (9 checks)
picosoc_inject With the injection / status TAP in PICOSOC_CHAIN: picosoc_inject 0 on the TAP found by the discovery reads 000 (1 check)
testbench After OpenOCD quits: led_diff_o = 000, LED0 follows the new switches 0xA5

It prints 4 => OK (testbench) and 19 OpenOCD OK : lines, then SCENARIO PASS; about 2 to 3.5 minutes (asylum-env image, build included; 27 ms of simulated time). Lines of the 4-TAP target:

PicoSoC JTAG chain : 4 TAP(s), from TDO
TAP 0 : IDCODE 0x10003001 : picosoc.inject
TAP 1 : IDCODE 0x10002001 : supervisor.cpu
TAP 2 : IDCODE 0x10011001 : user.cpu1
TAP 3 : IDCODE 0x10001001 : user.cpu0
Info : starting gdb server for supervisor.cpu on 3333
Info : starting gdb server for user.cpu1 on 3334
Info : starting gdb server for user.cpu0 on 3335

HWLA captures over JTAG (sim_soc3_wardrv_fsm_fault_c_user_openocd_hwla, no GDB): WardRV_fsm, supervisor, lock-step, fault injection, DEBUG_ENABLE with HWLA_LINK = "jtag" (default HWLA_* generics) and the user CPU debugger, firmwares user.c and supervisor.c, debug_mux_sel_i 10: the chain from TDO is the injection / status TAP, the TAP of the HWLA, the user CPU (3 TAPs). The testbench writes PICOSOC_CHAIN and PICOSOC_HWLA_BYTES (704: 64 samples of 11 bytes) in cosim.cfg. picosoc.cfg sources openocd/jtag_axis.tcl next to it (both copied from tools/openocd by the fileset); hwla/hwla2vcd.py (asylum-debug-hwla >= 3.1.0) and hwla/hwla_wardrv_fsm.args are in the work root.

Step Checks
testbench Before OpenOCD: LED0 = switches 0x5A, led_diff_o = 000
discovery picosoc_chain (the chain discovered by picosoc.cfg) is PICOSOC_CHAIN: the TAP of IDCODE 0x10004001 named picosoc hwla; the IDCODE of picosoc_hwla_tap (2 checks)
before the error picosoc_hwla_status: hwla_armed, TX enabled, RX disabled, 8-bit words, nothing to read (1 check)
error picosoc_inject 0x2 reads no difference flag, then picosoc_inject 0x0 (1 check). While INJECT holds the request the trap of CPU1 is set again after each reset of the user SoC: the supervisor resets it a few times (led_diff_o 4 in this run); the first injection (the trap of CPU1) triggers the HWLA
after the error picosoc_hwla_status (read until it changes, runtest 100 between two reads): hwla_triggered, hwla_sending, TX not empty and full, a capture is waiting (1 check)
dump picosoc_hwla_dump hwla.bin 1 768: 768 bytes read, the file has 768 bytes (2 checks)
after the dump picosoc_hwla_status: hwla_armed again (INJECT back to 0 before the dump: no new injection, no new trigger), nothing to read (1 check)
testbench After OpenOCD quits: led_diff_o not 000 (the resets counted by the supervisor), LED0 follows the new switches 0xA5
hook hwla_vcd hwla/hwla2vcd.py hwla.bin --args-file hwla/hwla_wardrv_fsm.args: one complete capture (64 samples, 103 clock cycles, trigger at the clock cycle 54), the VCD file has trigger and the named signals dcs, daddr, drdata, ics, iaddr, idata, diff

It prints 4 => OK (testbench) and 8 OpenOCD OK : lines, then SCENARIO PASS; about 4 minutes (build included, 13.5 ms of simulated time). The bytes of this capture are not compared with a UART capture: the time of the error comes from OpenOCD; the same bytes on both links are checked by the scenario hwla of tb_PicoSoC (sim_soc2_<cpu>_fault_c_user_hwla and _hwla_jtag).

921600 baud is 13 SoC clock cycles per bit: at 1562500 baud (8 cycles per bit) the receiver of uart_core samples the start bit too late (its synchronizer, its state machine and the half-bit tick of uart_baud_rate_gen add about 6 cycles) and loses the frames. OpenOCD 0.12 behaviours found by the co-simulation: OpenOCD lists the TAPs from TDO (the injection / status TAP first); the riscv target polls the hart before each OpenOCD command and its scans select its own IR (DMI) again, so a DR scan of another TAP after its irscan in a separate command stops OpenOCD (Assertion 'active == tap' failed): picosoc_inject turns the poll off around its IR and DR scans.

Targets

A target is a firmware build: its generators compile the user and supervisor programs into the ROMs, so the program is fixed when the target is built. Each target runs the scenarios that apply to its program and configuration. The reference configurations, sim_soc4_openblaze8_fault_c_user (supervisor, TMR, fault injection), its Modbus counterpart and the JTAG one sim_soc3_wardrv_fsm_fault_c_user_uart_jtag (supervisor, lock-step, the 3 TAPs) with its HWLA_LINK = "jtag" variant sim_soc3_wardrv_fsm_fault_c_user_uart_hwla_jtag (4 TAPs), have a build-only base target and one target per scenario (one CI job per scenario, a failure isolated).

Target Toplevel Description
sim_soc4_openblaze8_fault_c_user tb_PicoSoC Reference configuration of tb_PicoSoC: build and elaboration only (TESTS_LIST empty)
sim_soc4_openblaze8_fault_c_user_<name> tb_PicoSoC One target per scenario: _switch, _it_user, _fault_tmr
sim_soc4_openblaze8_fault_c_user_modbus_rtu tb_PicoSoC_modbus_rtu Reference configuration of the Modbus testbench: build only
sim_soc4_openblaze8_fault_c_user_modbus_rtu_<name> tb_PicoSoC_modbus_rtu One target per scenario: _basic, _fault_tmr, _sequence
sim_soc1_openblaze8_asm_identity, sim_soc1_<cpu>_c_identity tb_PicoSoC user_identity (assembler, C): switch; sim_soc1_openblaze8_c_identity with FSYS_INT = FSYS (clock divider ratio 1)
sim_soc1_wardrv_fsm_c_user_loop tb_PicoSoC user_loop.c with UART at 921600 baud: sequence, switch
sim_soc1_wardrv_fsm_fault_c_user_loop_inject_cpu_pc, _regfile_single, _regfile_double tb_PicoSoC user_loop.c at 921600 baud, WardRV_fsm, supervisor, USER_SAFETY = "none", fault injection, DEBUG_ENABLE: inject_cpu with TB_INJECT_CPU = 1 (inject_i(0) of the CPU copy 0: e.g. one copy of the PC, labo04), 8 (inject_i(3): e.g. one bit of the next word written in the register file, a single error corrected by the ECC, labo05) and 12 (inject_i(3) and inject_i(2) in the same cycle: e.g. two bits of that word, a double error detected by the ECC: a hardened CPU fails, reset of the user SoC)
sim_soc1_openblaze8_c_user, sim_soc2_<cpu>_c_user, sim_soc3_<cpu>_c_user tb_PicoSoC user.c without UART: switch, it_user
sim_soc2_openblaze8_fault_c_user tb_PicoSoC switch, it_user, fault_diff
sim_soc2_openblaze8_fault_c_user_uart_jtag tb_PicoSoC pad_mux, jtag_chain, jtag_inject, jtag_status, bitbang_chain: no supervisor, lock-step, fault injection, DEBUG_ENABLE (chain: the injection / status TAP only), JTAG over the UART at the default 115200 baud
sim_soc3_wardrv_fsm_fault_c_user_uart_jtag tb_PicoSoC Reference configuration of the JTAG scenarios: supervisor, lock-step, fault injection, DEBUG_ENABLE, both CPU debuggers (chain of 3 TAPs), it_user_i and inject_error_i active low, JTAG over the UART at 921600 baud; build only
sim_soc3_wardrv_fsm_fault_c_user_uart_jtag_<name> tb_PicoSoC One target per scenario: _pad_mux, _jtag_chain, _jtag_inject, _jtag_inject_cpu, _jtag_status, _jtag_cpu_user, _jtag_cpu_supervisor, _bitbang_chain, _bitbang_inject, _bitbang_cpu, _jtag_glitch, _trap_cpu0, _trap_cpu1, _trap_reset
sim_tap, sim_tap_inject, sim_tap_inject_cpu tb_PicoSoC_tap The injection / status TAP alone: build check, then one target per scenario
sim_soc1_wardrv_fsm_c_user_jtag_last tb_PicoSoC jtag_last, jtag_chain, bitbang_chain: the JTAG configuration of emu_ng_medium_soc1_wardrv_fsm (user CPU debugger only, no supervisor, no safety, no DEBUG_ENABLE: the last stages of the chain are wires), board polarities, JTAG over the UART at 921600 baud
sim_soc5_wardrv_fsm_c_user_uart_jtag tb_PicoSoC pad_mux, jtag_chain, jtag_cpu_user: no supervisor, TMR, user CPU debugger only, no DEBUG_ENABLE (01 idle, chain of 1 TAP)
sim_soc1x2_wardrv_fsm_c_user_jtag tb_PicoSoC jtag_chain: 2 user CPU clusters, each with its debug unit, and the injection / status TAP (chain of 3 TAPs)
sim_soc3_wardrv_fsm_fault_c_user_uart_hwla_jtag tb_PicoSoC The JTAG reference configuration with HWLA_LINK = "jtag": the TAP of the HWLA in the chain (4 TAPs, from TDI user CPU, supervisor CPU, HWLA, injection / status); build only
sim_soc3_wardrv_fsm_fault_c_user_uart_hwla_jtag_<name> tb_PicoSoC One target per scenario of the chain: _jtag_chain, _jtag_inject, _jtag_status (the capture read through jtag_axis), _bitbang_chain
sim_soc1_wardrv_fsm_fault_c_user_jtag_trap_tap tb_PicoSoC trap_tap: no supervisor, no safety (no difference flag), fault injection, DEBUG_ENABLE and the user CPU debugger (chain of 2 TAPs)
sim_soc2_wardrv_fsm_fault_c_user_openocd_jtag, _sim_soc2_wardrv_fsm_fault_c_user_openocd_bitbang tb_PicoSoC_openocd OpenOCD + GDB co-simulation through the JTAG pins (debug_mux_sel_i 10) and JTAG over the UART (11, 921600 baud): no supervisor, lock-step, fault injection, DEBUG_ENABLE, user CPU debugger (see Co-simulation with OpenOCD and GDB). The mode 11 one runs 18 to 34 minutes: the leading _ keeps it out of the CI and of nonreg_sim, run it by hand (make _sim_soc2_wardrv_fsm_fault_c_user_openocd_bitbang)
sim_soc3x2_wardrv_fsm_c_user_openocd_chain tb_PicoSoC_openocd OpenOCD co-simulation (no GDB) of the JTAG chain of 4 TAPs: 2 user clusters with their debuggers, supervisor CPU debugger, injection / status TAP; supervisor, lock-step, no fault injection; script chain.cfg: IDCODE of every TAP, the 3 riscv targets examined, halted and resumed
sim_soc3_wardrv_fsm_fault_c_user_openocd_hwla tb_PicoSoC_openocd OpenOCD co-simulation (no GDB) of the HWLA captures over JTAG: supervisor, lock-step, fault injection, DEBUG_ENABLE, HWLA_LINK = "jtag", user CPU debugger (chain of 3 TAPs); script hwla_check.cfg (see Co-simulation with OpenOCD and GDB), the capture decoded by hwla2vcd.py
sim_soc3x2_wardrv_fsm_c_user_openocd_discover, sim_soc1_wardrv_fsm_c_user_openocd_discover tb_PicoSoC_openocd OpenOCD co-simulation (no GDB) of the discovery of the chain, discover.cfg checked by discover_check.cfg: the chain of 4 TAPs of soc3x2 above, and the chain of 1 TAP of emu_ng_medium_soc1_wardrv_fsm (user CPU debugger only, no supervisor, no safety, no DEBUG_ENABLE)
sim_soc1_wardrv_fsm_c_user_openocd_generic, sim_soc3x2_wardrv_fsm_c_user_openocd_generic tb_PicoSoC_openocd OpenOCD co-simulation of picosoc.cfg without picosoc_chain (chain discovered): GDB scenario picosoc.py on the chain of 1 TAP; generic_check.cfg (TAPs, targets named and examined, halt / resume, picosoc_inject) on the chain of 4 TAPs
sim_soc2_<cpu>_fault_c_user_hwla, _hwla_tap tb_PicoSoC hwla, hwla_tap (lock-step, no supervisor), with DEBUG_ENABLE = true, HWLA_DEPTH = 512, HWLA_PRE_TRIGGER = 384 (the write of LED0 before the INJECT scan of 16 bits stays in the capture: about 125 samples before the trigger with WardRV_fsm; the difference flags after the trigger too) and a SoC clock of 1.152 MHz (FSYS_INT): 10 clock cycles per bit at 115200 baud; WardRV_fsm with HWLA_TIMESTAMP_WIDTH = 24
sim_soc2_<cpu>_fault_c_user_hwla_jtag, _hwla_jtag_tap tb_PicoSoC The same with HWLA_LINK = "jtag": the capture read through the TAP of jtag_axis (TCK of 10 SoC clock cycles); with the push button, the samples are the same as with the UART
sim_soc1_wardrv_fsm_fault_c_user_hwla, _hwla_tap, sim_soc5_wardrv_fsm_fault_c_user_hwla, _hwla_tap tb_PicoSoC hwla, hwla_tap with USER_SAFETY = "none" (soc1 with fault injection and DEBUG_ENABLE: the field diff stays 000) and "tmr" (soc5: 011), UART link, the generics of sim_soc2_wardrv_fsm_fault_c_user_hwla
sim_soc3_<cpu>_fault_c_user tb_PicoSoC switch, it_user, fault_lock_step
sim_soc4_wardrv_fsm_fault_c_user tb_PicoSoC switch, it_user, fault_tmr, with it_user_i and inject_error_i active low (as on the board)
sim_soc1_<cpu>_c_user_uart, _uart_spi, _uart_spi_mem, sim_soc2_<cpu>_c_user_uart, sim_soc4_<cpu>_c_user_uart tb_PicoSoC user.c with UART at 921600 baud (+ SPI loopback, + SPI flash model m25p40): switch, it_user, uart; sim_soc1_wardrv_fsm_c_user_uart with arst_i active high
sim_soc1x2_wardrv_fsm_c_hello_uart, sim_soc1x4_..., sim_soc1x6_... tb_PicoSoC user_hello.c on 2, 4, 6 clusters: hello
sim_soc3x2_wardrv_fsm_c_hello_uart, sim_soc4x2_wardrv_fsm_c_hello_uart tb_PicoSoC user_hello.c on 2 clusters with supervisor and lock-step / TMR in each cluster, no fault: hello
sim_soc1_<cpu>_c_test_<ip>, sim_soc1x2_<cpu>_c_test_mailbox tb_PicoSoC Integration firmware esw/test/test_<ip>.c: scenario test_<ip>, for <ip> in gpio, uart, spi, timer, crc, spinlock, gic, i2c, pwm (both CPUs), ram (WardRV only), mailbox (2 clusters)
sim_soc{1,2,3}_<cpu>_c_user_modbus_rtu, sim_soc3_<cpu>_fault_c_user_modbus_rtu, sim_soc4_wardrv_fsm_fault_c_user_modbus_rtu tb_PicoSoC_modbus_rtu basic, sequence (+ fault_lock_step / fault_tmr); the TMR one with the board polarities
lint_ghdl asylum.PicoSoC_top GHDL -Wall analysis and elaboration, default generics
lint_ghdl_synth_<config> asylum.PicoSoC_top ghdl --synth check (no latch) of 8 configurations: default, soc1, soc4_ng_medium, 4leds_reset_high, wardrv_soc1, wardrv_soc4_ng_medium, wardrv_soc4_ng_medium_debug, wardrv_soc1x4; default and 4leds_reset_high with the HWLA and the injection / status TAP (DEBUG_ENABLE = true), wardrv_soc4_ng_medium_debug with them and both CPU debuggers, the others without
syn_<config> asylum.PicoSoC_top Yosys synthesis (see Resources): syn_soc1, syn_soc4_ng_medium, syn_wardrv_soc1, syn_wardrv_soc4_ng_medium, syn_wardrv_soc4_ng_medium_debug
emu_ng_medium_* PicoSoC_top NG-MEDIUM board (NXmap, not in the CI): user.c (OpenBlaze8), user_loop.c (WardRV_fsm, but the SPI flash builds) and user_modbus_rtu.c builds of soc1 to soc4 for each CPU (user_loop.c at 9600 baud: emu_ng_medium_soc1_wardrv_fsm_user_loop ...), HWLA_DEPTH = 1024 and HWLA_PRE_TRIGGER = 16 with the other NG-MEDIUM generics; emu_ng_medium_soc1_wardrv_fsm with the debugger of the user CPU; emu_ng_medium_soc3_wardrv_fsm_fault_debug with DEBUG_ENABLE (HWLA, injection / status TAP) and both CPU debuggers; emu_ng_medium_soc3_wardrv_fsm_fault_debug_hwla_jtag the same with HWLA_LINK = "jtag" (checked with ghdl --synth only: NXmap not available)

<cpu> is openblaze8 (generators gen_picoblaze3_*) or wardrv_fsm (gen_rv32i_*). Every sim_*, lint_* and syn_* target is a job of the GitHub CI, run in the asylum-env image. The sim, lint and syn badges count the passed and failed targets of the last run on main.

The testbenches were validated with 33 RTL mutants of the SoC glue (address decoding, interrupt routing, lock-step compare, TMR vote, supervisor, reset and clock, multi-core), each scenario run alone: 31 are killed. The 2 survivors are a lock-step compare without the data bus and difference flags that are not sticky: the fault injection flips an instruction bit, which also changes the instruction stream and leaves the two CPUs different, so neither the data bus compare nor the stickiness can be seen with it.

The integration scenarios were validated with 45 integration mutants, each one run on the targets of its peripheral (both CPUs, 86 runs): wrong base addresses and GIC masks in addrmap_user.h (13), wrong bits in the drivers of esw/include (8), interrupt lines swapped or tied low, pins disconnected, address decoding, CRC polynomial, timer and clock divider in a copy of the RTL (20), and wrong stimuli in the testbench (4): all are killed, most of them by the FAIL <step> line of the firmware. The I2C and PWM scenarios were validated the same way with 40 more mutants (both CPUs, 80 runs): base addresses in addrmap_user.h and in the RTL, ICN2 address width, SCL / SDA pad input not connected, output enable inverted or off, SCL and SDA swapped, prescaler reset value, slave disabled, static prescaler of the PWM, pwm_o not driven or inverted (RTL copies), wrong bits or registers in i2c.h and pwm.h, wrong constants in the firmwares and in the testbench: 38 are killed. The 2 survivors are equivalent in these firmwares: i2c_wait polling bus_busy instead of busy (both fall at the STOP of a single master), and the slave waiting for slave_addressed instead of slave_read before writing the bytes of the read (with FIFOs of depth 0, the write of data waits until the remote master reads).

The scenario hwla was validated with 21 mutants in copies of the RTL, both CPUs (42 runs): trigger tied low or high, arm_i tied low, probe bits swapped (data address, instruction address, instruction bits 0 / 1 and 4 / 5, read / write strobes, write / read data, read data taken from the write data), baud tick of FSYS_INT/115200 (no - 1), of FSYS/115200 - 1 and of 9600 baud, parity enabled, CTS high, debug_uart_tx_o driven by a copy of uart_tx_o or by '1', PRE_TRIGGER 31, DEPTH 128, CHANGE_ONLY false, TIMESTAMP_WIDTH 8: all are killed. Only the swap of the instruction bits 0 and 1 survives with WardRV_fsm, where both bits are always 1 (RV32I): it is killed with OpenBlaze8.

The trigger on the error injection and the field diff were validated with 2 mutants in copies of the RTL: the trigger still on the difference flags (the OR of diff) is killed by sim_soc1_wardrv_fsm_fault_c_user_hwla and _hwla_tap (USER_SAFETY = "none": no difference, no capture); diff not captured ("000" in the probes) is killed by sim_soc2_wardrv_fsm_fault_c_user_hwla and sim_soc5_wardrv_fsm_fault_c_user_hwla (the field diff stays 000 after the trigger).

The injection inside the CPUs (4 bits per copy) was validated with 4 mutants: a level instead of a pulse (inject_cpu_o = the synchronized INJECT bits), the copies swapped (copy i from the bits of copy 2-i) and the bit 3 of each copy taken from its bit 0 are killed by sim_tap_inject_cpu (sim_tap_inject passes: [2:0] does not change); the bit 3 left out of the trigger of the HWLA is killed by sim_soc3_wardrv_fsm_fault_c_user_uart_jtag_jtag_inject_cpu (the HWLA stays armed). The scenario inject_cpu writing 0 in place of the mask is killed by both sim_soc1_wardrv_fsm_fault_c_user_loop_inject_cpu_* targets (the HWLA stays armed).

The UART pads and the JTAG scenarios were validated with 30 mutants in copies of the RTL, each scenario run alone on the 3 JTAG configurations (and fault_diff for the buttons), 420 runs: pad select decode (10, 01, wrong switch bit), TDO of the chain from another TAP, a CPU TAP missing from the chain, injection without the buttons, without the TDR, ORed before the polarity or inverted, INJECT / STATUS decoded the other way round, diff not read, STATUS fields swapped, output enables stuck or wrong in one mode (RTS* / TMS stuck at 1 or 0, CTS* / TDO driven in a UART mode, TX / TDI driven in the JTAG mode, TDO always driven), CTS* default inactive, debug requests not reaching CPU1 (lock-step) or CPU2 (TMR), debug memory answers of CPU1 not delayed, ndmreset not connected, no synchronizer input: 27 are killed. The 3 survivors are not observable with the fault model of the SoC or the firmware: RX default 0 (the break received by the user UART out of its modes only feeds the echo, which goes to the unselected TX pad), no compare and no vote of the debug memory accesses of the copies (inject_error_i flips the instructions of the program ROM, the debug code comes from the Debug Module: a fault never reaches these accesses).

The debug units in cpu_wrapper were validated with 10 more mutants (each scenario alone on the JTAG configurations, 100 runs): a copy of the CPU without the JTAG pins (CPU1 lock-step or TMR, CPU2 TMR), the JTAG pins of CPU1 not delayed, the OpenBlaze8 wire broken (TDO = 0) and the supervisor SoC before the user SoC in the chain are killed. Equivalent with the fault model of the SoC (the copies stay identical, inject_error_i never reaches the debug units): TDO and ndmreset not compared (lock-step) or not voted (TMR). TCK not resynchronized (then in cpu_safety, now in PicoSoC_top) passes these scenarios: the race it avoids (a TCK edge seen one SoC clock earlier by CPU0 than through the lock-step delay line) needs an edge at the same time as a clock edge, a metastable case of the board; it is killed by jtag_glitch (below).

The resynchronization of TCK in front of every TAP was validated with 4 mutants in copies of the RTL, each run on sim_soc3_wardrv_fsm_fault_c_user_uart_jtag_jtag_glitch (chain of 3 TAPs, as emu_ng_medium_soc3_wardrv_fsm_fault_debug): the TCK pad as the clock of the injection / status TAP (PicoSoC_tap), of the supervisor CPU debug unit (PicoSoC_supervisor), of both (the RTL before the resynchronization), or of the user CPU debug unit (cpu_safety): all are killed: the IDCODEs read with the bounces are wrong for the TAP clocked by the pad and for every TAP between it and TDI (its extra shifts move their bits). Since 4.7.2 one synchronizer in PicoSoC_top serves every TAP; the mutant without it (every TAP clocked by the TCK pad) is killed by the same target: the IDCODEs read with the bounces are 000000000000000002200210 instead of 100010011000200110003001.

The trap of the error injection (PicoSoC_inject) was validated with mutants in copies of the RTL, each run on the trap_* targets and the TMR fault targets (fault_tmr of both CPUs, the Modbus fault_tmr): no trap (the request goes straight to the CPUs) is killed by the 4 trap_* scenarios (a request of one cycle is lost) and the TMR targets; the trap of CPU1 cleared by diff(1) only by trap_cpu1 and trap_reset (the lock-step trap of CPU1 never clears: one reset after another) and fault_tmr; no clear by the 1 -> 0 of INJECT by trap_tap; a trap reset by the reset of the user SoC (first version of the trap) by trap_reset and trap_tap. The clear on the level of the flags instead of their rising edge is killed by the Modbus fault_tmr (after a first error voted out, the flags of the faulty copy stay set and also involve the other copies: the second error is never injected) and by fault_tmr.

JTAG over the UART, the TMR vote of vote and the ics probe were validated with mutants in copies of the RTL (before the removal of SRST and of bitbang_srst), each target run alone on the JTAG configurations, the TMR fault targets and the hwla targets: code 11 decoded as 10 or as 00, TDI and TMS swapped at the input of the chain, the chain fed by the pads in mode 11, the TX pad not driven in mode 11, the RX of the UART inverted, its baud divider without - 1 (killed at 921600 baud, not at 115200 where the error is 1 %), the TDO of jtag_bitbang taken before the last stage and jtag_bitbang on the reset of the user SoC are killed by the bitbang_* scenarios (and pad_mux, jtag_last); the OR of the TDO enables dropped at a wire stage only by jtag_last; a copy missing from the TMR vote (vote(cpu0, cpu1, cpu1)) by fault_tmr of both CPUs (a voted-out error kept active during its checks); ics stuck at 1 or missing from the probes by hwla.

The HWLA link over JTAG and the flags of the HWLA in STATUS (4.8.0) were validated with 7 mutants in copies of the RTL, each scenario run alone on sim_soc2_wardrv_fsm_fault_c_user_hwla_jtag, the sim_soc3_wardrv_fsm_fault_c_user_uart_hwla_jtag_* targets jtag_chain, jtag_inject, jtag_status and sim_soc3_wardrv_fsm_fault_c_user_uart_jtag_jtag_status (UART link): all are killed. No back-pressure (tready of the HWLA tied to 1 with jtag_axis: the bytes beyond the FIFO lost) by hwla (the write of LED0 not in the capture) and jtag_status (not sending after the error); the TAP of the HWLA not in the chain by the Capture-IR monitor in hwla, jtag_inject, jtag_status; the IDCODE of the injection / status TAP given to jtag_axis by jtag_chain; debug_uart_tx_o driven by the HWLA with the JTAG link by hwla (idle check); the flags armed / triggered swapped, sending taken from tready instead of tvalid, and constant flags in STATUS by jtag_status (both links).

The refactoring of 4.3.0 (records of cpu_safety, active_high, PicoSoC_clkrst) was validated with 14 mutants in copies of the RTL, each scenario run alone on 34 (target, scenario) pairs of the lock-step, TMR, JTAG, hwla and polarity configurations (510 runs, the unmutated copy passes them all): a pair of copies not compared (0-1: 17 runs, 1-2: fault_tmr of both CPUs), a copy missing from the vote (fault_tmr), the lock-step delay of the inputs of CPU1 or of the compared outputs of CPU0 off by one (20 runs each), the fault polarity low ignored (11), it_user_i always active high (it_user, jtag_status, pad_mux with the board polarities), the reset polarity inverted (all) are killed; of the fields of the record "/=", iaddr left out is killed (fault_tmr of WardRV_fsm), ics, it_ack, sbi_ini, jtag_tgt or ndmreset left out survives: with the fault model of the SoC (an instruction bit flipped), a copy that differs differs on several outputs, as the survivors of the data bus compare above. debug_mux_sel_i was checked with 2 more mutants on the 44 simulation targets of the UART pads, JTAG and Modbus: its two bits swapped in PicoSoC_pads (killed by 10 targets: pad_mux, jtag_*, jtag_last) and the switch MSBs still selecting the pads (killed by 34: uart, pad_mux, jtag_*, Modbus, whose switch values have MSBs other than the code of debug_mux_sel_i).

uart_core (4.4.0, the UART of PicoSoC_hwla and of PicoSoC_jtag_over_uart) was checked with 3 mutants in copies of the RTL, each run on the 16 simulation targets of the HWLA and of the JTAG configurations (48 runs; every => OK count of the 95 targets is unchanged by the move to uart_core): the uart_core of the HWLA without transmitter (TX_ENABLE = false: nothing on debug_uart_tx_o) is killed by hwla (both CPUs) and pad_mux (4 targets); the uart_core of JTAG over the UART without receiver (RX_ENABLE = false) or without transmitter is killed by bitbang_chain, bitbang_cpu, bitbang_inject and jtag_last (5 targets each: no answer to 'R').

The OpenOCD + GDB co-simulations were validated with 4 mutants in copies of the RTL, each run on both co-simulation targets (8 runs): the TDO of the chain on the TMS pad instead of CTS* (PicoSoC_pads) and the TCK and TMS pads swapped (mode 10) are killed by _openocd_jtag (OpenOCD: JTAG scan chain interrogation failed: all ones, no IDCODE, GDB cannot connect); INJECT decoded from another IR code (PicoSoC_tap) is killed by both targets (picosoc_inject reads 000, led_diff_o stays 000); TCK and TMS of jtag_bitbang swapped at the input of the chain (mode 11) is killed by _openocd_bitbang. A mutant of one mode passes the target of the other mode (path not used). A failed check of the testbench stops the simulation before the hook that prints openocd.log and gdb.log: they stay in the build directory of the target.

The co-simulation of the chain of 4 TAPs was validated with 3 mutants, each killed by sim_soc3x2_wardrv_fsm_c_user_openocd_chain (SCENARIO FAIL or no SCENARIO PASS): a wrong -expected-id in chain.cfg (user.cpu1 0x10021001: the IDCODE of the scan of the chain and of the IDCODE instruction differ), two TAPs swapped in chain.cfg (user.cpu0 before user.cpu1: 4 IDCODE checks fail) and the supervisor stage of the chain made a wire in a copy of the RTL (PicoSoC_top: 3 TAPs left, 3 IDCODEs of the scan fail, IR capture error, the supervisor target is not examined and OpenOCD stops on its halt).

The co-simulation of the discovery of the chain was validated with 3 mutants, each killed by sim_soc3x2_wardrv_fsm_c_user_openocd_discover (SCENARIO FAIL): the supervisor stage of the chain made a wire in a copy of the RTL (PicoSoC_top: 3 TAPs printed, the number of TAPs and 3 IDCODEs fail), the cluster of a user TAP taken from the bits 23 to 12 of its IDCODE in a copy of discover.cfg (user cpu17, user cpu1: the picosoc_chain line fails) and the TAPs printed from TDI (lreverse of jtag names: 4 IDCODEs fail).

The co-simulations of picosoc.cfg on a discovered chain were validated with 4 mutants of scratch copies, each killed: a wrong IDCODE table entry in discover.tcl (supervisor 0x10004001: the supervisor TAP is unknown, 2 targets instead of 3, sim_soc3x2_wardrv_fsm_c_user_openocd_generic SCENARIO FAIL), the chain read from TDI in picosoc_discover (lreverse of the scan_chain lines: the targets on the wrong TAPs, not examined, sim_soc3x2_wardrv_fsm_c_user_openocd_generic fails), the TAPs of jtag names taken from TDI in picosoc.cfg (lreverse: same failure) and a wrong user CPU entry in discover.tcl (0x10001002: no target, no GDB server, sim_soc1_wardrv_fsm_c_user_openocd_generic fails at the timeout of the kit).

How to Run

From a clone of asylum-project (in the asylum-env image, or with GHDL, FuseSoC and the toolchains installed):

make help                                        # variables, rules and targets
make sim_soc4_openblaze8_fault_c_user_fault_tmr  # one scenario, log in log/
make sim_soc1_wardrv_fsm_c_user_uart_spi         # every scenario of a firmware build
make sim_soc2_wardrv_fsm_fault_c_user_openocd_jtag  # OpenOCD + GDB co-simulation (openocd, gdb-multiarch, gcc)
make _sim_soc2_wardrv_fsm_fault_c_user_openocd_bitbang  # the same over the UART, 18 to 34 min: by hand only, not in the CI
make sim_soc3x2_wardrv_fsm_c_user_openocd_chain  # OpenOCD co-simulation of the chain of 4 TAPs (openocd, gcc)
make sim_soc1_wardrv_fsm_c_user_openocd_discover  # OpenOCD co-simulation of tools/openocd/discover.cfg (openocd, gcc)
make sim_soc1_wardrv_fsm_c_user_openocd_generic   # OpenOCD + GDB co-simulation of tools/openocd/picosoc.cfg, chain discovered (openocd, gcc, gdb-multiarch)
make nonreg_sim                                  # every sim_* target
make nonreg_lint                                 # every lint_* target
make nonreg_syn                                  # every syn_* target (Yosys, figures of Resources)
make TARGETS_FILTER=wardrv nonreg_sim

To run a list of scenarios, build the target once, then run the list without recompiling (same --build-root and --no-export as the Makefile, so the build is reused; any generic of the target can be overridden after the VLNV):

make sim_soc4_openblaze8_fault_c_user           # build and elaboration (TESTS_LIST empty)
fusesoc --cores-root . run --build-root build --no-export --run --target sim_soc4_openblaze8_fault_c_user asylum:soc:PicoSoC:4.8.6 --TESTS_LIST=fault_tmr,switch

To add a scenario: a package tb_PicoSoC_<name>_pkg with a procedure run, its name in C_TESTS, its applicability in test_applies and its case in run_test of tb_PicoSoC_tests_pkg, the file in the files_sim fileset, the name in the TESTS_LIST of the targets it applies to, then make mk/targets.txt and make ci_generate. An integration firmware esw/test/test_<ip>.c is a scenario of the same name: add it to C_INTEGRATION (it applies to its firmware only), give it a package when the testbench drives or checks pins (else run_test only calls wait_pass), and add its generators gen_rv32i_user_test_<ip> / gen_picoblaze3_user_test_<ip> and its targets sim_soc1_<cpu>_c_test_<ip> to the core.

Outside the CI, GHDL writes a waveform dut.fst.

Dependencies and Related IPs

Core Repository Purpose
asylum:utils:pkg asylum-utils-pkg sbi_pkg (SBI records, "/=" of the lock-step compare, vote of the TMR vote, >= 1.11.0), logic_pkg, math_pkg; the testbenches need >= 1.10.0 (string_pkg lists of TESTS_LIST)
asylum:target:techmap asylum-target-techmap sync2dffrn (resets, debug_mux_sel_i of the pad multiplexer, injection of the JTAG TDR), obuf, iobuf
asylum:component:clock_divider asylum-component-clock_divider SoC clock (PicoSoC_clkrst)
asylum:component:GPIO asylum-component-gpio sbi_GPIO_irq: switches, LEDs, supervisor GPIOs
asylum:communication:uart asylum-communication-uart sbi_uart; uart_core (>= 3.1.0): HWLA output (PicoSoC_hwla, transmitter only), JTAG over the UART (PicoSoC_jtag_over_uart, receiver and transmitter)
asylum:debug:HWLA asylum-debug-hwla hwla (DEBUG_ENABLE); tools/hwla2vcd.py reads its captures, copied to hwla/ of the work root of every target (>= 3.1.0: --signal and comments of the argument files of tools/hwla, copied next to it)
asylum:debug:jtag asylum-debug-jtag jtag_pad_mux (UART pads), jtag_tap, jtag_tdr_inout, jtag_tdr_in (injection / status TAP), jtag_bitbang (JTAG over the UART, >= 1.1.0), jtag_axis (HWLA captures over JTAG, >= 1.3.0, with fifo_async of asylum-component-fifo >= 1.3.0), jtag_pkg; tools/openocd/jtag_axis.tcl (OpenOCD procedures of jtag_axis: a copy of it is in tools/openocd, sourced by picosoc.cfg)
asylum:communication:SPI asylum-communication-spi sbi_spi; fmf:memory:flash_nor (flash models of the testbench)
asylum:system:GIC asylum-system-gic sbi_GIC (>= 2.0.0)
asylum:component:timer asylum-component-timer sbi_timer
asylum:component:crc asylum-component-crc sbi_crc
asylum:system:spinlock asylum-system-spinlock sbi_spinlock
asylum:communication:I2C asylum-communication-i2c sbi_I2C
asylum:component:PWM asylum-component-pwm sbi_PWM
asylum:system:mailbox asylum-system-mailbox sbi_mailbox (>= 1.1.0)
asylum:infrastructure:icn asylum-infrastructure_icn sbi_icn
asylum:component:ram asylum-component-ram sbi_ram
asylum:component:fifo asylum-component-fifo FIFOs of the peripherals
asylum:processor:OpenBlaze8 asylum-processor-OpenBlaze8 sbi_OpenBlaze8
asylum:processor:WardRV asylum-processor-WardRV sbi_WardRV_fsm, WardRV_debug (debug units in cpu_wrapper, >= 1.2.0: TAP of asylum-debug-jtag); the GDB helpers gdb_lib.py of the co-simulation (>= 1.5.0)
asylum:utils:generators asylum-utils-generators pbcc_gen / rvcc_gen (firmware to ROM), regtool of the peripherals
asylum:utils:ghdl_synth, asylum:utils:yosys_synth asylum-utils-generators lint_ghdl_synth_* check, syn_* synthesis
bitvis:verification:uvvm UVVM Verification library, UART and I2C VIPs
asylum:verification:uvvm asylum-verification-uvvm JTAG BFM jtag_bfm_pkg, its chain fields (head_ir, tail_ir, head_dr, tail_dr) and its Capture-IR monitor; remote_bitbang BFM rbb_bfm_pkg and its monitor rbb_uart_monitor (JTAG over the UART, >= 1.3.0)
asylum:verification:openocd asylum-verification-uvvm OpenOCD co-simulation kit (>= 1.0.0): rbb_server.c, rbb_jtag, rbb_axis, hooks rbb/cosim.sh of tb_PicoSoC_openocd

All the IPs: asylum-project.

License

Apache License 2.0, see LICENSE.

Exception: the SPI flash models (fmf:memory:flash_nor, from the Free Model Foundry, GPL-2.0) are a dependency of the simulation targets only, they are not in this repository and not part of the SoC.

About

Minimal SoC based on Picoblaze clone or RISCV academic processor

Topics

fusesocmodbuspicoblazeriscvsafetysocspiuart

Resources

Readme
Apache-2.0 license
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.