xls icon indicating copy to clipboard operation
xls copied to clipboard

DSLX: Remove proc initial value specification from the BUILD flow

Open RobSpringer opened this issue 2 years ago • 2 comments

To convert a DSLX proc into IR, we need to specify an initial value for the proc's state. That specification is currently done in the BUILD file, which is fragile. Consider the following example:

xls_dslx_opt_ir(
    name = "aes_128_ctr",
    dslx_top = "aes_128_ctr",
    ir_conv_args = {
        "top_proc_initial_state": "'(0, (0, [0, 0, 0, 0], 0, 0), 0, 0)'",
    },
    library = ":aes_128_ctr_dslx",
)

First of all, this is simply hard to read or parse for human eyes, and secondly, it's hard to maintain: what if the state changes for aes_128_ctr? We need to figure out some way to remove initial values from this flow.

RobSpringer avatar Aug 29 '22 20:08 RobSpringer

I'd think we need a construct on the top level proc in the DSL and it could just be extracted as part of IR conversion? Is there a natural place to put that?

cdleary avatar Aug 29 '22 20:08 cdleary

From #735

A thought is to have the initial values declared in a 'parameter list' for the proc.

In the following example, 'main(u32: 1)' has the inital values.

proc main(u32: 1) {
  c: chan<u32> out;

  config(c: chan<u32> out) {
    (c)
  }

  next(tok: token,  a: u32) {
    let tok = send(tok, c,  a);
    let a = a + u32:1;
    (a)
  }
}

vincent-mirian-google avatar Oct 06 '22 19:10 vincent-mirian-google

Part of this: enable proc-scoping of constants, such that we can define a default (but overrideable) initial state for the proc that doesn't leak out (e.g. if we define multiple procs in the same file, having to proc-name-prefix their default initial states seems clumsy).

RobSpringer avatar Oct 20 '22 17:10 RobSpringer

I've a patch out (internally) to enable specifying constants as initial values, but this will need to be expanded to support ColonRef'ed constants.

RobSpringer avatar Oct 24 '22 19:10 RobSpringer