Commit graph

36 commits

Author SHA1 Message Date
hanatonikkou
d69a03393b fix formatting, fix bitfield offsets 2026-04-28 20:01:34 +02:00
hanatonikkou
4bb8b55777 add dali library to bio-lib 2026-04-28 15:20:48 +02:00
bunnie
c448fc2f2e add event mask macro 2026-03-21 01:25:51 +08:00
bunnie
c45609ed1b regenerate BIO libs based on updates to math lib 2026-03-20 22:35:06 +08:00
bunnie
c5e4d02a9a put note about division routine possibly being sus 2026-03-20 22:32:08 +08:00
bunnie
75e7937301 fixes to fp_16 library
- add saturating operations
- division was broken

fp_12 library might also be sus...
2026-03-20 22:31:08 +08:00
bunnie
af6260fb43 add a check for div instructions without "softdiv.h"
This will hopefully save some troubles for developers who
accidentally invoke a divide without realizing it.

Prints an error with instructions on how to resolve the
situation.
2026-02-22 03:42:51 +08:00
bunnie
7e37aa50c8 clang2rustasm.py: improve handling of more cases in clang code
- handle .rodata, .data, .bss, .set labels better. This allows
for static globals
- handle call instructions. These are manually resolved by
changing the call pseudo-instruction into a jal with a rust
assembly-compliant label.
2026-02-22 03:34:42 +08:00
bunnie
db6aa1255a rename fixed point converters
Q20.12 and Q16.16 come as .h files in the BIO C library,
so converters in Rust to shove data to and from the BIO in
those formats are provided.
2026-02-22 03:33:23 +08:00
bunnie
75ce3f886d constrain the C compiler codegen
1. we can't resolve jump tables in Rust assembly. The label
grammar isn't rich enough to do this. As a result, this code
genreation method is suppressed.

2.there is no 'div' instruction on this PicoRV, so the +m is
converted to +zmmul, which correctly emits mulitplies, but
skips the divide.

A soft divide library is provided for programs that require
division.
2026-02-22 03:23:57 +08:00
bunnie
02d90fe056 add a more complicated demo program
This C routine incorporates statics, arrays, globals,
switch/case, division, and a bunch of other stuff that
is designed to exercise corner cases in the assembly conversion
script.

The program itself just cycles LEDs in a rainbow vomit pattern.
2026-02-22 03:20:57 +08:00
bunnie
8ee6d86748 cleanup math test Fp refernce 2026-02-22 03:20:11 +08:00
bunnie
c80877d064 add various C libraries for BIO use.
Note that there is no LTO/trimming in the BIO flow, so
wantonly including libraries you don't use just grows
your code size for no use.
2026-02-22 03:19:04 +08:00
bunnie
8f709216d6 add autogeneration header to math_test.rs 2026-02-20 23:54:34 +08:00
bunnie
905939d8f1 featurify all BIO modules
the reason we do this is that if we don't switch off library
modules, they are compiled in and just become dead code in the
OS image. with enough modules, this will eventually become
a significant drag on binary size.
2026-02-20 23:53:09 +08:00
bunnie
9e34da0bf7 add autogeneration header to output artifacts 2026-02-20 23:52:16 +08:00
bunnie
6176d3379d streamline zig build flow 2026-02-20 23:51:58 +08:00
bunnie
aa06be9c82 commit an initial c test program
this is a "math test" that can compute cosines in fixed point
using the BIO.
2026-02-20 21:02:54 +08:00
bunnie
6cc9e2d5f7 fix constant table in cosine 2026-02-20 21:01:55 +08:00
bunnie
9d23703e45 fix API for new code specification method 2026-02-20 21:01:23 +08:00
bunnie
c1571479d6 remove out of place comment 2026-02-20 21:01:00 +08:00
bunnie
a6a8341223 Fix BIO erratum in assembly translator.
Getting compiled code going has revealed a couple of frankly
embarassing erratum in the BIO. Kind of shameful to make such
a n00b mistake but I guess my sole defense is I had to put it
together in a hurry with little resources.

