URL
https://opencores.org/ocsvn/tinycpu/tinycpu/trunk
Subversion Repositories tinycpu
[/] [tinycpu/] [trunk/] [docs/] [design.md.txt] - Rev 5
Go to most recent revision | Compare with Previous | Blame | View Log
This is the design of TinyCPU. It's goals are as follows:1. 8-bit registers and operations (8 bit processor)2. 16-bit address bus3. fixed 16-bit instruction length4. use a small amount of "rich" instructions to do powerful things5. 1 instruction per clock cycleRegister list:r0-r5 general purpose registerssp stack pointer (represented as r6)ip instruction pointer register (represented as r7)cs, ds, es, ss segment registers (code segment, data segment, extra segment, stack segment)tr truth register for conditionalsgeneral opcode formatfirst byte:first 4 bits: actual instructionnext 3 bits: (target) registerlast 1 bit: conditionalsecond byte:first 1 bit: second portion of condition (if not immediate) (1 for only if false)next 1 bit: use extra segmentnext 3 bits: other registerlast 3 bits: extra opcode information or third register. such as for ADD it could be target=source+third_register...or second byte is immediate valueFor opcodes requiring 3 registers but without room, the target opcode is assume to be the second operation. Such as for AND, target=source AND targetshort list of instructions: (not final, still planning)immediates:1. move reg, immediate2. move [reg], immediate3. push and move reg, immediate (or call immediate)4. push immediate5. jmp immediategroups: (limited to 2 registers and no immediates. each group has 8 opcodes)group 1:move(store) [reg],regmove(load) reg,[reg]out reg1,reg2 (output to port reg1 value reg2)in reg1,reg2 (input from port reg2 and store in reg1)pop regpush regmove segmentreg,regmove reg,segmentreggroup 2:and reg1,reg2 (reg1=reg1 and reg2)or reg, regxor reg,regnot reg1,reg2 (reg1=not reg2)left shift reg,regright shift reg,regrotate right reg,regrotate left reg,reggroup 3: comparesis greater than reg1,reg2 (TR=reg1>reg2)is greater or equal to reg,regis less than reg,regis less than or equal to reg,regis equal to reg,regis not equal to reg,regequals 0 regnot equals 0 reggroup 4:push segmentregpop segmentregpush and move reg, reg (or call reg)exchange reg,regexchange reg,segclear TRSet TRgroup 5:increment regdecrement regfar jmp reg1, reg2 (CS=reg1 and IP=reg2)far call reg1,reg2far jmp [reg] (first byte is CS, second byte is IP)push extended segmentreg, reg (equivalent to push seg; push reg)pop extended segmentreg, reg (equivalent to pop reg; pop seg)reset processor (will completely reset the processor to starting state, but not RAM or anything else)3 register instructions:1. add reg1, reg2, reg3 (reg1=reg2+reg3)2. sub reg1, reg2, reg3opcodes used: 12 of 16. 4 more opcodes available. Decide what to do with the room later.0 -nop (doesn't do a thing)1 -move immediate (only uses first byte)2 -move3 -push4 -push immediate5 -push and move (or call when acting on ip)6 -compare (is less than, is less than or equal, is greater than, is greater than or equal, is equal, is not equal) (6 conditions room for 2 more in extra)7 -add8 -subtract9 -bitwise operations (xor, or, and, shift right, shift left, not)x -multiply (if room)x -divideconditionals0 -- always1 -- only if truefor only if false, there should basically be another compare or if applicable an always afterwardspushpopmoveaddsublimitations that shouldn't be passed with instructions* Doing 2 memory references* pushing a memory reference (equates to 2 memory references)Note it is possible however to read and write 16bits at one time to the memory to consecutive addresses.segments:DS is used in all "normal" memory referencesSS is used in all push and pop instructionsES is used when the ExtraSegment bit is set for either push/pop or normal memory referencesCS is only used for fetching instructions
Go to most recent revision | Compare with Previous | Blame | View Log
