FRISCjs FRISC processor simulator in JavaScript

Load/save and import/export FRISC configurations

This page enables you to save the current configuration of the simulator locally (under a specific name) so that you may load it next time you use FRISCjs. Currently, a configuration consists of the FRISC assembly program defined in the editor, the CPU speed, memory size and the set of defined I/O units. In the future, the configuration might be extended to include defined breakpoints, CPU state, etc. Furthermore, this page enables you to export configurations in text format so that they can be shared (e.g. via e-mail) and saved externally (e.g. as a GitHub gist), and import previously exported configurations. In order to save/load and import/export, the simulator must be in a stopped state.

Save current configuration locally

Load or delete existing configuration

Export current configuration to text

Import configuration from text as current configuration

Basic usage instructions

  1. Enter your FRISC assembler program into the textbox on the left.
  2. Press the "Settings" button to define the CPU speed (in Hz, default is 1000Hz, min is 1Hz) and the memory size (in KB, default is 256KB, min is 1KB, max is 1000KB). These options can't be changed after the program is loaded. Also, select the base for displaying register status (decimal or hexadecimal, default is hex). This option can be changed even while the loaded program is being executed.
  3. Press the "Load" button to parse and assemble the program, and then load it into memory. In case of parsing errors, the error message, line and column numbers will be logged to the log output screen.
  4. After the program loads into memory, the program editor is replaced with a location-by-location view of the complete memory. For each location, the location address, its value in hex and dec base, and value interpreted as a FRISC instruction are shown. Furthermore, the memory view provides several advanced features:
    • search - the search-box below the memory view provides a fast way to jump to any location.
    • breakpoints - for each location, the memory view also provides a "Break" checkbox which will pause the CPU when it reaches that memory location.
    • next instruction highlight - the location of the instruction that will be executed next by the CPU is highlighted.
  5. Press the "Run all" button to start the CPU with the defined execution speed. As the program is executing, the value of the registers is updated and the log output screen logs every executed instruction and CPU state.
  6. Press the "Pause" button to pause CPU execution.
  7. Press the "Run one" button to force the CPU to execute only the next instruction (step-by-step execution).
  8. Press the "Stop" button to stop the CPU completely, unload the program from memory and return to defining the program in the editor.
  9. Press the "Clear log" button to clear the log output screen.

IO units instructions

  1. IO units must be defined before loading a FRISC program into memory.
  2. Define a unique name to identify an IO unit.
  3. Select the IO unit type. FRISCjs supports 4 IO unit types: Generic IO, FRISC CT, FRISC PIO and FRISC DMA. The Generic IO unit is a unit with no pre-defined behavior or number of memory mapped locations, and enables users to manually set the unit state at runtime. The FRISC CT, FRISC PIO and FRISC DMA units all have pre-defined behavior, parameters and number of memory mapped locations, and their state cannot be set manually during runtime. Multiple units of same type can be added (e.g. two FRISC CT units at the same time).
  4. Select the interrupt level for the unit. Multiple units may be connected to the same interrupt, except for INT3 which is unmaskable.
  5. Define the start of the memory mapping for the unit as a HEX base memory location. Writing to memory locations mapped to an IO unit will result in sending data to the IO unit, not the memory module. Similarly, reading from a memory mapped location will result in receiving data from the IO unit, not the memory module.
  6. Define the number of memory mapped 4-byte locations. This number is pre-defined for standard FRISC IO units, and is configurable for Generic IO units.
  7. Define the required parameters for some units, e.g. the frequency for FRISC CT and PIO units.
  8. Click "Add" to create and display the unit. In case of errors, the error message will be logged to the log output screen. Each unit is displayed with its name, parameters, interrupt state and memory mapped locations. For each location, the address of the location and its value in decimal, hexadecimal and binary bases are shown. The interrupt state and memory mapped location values can be changed manually through the user interface for Generic IO unit types.
  9. Each unit can be removed by clicking the "X" button in the upper left corner, but only while the CPU is stopped.
  10. After adding all desired IO units, load the program into memory as described above. As the program executes, the state of the memory mapped locations and the interrupt state will automatically refresh.
  11. The state of the memory mapped locations for all IO units is automatically reset when the CPU is stopped, as described above.

Examples

This page contains examples for using FRISCjs. Each example is given as a brief description and a link to a configuration which can be loaded using the Load/Save tab. Just copy/paste the configuration into the import box and click "Import".

Simple addition example

This most basic example adds values from registers R0 and R1 and stores the result into R2.

All instructions example

This example doesn't do anything useful, but contains every FRISC instruction. Useful for testing and debugging.

FRISC CT example

This example uses a FRISC CT IO unit for simple counting - an in-memory counter is incremented for every 400 periods of the FRISC CT unit. The configuration contains a FRISC CT unit configured at 1000Hz.

FRISC PIO example

This example uses a FRISC PIO IO unit for reading 40 data items. The configuration contains a FRISC PIO unit configured at 1000Hz.

FRISC DMA example

This example uses a FRISC DMA IO unit for transferring 1000 4-byte words from an IO unit mapped on 0xFFFF3330 to memory starting from location 0x4000, using halting transfer mode.

About

FRISCjs is a simulator of the FRISC processor written in JavaScript. FRISC is a simple, educational RISC processor developed at the University of Zagreb, Faculty of Electrical Engineering and Computing. The simulator has two parts: a FRISC assembler (built using PEGjs) which translates FRISC assembly code to machine code and a FRISC CPU simulator which executes machine code. This Web application is a graphical interface for the simulator, while there also exists a console interface which runs on NodeJS.

Source code and bug reports

The complete source code for FRISCjs and this Web application is available on GitHub. Please use the GitHub issue tracker for reporting bugs and feature requests.

Credits and license

FRISCjs was developed by Ivan Zuzak. License: Apache 2.0. Contributors: Ivan Budiselic, Stanko Krtalic.

FRISCjs is built with many open-source projects: PEGjs, NodeJS, jQuery, Bootstrap, Ace, Mustache and Keymaster.

R0
0
R1
0
R2
0
R3
0
R4
0
R5
0
R6
0
R7
0
PC
0
SR
0
IIF
1

SR-N
0
SR-C
0
SR-V
0
SR-Z
0
SR-EINT0
0
SR-EINT1
0
SR-EINT2
0
SR-GIE
0
IO units