Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Unable to use interface method argument in `when` guard
Un-commenting the commented-out lines in the snippet below...
?
?
?
?
causes compilation to fail with:
?
?
```bash
$TOPMODULE=mkSim make b_compile b_link b_sim mkdir ?-p build_b_sim Compiling for Bluesim ... bsc -u -sim -simdir build_b_sim -bdir build_b_sim -info-dir build_b_sim -keep-fires -aggressive-conditions -no-warn-action-shadowing -check-assert -cpp -show-schedule +RTS -K128M -RTS ?-show-range-conflict ? ? ?-p bs/:bsv/:+ -g mkSim ?bs/Top.bs? checking package dependencies <snipped>
5 warnings generated.
compiling bs//TagEngine.bs Warning: "bs//TagEngine.bs", line 43, column 8: (P0223) ? Definition of `counter' is not used. Error: "bs//TagEngine.bs", line 70, column 20: (T0004) ? Unbound variable `tag' make: *** [Makefile:103: b_compile] Error 1 ``` ?
Is this intentional? Are you not allowed to use interface method arguments in when guards?
|
|||||||||||||
It is intentional.? The logical order of events for a method is that the RDY is available first, then the arguments are provided (and an EN signal, if it's an action), and then the return value is output (if it has one).? So a method's RDY can't depend on its arguments.? Though BSC could certainly be improved to give a more direct error message, than just the generic one about the variable not being in scope. J On Mon, Mar 24, 2025 at 1:21?AM Yehowshua Immanuel via <programmed4jesus=[email protected]> wrote:
|
|||||||||||||
Another option is to have two separate methods: one that takes the argument and returns if it's ok, and a method that can then be called to do the action. J On Mon, Mar 24, 2025 at 9:35?AM Yehowshua Immanuel via <programmed4jesus=[email protected]> wrote:
|
|||||||||||||
Kudos to bluespec for consistent semantics... I tried to use RWire within the module such that you had to call the following in the same rule to retire a tag:
?
```
tagEngine.setTagToRetire 12 tagEngine.retireTag; ``` ?
But the compiler complained that can fire for the rule depended on will fire in the rule - so yeah didn't work. I can just make sure the tag requestor never attempts to request an invalid tag since I have control over the requestor...
?
Full coded attempt here: |
|||||||||||||
Here are three other possibilities: -- canRetireTag sets the tag and returns if ready, used in the same rule rules ? "do_retire": when True ==> ? ? do ?? ? ? b :: Bool ?? ? ? b <- tagEngine.canRetireTag tag ?? ? ? if (b) then ? ? ? ? tagEngine.retireTag ? ? ? ? ... ?? ? ? else ? ? ? ? noAction -- canRetireTag sets the tag and returns if ready, used in separate rules (if needed) ? "check_retire": when True ==> ? ? do ? ? ? b :: Bool ? ? ? b <- tagEngine.canRetireTag tag ? ? ? w_canRetire := b ? "do_retire": when (w_canRetire) ==> ? ? do ? ? ? tagEngine.retireTag ? ? ? ... -- canRetireTag is pure value rules ??"do_retire": when (tagEngine.canRetireTag tag) ==> ? ??do ? ? ??tagEngine.retireTag tag ? ? ??... J On Mon, Mar 24, 2025 at 11:49?AM Yehowshua Immanuel via <programmed4jesus=[email protected]> wrote:
|
to navigate to use esc to dismiss