HateLace/README.md

108 lines
2.4 KiB
Markdown
Raw Normal View History

2024-04-21 20:47:21 +02:00
# HateLace - A Simple Computer
```mermaid
classDiagram
class Computer {
- Memory memory
- Program program
+ Computer(Memory Memory)
+ void load(Program program)
+ void run()
}
class Memory {
+ Word read(Address address)
+ int size()
+ void write(Address address, Word data)
+ void dump()
2024-04-21 20:47:21 +02:00
}
class ProgramCounter {
- int PC
- int SysTick
- boolean haltFlag
+ ProgramCounter()
+ ProgramCounter(int PC)
+ int getPC()
+ int getSysTicks()
+ int incPC()
+ int setPC(int PC)
+ boolean halted()
+ void halt()
}
class Program
2024-04-21 20:47:21 +02:00
class ArrayList
class Word {
+ <T> T getValue()
2024-04-21 20:47:21 +02:00
+ Word add(Word other)
+ Word subtract(Word other)
+ Word multiply(Word other)
+ Word divide(Word other)
+ String toString()
+ boolean equals(Object other)
}
class Address {
- int address
+ Address(int address)
+ int getAddress()
2024-04-21 21:01:54 +02:00
+ String toString()
2024-04-21 20:47:21 +02:00
}
class LongMemory
class LongWord
2024-04-21 20:47:21 +02:00
Computer --> Memory
Computer --> Program
Computer --> ProgramCounter
Program <-- ArrayList
Program : +toString()
2024-04-22 00:17:07 +02:00
Memory --|> LongMemory
Word --|> LongWord
```
```mermaid
classDiagram
class Instruction {
+ 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
2024-04-22 00:17:07 +02:00
Instruction <|-- Word
Instruction <|-- Address
Add <|-- Instruction
Copy <|-- Instruction
Halt <|-- Instruction
Jump <|-- Instruction
JumpEq <|-- Instruction
Mul <|-- Instruction
Print <|-- Instruction
2024-04-21 20:47:21 +02:00
```
2024-04-21 20:53:38 +02:00
```mermaid
sequenceDiagram
participant Computer
participant Program
participant Memory
participant ProgramCounter
participant Instruction
Computer -> Program: load(program)
loop Program Execution
Program -> Computer: run()
loop Instructions Execution
Computer -> ProgramCounter: incPC()
ProgramCounter -> Program: getPC()
Program -> Program: executeInstruction()
Program -> Instruction: execute(memory, PC)
Instruction -> Memory: read/write(address)
Program -> ProgramCounter: incPC()
end
end
```