Splitting instructions into their own mermaid figure
This commit is contained in:
parent
273628c41a
commit
99c8de87b1
1 changed files with 44 additions and 106 deletions
150
README.md
150
README.md
|
@ -10,12 +10,11 @@ classDiagram
|
||||||
+ void run()
|
+ void run()
|
||||||
}
|
}
|
||||||
class Memory {
|
class Memory {
|
||||||
+ abstract Word read(Address address)
|
+ Word read(Address address)
|
||||||
+ abstract int size()
|
+ int size()
|
||||||
+ abstract void write(Address address, Word data)
|
+ void write(Address address, Word data)
|
||||||
+ abstract void dump()
|
+ void dump()
|
||||||
}
|
}
|
||||||
class Program
|
|
||||||
class ProgramCounter {
|
class ProgramCounter {
|
||||||
- int PC
|
- int PC
|
||||||
- int SysTick
|
- int SysTick
|
||||||
|
@ -29,32 +28,10 @@ classDiagram
|
||||||
+ boolean halted()
|
+ boolean halted()
|
||||||
+ void halt()
|
+ void halt()
|
||||||
}
|
}
|
||||||
class Instruction {
|
class Program
|
||||||
+ abstract void execute(Memory memory, ProgramCounter pc)
|
|
||||||
# abstract String opcode()
|
|
||||||
# abstract Object[] operands()
|
|
||||||
+ abstract String toString()
|
|
||||||
}
|
|
||||||
class ArrayList
|
class ArrayList
|
||||||
class Word {
|
class Word {
|
||||||
+ abstract <T> T getValue()
|
+ <T> T getValue()
|
||||||
+ abstract Word add(Word other)
|
|
||||||
+ abstract Word subtract(Word other)
|
|
||||||
+ abstract Word multiply(Word other)
|
|
||||||
+ abstract Word divide(Word other)
|
|
||||||
+ abstract String toString()
|
|
||||||
+ abstract boolean equals(Object other)
|
|
||||||
}
|
|
||||||
class Address {
|
|
||||||
- int address
|
|
||||||
+ Address(int address)
|
|
||||||
+ int getAddress()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class LongWord {
|
|
||||||
- Long value
|
|
||||||
+ LongWord(Long value)
|
|
||||||
+ Long getValue()
|
|
||||||
+ Word add(Word other)
|
+ Word add(Word other)
|
||||||
+ Word subtract(Word other)
|
+ Word subtract(Word other)
|
||||||
+ Word multiply(Word other)
|
+ Word multiply(Word other)
|
||||||
|
@ -62,88 +39,49 @@ classDiagram
|
||||||
+ String toString()
|
+ String toString()
|
||||||
+ boolean equals(Object other)
|
+ boolean equals(Object other)
|
||||||
}
|
}
|
||||||
class Add {
|
class Address {
|
||||||
- Address src
|
- int address
|
||||||
- Word imm
|
+ Address(int address)
|
||||||
- Address dest
|
+ int getAddress()
|
||||||
+ Add(Address src, Word imm, Address dest)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
+ String toString()
|
||||||
}
|
}
|
||||||
class Copy {
|
class LongMemory
|
||||||
- Word imm
|
class LongWord
|
||||||
- Address dest
|
|
||||||
+ Copy(Word imm, Address dest)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class Halt {
|
|
||||||
+ Halt()
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class Jump {
|
|
||||||
- int index
|
|
||||||
+ Jump(int index)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class JumpEq {
|
|
||||||
- int index
|
|
||||||
- Address src
|
|
||||||
- Word imm
|
|
||||||
+ JumpEq(int index, Address src, Word imm)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class Mul {
|
|
||||||
- Address src1
|
|
||||||
- Address src2
|
|
||||||
- Address dest
|
|
||||||
+ Mul(Address src1, Address src2, Address dest)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
class Print {
|
|
||||||
- Address address
|
|
||||||
+ Print(Address address)
|
|
||||||
+ void execute(Memory memory, ProgramCounter PC)
|
|
||||||
+ String opcode()
|
|
||||||
+ Object[] operands()
|
|
||||||
+ String toString()
|
|
||||||
}
|
|
||||||
Memory <|-- LongMemory
|
|
||||||
Word <|-- LongWord
|
|
||||||
Program <-- ArrayList
|
|
||||||
Program --|> Instruction
|
|
||||||
Program : +toString()
|
|
||||||
Computer --> Memory
|
Computer --> Memory
|
||||||
Computer --> Program
|
Computer --> Program
|
||||||
Computer --> ProgramCounter
|
Computer --> ProgramCounter
|
||||||
ProgramCounter --> Program
|
Program <-- ArrayList
|
||||||
ProgramCounter --> Instruction
|
Program : +toString()
|
||||||
ProgramCounter : +toString()
|
Memory <|-- LongMemory
|
||||||
Instruction : +toString()
|
Word <|-- LongWord
|
||||||
Instruction <|-- Add
|
|
||||||
Instruction <|-- Copy
|
|
||||||
Instruction <|-- Halt
|
```
|
||||||
Instruction <|-- Jump
|
|
||||||
Instruction <|-- JumpEq
|
```mermaid
|
||||||
Instruction <|-- Mul
|
classDiagram
|
||||||
Instruction <|-- Print
|
class Instruction {
|
||||||
Add --> Address
|
+ void execute(Memory memory, ProgramCounter pc)
|
||||||
|
# String opcode()
|
||||||
|
# Object[] operands()
|
||||||
|
+ String toString()
|
||||||
|
}
|
||||||
|
class Add
|
||||||
|
class Copy
|
||||||
|
class Halt
|
||||||
|
class Jump
|
||||||
|
class JumpEq
|
||||||
|
class Mul
|
||||||
|
class Print
|
||||||
|
Instruction --|> Word
|
||||||
|
Instruction --|> Address
|
||||||
|
Add --|> Instruction
|
||||||
|
Copy --|> Instruction
|
||||||
|
Halt --|> Instruction
|
||||||
|
Jump --|> Instruction
|
||||||
|
JumpEq --|> Instruction
|
||||||
|
Mul --|> Instruction
|
||||||
|
Print --|> Instruction
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
|
|
Loading…
Reference in a new issue