Introduction #
CPUlm is a reduced-instruction set computer (RISC) processor with support for arithmetic-logic instructions (including multiplication and division), conditional and unconditional jumps, memory reading and writing, etc. The documentation of the full instruction set and the assembly language are given here (in French).
The ecosystem includes:
- the processor netlist itself (automatically generated from Python code)
- a netlist simulator written in C++,
- a netlist optimizing compilator written in OCaml (that generates C code),
- a virtual machine implementing the CPUlm instruction-set architecture (ISA), written in C++,
- the clock program written in CPUlm assembly code.
This project was originally written as part of the CPU design course at the Ecole Normale Normale Superieure de Paris. The work was carried out in a group, whose members are listed below:
- Gabriel Desfrene ,
- Hubert Gruniaux (myself),
- Vincent Jules, and,
- Clément Rouvroy .
The slides of the presentation are available here (in French).
The syntax supported by the assembler along with the instructions and virtual instructions implemented are defined here (in French).
There is also a very sparse, mainly the outline of the CPU circuit, documentation of the CPU here (in French).
Example of assembly code #
You can find the source code of the clock program (the one you see at the top of the page) in the repo https://github.com/CPUlm/Meta . These are the program.ulm and drawing.ulm files.
A smaller example is provided to give a vague idea of the assembly code understood by our CPU:
; Function: int add(int x, int y)
add:
add rout r20 r21
ret
; Function: int abs(int x)
abs:
test r20
jmp.n $_branch ; jump if r20 is negative
mov rout r20
_branch:
loadi rout 0
; Function: void main()
main:
loadi r20 5
loadi r21 10
call $add
mov r0 rout
; print r0 someway...
halt
Overview of the CPU #

The CPU netlist is written in Python using the carotte.py library. It can be found here .
Once the Python is executed, an output cpulm.net
file is generated that contains the description of the netlist (list of logical gates and their connections).
A (very) small overview of cpulm.net
:
...
_l_3805 = XOR _l_3803 _l_3804
_l_3806 = XOR _l_3805 _l_3801
_l_3807 = AND _l_3805 _l_3801
_l_3808 = AND _l_3803 _l_3804
_l_3809 = OR _l_3807 _l_3808
_l_3810 = CONCAT _l_3802 _l_3806
_l_3811 = SELECT 3 _l_3785
_l_3812 = SELECT 3 _l_3786
_l_3813 = XOR _l_3811 _l_3812
_l_3814 = XOR _l_3813 _l_3809
_l_3815 = AND _l_3813 _l_3809
_l_3816 = AND _l_3811 _l_3812
_l_3817 = OR _l_3815 _l_3816
_l_3818 = CONCAT _l_3810 _l_3814
...
This netlist can then be:
- simulated,
- compiled to C, or
- used to make a real circuit.