Tesla-A16D16 Processing Unit
Description:
The Tesla-A16D16 is the smallest 16-Bit computer/processor on Powder Toy at 155x92 pixels in size.
The A16D16 can either be used as a standalone computer by running it off of internal memory alone, or as a processor component by connecting it to external memory chips or even slave processors/coprocessors.
Physical:
The T-A16D16 has seventeen registers: One Program Counter (PC), one Operation Output Register (R0), and fifteen General Purpse Registers (R1-RF)
The processor has four condition flags: The Carry Flag, Zero Flag, Equal Flag, and the Greater Than/Lesser Than flag (set = greater/equal, unset = lesser).
The ALU in the A16D16 has three primary components: The AU (Arithmetic Unit), in charge of mathematical operations; RU, (Relativity Unit), which determines if numbers are equal, greater, or lesser than one another; And the LU (Logic Unit), which handles bit-logic operations.
Pinout:
The T-A16D16 has 6 I/O pulse ports, and four I/O data ports.
P0:"START", Input, resumes operation if the processor is stopped.
P1:"STOPPED", Output, pulses if the processor stops.
P2:"OPRUN", Output, pulses upon executing a command.
P3:"PCOVERFLOW", Output, pulses if the Program Counter overflows.
P4:"ROMMODE", Input, sets the internal disk to ROM mode.
P5:"RAMMODE", Input, sets the internal disk to RAM mode.
AO:"ADDRESSOUT", Output, a DMP signal that is sent out of the address that is being pointed to is greater than 0x00FF.
DI:"DATAIN", Input, SBS or Raw Spectra data expected to be taken in after a data read from memory, is not expected if read from interal memory.
DO:"DATAOUT", Output, output from the internal information bus.
MDI:"MEMORYDATAIN", Input, data in specifically for the internal memory, value used to write.
Memory
The T-A16D16 has one tellabyte (0x100 bytes) of internal TMM, "Toggle Mode Memory", mapped to addresses 0x0000 to 0x00FF.
The TMM has two modes, ROM mode and RAM mode.
The memory in the disk is not connected to the data bus in the A16D16. It's recommended that, if a user wishes to write to the disk, they forward the DO port to the DMI port.
Timing:
1 :Send DMP read request at address of Program Counter
2 :Increment Program Counter. If Program Counter overflows, send a PCOVERFLOW pulse
3 :If requested address is greater than 0x0100, send DMP request to internal TMM. Else, send DMP request out of AO port
4 :Wait for DATAIN pulse
5 :Load bits 8 to 11 (0x-X--) into condition checker
6 :Load bits 12 to 15 (0xX---) into Control Unit
7 :Run condition check
8 :If condition is 0xF, "STOP", send STOP pulse, wait for START pulse and then go to step 10
9 :If condition is not met, go to step one
10:Move the selector on the Control unit to the opcode defined in the command
11:Pulse the selector and reset its position, and send an OPRUN pulse
12:Run operation
13:Go to step 1
Commands:
|Decimal
| |Hexidecimal
| | |Binary
| | | |Effects flags
| | | | |Length in bytes
| | | | | |Mneumonic
|00|0|0000|0000|1|Nop
|01|1|0001|00=g|1|Eval rg1,rg2
|02|2|0010|0000|1|RL rg1,d4
|03|3|0011|0000|1|RR rg1,d4
|04|4|0100|0000|2|LD rg1,d16
|05|5|0101|0000|1|LD rg1,rg2
|06|6|0110|0000|1|LD rg1,(rg2)
|07|7|0111|0000|1|LD (rg1),rg2
|08|8|1000|0000|1|JR a8
|09|9|1001|0000|1|JP rg1
|10|A|1010|cz00|1|Add rg1,d4
|11|B|1011|cz00|1|Add rg1,rg2
|12|C|1100|0000|1|And rg1,rg2
|13|D|1101|0000|1|Or rg1,rg2
|14|E|1110|0000|1|Xor rg1,rg2
|15|F|1111|0000|1|Inv rg1
Nop
Nybble:0x0, 0000
Example: "Nop" Does nothing
No Operation
Eval rg1,rg2
Nybble:0x1, 0001
Example: "Eval R7,R3" Evaluates Register 7 as the first number and Register 3 as the second
Resets Equals and GTR/LSR flags.
Sets the Equals flag if the selected registers are equal.
Sets the GTR/LSR flag if the first register is greater than or equal to the second register
RL rg1,d4
Nybble:0x2, 0010
Example: "RL R6,4" will shift R6 left by two bits
Bit shifts a register right and loads the result into the same register. Can move a maxiumum of four bits to the left. d4 Must equal 2^n, or 0, n being an integer between zero and three, or else the operation will be ineffective.
RR rg1,d4
Nybble:0x3, 0011
Example: "RL R5,8" will shift right R6 by three bits
Bit shifts a register right and loads the result into the same register. Can move a maxiumum of four bits to the left. d4 Must equal 2^n, or 0, n being an integer between zero and three, or else the operation will be ineffective.
LD rg1,d16
Nybble:0x4, 0100
Example: "LD RB,0504" loads 0x0505 into Register B
Loads a 16-Bit value into a register. Note, this is the only two-byte instruction.
LD rg1,rg2
Nybble:0x5, 0101
Example: "LD RE,R2" loads Register 2 into Register E
Loads a 16-Bit value from register two into register one.
LD rg1,(rg2)
Nybble:0x6, 0110
Example: "LD R9,(R8)" loads the 16-bit data at the address in Register 8 into Register 9
Loads a 16-Bit value from memory at the address of the second register into the first register
LD (rg1),rg2
Nybble:0x7, 0111
Example: "LD (R2),RF" loads the 16-bit data in Register F into the memory at the adress stored in Register 2
Loads the 16-Bit value of the second register into memory at the address of the first register
JR a8
Nybble:0x8, 1000
Example: "JR 82" sets the lower eight bytes of the Program Counter to 0x82
Loads bits 0-7 with an 8-bit value. Used for short-distance jumps.
JP rg1
Nybble:0x9, 1001
Example: "JP R2" loads Register 2 into the Program Counter
Loads the first register into the Program counter
Add rg1,d4
Nybble:0xA, 1010
Example: "Add R4,3" Adds three to the value in Register 4 and loads it back into Register 4
Resets the Carry and Zero flags. Carry flag is set if the operation causes an overflow. Zero flag is set if the result equals zero.
Adds a 4-bit value to the first register and loads the result into the first register.
Even though the A16D16 does not have a dedicated Increment OPCode, one can easily emulate it by setting the d4 to 1.
Add rg1,rg2
Nybble:0xB, 1011
Example: "Add R3,R8" Adds Register 3 and Register 8 and loads the result into Register 0
Resets the Carry and Zero flags. Carry flag is set if the operation causes an overflow. Zero flag is set if the result equals zero.
Adds the first register to the second register. The result is stored in Register 0, regardless of the inputs.
And rg1,rg2
Nybble:0xC, 1100
Example: "And RD,R4" Does a bitwise AND of Register D and Register 4 and loads the result into Register 0
Does a bitwise AND of the first register to the second register. The result is stored in Register 0, regardless of the inputs.
Or rg1,rg2
Nybble:0xD, 1101
Example: "Or R2,R5" Does a bitwise OR of Register 2 and Register 5 and loads the result into Register 0
Does a bitwise OR of the first register to the second register. The result is stored in Register 0, regardless of the inputs.
Xor rg1,rg2
Nybble:0xE, 1110
Example: "Xor RA,RC" Does a bitwise XOR of Register A and Register C and loads the result into Register 0
Does a bitwise XOR of the first register to the second register. The result is stored in Register 0, regardless of the inputs.
Inv rg1
Nybble:0xF, 1111
Example: "Inv R3" Inverts Register 3
Inverts every bit of the first register and loads it back into the first register
Conditions
|Decimal
| |Hexidecimal
| | |Binary
| | | |Mneumonic
| | | | |Condition
|00|0|0000| |Run Regardless of Flags
|01|1|0001|x |Do not Run Regardless of Flags
|02|2|0010|c |Run if Carry
|03|3|0011|nc |Run if not Carry
|04|4|0100|z |Run if Zero
|05|5|0101|nz |Run if not Zero
|06|6|0110|= |Run if Equal
|07|7|0111|≠ |Run if not Equal
|08|8|1000|≥ |Run if Greater Than/Equal to
|09|9|1001|< |Run if Lesser Than
|10|A|1010|> |Run if Greater Than
|11|B|1011|znc |Run if Zero and not Carry
|12|C|1100|cnz |Run if Carry and not Zero
|13|D|1101|cz |Run if Carry and Zero
|14|E|1110|nznc|Run if not Carry and not Zero
|15|F|1111|STOP|Do not run until start pulse
You should make a tutorial on how to build these, then people can truly appreciate your work and not just stare at them hours on end figuring out where the first spark comes from :P
All in all I'm a big fan of your work! Keep it up!
Absolutely love looking at your saves. You probably could go even further with @dom2mom's YouTube videos, but I think you're more advanced. Keep up the good work!