calyxir / calyx

Intermediate Language (IL) for Hardware Accelerator Generators
https://calyxir.org
MIT License
446 stars 44 forks source link

eDSL: reserved names, nonexistent ports #2017

Open anshumanmohan opened 1 week ago

anshumanmohan commented 1 week ago

Right now the eDSL lets you generate pretty free-wheeling Calyx, even if that Calyx is clearly wrong. I wonder how people feel about making the eDSL a little cleverer.

Below I refer to mwe.py; it generates mwe.yx.

Reserved Names

As we know, Calyx adds go and done ports to components so that they may be used as cells in multi-component designs. However, the eDSL happily lets you add ports with those very names.

https://github.com/calyxir/calyx/blob/148690e96179c73c16d53f4ba7fa85b7fb51a464/calyx-py/test/mwe.py#L4-L7

I don't know what Calyx would make of this; hopefully it would catch it and stop you from proceeding. However, I kinda think that the eDSL could just weed out some of this stuff if we teach it some rules.

Nonexistent Ports

The eDSL lets you assign to ports that don't exist.

https://github.com/calyxir/calyx/blob/148690e96179c73c16d53f4ba7fa85b7fb51a464/calyx-py/test/mwe.py#L9

I regret to share that I don't actually have a port called flamingo on that component. Similarly, the eDSL lets you define a std_add called adder and then read/write to a port called adder.penguin. I think, when someone uses the {thing}.{port_name} notation to read from or write to a port, the eDSL could just check if thing actually has a port by that name. Another example of a thing that Calyx probably catches later on, but the eDSL is totally equipped to catch early on.

rachitnigam commented 1 week ago

Sounds like a good idea to me! Also, do you mind adding relevant labels to the issue ("calyx-py", "need triage / available")

anshumanmohan commented 1 week ago

Whoops mis-click...