aboutsummaryrefslogtreecommitdiff
path: root/arch/dummy
diff options
context:
space:
mode:
Diffstat (limited to 'arch/dummy')
-rw-r--r--arch/dummy/arch.c (renamed from arch/dummy/arch.j2.c)57
-rw-r--r--arch/dummy/arch_vars.py34
2 files changed, 41 insertions, 50 deletions
diff --git a/arch/dummy/arch.j2.c b/arch/dummy/arch.c
index f51494f..cf30ba1 100644
--- a/arch/dummy/arch.j2.c
+++ b/arch/dummy/arch.c
@@ -1,32 +1,25 @@
-// 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 %}
+#if (defined(COMMAND_BENCH) || defined(COMMAND_NEW)) && defined(ANC_BYTES)
void arch_core_init(struct Core *core) {
assert(core);
- {% if arch_vars.mvec_loop %}
- uint64_t addr = {{ uint64_half }};
- {% else %}
+#if defined(MVEC_LOOP)
+ uint64_t addr = UINT64_HALF;
+#else
uint64_t addr = 0;
- {% endif %}
+#endif
- for (uint64_t i = 0; i < {{ args.clones }}; ++i) {
- uint64_t addr_clone = addr + (({{ mvec_size }} / {{ args.clones }})) * i;
+ for (uint64_t i = 0; i < CLONES; ++i) {
+ uint64_t addr_clone = addr + (MVEC_SIZE / 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;
+ panc->mb0s = ANC_SIZE;
+ panc->ip = addr_clone;
+ panc->sp = addr_clone;
}
}
-{% endif %}
+#endif
void arch_core_free(struct Core *core) {
assert(core);
@@ -34,7 +27,7 @@ void arch_core_free(struct Core *core) {
(void)core;
}
-{% if args.command in ["load", "new"] %}
+#if defined(COMMAND_LOAD) || defined(COMMAND_NEW)
void arch_core_save(FILE *f, const struct Core *core) {
assert(f);
assert(core);
@@ -42,9 +35,9 @@ void arch_core_save(FILE *f, const struct Core *core) {
(void)f;
(void)core;
}
-{% endif %}
+#endif
-{% if args.command in ["load"] %}
+#if defined(COMMAND_LOAD)
void arch_core_load(FILE *f, struct Core *core) {
assert(f);
assert(core);
@@ -52,7 +45,7 @@ void arch_core_load(FILE *f, struct Core *core) {
(void)f;
(void)core;
}
-{% endif %}
+#endif
uint64_t arch_proc_mb0_addr(const struct Core *core, uint64_t pix) {
assert(core);
@@ -117,7 +110,7 @@ void arch_proc_step(struct Core *core, uint64_t pix) {
return;
}
-{% if not args.optimized %}
+#if !defined(NDEBUG)
void arch_validate_proc(const struct Core *core, uint64_t pix) {
assert(core);
assert(mvec_proc_is_live(core, pix));
@@ -127,25 +120,25 @@ void arch_validate_proc(const struct Core *core, uint64_t pix) {
assert(true);
}
-{% endif %}
+#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 %}
+#define INST(index, label, mnemonic, symbol) case index: return symbol;
+ INST_SET
+#undef INST
}
}
const char *arch_mnemonic(uint8_t inst) {
switch (inst) {
- {% for i in arch_vars.inst_set %}
- case {{ loop.index0 }}: return "{{ i[0]|join(' ') }}";
- {% endfor %}
+#define INST(index, label, mnemonic, symbol) case index: return mnemonic;
+ INST_SET
+#undef INST
}
}
-{% if data_push_path is defined %}
+#if defined(DATA_PUSH_PATH)
void arch_push_data_header() {
assert(g_sim_data);
}
@@ -153,4 +146,4 @@ void arch_push_data_header() {
void arch_push_data_line() {
assert(g_sim_data);
}
-{% endif %}
+#endif
diff --git a/arch/dummy/arch_vars.py b/arch/dummy/arch_vars.py
index bc97ea9..0266e53 100644
--- a/arch/dummy/arch_vars.py
+++ b/arch/dummy/arch_vars.py
@@ -1,18 +1,6 @@
-def gen_arch_vars(_):
- return {
- "core_fields": [],
- "mvec_loop": True,
-
- "proc_fields": [
- ("uint64_t", "ip"),
- ("uint64_t", "sp"),
- ("uint64_t", "mb0a"),
- ("uint64_t", "mb0s"),
- ("uint64_t", "mb1a"),
- ("uint64_t", "mb1s"),
- ],
-
- "inst_set": [
+class ArchVars:
+ def __init__(self, _):
+ self.inst_set = [
(["dummy", f"{i:02x}"], symbol)
for i, symbol in enumerate(
"⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟"
@@ -20,7 +8,17 @@ def gen_arch_vars(_):
"⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟"
"⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿"
)
- ],
+ ]
- "inst_count": 2 ** 7,
- }
+ self.core_fields = []
+ self.data_is_compressed = False
+ self.mvec_loop = True
+
+ self.proc_fields = [
+ ("uint64_t", "ip"),
+ ("uint64_t", "sp"),
+ ("uint64_t", "mb0a"),
+ ("uint64_t", "mb0s"),
+ ("uint64_t", "mb1a"),
+ ("uint64_t", "mb1s"),
+ ]