102 SIC-1 8-bit SUBLEQ Single Instruction Computer

102 : SIC-1 8-bit SUBLEQ Single Instruction Computer

Design render

How it works

SIC-1 is an 8-bit Single Instruction computer. The only instruction it supports is SUBLEQ: Subtract and Branch if Less than or Equal to Zero. The instruction has three operands: A, B, and C. The instruction subtracts the value at address B from the value at address A and stores the result at address A. If the result is less than or equal to zero, the instruction jumps to address C. Otherwise, it proceeds to the next instruction.

Memory map

The SIC-1 computer has an address space of 256 bytes, and and 8-bit program counter. The first 253 bytes are used for the program memory, and the last 3 bytes are used for input, output, and for halting the computer:

Address Label Read Write
253 @IN ui pins Ignored
254 @OUT Returns 0 uo pins
255 @HALT Returns 0 Ignored

Setting the program counter to 253, 254, or 255 will halt the computer.

Each instruction is 3 bytes long, and the program counter is incremented by 3 after each instruction, except when a branch is taken.

For more information, check out the SIC-1 Assembly Language Reference.

Execution cycle

Each instruction takes 6 cycles to execute, regardless of whether a branch is taken or not. The execution of an instruction is divided into the following stages:

  1. Fetch A: Read the value at address PC
  2. Fetch B: Read the value at address PC+1
  3. Fetch C: Read the value at address PC+2
  4. Read valA: Read the value at address A
  5. Read valB: Read the value at address B
  6. Store: Subtract valB from valA, store the result at A, and branch if the result is less than or equal to zero.

The pseudocode for the execution cycle is as follows:

(1) A <= memory[PC]
(2) B <= memory[PC+1]
(3) C <= memory[PC+2]
(4) valA <= memory[A]
(5) valB <= memory[B]
(6) result <= valA - valB
    memory[A] <= result
    if result <= 0:
      PC = C
    else:
      PC = PC + 3

Control signals

The uio pins are used to load a program into the computer, and to control the computer:

uio pin Name Type Description
0 run input Start the computer
1 halted output Computer has halted
2 set_pc input Set the program counter to the value on ui pins
3 load_data input Load the value from the ui pins into the memory at the PC
4 out_strobe output Pulsed for one clock cycle when the computer writes to @OUT (uo pins)
5 dbg[0] input Debug select bit 0
6 dbg[1] input Debug select bit 1
7 dbg[2] input Debug select bit 2

Debug interface

The dbg pins are used to expose internal signals for debugging on the uo pins. When the dbg pins are set to 0, the uo pins will output the @OUT value. For other values of dbg, the uo pins will output the following signals:

dbg[2:0] Signal
0 None
1 PC
2 A
3 B
4 C
5 valA
6 result (valA - valB)
7 state (3 bits )

The state signal is a 3-bit value that represents the current state of the computer, corresponding to the execution cycle stages described above (1-6), and a 3-bit value of 0 when the computer is halted.

Programming the SIC-1

You can use the online SIC-1 app to compile and simulate your SIC-1 programs. Click on "Run game" and then "Apply for the job", close the "Electronic mail" popup. Paste the code and click on "Compile" (on the bottom left). You'll see the compiled code in the "Memory" window on the right, and will be able to step through the code.

To load a program and run a program, follow this sequence:

  1. Set the ui pins to 0 (target address)
  2. Pulse the the load_pc pin
  3. Set the ui pins to the value you want to load
  4. Pulse the load_data pin
  5. Repeat steps 3-4 until you have loaded the entire program
  6. Set the ui pins to the address you want to start at (usually 0)
  7. Pulse the set_pc pin
  8. Set the run pin to 1. The computer will start running the program, and the halted pin will go high when the program is done.

If you want to step through the program, you can pulse the run pin to advance one instruction at a time.

IO

#InputOutputBidirectional
0in[0]out[0]run
1in[1]out[1]halted
2in[2]out[2]set_pc
3in[3]out[3]load_data
4in[4]out[4]out_strobe
5in[5]out[5]dbg[0]
6in[6]out[6]dbg[1]
7in[7]out[7]dbg[2]

Chip location

