So I've been looking to add structs to SUS. But I'm not entirely convinced by my current approach.
Basically, I had the idea of integrating struct declarations with the existing SUS generative code system, but instead of
A regular struct looks pretty unassuming:
struct MyVec3 {
int x
int y
int z
}
And having the generative code would allow for templated structs like
struct MyVec<T> {
input gen int SIZE
T[SIZE] arr
}
And even structs with optional fields like
struct BRAMRead<T> {
input gen bool ECC_INCLUDED
T read_data
if ECC_INCLUDED { // (compiletime)
bool ecc_did_error
}
}
The idea here is that any non-gen (compiletime) declaration is interpreted as a struct field, whereas gen declarations (like the template parameters), are executable compile-time code.
While this is easy to implement, and even gains a little bonus for language consistency, I can't help but fear I might be shooting myself in the foot somehow.
So I've been looking to add structs to SUS. But I'm not entirely convinced by my current approach.
Basically, I had the idea of integrating struct declarations with the existing SUS generative code system, but instead of
A regular struct looks pretty unassuming:
And having the generative code would allow for templated structs like
And even structs with optional fields like
The idea here is that any non-
gen
(compiletime) declaration is interpreted as a struct field, whereasgen
declarations (like the template parameters), are executable compile-time code.While this is easy to implement, and even gains a little bonus for language consistency, I can't help but fear I might be shooting myself in the foot somehow.