Skip to content

Commit

Permalink
feat: update project tt_um_urish_sic1 from urish/tt09-sic1
Browse files Browse the repository at this point in the history
Commit: 9f8cb77c9747f58f884ffce7adcc596b1a5da6c4
Workflow: https://github.com/urish/tt09-sic1/actions/runs/11767311260
  • Loading branch information
TinyTapeoutBot authored and urish committed Nov 10, 2024
1 parent ad8ccd7 commit db564f8
Show file tree
Hide file tree
Showing 8 changed files with 29,606 additions and 29,061 deletions.
4 changes: 2 additions & 2 deletions projects/tt_um_urish_sic1/commit_id.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"app": "Tiny Tapeout tt09 a48b1c74",
"repo": "https://github.com/urish/tt09-sic1",
"commit": "42a434910c15a7a5b44e995b5a2dcaf4f9e743dc",
"workflow_url": "https://github.com/urish/tt09-sic1/actions/runs/11759574626",
"commit": "9f8cb77c9747f58f884ffce7adcc596b1a5da6c4",
"workflow_url": "https://github.com/urish/tt09-sic1/actions/runs/11767311260",
"sort_id": 1731188988566,
"openlane_version": "OpenLane2 2.1.9",
"pdk_version": "open_pdks bdc9412b3e468c102d01b7cf6337be06ec6e9c9a"
Expand Down
60 changes: 57 additions & 3 deletions projects/tt_um_urish_sic1/docs/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ You can also include images in this folder and reference them in the markdown. E

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.

The SIC-1 computer has an address space of 256 bytes, and and 8-bit program counter. The first 253 bytes are used for program memory, and the last 3 bytes are used for input, output, and for halting the computer:
### 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 |
|---------|-------|-----------|-----------|
Expand All @@ -25,6 +27,58 @@ Each instruction is 3 bytes long, and the program counter is incremented by 3 af

For more information, check out the [SIC-1 Assembly Language Reference](https://github.com/jaredkrinke/sic1/blob/master/sic1-assembly.md).

## How to test
### 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) |

## Programming the SIC-1

You can use the [https://jaredkrinke.itch.io/sic-1](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.

Programming & testing instructions will be added later.
If you want to step through the program, you can pulse the `run` pin to advance one instruction at a time.
2 changes: 1 addition & 1 deletion projects/tt_um_urish_sic1/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pinout:
uio[1]: "halted"
uio[2]: "set_pc"
uio[3]: "load_data"
uio[4]: ""
uio[4]: "out_strobe"
uio[5]: ""
uio[6]: ""
uio[7]: ""
Expand Down
Loading

0 comments on commit db564f8

Please sign in to comment.