Thanks for the update! Both the board and the experimental AmForth-RV implementation look really interesting. I'm curious how you're planning to use the compiled C object support. I can see that being helpful to access existing high-level building blocks for things like USB. Is it possible to give a walk-through of how it works?

Cheers!  Keith

On 2/6/24 02:23, h...@tjnw.co.uk wrote:
A risc-v update.

AmForth-RV update

Good progress made with the CH32V307 [0]

Words defined in the RAM dictionary can now be appended to the FLASH
dictionary so user defined words (individual words or the entire RAM
dictionary) are able to survive a reset. This was one of my major
milestones and (in my mind) a requirement for a self-hosted Forth. I
was not able to achieve this with the FE310 based red v board.

Additionally, something new to AmForth. Compiled C objects can be linked
into AmForth-RV and called from within CODEWORDs. This is a build
level modification and arguments are passed to the C function using
assembly according to the risc-v calling convention.

The CH32V307 makes a very good target mcu for AmForth-RV and for
experimenting with embedded RISC-V in general.

- The development board is inexpensive and available [1] [2]
- There is official documentation and many 3rd party resources
- The mcu can program its own flash whilst executing from flash
- AmForth-RV can be built with an open source toolchain (build in < 3s, flash in < 6s )

If you are interested in trying some risc-v hardware I think it is a
good choice.

AmForth-RV is still experimental, but has made a step in the direction
of being less so. There are quite a few decisions to be made, so any
thoughts on what AmForth-RV might look like in the future are very much welcomed.

Best wishes,
Tristan

[0] https://github.com/openwch/ch32v307
[1] https://wchofficialstore.aliexpress.com/store/1100367542
[2] https://www.aliexpress.com/item/1005004329125620.html
(and many other suppliers)

A brief annotated/edited session showing saving a RAM dictionary word.

// see if a word 3+ has been defined //

 ok
show 3+
LFA..... (LFA)... FFA..... (FFA)... NFA..... XT...... (XT).... word....
 ok

// no it has not, so define it in the RAM dictionary //

: 3+ 1+ 1+ 1+ ;
 ok

// and see that it exists //

show 3+
LFA..... (LFA)... FFA..... (FFA)... NFA..... XT...... (XT).... word....
20003A54 200039B4 20003A58 00000000 20003A5C 20003A60 COLON    3+ (in RAM)
 ok

// now append the word 3+ to the FLASH dictionary //

save 3+
3+ HHHHBBBB 3+
 ok

// and see that it exists //

show 3+
LFA..... (LFA)... FFA..... (FFA)... NFA..... XT...... (XT).... word....
0000D200 0000D094 0000D204 00000000 0000D208 0000D20C COLON    3+ (in FLASH) 20003A54 200039B4 20003A58 00000000 20003A5C 20003A60 COLON    3+ (in ROM)
 ok

// it does, twice, once in RAM and once in FLASH //

// reset the board //

AmForth-RV 7.0 RV32IMAFC WCH CH32V307
Fri 19 Jan 2024 16:46:34 GMT

// see if 3+ exists //

words
3+ forth-wordlist environment riscv-wordlist @cycle type0
hifive-turnkey rev-info build-info mtimecmp mtime led.init -led +led
forth-wordlist >flash.p ram>flash flash>ram ram>rom rom>ram

// see if it works //

100 3+
 ok
u.
103  ok



_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel



_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to