Skip to content

Assembler, simulator and documentation for the LAVAL computer

License

Notifications You must be signed in to change notification settings

jdecourval/laval-simulator

Repository files navigation

LAVAL simulator

This repository contains documentation and source code for the LAVAL CPU and its simulator. The LAVAL CPU is a custom made CPU architecture and ISA first made as a challenge for the CSGames 2018. Participants had to program simple algorithms in assembly.

For more information on the architecture, refer to the manual:

English documentation

Documentation française

LAVAL computer

Some examples programs are available here:

; Compute the base 2 logarithm of a rounded down. result = floor(log2(a))

.cores 1, 1, 2
.mem_number 5
.mem_size 5
.core_to_mem 0, 3
.in 0

0:
    MUX CURRENT, BEFORE, CURRENT
    MXL
    MUX CURRENT, CURRENT, AFTER
    JMP 1

1:
    JEZ 2
    LSR 1
    MXD
    SYN
    JMP 1

2:
    MXL
    SYN
    CSU 1
    HLT

3:
    MUX CURRENT, CURRENT, BEFORE
    JMP 4

4:
    SYN
    MXD
    CAD 1
    JMP 4

Getting Started

Prerequisites

To compile this project you need:

GCC >= 7.1
cmake

GCC 7 is available in ArchLinux Core repository and in Ubuntu 17.10. If you are using an older Ubuntu release, you can use this ppa to easily download a new GCC version. Any distros should work as long as you somehow install GCC 7.

It should be possible to build this project using a recent version of Clang but it currently have issues compiling some C++ features. Refer to 31852 and 33222 for more information. It is probably feasible to work around those bug by using clang's libc++ instead of GCC's libstdc++. Please contact me if you successfully built this project using clang.

To compile documentation from markdown to pdf, you need

pandoc

Compiling

Simulator:

mkdir build
cd build
cmake ..
make

Documentation:

cd doc
./build.sh

Running the tests

Tests are programmed using the Catch2 testing framework. After compiling, run the generated test executable:

./build/lib/tests/LavalTests

As of today, some tests are outdated, expect some failures.

Using the simulator

Please refer to its included help:

./build/sources/simulator --help

For most use cases, you probably want to both compile and simulate your programs like so:

./build/sources/simulator -cs lib/tests/integration/multiplication.laval

Called this way, the simulator will get its inputs from stdin. This also allows you to provide inputs using a file:

./build/sources/simulator -cs lib/tests/integration/gaussian_small.laval < lib/tests/integration/spaceship.in

Built With

  • catch2 - Test framework
  • cereal - Used by the assembler to serialize some structure to binary
  • GSL - A useful library to support modern and safe C++ development

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details.

Acknowledgments

  • TIS-100, an assembly language programming game nobody never asked for but greatly inspired me!

About

Assembler, simulator and documentation for the LAVAL computer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published