Pruned #includes for NEDsim simulator files.
[screensavers] / hacks / NEDsim / simulator.h
/* (c) 2021 Aaron Taylor <ataylor at subgeniuskitty dot com> */
/* See LICENSE.txt file for copyright and license details. */
#include <stdbool.h>
/* Bytes per word. */
#define BPW 4
/* Syllables per word. */
#define SPW 5
/* Storage definitions. */
#define STACK_LENGTH 65536
#define RAM_LENGTH 67108864
#define RAM_BASE_ADDRESS 0x20000000
struct NEDpsw {
bool zero;
bool negative;
};
struct NEDthread {
uint32_t stack[STACK_LENGTH];
uint32_t sp;
uint32_t pc;
uint8_t sc;
struct NEDpsw * psw;
};
struct NEDhack {
uint32_t iw;
bool resume_word;
};
struct NEDstate {
bool halted;
uint8_t ram[RAM_LENGTH];
/* Although NED is multi-threaded, this screensaver is restricted to a single thread. */
struct NEDthread * thread[1];
struct NEDthread * active_thread;
struct NEDhack * hack;
};
enum syllables {
MVSTCK = 0b00001111,
JMP = 0b00001110,
SWAP = 0b00001101,
ADD = 0b00001100,
XOR = 0b00001011,
NOT = 0b00001010,
OR = 0b00001001,
AND = 0b00001000,
BRZ = 0b00000111,
TEST = 0b00000110,
CMPSWP = 0b00000101,
SHIFT = 0b00000100,
STORE = 0b00000011,
LOAD = 0b00000010,
NOP = 0b00000001,
HALT = 0b00000000
};
struct NEDstate * init_simulator(char * input_file);
struct NEDstate * run_simulator(struct NEDstate * state);
uint32_t ram_r_word(struct NEDstate * state, uint32_t address);