diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-14 00:04:10 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-04-14 00:56:48 +0300 |
| commit | e6d966cebc15e21cb64012d314f74f54dc35eead (patch) | |
| tree | f078c1b23063f8daf71fa0acebf1fed7f0e2781b /src | |
| parent | b5a8de55f896a6ce474fb6e9ccba2f33b019e74e (diff) | |
Get interrupts working
Diffstat (limited to 'src')
| -rw-r--r-- | src/asm_ops.py | 7 | ||||
| -rwxr-xr-x | src/ucode.py | 54 |
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]), ] |
