Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20880 Discussions

Forth and NIOS II

Altera_Forum
Honored Contributor II
1,742 Views

Attached is an implementation of FIG Forth for the NIOS II. There ANSI and personal changes/extensions. It is in NIOS II assembly and Forth with a load module size of about 13K Bytes. This version has no disk/screen support. My goal was to keep the size small for my embedded NIOS II without any external ram. It is configured for the simple RS232 UART. To use the module, set the UART address, change the memory size if the setting of 32KB is too large, and run gcc. There are a few lines on the assembler commands but very little to no documentation included (other than the ANSI and FIG documents). There is much available on the www about Forth and FIG forth. 

 

As configured, this package assemblies with an origin of 0x0 but should work properly at any load address in the lower quarter of the NIOS address space. I've had it copy itself to several different locations in the first 1MB and then restart without problems. This slows it somewhat but I didn't need to deal with the relocation issues. 

 

There is also a JTAG UART version of one file but there were issues with lost characters, in both directions, when using the NIOS Terminal. There are much better serial port programs available to use with RS232. 

 

The NIOS command line debugger documentation is available at: C:\altera\kits\nios2_60\bin\fs2\doc\Nios2-HW-Reference.pdf 

This tool, NIOS CONSOLE, is useful but can be slow going. 

 

There are several other posts available that appear to help with booting and using EPCS as a source for a user Forth program that is compiled after the NIOS and Forth is going. I redirect the test inout to external FLASH to accomplish that function (that code I'll put up after a few more days of testing). 

 

As with all of this posted IP, "Use at your own risk".
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
1,015 Views

This is an update to the original Forth I posted, .S files only. Errors found and corrected along with additions. The BEGIN-WHILE-REPEAT had an error, several others also. Added S" (almost ANSI) and made CREATE operate per ANSI. String constants now kept in entered case. There is an example of how to redirect the terminal input and output to compile from Forth sorce in memory, flash, etc (SLOAD/LOAD/FLSHKEY in fig6). I use it to load 70KB of Forth source code (includes comments & white space, the DOS files) to the vocabulary. Diagnostic and test code written several years ago have ported very quickly to this environment.

0 Kudos
Reply