Here's the bugs:

BUG 1 ("phantom rs1"): For lui/auipc/jal, the 5-bit field at
instruction bits [19:15] is not gated off. If that field decodes
to register 16-19 (x16-x19) for just these instruction types,
a spurious pending read is made from the corresponding FIFO,
which affects correctnes and can block execution.

BUG 2 ("phantom rs2"): For non-R/S/B-type instructions, the 5-bit
field at instruction bits [24:20] should be gated off but isn't.
When that field equals 20 (0b10100), a spurious `quantum` signal
triggers, which can affect the instruction fetch pipeline

This script inspects the output of the Clang assembly, and in the
process of translating it to Rust assembly, transparently patches
almost all of the cases with work-arounds. The assumptions and
exceptions for the work-arounds are:

- The stack pointer is initialized and valid. This is always
true for Clang-derived scripts because it's in the _start()
routine

- No interrupts that can mutate stack: true because interrupts aren't
supported in this implementation.

There is one edge case that isn't covered: J-type instructions
aren't patchable at this stage because the label offsets haven't
been resolved into instructions. However, "naked" jal instructions
are rare in compiled code - it's always jalr, which is an I-type
instruction. This is noted as a warning when the script runs, and
is fixable by simply inserting a "nop" after the jal instruction
if the target is at the wrong address - this will shift the immediate
so that it no longer contains the 0x14 (decimal 20) pattern in
the immediate field.
2026-02-20 18:40:37 +08:00
bunnie
db78b28b37 checkpoint the c -> rust asm flow for the BIO
An abomination: a zig-based C toolchain, installed via python,
compiles to clang assembly, translated by python script, into
Rust assembly. Then compiled and linked into your app.

Really tempting fate with this one...will I come back to this
commit in a couple years and be filled with regret?

Already, I have some misgivings - the zig toolchain is
definitely not stable, and has been through some API changes,
and doesn't run on all platforms. But - I forge ahead.
2026-02-20 02:19:46 +08:00
bunnie
b932d7d755 fix a the mul demo
we don't have to do the weird mul coding anymore because
we added ".option arch, +m" to bio_code! macro
2026-02-20 02:11:09 +08:00
bunnie
84e276f712 add BIO sketch for qspi to 8080 converter
quick feasibility study to confirm that BIO can convert
a QSPI video stream into 8080-style display stream support.
One of those quirky weird applications that I think BIO is
kind of perfect for.

I think it should work, at the speeds required, but nothing
compares to actual hardware testing.
2026-01-24 23:55:22 +08:00
bunnie
079ec33134 improve formatting & timing slightly 2026-01-06 15:43:50 +08:00
bunnie
d1a3eb4b58 handle clock counter rollover case & fix bug in assembly register naming
t3 doesn't actually exist
2026-01-06 15:40:14 +08:00
bunnie
dd18ddf97c convert avalanche TRNG interface into the Xous BIO API 2026-01-05 21:53:39 +08:00
bunnie
b02f1563ae don't put pin snapping into ws2812 implementation
the pin snapping makes the application not composable with
other applications that don't use the exact same snapping mode.
2026-01-05 08:56:38 +08:00
bunnie
9a94ea48ad add captouch demo
some basic APIs in place to help make touch a little easier
to use.
2026-01-05 08:53:13 +08:00
bunnie
6398415265 update lib refs 2026-01-03 22:55:47 +08:00
bunnie
e2097f171e add demo for doing multiply instructions 2026-01-03 22:55:20 +08:00
bunnie
c81911e498 move readme to a customary location 2026-01-02 12:54:01 +08:00
bunnie
f9e17f7a63 add a README for the BIO libraries 2026-01-02 12:42:46 +08:00
bunnie
acaa3b6874 cleanup warnings 2026-01-02 12:26:09 +08:00
bunnie
437c5e1d85 start the bio-lib
this is where a collection of BIO applications will eventually live...
2026-01-02 11:25:49 +08:00