Open ThePerfectComputer opened 2 months ago
The issues lies in the switch statement as A works but not B:
attribute \generator "Amaranth"
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:19"
attribute \top 1
module \top
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:21"
process $26
assign $11 [4:0] \ctr [4:0]
end
end
attribute \generator "Amaranth"
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:19"
attribute \top 1
module \top
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:22"
process $34
assign \stb [0] 1'0
switch $6 [0]
case 1'1
assign \stb [0] 1'1
case
end
end
end
The minified example I gave above technically wasn't complete... I added back the full context to that example which was derived from this amaranth lang example. After adding back that full context, Haskellator failed to parse the emitted RTLIL; thus I am re-opening this issue.
This is also an indicator that we should expand the corpus with examples emitted directly from amaranth lang. Perhaps the correct approach would be to comb through the amaranth lang repo and emit RTLIL examples from it - as detailed out in issue #2.
The original example with the full context really appears to be invalid RTLIL according to the official documentation and grammar: "the body of a process consists of zero or more assignments, exactly one switch, and zero or more syncs."
<process-body> ::= <assign-stmt>* <switch>? <assign-stmt>* <sync>*
I could update the parser to accept this, but it doesn't seem like a very subtle difference and I wonder what's going on here.
Here's the original failing example for reference:
attribute \generator "Amaranth"
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:19"
attribute \top 1
module \top
attribute \src "/Users/yehowshuaimmanuel/git/Haskellator1/fsm.py:21"
process $26
assign $11 [4:0] \ctr [4:0]
switch $1 [0]
case 1'1
assign $11 [4:0] 5'10011
case
assign $11 [4:0] $2 [4:0]
end
switch \fsm_state [2:0]
case 3'000
switch $3 [0]
case 1'1
assign $11 [4:0] 5'01010
end
case 3'001
case 3'010
case 3'011
case 3'100
end
switch \rst [0]
case 1'1
assign $11 [4:0] 5'00000
end
end
end
Here is an MVP of what causes Haskellator to fail: