Support Code
sentinel-rt
sentinel-rt is an currently-empty Rust support crate. If necessary, it will
contain support routines optimized for the Sentinel RISC-V implementation
that LLVM or Rust wouldn’t generally know about. I have three potential use
cases:
Wrappers over custom opcodes[1] and the slow shift operators :),
Related to 1.,
compiler-builtinsspecialization if possible[2].Runtime/Machine Mode code that is incompatible with the existing
riscv-rt, but compatible with the RISC-V spec[3].
However, at present, I don’t need any special support code, so sentinel-rt
is just a reserved crate with example code for demo bitstreams.
Note
If I expand demos such that multiple linker scripts are required, the examples
directory will become an examples crate. Do not depend on
sentinel-rt/examples being stable; the source root is already
a workspace!
Verilog Generator
See sentinel_cpu.gen.
Examples
AttoSoC
Small example SoC to demonstrate Sentinel on small FPGAs.
- class examples.attosoc.WBMemory(*args, src_loc_at=0, **kwargs)
Memory exposed over the Wishbone bus.
Granularity is always 8, and data width is always 32. The RAM itself consumes 25 bits (32 MB) of address space starting at address 0.
- Parameters:
num_bytes (int) – Size of the memory in number of bytes.
- bus
Wishbone bus interface.
- Type:
In(wishbone.Signature)
- property init
User contents of memory, if any.
Contents always start at address 0.
- elaborate(plat)
- class examples.attosoc.WBLeds(*args, src_loc_at=0, **kwargs)
GPIO peripheral over the CSR bus.
- bus
Wishbone bus interface.
- Type:
In(wishbone.Signature)
- leds
LED outputs.
- Type:
Out(8)
- gpio
Array of 8 GPIO pins. Each GPIO pin has the following signature:
Signature({ "i": In(1), "o": Out(1), "oe": Out(1) })
Registers
LEDs Output Register
Bidirectional GPIO Register
- Bidirectional Output Enable Register
Bit set == Output Enabled.
- elaborate(plat)
- class examples.attosoc.RWStrobe(*args, src_loc_at=0, **kwargs)
A read/write field action, without built-in storage.
- Parameters:
shape (shape-castable) – Shape of the field.
- port
Field port.
- Type:
FieldPort
- r_data
Read data. Drives
port.r_data. SeeFieldPort.- Type:
Signal(shape)
- r_stb
Read strobe. Driven by
port.r_stb. SeeFieldPort.- Type:
Signal()
- w_data
Write data. Driven by
port.w_data. SeeFieldPort.- Type:
Signal(shape)
- w_stb
Write strobe. Driven by
port.w_stb. SeeFieldPort.- Type:
Signal()
- elaborate(platform)
- class examples.attosoc.CSRLeds(*args, src_loc_at=0, **kwargs)
GPIO peripheral over the CSR bus.
- bus
CSR bus interface- forwards to CSR bridge bus.
- Type:
In(csr.Signature)
- leds
LED outputs.
- Type:
Out(8)
- gpio
Array of 8 GPIO pins. Each GPIO pin has the following signature:
Signature({ "i": In(1), "o": Out(1), "oe": Out(1) })
- bridge
CSR bridge holding the registers.
- Type:
csr.Bridge
- class Leds(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- leds: <amaranth_soc.csr.reg.Field object at 0x7078c5119a30>
- class InOut(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- inout: <amaranth_soc.csr.reg.Field object at 0x7078c5118ec0>
- class OE(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- oe: <amaranth_soc.csr.reg.Field object at 0x7078c5119070>
- elaborate(plat)
- class examples.attosoc.WBTimer(*args, src_loc_at=0, **kwargs)
Basic 15-bit timer with IRQ, exposed over the Wishbone bus.
IRQ is set whenever bit 14 is set. IRQ and bit 14 is cleared on read of the IRQ register.
- bus
Wishbone bus holding the registers.
- Type:
In(wishbone.Signature)
- irq
IRQ line
- Type:
Out(1)
Registers
IRQ Register
- elaborate(plat)
- class examples.attosoc.CSRTimer(*args, src_loc_at=0, **kwargs)
Basic 15-bit timer with IRQ, exposed over the CSR bus.
IRQ is set whenever bit 14 is set. IRQ and bit 14 is cleared on read of the IRQ register.
- bus
CSR bus interface- forwards to CSR bridge bus.
- Type:
In(csr.Signature)
- irq
IRQ line
- Type:
Out(1)
- bridge
CSR bridge holding the registers.
- Type:
csr.Bridge
- class IRQ(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- irq: <amaranth_soc.csr.reg.Field object at 0x7078c5118bf0>
- elaborate(plat)
- class examples.attosoc.UART(*args, src_loc_at=0, **kwargs)
Basic hardcoded UART.
- Parameters:
- elaborate(platform)
- class examples.attosoc.WBSerial(*args, src_loc_at=0, **kwargs)
UART exposed over the Wishbone bus.
- bus
Wishbone bus holding the registers.
- Type:
In(wishbone.Signature)
- rx
Serial RX
- Type:
In(1)
- tx
Serial TX
- Type:
Out(1)
- irq
IRQ line
- Type:
Out(1)
Registers
Transmit and Receive Register
- IRQ Register
Bit 0: RX register full
Bit 1: TX register empty
- elaborate(plat)
- class examples.attosoc.CSRSerial(*args, src_loc_at=0, **kwargs)
UART exposed over the CSR bus.
- bus
CSR bus interface- forwards to CSR bridge bus.
- Type:
In(csr.Signature)
- rx
Serial RX
- Type:
In(1)
- tx
Serial TX
- Type:
Out(1)
- irq
IRQ line
- Type:
Out(1)
- bridge
CSR bridge holding the registers.
- Type:
csr.Bridge
- class TXRX(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- txrx: <amaranth_soc.csr.reg.Field object at 0x7078c5118e00>
- class IRQ(*args, src_loc_at=0, **kwargs)
A CSR register.
- Parameters:
fields (
dictorlistorField) – Collection of register fields. IfNone(default), a dict is populated from Python variable annotations.fieldsis used to create aFieldActionMap,FieldActionArray, orFieldAction, depending on its type (dict, list, or Field).
Interface attributes
- element
Element Interface between this register and a CSR bus primitive.
- field
Collection of field instances.
- Type:
FieldActionMaporFieldActionArrayorFieldAction
- f
Shorthand for
Register.field.- Type:
FieldActionMaporFieldActionArrayorFieldAction
- raises TypeError:
- raises ValueError:
If
fieldsis notNoneand at least one variable annotation is aField.- raises ValueError:
If
element.accessis not readable and at least one field is readable.- raises ValueError:
If
element.accessis not writable and at least one field is writable.
- irq: <amaranth_soc.csr.reg.Field object at 0x7078c5118d70>
- elaborate(plat)
- class examples.attosoc.BusType(*values)
Choose between Wishbone and CSR Peripheral Interfacing.
- class examples.attosoc.AttoSoC(*args, src_loc_at=0, **kwargs)
AttoSoC constructor.
Create a Sentinel SoC with LEDs/GPIO, timer, and UART.
- Parameters:
- cpu
The Sentinel CPU
- mem
CPU Memory
- leds
The LEDs/GPIO peripheral
- timer
The timer peripheral
- serial
The UART peripheral
- property rom
Memory contents of user program, if any.
- print_memory_map()
Print out memory map of attached AttoSoC peripherals.
- elaborate(plat)
- examples.attosoc.demo(args)
AttoSoC generator entry point.
- examples.attosoc.main()
AttoSoC generator command-line parser.