From 3b6e25a9b36e938d12595212cb13fd681d33d33d Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Fri, 10 Jan 2020 21:44:15 -0500 Subject: [PATCH] Add a revision of the ISA design --- .gitignore | 2 ++ isa.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 isa.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be30245 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +\#*# +*.swp diff --git a/isa.txt b/isa.txt new file mode 100644 index 0000000..4c77802 --- /dev/null +++ b/isa.txt @@ -0,0 +1,43 @@ +ALU2: add sub and lsl rol or xor bic +ALU1: inc dec neg compl +ALUI: add7 sub6 lsl lsr asr rot and or xor + +76543210 +-------- +0000aabb => MOVE: a = b # when a != b +0000aabb => CALL: call a # when a == b, r0 <- ret +0001aaoo => ALU1: a = op a +001faa00 0iiiiiii => LDST: a <-> [imm] +001faa00 1iiiiibb => LDST: a <-> [b + imm] +001faa10 => LDST: a <-> [r2] +001faabb => LDST: a <-> [b-1:b] +0100aabb iiiiiiii => JMPR: jump aa # when a == b +01010000 iiiiiiii => JMPI: jump offset +01010101 iiiiiiii => CALI: call offset +01010101 iiiiiiii => CALI: call offset +010oaabb oiiiiiii => BRNC: branch if a op b +0110aa00 0iiiiiii => ALUI: a = a + imm +0110aa00 10iiiiii => ALUI: a = a - imm +0110aa00 11oooiii => ALUI: a = a op imm +0110aaoo iiiiiiii => ALUI: a = a {and, or, xor} imm +0111aabb => SKIP: skip if a ule b +1oooaabb => ALU2: a = a op b + + +Encoding branch conditions: +We want: eq/ne, test/testn, lt/gt, ule/ugt +We have 2 operand bits, so we can encode eq, test, lt, ult, and get the negations by swapping operands. +For example, if aa < bb, then we use eq, and if bb < aa, we use ne. +This is natural for lt/gt, and the comparison for eq/ne etc. just needs 1 LUT4. + +Load/store should use register pairs, and then specific registers numbers can encode whether it should use the larger instructions. + +Skip is valuable because it lets you implement wider add/sub with a relatively short instruction sequence. +For instance, you can do: + +a1 = a1 + b1 +a2 = a2 + b2 +skip if b1 ule a1 +a2 = inc a2 + +to compute [a2:a1] + [b2:b1] -- 2.47.0