594 Commits

Author SHA1 Message Date
Daniel Jobson
ea7f7107f0
PoC: fw: Import spi.[ch] and flash.[ch] 2025-02-07 12:54:08 +01:00
Mikael Ågren
d1b8b6eee8
PoC: testfw: Break out tests running in app mode into separate app
App mode can no longer be controlled from software. So the tests have to
run from firmware RAM.
2025-02-07 12:54:08 +01:00
Mikael Ågren
1a505f4a21
PoC: testfw: Remove blake2s test
Removing the blake2s test since the possibility for the firmware to
expose a blake2s function to the app has been removed.
2025-02-07 12:54:07 +01:00
Mikael Ågren
926f3c68ed
PoC: Add experimental syscalls to firmware
Adds:
- SYSCALL_RESET
- SYSCALL_SET_LED
2025-02-07 12:54:07 +01:00
Mikael Ågren
e851efd35e
PoC: tb: Expand existing tests with access checks in app mode and syscalls
Checks availability of:
- CDI
- UDI
- RAM
- SPI
2025-02-07 12:54:07 +01:00
Mikael Ågren
97005bb83c
PoC: tb: Fix tb_tk1 test10 (SPI loop back test)
Fix test10. It broke while implementing interrupt based syscalls.

Cleaning up after the previous test. We reset the memory bus to a known
idle state. We also reset the DUT to make the SPI master visible.
2025-02-07 12:54:06 +01:00
Mikael Ågren
8c6e4a3352
PoC: tb: Fix tb_tk1 test5 (APP_START/APP_SIZE)
Fix test1. It broke while implementing interrupt based syscalls.

Instead of writing to ADDR_SYSTEM_MODE_CTRL, app mode is now entered
automatically when executing outside of ROM.
2025-02-07 12:54:06 +01:00
Mikael Ågren
6c2a7ef6c7
PoC: tb: Fix tb_tk1 test3 (CDI)
Fix test1. It broke while implementing interrupt based syscalls.

Instead of writing to ADDR_SYSTEM_MODE_CTRL, app mode is now entered
automatically when executing outside of ROM.
2025-02-07 12:54:06 +01:00
Mikael Ågren
5c56304b5d
PoC: tb: Add fetch instruction helper task to tb_tk1 2025-02-07 12:54:05 +01:00
Mikael Ågren
a646c8bfb4
PoC: tb: Remove tb_tk1 blake2s test
Removing the blake2s test since the blake2s registers are removed.
2025-02-07 12:54:05 +01:00
Mikael Ågren
007aa69052
PoC: tb: Update tk1 test bench with new ports
Fixing tests that broke when adding interrupt based syscalls
2025-02-07 12:54:05 +01:00
Mikael Ågren
93a74bcd1b
tb: Display errors in tb_tk1 even if DEBUG is 0
Always display errors to make them easy to find and troubleshoot.
2025-02-07 12:54:04 +01:00
Mikael Ågren
3269d25617
PoC: tb: Write data only once per call to write_word() in tb_tk1
Keep WE and CS high for one clock cycle instead of two. To avoid writing
the same address twice.
2025-02-07 12:54:04 +01:00
Mikael Ågren
7f95e0912f
PoC: Remove IRQ30 from fw/irqpoc_c_example
Removing IRQ30 since it us no longer exist
2025-02-07 12:54:04 +01:00
Mikael Ågren
82d408f405
PoC: Remove IRQ30 from fw/irqpoc_with_app
Removing IRQ30 since it us no longer exist
2025-02-07 12:54:03 +01:00
Mikael Ågren
14f266e506
PoC: Remove IRQ30 from fw/irqpoc_led_toggle
Removing IRQ30 since it us no longer exist
2025-02-07 12:54:03 +01:00
Mikael Ågren
052029236d
PoC: Remove IRQ30 from fw/irqpoc
Removing IRQ30 since it us no longer exist
2025-02-07 12:54:03 +01:00
Daniel Jobson
2ec2196e92
PoC: Make sensitive assets only readable/writable before system_mode is set
After the first time system_mode is set to one, the assets will no
longer be read- or writeable, even if system_mode is set to zero at a
later syscall. This is to make sure syscalls does not have the same
privilege as the firmware has at first boot.

