From 9f3b5f17b9c14012664a1183e4379e3e32748bb2 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 21 Apr 2024 20:47:21 +0200 Subject: [PATCH] Mermaid diagram for classes --- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..88d3e71 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# HateLace - A Simple Computer + +```mermaid +classDiagram + class Computer { + - Memory memory + - Program program + + Computer(Memory Memory) + + void load(Program program) + + void run() + } + class Memory { + + abstract Word read(Address address) + + abstract int size() + + abstract void write(Address address, Word data) + + abstract void dump() + } + 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 + class Instruction { + + abstract void execute(Memory memory, ProgramCounter pc) + # abstract String opcode() + # abstract Object[] operands() + + abstract String toString() + } + class ArrayList + class Word { + + abstract 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 subtract(Word other) + + Word multiply(Word other) + + Word divide(Word other) + + String toString() + + boolean equals(Object other) + } + class LongMemory { + - long[] memory + + LongMemory() + + LongMemory(int size) + + Word read(Address address) + + int size() + + void write(Address address, Word data) + + void dump() + } + Memory <|-- LongMemory + Word <|-- LongWord + Program <-- ArrayList + Program --|> Instruction + Program : +toString() + Computer --> Memory + Computer --> Program + Computer --> ProgramCounter +```