lac-dcc / chimera

A tool for synthesizing Verilog programs
GNU General Public License v3.0
42 stars 4 forks source link

Cannot assign to non-variable #29

Closed luizademelo closed 2 months ago

luizademelo commented 2 months ago

Jasper Output

[ERROR (VERI-1007)] ./1_gram_verilog_file_504.v(5): cannot assign to non-variable 'id_1'

Seed to reproduce

Description

Parameters should be treated as constants. There cannot exist continuous or procedural assignments to parameters.

pronesto commented 2 months ago

Guys, I see two ways to deal with this issue.

My first (and favored) approach would be to change the pass that assigns names to placeholders. This pass should be augmented with some state information while it traverses the AST of programs. In particular, whenever it assigns a name to a parameter, this name should be inserted into a table of immutable names. Then, when finding a name for the left side of an assignment, it should consult the table of immutable names, to prevent any name stored there from being used in this situation.

The second approach would be to augment constraint generation, during type inference, so that we produce a pair (IMMUTABLE, id), whenever we see id used as a parameter. And whenever we see id used as the left side of an assignment, we create a pair (MUTABLE, id). Any attempt to unify IMMUTABLE and MUTABLE should result in error. I think this approach is not as good as the first, because it will restrict the programs that we can generate.

joaovam commented 2 months ago

Hi Fernando,

The second approach is similar to the one we adopted in #23, It was already included in the latest tests we made using Jasper, version 8, I went through the code and It works accordingly.

The first approach seems more appropriate, however, it would ask for more complex modifications in the code. We would need to rename the variables in two distinct passes, where the first one just renames, so that we do not have only generic tokens in the type inference, and the second uses the type inference information to unify which IDs can be the same. Do you think it would be worth it?