Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible preprocessor problem. #232

Closed
at91rm9200 opened this issue Aug 4, 2022 · 3 comments
Closed

Possible preprocessor problem. #232

at91rm9200 opened this issue Aug 4, 2022 · 3 comments

Comments

@at91rm9200
Copy link

Hello Sylvain,

the following source for the icestick results in a preprocessor error. This worked with an earlier Silice version from May 2022.

$$if ICESTICK then
   algorithm main(output uint5 leds, inout uint8 pmod)
$$else
   algorithm main(output uint5 leds)
$$end
{
  while (1) {
  }
}
silice-make.py -s blinky1.si -b icestick -p basic,pmod -o BUILD_icestick
* Source file                :  /home/bernd/fpga/silice/2208/Silice/mue/project/test_icestick/blinky1.si    [ok]
* Silice bin directory       :  /home/bernd/fpga/silice/2208/Silice/bin
* Build output directory     :  /home/bernd/fpga/silice/2208/Silice/mue/project/test_icestick/BUILD_icestick  (exists)
* Silice frameworks directory:  /home/bernd/fpga/silice/2208/Silice/frameworks [ok]
* boards description file    :  /home/bernd/fpga/silice/2208/Silice/frameworks/boards/boards.json 	[ok]
<<=- compiling blinky1.si for icestick -=>>
using default variant  configurable
using variant          configurable
using build system     edalize
assembling source /home/bernd/fpga/silice/2208/Silice/frameworks/libraries/memory_ports.si.
assembling source /home/bernd/fpga/silice/2208/Silice/mue/project/test_icestick/blinky1.si.
functionalizing unit main
error: [parser] Pre-processor directives are unbalanced within the unit, this is not supported.

Regards, Bernd.

sylefeb added a commit that referenced this issue Aug 5, 2022
@sylefeb
Copy link
Owner

sylefeb commented Aug 5, 2022

Hello Bernd,

Sorry, you stumbled on one of the very few breaking changes I had to make thus far (I try very hard not to introduce any). The fix is very simple but requires a code change:

algorithm main(
$$if ICESTICK then
  output uint5 leds, inout uint8 pmod
$$else
  output uint5 leds
$$end
) {
  while (1) {
  }
}

The rule is that you can freely have preprocessor if-then-else between the '(' and ')' of the algorithm (or unit) in/out declaration, and between the '{' and '}' of the algorithm block. However there should not be an if-then-else enclosing and repeating these parentheses and braces.

I had to introduce this constraint when implementing the new preprocessor (that allows instantiation time preprocessing). There is a technical constraint there that the preprocessor has to be able to extract a 'simple' form of the algorithm or unit, free of top level if-then-else.

I was hopeful no one would encounter this breaking change, but you just prove me wrong ;-) I'll revise the documentation and try to clarify the error message.

Thanks for the report!
Best regards,
Sylvain

@sylefeb
Copy link
Owner

sylefeb commented Aug 5, 2022

@at91rm9200
Copy link
Author

Hello Sylvain,

thank you for the explanation.

Regards, Bernd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants