diff options
| author | Paul Oliver <contact@pauloliver.dev> | 2025-11-19 04:42:58 +0100 |
|---|---|---|
| committer | Paul Oliver <contact@pauloliver.dev> | 2025-11-19 16:40:08 +0100 |
| commit | 0075d1b10c475d303a314a3425ee472252855f32 (patch) | |
| tree | 2537411ad2b9691f413eeab62d7f541724ea47c6 /arch/dummy/arch.j2.c | |
| parent | d91b8a6196af711f9dface0c2a0d37794c12ac02 (diff) | |
Python/SQLite refactor
- Uses Python/Jinja2 to preprocess C files
- Uses SQLite3 for data compression
Diffstat (limited to 'arch/dummy/arch.j2.c')
| -rw-r--r-- | arch/dummy/arch.j2.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/arch/dummy/arch.j2.c b/arch/dummy/arch.j2.c new file mode 100644 index 0000000..d62d411 --- /dev/null +++ b/arch/dummy/arch.j2.c @@ -0,0 +1,130 @@ +// Author: Paul Oliver <contact@pauloliver.dev> +// Project: salis-v3 + +// Defines a minimal viable architecture for the Salis VM. +// Useful for debugging and benchmarking. May be used as a template when +// implementing a new architecture. + +{% if args.command in ["bench", "new"] and anc_bytes is defined %} +void arch_anc_init(struct Core *core) { + assert(core); + + {% if arch_vars.mvec_loop %} + uint64_t addr = {{ uint64_half }}; + {% else %} + uint64_t addr = 0; + {% endif %} + + for (uint64_t i = 0; i < {{ args.clones }}; ++i) { + uint64_t addr_clone = addr + (({{ mvec_size }} / {{ args.clones }})) * i; + + struct Proc *panc = proc_fetch(core, i); + + panc->mb0a = addr_clone; + panc->mb0s = {{ anc_bytes|length }}; + panc->ip = addr_clone; + panc->sp = addr_clone; + } +} +{% endif %} + +uint64_t arch_proc_mb0_addr(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->mb0a; +} + +uint64_t arch_proc_mb0_size(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->mb0s; +} + +uint64_t arch_proc_mb1_addr(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->mb1a; +} + +uint64_t arch_proc_mb1_size(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->mb1s; +} + +uint64_t arch_proc_ip_addr(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->ip; +} + +uint64_t arch_proc_sp_addr(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + return proc_get(core, pix)->sp; +} + +uint64_t arch_proc_slice(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return 1; +} + +void arch_on_proc_kill(struct Core *core) { + assert(core); + assert(core->pnum > 1); + + (void)core; +} + +void arch_proc_step(struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + + (void)core; + (void)pix; + + return; +} + +{% if not args.optimized %} +void arch_validate_proc(const struct Core *core, uint64_t pix) { + assert(core); + assert(mvec_proc_is_live(core, pix)); + + (void)core; + (void)pix; + + assert(true); +} +{% endif %} + +wchar_t arch_symbol(uint8_t inst) { + switch (inst) { + {% for i in arch_vars.inst_set %} + case {{ loop.index0 }}: return L'{{ i[1] }}'; + {% endfor %} + } +} + +const char *arch_mnemonic(uint8_t inst) { + switch (inst) { + {% for i in arch_vars.inst_set %} + case {{ loop.index0 }}: return "{{ i[0]|join(' ') }}"; + {% endfor %} + } +} + +{% if data_push_path is defined %} +void arch_push_data_header() { + assert(g_sim_data); +} + +void arch_push_data_line() { + assert(g_sim_data); +} +{% endif %} |
