Experiments with eco32-30-port-7

0. Overview

1. The project was re-organized to separate software from hardware properly.
2. The hardware is in no way different from version 6.
3. The monitor has a new command 'load', which loads an S-record file from one of the serial lines.
4. The 'loadserver', running on a Linux PC, feeds S-records to the starter board.
5. The tool 'bin2exo' can be used to produce an S-record file from the binary linker output.

It is thus possible to prepare an executable program on the development machine, and then transfer and run it on the starter board. The program must be written in assembler for the time being, but can be programmed in C once we have the real memory working (because it is difficult to get the standard library running within 4K bytes of memory which we have available now).

1. Project organization

After unpacking, you will find the following main subdirectories:

asld - assembler, linker, and object file dump utility
fpga - ECO32 hardware for the S3E board (same as version 6)
loadserv - load server
monitor - ECO32 machine monitor
tools/bin2exo - converter from binary to S-records
tools/bin2mcs - converter from binary to Intel Hex
tools/chrgen - build the contents of the display's character generator
tools/dspmem - build the initial contents of the display's screen memory
tools/flash - Picoblaze-based FPGA circuit to program the flash ROM

2. Preparing a program for loading

Edit a program, such as this one, with any text editor. Store it in a file, named e.g. 'hello.s'. Next, you have to assemble it with the assembler 'build/bin/as' (assuming that we are in any subdirectory directly below the main project directory):

../build/bin/as -o hello.o hello.s'

Except for the output file name, there are no other options to set. In the next step, the program must be linked:

../build/bin/ld -h -o hello.bin -rc 0xC0000000 hello.o

Here, you have several options (which are listed if you call 'ld' with '-?' as argument). In this example, we use '-h' (no object header is written: we are preparing a standalone program that will be loaded into physical memory without the help of an operating system), '-o' to specify the output file name, and '-rc' to relocate the code to virtual address 0xC0000000. Finally, the binary file 'hello.bin' must be converted to an S-record file:

../build/bin/bin2exo -S3 0x00000000 hello.bin hello.exo

You can choose between S1/S2/S3 records; the difference is the number of bytes used for addresses (S1: 2 bytes, S2: 3 bytes, S3: 4 bytes). The number 0x00000000 specifies the physical load address. 'hello.bin' is the input file name, 'hello.exo' is the output filename. The output is plain ASCII, so you can easily inspect it.

3. Loading and executing a program

Please program the monitor into the flash ROM of the starter board and load the ECO32 design into the FPGA. Connect one of the serial lines to the development machine where 'hello.exo' resides. Start the load server:

../build/bin/loadserv hello.exo

Assuming that you use serial line 1, type 'load 1' at the ECO32 console. You should see the monitor connecting to the load server, loading the S-records, and finally closing the connection. On the server side you can see the same steps, from the server's perspective. It is possible to first initiate the load command and then start the server, but please note that after 10 unsuccessful attempts to connect (with about 3 seconds in between), the monitor gives up and returns to the command loop.

Addresses in the S-records are specified as physical addresses. The monitor converts them to directly-mapped virtual addresses by setting the two MSBs to 1 (effectively doing an OR with the constant 0xC0000000). When loading the program is finished, the program counter set to the virtual load address. You can see that by looking at the registers (with the 'r' command). Consequently, if you type 'c' (the 'continue' command), the loaded program is executed, starting at its load address. You can of course set any other value for the program counter prior to starting the program.