We need to monitor when system_mode is set to one, otherwise we might
accedentially lock the assets before actually leaving firmware, for
example if firmware would use a function set in any of the registers
used in system_mode_ctrl.

Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-07 12:54:02 +01:00
Mikael Ågren
7f34f5db91
PoC: Remove low privilege syscall 2025-02-07 12:54:02 +01:00
Daniel Jobson
ecdbb25013
PoC: Deny access to the SPI master in app mode
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-07 12:54:02 +01:00
Mikael Ågren
4877e0ab99
PoC: Add example firmware with embedded that calls syscalls implemented in C
App is embedded in firmware and is loaded into app RAM when firmware
starts.
App continuously calls SET_LED syscalls.

Simulation: `make tb_application_fpga_irqpoc_c_example`
2025-02-07 12:54:01 +01:00
Mikael Ågren
62dba7c4fe
PoC: Control access to FW RAM
Allow FW RAM access only in the following execution contexts:
- Firmware mode
- IRQ_SYSCALL_HI

Input port `system_mode` of the `fw_ram` module is replaced with an
enable port. Since access to FW RAM not longer depend only on
system_mode
2025-02-07 12:54:01 +01:00
Mikael Ågren
a871d23d5d
PoC: Add basic syscall example firmware
Adds a basic example firmware that copies an app to app RAM. The app
triggers syscall interrupts and tries to execute ROM code from app mode.

A make target (`tb_application_fpga_irqpoc_with_app`) that simulates a
Tkey running the firmware is added.
2025-02-07 12:54:01 +01:00
Mikael Ågren
e4d19e83ce
PoC: Trap when executing from ROM in app mode
Only allow executing from ROM when in one of the following execution
contexts:
- Firmware mode
- IRQ_SYSCALL_LO
- IRQ_SYSCALL_HI

Co-authored-by: Daniel Jobson <jobson@tillitis.se>
2025-02-07 12:54:00 +01:00
Mikael Ågren
b53666e497
PoC: Remove Blake2s register 2025-02-07 12:54:00 +01:00
Daniel Jobson
2d762faba7
PoC: Automatically control system_mode in hardware
Instead of manually switching to app mode using the system mode
register, app mode will be enabled when executing outside of firmware
ROM.

Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2025-02-07 12:54:00 +01:00
Mikael Ågren
d36e9c9e3d
PoC: Add LED toggling interrupt example
Add example firmware for demoing interrupts on Tkey hardware.
2025-02-04 12:26:01 +01:00
Mikael Ågren
5535323b06
PoC: PicoRV32 interrupts
A proof-of-concept of enabling PicoRV32 interrupts. Two interrupt
sources, which can be triggered by writes to memory addresses, are
added.  The design has only been simulated, not run on hardware.

Synthesis:

Ice40 LC utilization is 93% (4934/5280) when built using tkey-builder:4

Simulation:

A `tb_application_fpga_irqpoc` target is added. Running `make
tb_application_fpga_irqpoc` creates `tb_application_fpga_sim.fst` which
can be inspected in GTKWave or Surfer.

Firmware:

A simple firmware is added in `fw/irqpoc`. It enables both interrupts
and triggers each interrupt once.

Custom PicoRV32 instructions are located in `custom_ops.S`. It is
imported from upstream PicoRV32 commit:
70f3c33ac8
2025-02-04 12:25:57 +01:00
Michael Cardell Widerkrantz
a5ed3cfaa9
Build: Don't depend on uds.hex and udi.hex
synth.json shouldn't depend on uds.hex and udi.hex because that
triggers a complete rebuild of the bitstream if the UDI or UDS are
changed.