Controller Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux Mux tt_um_chip_rom (Chip ROM) tt_um_factory_test (Tiny Tapeout Factory Test) tt_um_oscillating_bones (Oscillating Bones) tt_um_tt_tinyQV (TinyQV - Crowdsourced Risc-V SoC) tt_um_rejunity_atari2600 (Atari 2600) tt_um_rejunity_lgn_mnist (LGN hand-written digit classifier (MNIST, 16x16 pixels)) tt_um_izh_neuron_lite (LIF Neuron) tt_um_blptrk_weaving01 (weaving in silicon #1) tt_um_rte_eink_driver (E-ink display driver) tt_um_bleeptrack_prism (Prism) tt_um_zerotoasic_logo_screensaver (VGA Screensaver with Zero to ASIC Logo) tt_um_kianV_rv32ima_uLinux_SoC (KianV uLinux SoC) tt_um_nefelimet_updown_cntr (3-bit up-down counter) tt_um_wokwi_434917577229968385 (LIF neuron) tt_um_wokwi_434917320361309185 (TinyTapeout 2025) tt_um_wokwi_434917171311441921 (MC first Wokwi) tt_um_wokwi_434917344830882817 ('') tt_um_wokwi_434918300941464577 (WowkiProject) tt_um_wokwi_434917453767462913 (Mini Calculator v1) tt_um_wokwi_434917219039482881 (and) tt_um_wokwi_434917025263649793 (DigOTA) tt_um_wokwi_434917044822739969 (TinyTapeoutWorkshop) tt_um_wokwi_434921821909078017 (and gate) tt_um_wokwi_434917167895180289 (Encoder) tt_um_wokwi_434917143298726913 (Chip design from Wokwi) tt_um_wokwi_434921804663145473 (Tapeout try) tt_um_wokwi_434917374201501697 (dummy) tt_um_wokwi_434917318393129985 (Tiny Tapeout Template Copy) tt_um_wokwi_434917632188986369 (Timo 1) tt_um_wokwi_434917842159020033 (And Gate) tt_um_wokwi_434917427319226369 (Tiny Tapeout Chip) tt_um_wokwi_434917260383792129 (Tiny Tapeout Workshop Project by Nick Figner) tt_um_wokwi_434917040492120065 (4 bit incrementer) tt_um_wokwi_434917990496885761 (Projekt) tt_um_wokwi_434917381796339713 (Nils Tinytapeout Proj) tt_um_wokwi_434917317189363713 (tinytapeoutchip) tt_um_wokwi_434917679388544001 (tiny tapeout chip) tt_um_wokwi_434917506576906241 (ToDo) tt_um_wokwi_434917139713644545 (in progress) tt_um_wokwi_434917382645687297 (numbers) tt_um_wokwi_434917816595781633 (number display) tt_um_wokwi_434918311072808961 (GG) tt_um_wokwi_434917362908337153 (noclue) tt_um_wokwi_434917682511205377 (Random) tt_um_wokwi_434925031692840961 (demo-tiny) tt_um_wokwi_434917760986646529 (Barans erster Template Design) tt_um_wokwi_434917419779963905 (Tapeout Test1) tt_um_wokwi_434917684709021697 (Tiny Tapeout Template Copy_Orion) tt_um_wokwi_434918956220790785 (Simple classification perceptron ) tt_um_wokwi_434918068909406209 (Tiny Tapeout) tt_um_parx (example-verilog) tt_um_wokwi_434917624377094145 (brostarscard) tt_um_urish_simon (Simon Says memory game) tt_um_emmk_riscv (ENSEIRB-MATMECA RISC-V ASIC) tt_um_abhinav8prasad_dds (8-bit DDS sine wave generator) tt_um_wokwi_436554456427191297 (OCDCpro TT key lock test design IHP) tt_um_wokwi_434391222509479937 (4-Bit Adder) tt_um_ihp_logo_screensaver (VGA Screensaver with the IHP Logo) tt_um_pqn (PQN Model with Verilog) tt_um_Xelef2000 (RNG) tt_um_gamepad_pmod_demo (Gamepad Pmod Demo) tt_um_anujic (Morse Code Trainer) tt_um_rodald_cpr (CRP - Custom Risc Processor) tt_um_alif_dual_unileak (LIF Neuron) tt_um_riscv_mini_ihp (RISC-V Mini IHP) tt_um_wokwi_434917200607612929 (test_design) tt_um_alif_single_dualleak (Simple LIF Neuron) tt_um_blptrk_weaving02 (weaving in silicon #2) tt_um_blptrk_weaving03 (weaving in silicon #3) tt_um_blptrk_weaving04 (weaving in silicon #3) tt_um_dumbrv_yliu_hashed (DUMBRV) tt_um_iz_neuron (IZH Neuron) tt_um_test_chip_pius (Verilog OR-Gate) tt_um_pwm_block (PWM_SPI) tt_um_2048_vga_game (2048 sliding tile puzzle game (VGA)) tt_um_dpi_adexp (AdExp DPI Neuron ) tt_um_urish_sic1 (SIC-1 8-bit SUBLEQ Single Instruction Computer) tt_um_cedrichirschi_sar (SAR ADC Controller) tt_um_htfab_yadge (Yet Another Diffraction Grating Experiment) tt_um_ds_comp_adc (Delta Sigma Comparator Based ADC) tt_um_tinytapeout_logo_screensaver (VGA Screensaver with Tiny Tapeout Logo) Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available Available