F21 Emulator with Machine Forth
Version 3 Updated 3/8/2000
640x480 video, write ROM, and F21 mouse
Program History and Design
Versions 2 and 3 of the F21 Emulator were released for free use on 3/8/2000. It is available on the F21 Emulator Updates Page The information about the changes specific to versions 2 and 3 are on the updates page.
The original S21 simulator for the MuP21 microprocessor was modified by Dr. Michael Monvelishsky, Jeff Fox, and Maxim Sokolnikov to support F21 development. The program was modified to reflect the 18 cell deep data and 17 cell deep return stacks on the F21 chips and the chip timing and register addresses were modified to reflect current F21 designs. The S21 simulator was written in F-PC and used arrays in memory that could be loaded from or saved to disk to simulate 16K words of MuP21 memory. The F21 simulator uses virtual memory feature of F-PC to simulate the full 1M word DRAM memory space of the F21 in the PC file TARGET.P21. The F21 Emulator program uses EMM to hold the simulated F21 memory for even greate speed. It also combines the F21 simulator/debugger with the hypertext view and editing capabilities in F-PC and an F21 assembler to create a combined simulator/debugger/assembler/editor. Ultra Technology offers a lower performance F21 Simulator to test and examine F21 code.
Stas V. Pereverzev modified the user interface and internals of the F21 simulator, coded lots of things in assembler and made it much faster and easier to use.
This F21 emulator with integrated assembler/editor/debugger has been certified for simulating F21 programs by Ultra Technology.
Version 1.2 introduces the ROM read feature. If a file named F21.ROM is found when F21.EXE is started it will be loaded into the simulated F21 ROM space and execution will start at address 1AAAAA in ROM. On the fastest PCs version 1.2 will run at very close to the speed of a real F21 running code in DRAM while generating video or about 20mips. I get 5.7 simulated F21 mips on nops on my 120mhz pentium.
To start F21 with a source file enter F21.EXE TEST.SEQ at the DOS command prompt or link this command to an Icon in Windows. The source file specified on the command line will be assembled when the program starts and can be reasembled at any time after leaving the editor with the L key.
When the program starts it will display
The left column are addresses in the F21 memory space, the second colum is the contents of that memory and the next column is a disassembly of each memory cell as one to four CPU opcodes or arguments.
The center column in blue shows some of the CPU register names and contents.
The last two columns are a memory dump.
In the above example you see the compiled code for the emudemo4, the moving video window demo.
The E key brings up the editor. The source that compiled the above demo looks like:
key will display the following help screen:
The first four command keys are the arrow keys. These four keys are the command interface to the disassembler for the F21. Each location in memory is disassembled into one to four five bit values between 0 and 1F (| 0 0 0 0 |). Each of these five bit opcodes is disassemled and display.
The source file specified on the command line starting the program will be compiled when the program is started. The user can edit the file at any time with the E key and reassemble it with the L key. The system will compile applications very quickly.
It should be noted that the data stack is actually 18 registers deep and has a circular array of 16 registers at the bottom. The return stack is 17 registers deep and has a circular array of 16 registers at the bottom. The way this functions is that if a 0 and a 1 and a 2 are placed on the F21 data stack in that sequence when the 2 goes into the T register the 1 will go into the S (second) register and the 0 will be written to the register in the circular 16 register array that is pointed to by the current value of an internal 4 bit register. If 15 more items were written then all the data stack registers would be filled. If the items were written with their sequence values as the first the three then when things fill T would contain 11H, S would contain 10H, and values 0 through 0FH would be in the 16 circular data stack registers. If the values in the stack are removed the bottom 16 items will repeat as the four bit pointer wraps while pointing to the active register in the stack array. In the example above if we removed items from the stack we would get 11,10,F,E,D,C,B,A,9,8,7,6,5,4,3,2,1,0,F,E, D,C,B,A,9,8,7,6,5,4,3,2,1,0,...
The B command sets a system breakpoint at the address where the cursor is located in the simulator.
If your code does not reach one of the three breakpoints you have set fairly quickly you should use the "ESC" key or "CONTROL_BREAK" to stop program execution and examine the registers.
The SPACE_BAR is the command to single step the current instruction in the F21. Note that the function show by the disassembler will be performed when the spacebar is pressed.
Resetting the Memory Pointer (Program Counter)
To reset the Program Counter use the "A" command. The "A" command will prompt for a new Address for the program counter. The memory pointer can be set to DRAM 0-FFFFF, Slow SRAM 10000-13FFF, Fast SRAM 140000-143FFF, Slow ROM 180000-1BFFFF, or Fast ROM 1C0000-1FFFFF.
The "G" command will begin repeated instruction execution until one of the breakpoints is reached, or the "ESC" key is pressed. The program will display each instruction if trace is on, or nothing if trace is off until a breakpoint is reached, or "ESC" is pressed. One can also stop the execution of F21 programs by breaking out completely to the F-PC Forth environment with the CONTROL_BREAK key. From F-PC you can return to the F21 environment at the same point that you broke out with the command "CHIP" from the F-PC FORTH environment. The "T" key in the F21 program toggles the trace function on and off.
The "L" command will compile the source file loaded from the command line when the F21 program is started. The file can be edited with the "E" command with access to the hypertext link and index capabilities built into the F-PC program editor.
The "F" command will exit the F21 emulaor program into F-PC. One has access to any F-PC word of feature from the command line. To restart the simulator/debugger/assembler/editor from Forth type "CHIP" The Forth command "CHIP" restarts just where you left off. This was an unintentional feature of the current implementation. It is not a very useful environment because internals of F-PC have been modified. Just return to the Emulator if you go there.
All registers execpt the Program Counter are set with the "R" command. The "R" command will only accept the register names that are displayed on the display (A,R3,R2,R1,R ,T,N,S2,S3,S4,S5). After a register has been designated then a value will be accepted and the register value set.
Saving Program Files
The F21 simulator program simulates the F21's DRAM memory of one million 20 bit cells in F-PC virtual memory in the file TARGET.P21. All changes to the F21 memory will be saved in the TARGET.P21 memory image. Just as with the S21 simulator the .P21 extension represents a target DRAM memory image. The Emulator will use EMM to hold the simulated F21 memory. No utility is presently provided to load or save program images. Programs can usually be compiled in a few seconds at most from source code.
F21 Emulator Source Code
The souce code to the F21 simulator/debugger/assembler/editor program is in the .SEQ files distributed with the F21.EXE file. To compile a new copy of F21.EXE enter F FLOAD SIM-F21.SEQ. SIM-F21.SEQ is the top level source file. The file F21ASM.SEQ contains the code to simulate the F21 instructions. The file VGA2.SEQ contains the code for display of the simulated F21 composite video output (center 320x400 pixels only) in the 320x400 VGA video mode. VID-F21 contains the code that decodes the F21 memory image bitmap for display in VGA mode. BLOCK.SEQ is the virtual memory block code from F-PC. REAL-F21.SEQ contains the code for simulating the internal operation of the F21 chip. WATCHING.SEQ contains the source code for the simulation of timing, dissassembly, initialization and display of information in the F21 program. DOS-MEM.SEQ contains assembler routines to speed access to simulated memory.
Composite and RGB Video Output Simulation
In version 1.1 the V key will display a simulated F21 composite video display that covers most of the displayable screen on most TVs. It is a 320x400 pixel image with 15 colors. F21 is also capable of displaying 640x480 x16 RGB VGA display and is supported by the later versions of the emulator. In the simualtor the V key scans the F21 video memory map and displays the image F21 would display.
The T key toggles the video simulation on/off. With Video on when the F21 writes to video memory the screen will be updated to simulate F21 updating video memory in real time.