Instead, we want only the application_fpga.asc to depend on them, so
we can patch in the UDS and UDI with tools/patch_uds_udi.py in an
existing application_fpga_par.json.
2025-01-20 14:48:53 +01:00
Daniel Jobson
66888a3756
tb: Make uart selftesting
- Exit with the right exit code
2024-12-09 13:55:43 +01:00
Daniel Jobson
c637c745cc
tb: Make trng selftesting
- Exit with the right error code
2024-12-09 13:55:43 +01:00
Daniel Jobson
ac853c87ec
tb: Make touch_sense selftesting
- Check for expected word
- Exit with the right error code
2024-12-09 13:55:42 +01:00
Daniel Jobson
c547042553
tb: Make tb_tk1_spi_master.v selftesting
- Compare against expected value
- Exit with the correct error code
2024-12-09 13:55:42 +01:00
Daniel Jobson
09c3d9b58e
tb: Make tb_tk1.v selftesting
- Exit with the right error code
2024-12-09 09:42:42 +01:00
Jonas Thörnblad
07dec8b8dc
Add make target for testbench simulation and simulation firmware.
Create separate sources for FPGA specific code, testbench simulation
specific code, verilator simulation specific code.
2024-11-28 16:10:01 +01:00
Jonas Thörnblad
ede92af2c1
Updated application_fpga_verilator.cc to match module application_fpga_sim.
- include printout of used clock and baud rate speed
- Use the the same clock frequency as target
2024-11-28 16:10:01 +01:00
Jonas Thörnblad
48c9709164
Set APP_SIZE if not defined. 2024-11-28 16:10:01 +01:00
Jonas Thörnblad
a99e69f33e
Remove non-working make targets for "post-synthesis functional simulation"
and "post-place and route functional simulation".
2024-11-28 16:10:00 +01:00
Jonas Thörnblad
15ce2c438b
Add needed changes to firmware for simulation. 2024-11-28 16:10:00 +01:00
Jonas Thörnblad
fe9055ea23
Add script to split app into simulation ram
Co-authored-by: Mikael Ågren <mikael@tillitis.se>
2024-11-28 16:10:00 +01:00
Jonas Thörnblad
3cd902f792
Add top level testbench for application_fpga_sim.v 2024-11-28 16:10:00 +01:00
Jonas Thörnblad
4260e1d5ac
Update application_fpga_sim.v to match application_fpga.v 2024-11-28 16:10:00 +01:00
Jonas Thörnblad
a330aa15ec
Add verilog file for TRNG simulation 2024-11-28 16:10:00 +01:00
Jonas Thörnblad
d3b9660180
Align module name with its file name. 2024-11-28 16:09:59 +01:00
Jonas Thörnblad
e54045a4dd
Add APP_SIZE parameter to tk1 block to set size of application when simulating. 2024-11-28 16:09:59 +01:00
Daniel Jobson
5b49d80891
tb: make timer core testbench selftesting
- Compare against an expected result and count errors
- Exit with the right error code
- Clean up the output
2024-11-27 08:10:15 +01:00
Daniel Jobson
c735c6fdde
tb: make tb_timer.v selftesting
- Compare against an expected result and count errors
- Exit with the right error code
- Lower write_word() to 1 clk cycle instead of two. It only requires one
  clock cycle to write, otherwise if it is two one have to compensate for it
  in the tests since we are counting cycles.
2024-11-27 08:10:15 +01:00
Daniel Jobson
6bdedf4f86
Fix bug in timer core, where it misses clock cycles
Remove redundant timer state. This fixes a bug where the timer misses a
clock cycle every time the prescaler counter reaches 1. This means if
one uses a large prescaler, like 18E6, it is barely noticeable, but if
one have a low prescaler and a high timer value it becomes significant.
This also yields the running_* registers redundant, which are removed.

Add clarity to the readme.

Update the timer to default to values of one, for prescaler and timer
count.
2024-11-27 08:10:15 +01:00
Daniel Jobson
3d7a97ecbc
fpga: remove the API for configuring the UART core
This removes the possibility to configure the bit rate, data bits and
stop bits at runtime from the API. This reduces the
usage of LCs with ~4%.

It is still possible to configure the core before building.

Update digest of application_fpga.bin.sha256
2024-11-26 15:24:12 +01:00
Jonas Thörnblad
0445c8f993
Add nextpnr flag '--exit-on-failed-target-frequency' 2024-11-22 15:47:42 +01:00