Advertisement
Guest User

CPLD CPU Info

a guest
Apr 5th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. CPU Data, this should give a rough idea on how i did my CPU, which can hopefully be useful to you to design your own further.
  2.  
  3. ---------------Structure:
  4. 8 bit Data Bus
  5. 16 bit Address Bus
  6. 7 bit Opcodes (bit 7 is thrown away)
  7. Instruction lenght(s): 1-3 bytes (including Opcode)
  8.  
  9. ---------------Registers:
  10. Accumulator (A) (8 bits)
  11. Secondary Register (B) (8 bits)
  12. Index Register (X) (8 bits)
  13. Page Register (N) (8 bits)
  14. Stack Pointer (SP) (16 bits)
  15. Program Counter (PC) (16 bits)
  16.  
  17. ---------------Addressing Modes:
  18.  
  19. Immediate: Operand is the value directly following the instruction
  20. OPC 0xLL (LL is the 8 bit data)
  21. OPC 0xHHLL (HHLL is the 16 bit data)
  22.  
  23. Absolute: Operand is an Address used to load the value
  24. OPC 0xHHLL (value is loaded from address 0xHHLL)
  25.  
  26. Asbolute X: Operand is an Address used to load the value, effective address is added with X
  27. OPC 0xHHLL (value is loaded from address 0xHHLL + X) (X is sign extended to 16 bits)
  28.  
  29. N-Page: Operand is an N-Page Address used to load the value, effective address is combined from the N Register and 0xLL
  30. OPC 0xLL (value is loaded from address 0xNNLL, where 0xNN is taken from the N Register)
  31.  
  32. N-Page X: Operand is an N-Page Address used to load the value, effective address is combined from the N Register and 0xLL plus X
  33. OPC 0xLL (value is loaded from address 0xNNLL + X, where 0xNN is taken from the N Register) (X is sign extended to 16 bits)
  34.  
  35. ---------------Arithmetic/Logic Instructions:
  36. Flags:
  37. Z (Zero) - set when an ALI outputs a result equal to 0
  38. C (Carry) - set when an ALI outputs a result that went above 0xFF (255)
  39. N (Negative) - set when an ALI outputs a result that went below 0x00 (0)
  40.  
  41. these are the basic ALIs i always try to implement:
  42. note that "S" refers to the "source", which is just the data that could come from any of the above mentioned Addressing Modes or a Register.
  43.  
  44. ADD - Addition - A + S -> A - Flags: Z C 0
  45. INC - Increment - S + 1 -> S - Flags: Z C 0
  46. SUB - Subtract - A - S -> A - Flags: Z 0 N
  47. DEC - Decrement - S - 1 -> S - Flags: Z 0 N
  48. AND - Logic AND - A & S -> A - Flags: Z 0 0
  49. OR - Logic OR - A ∥ S -> A - Flags: Z 0 0
  50. XOR - Logic XOR - A ⊻ S -> A - Flags: Z 0 0
  51. CMP - Compare - A ? S - Flags: Z C N
  52.  
  53. Compare stores no result, it only updates the flags.
  54. the flags function a bit differently when used in a Compare (CMP) instruction:
  55. Z - set when A = S
  56. C - set when A > S (unsigned)
  57. N - set when A < S (unsigned)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement