diff --git a/ABI.md b/ABI.md new file mode 100644 index 0000000..accef10 --- /dev/null +++ b/ABI.md @@ -0,0 +1 @@ +# Processor C ABI diff --git a/BOOT.md b/BOOT.md new file mode 100644 index 0000000..f0ab787 --- /dev/null +++ b/BOOT.md @@ -0,0 +1 @@ +# Processor booting method diff --git a/INSTRUCTIONS.md b/INSTRUCTIONS.md index 6ce6421..278cbb0 100644 --- a/INSTRUCTIONS.md +++ b/INSTRUCTIONS.md @@ -80,6 +80,11 @@ action: `A += q; [A] = imm32` ### ADDI ### ADDIC +### SUB Subtract +### SUBC Subtract with carry +### SUBI Subtract immediate +### SBIC Subtract immediate with carry + ### MLA Multiply and add syntax: `MLA A, Ra, Rb, Rc` action: `A = Rc + (Ra * Rb)` @@ -129,11 +134,8 @@ action: `A = F.C + imm + (Ra * Rb)` syntax: `SMLIAC A, Ra, imm, Rc` action: `A = F.C + Rc + (Ra * imm)` - -### SUB Subtract -### SUBC Subtract with carry -### SUBI Subtract immediate -### SBIC Subtract immediate with carry +### MUL, MULS, IMUL, MULI, etc. +can be macro'd with multiply and adds ### AND ### ANDI with immediate @@ -177,6 +179,24 @@ syntax: `RJZS imm` # Stack manipulation ### CALL +could be implemented with push/jump ### RCALL +could be implemented with pop/jump + ### PUSH ### POP + + +# Planned to haves + +- 1-cycle shift and add +- 1-cycle intger division +- floating point arithmetic +- interrupts +- atomic compare-and-swap +- atomic load-link/store-conditional +- memory management +- memory-mapped registers +- sine and cosine functions, see [cordic][1] + +[1]: https://en.wikipedia.org/wiki/CORDIC diff --git a/MEMORY_MAP.md b/MEMORY_MAP.md new file mode 100644 index 0000000..050df62 --- /dev/null +++ b/MEMORY_MAP.md @@ -0,0 +1,2 @@ +# Register memory map + diff --git a/decode.dig b/decode.dig new file mode 100644 index 0000000..678c603 --- /dev/null +++ b/decode.dig @@ -0,0 +1,279 @@ + + + 1 + + + + In + + + Label + I + + + Bits + 32 + + + + + + Splitter + + + Input Splitting + 32 + + + Output Splitting + 5,4,4,4,15 + + + + + + Out + + + Label + r0 + + + Bits + 4 + + + + + + Out + + + Label + r1 + + + Bits + 4 + + + + + + Out + + + Label + r2 + + + Bits + 4 + + + + + + ROM + + + AddrBits + 5 + + + Bits + 32 + + + Data + 1,2,3 + + + + + + Const + + + + + Out + + + Label + o + + + intFormat + bin + + + Bits + 32 + + + + + + Splitter + + + Input Splitting + 15 + + + Output Splitting + 4 + + + + + + Splitter + + + Input Splitting + 15 + + + Output Splitting + 5 + + + + + + Out + + + Label + r4 + + + Bits + 4 + + + + + + Out + + + Label + i5 + + + Bits + 5 + + + + + + Out + + + Label + i15 + + + Bits + 15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main.dig b/main.dig index 6ac719a..d6c1323 100644 --- a/main.dig +++ b/main.dig @@ -6,14 +6,154 @@ registers.dig - + alu.dig - + + + + sreg.dig + + + + + pc.dig + + + shapeType + SIMPLE + + + + + + decode.dig + + + + + RAMSinglePort + + + AddrBits + 16 + + + Bits + 32 + + + + + + Splitter + + + Input Splitting + 32 + + + Output Splitting + 16,16 + + + + + + Register + + + Label + IR + + + Bits + 32 + + + + + + Not + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pc.dig b/pc.dig new file mode 100644 index 0000000..921c73e --- /dev/null +++ b/pc.dig @@ -0,0 +1,282 @@ + + + 1 + + + + Add + + + Bits + 32 + + + + + + Register + + + Label + PC + + + Bits + 32 + + + + + + Multiplexer + + + Bits + 32 + + + + + + Const + + + Value + 4 + + + Bits + 32 + + + + + + Const + + + Value + 0 + + + + + + Out + + + Label + PC + + + Bits + 32 + + + + + + Out + + + Label + O + + + + + + Multiplexer + + + Bits + 32 + + + + + + In + + + Label + A + + + Bits + 32 + + + + + + In + + + Label + J + + + + + + In + + + Label + W + + + + + + Clock + + + Label + CK + + + + + + In + + + Label + RA + + + Bits + 32 + + + + + + In + + + Label + RJ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shift32.dig b/shift32.dig index 2fa3cf8..37177f5 100644 --- a/shift32.dig +++ b/shift32.dig @@ -20,14 +20,14 @@ Splitter - - Input Splitting - 1,31 - mirror true + + Input Splitting + 1,31 + Output Splitting 32 @@ -146,14 +146,14 @@ Splitter - - Input Splitting - 8,24 - mirror true + + Input Splitting + 8,24 + Output Splitting 32 @@ -225,7 +225,7 @@ 32 - + In @@ -239,7 +239,7 @@ 5 - + Splitter @@ -278,6 +278,10 @@ Splitter + + rotation + + Input Splitting 1*2 @@ -286,10 +290,6 @@ Output Splitting 2 - - rotation - - @@ -421,7 +421,7 @@ Ci - + Splitter @@ -437,16 +437,6 @@ - - In - - - Label - ROT - - - - Splitter @@ -488,7 +478,7 @@ nor32.dig - + Splitter @@ -502,7 +492,7 @@ 32 - + Not @@ -512,7 +502,7 @@ true - + Const @@ -522,7 +512,7 @@ 0 - + Splitter @@ -536,25 +526,25 @@ 1*32 - + Splitter - - Input Splitting - 1*32 - mirror true + + Input Splitting + 1*32 + Output Splitting 32 - + Multiplexer @@ -564,7 +554,7 @@ 32 - + Splitter @@ -578,7 +568,7 @@ 1*32 - + Splitter @@ -596,7 +586,7 @@ 32 - + Multiplexer @@ -606,41 +596,303 @@ 32 - + - In + Out Label - SHR + o + + + Bits + 32 - + Out Label - o + C_o + + + + + + In + + + Label + OP Bits - 32 + 3 - + - Out + Text - Label - C_o + Description + OPCODE for shifter + +000 -> logical shift left +001 -> logical shift right +010 -> shift left trough carry +011 -> shift right trough carry +110 -> arithmetic shift right +100 -> rotate left +101 -> rotate right + + + + + + And + + + inverterConfig + + In_1 + + + + + + + And + + + inverterConfig + + In_3 + + + + Inputs + 3 + + + + + + Splitter + + + Input Splitting + 3 + + + Output Splitting + 1*3 + + + + + + Or + + + + + Tunnel + + + NetName + inv + + + + + + And + + + inverterConfig + + In_2 + + + + + + + Tunnel + + + NetName + rot + + + + + + And + + + inverterConfig + + In_1 + + + + + + + Tunnel + + + NetName + shc - + + + + And + + + + + Tunnel + + + NetName + arit + + + + + + Tunnel + + + rotation + + + + NetName + inv + + + + + + Tunnel + + + rotation + + + + NetName + inv + + + + + + Tunnel + + + rotation + + + + NetName + rot + + + + + + Multiplexer + + + + + Multiplexer + + + + + Splitter + + + Input Splitting + 32 + + + Output Splitting + 1 + + + + + + Const + + + Value + 0 + + + + + + Tunnel + + + rotation + + + + NetName + shc + + + + + + Tunnel + + + rotation + + + + NetName + arit + + + + + + Multiplexer + + + Bits + 5 + + + + + + Const + + + Bits + 5 + + + @@ -652,22 +904,34 @@ + + + + - - + + - - + + + + + + + + + + @@ -689,16 +953,24 @@ - - + + + + + + - - + + - - + + + + + + @@ -713,112 +985,124 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + - - + + - - + + @@ -829,40 +1113,20 @@ - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + @@ -901,12 +1165,8 @@ - - - - - - + + @@ -916,6 +1176,10 @@ + + + + @@ -924,10 +1188,26 @@ + + + + + + + + + + + + + + + + @@ -940,13 +1220,25 @@ + + + + + + + + - - + + + + + + @@ -969,8 +1261,8 @@ - - + + @@ -993,44 +1285,48 @@ - - - - - - + + - - + + - - + + + + + + + + + + - - + + - - + + - - + + @@ -1041,12 +1337,12 @@ - - + + - - + + @@ -1109,24 +1405,24 @@ - - + + - - + + - - + + - - + + - - + + @@ -1137,17 +1433,21 @@ - - - - - - + + + + + + + + + + @@ -1169,8 +1469,8 @@ - - + + @@ -1189,60 +1489,64 @@ - - + + + + + + - - + + - - + + + + + + - - + + - - + + - - + + - - - - - - + + - - + + - - + + - - + + - - + + @@ -1253,17 +1557,29 @@ - - - - - - + + + + + + + + + + + + + + + + + + @@ -1281,23 +1597,23 @@ - - + + - - + + - + - - + + - + @@ -1316,21 +1632,37 @@ + + + + + + + + + + + + + + + + - - + + - - + + @@ -1345,36 +1677,36 @@ - - + + + + + + + + + + - + - - - - - - + + - - - - - - + + @@ -1384,17 +1716,45 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1433,36 +1793,16 @@ - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + @@ -1497,24 +1837,32 @@ - - + + - - + + + + + + + + + + - - + + @@ -1529,36 +1877,36 @@ - - + + + + + + - - + + - - + + - - - - - - + + - - + + @@ -1569,24 +1917,32 @@ - - + + - - + + + + + + + + + + - - + + - - + + @@ -1605,28 +1961,28 @@ - - + + - - + + - - + + - - + + - - + + @@ -1645,28 +2001,44 @@ - - + + - - + + - - + + - - + + - - + + + + + + + + + + - - + + + + + + + + + + @@ -1732,14 +2104,6 @@ - - - - - - - - @@ -1754,7 +2118,7 @@ - + @@ -1762,11 +2126,7 @@ - - - - - + @@ -1776,25 +2136,33 @@ + + + + - + - - + + + + + + - - + + @@ -1802,7 +2170,7 @@ - + @@ -1814,19 +2182,15 @@ - + - - - - - + - - + + @@ -1836,6 +2200,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1845,12 +2237,16 @@ - - + + + + + + - + @@ -1858,11 +2254,27 @@ - + + + + + + + + + + + + + + + + + - - + + @@ -1884,10 +2296,6 @@ - - - - @@ -1950,7 +2358,11 @@ - + + + + + @@ -1960,6 +2372,18 @@ + + + + + + + + + + + + @@ -1976,6 +2400,10 @@ + + + + @@ -2050,11 +2478,7 @@ - - - - - + @@ -2076,6 +2500,14 @@ + + + + + + + + @@ -2149,8 +2581,8 @@ - - + + diff --git a/sreg.dig b/sreg.dig new file mode 100644 index 0000000..4254b39 --- /dev/null +++ b/sreg.dig @@ -0,0 +1,498 @@ + + + 1 + + + + Register + + + Label + sreg + + + Bits + 32 + + + + + + Splitter + + + Input Splitting + 1*32 + + + Output Splitting + 32 + + + + + + In + + + Label + Z_i + + + + + + In + + + Label + C_i + + + + + + In + + + Label + N_i + + + + + + In + + + Label + V_i + + + + + + Const + + + Value + 0 + + + + + + Clock + + + Label + CK + + + + + + In + + + Label + w + + + + + + Splitter + + + Input Splitting + 32 + + + Output Splitting + 1*32 + + + + + + Out + + + Label + Z_o + + + + + + Out + + + Label + C_o + + + + + + Out + + + Label + N_o + + + + + + Out + + + Label + V_o + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file