aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asm_ops.py7
-rwxr-xr-xsrc/ucode.py54
2 files changed, 38 insertions, 23 deletions
diff --git a/src/asm_ops.py b/src/asm_ops.py
index 61e2caa..78ec356 100644
--- a/src/asm_ops.py
+++ b/src/asm_ops.py
@@ -109,6 +109,11 @@ def make_lpc(meta: Meta, symbols: Symbols, target: str) -> int:
(target_e << 9)
return word
+def make_rti(meta: Meta, symbols: Symbols) -> int:
+ """RTI 1110 XXXX XXXX XXXX"""
+ word = (0b1110 << 12)
+ return word
+
def make_hlt(meta: Meta, symbols: Symbols) -> int:
"""HLT 1111 XXXX XXXX XXXX"""
word = (0b1111 << 12)
@@ -126,6 +131,7 @@ operations: OpWordDict = {
"brr": make_brr,
"bri": make_bri,
"lpc": make_lpc,
+ "rti": make_rti,
"hlt": make_hlt,
}
@@ -147,6 +153,7 @@ default_expansions: OpExpansionDict = {
"brr": lambda *args: expand_id("brr", *args),
"bri": lambda *args: expand_id("bri", *args),
"lpc": lambda *args: expand_id("lpc", *args),
+ "rti": lambda *args: expand_id("rti", *args),
"hlt": lambda *args: expand_id("hlt", *args),
}
diff --git a/src/ucode.py b/src/ucode.py
index 1d050c8..07d0554 100755
--- a/src/ucode.py
+++ b/src/ucode.py
@@ -12,26 +12,34 @@ if len(sys.argv) != 2:
outfile_path = sys.argv[1]
-PC_CO = 0b0000_0000_0000_0001
-PC_IE = 0b0000_0000_0000_0010
-PC_OE = 0b0000_0000_0000_0100
-MAR_IE = 0b0000_0000_0000_1000
-MEM_IE = 0b0000_0000_0001_0000
-MEM_OE = 0b0000_0000_0010_0000
-RW_IE = 0b0000_0000_0100_0000
-R1_OE = 0b0000_0000_1000_0000
-R2_OE = 0b0000_0001_0000_0000
-IR_IE = 0b0000_0010_0000_0000
-IM_M = 0b0000_0100_0000_0000
-LI_OE = 0b0000_1000_0000_0000
-ALU_OE = 0b0001_0000_0000_0000
-FR_IE = 0b0010_0000_0000_0000
-HALT = 0b0100_0000_0000_0000
-US_RS = 0b1000_0000_0000_0000
+PC_CO = 1 << 0
+PC_IE = 1 << 1
+PC_OE = 1 << 2
+MAR_IE = 1 << 3
+MEM_IE = 1 << 4
+MEM_OE = 1 << 5
+RW_IE = 1 << 6
+R1_OE = 1 << 7
+R2_OE = 1 << 8
+IR_IE = 1 << 9
+IM_M = 1 << 10
+LI_OE = 1 << 11
+ALU_OE = 1 << 12
+FR_IE = 1 << 13
+HALT = 1 << 14
+US_RS = 1 << 15
+ISRA_OE = 1 << 16
+IM_DS = 1 << 17
+IM_EN = 1 << 18
+IPC_IE = 1 << 19
+IPC_OE = 1 << 20
+NOP5 = 1 << 21
+NOP6 = 1 << 22
+NOP7 = 1 << 23
BRANCH_FLAG_STATES_N = 2
UCODE_N: int = 2**3
-CONTROL_WORD_SIZE = 2
+CONTROL_WORD_SIZE = 3
def not_branch(bs: list[int]) -> list[list[int]]:
return BRANCH_FLAG_STATES_N * [bs]
@@ -71,12 +79,12 @@ ucode = [
nop(),
# NOP 1011 XXXX XXXX XXXX
nop(),
- # NOP 1100 XXXX XXXX XXXX
- nop(),
- # NOP 1101 XXXX XXXX XXXX
- nop(),
- # NOP 1110 XXXX XXXX XXXX
- nop(),
+ # ISRP0 1100 XXXX XXXX XXXX
+ not_branch([IM_EN|PC_OE|IPC_IE, ISRA_OE|MAR_IE, MEM_OE|PC_IE, US_RS, 0, 0, 0, 0]),
+ # ISRP1 1101 XXXX XXXX XXXX
+ not_branch([IM_EN|PC_OE|IPC_IE, ISRA_OE|MAR_IE, MEM_OE|PC_IE, US_RS, 0, 0, 0, 0]),
+ # RTI 1110 XXXX XXXX XXXX
+ not_branch([*fetch, IM_DS|IPC_OE|PC_IE, US_RS, 0, 0, 0, 0]),
# HLT 1111 XXXX XXXX XXXX
not_branch([*fetch, HALT, 0, 0, 0, 0, 0]),
]