开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

StmtFSM examples in BH syntax


 
Edited

I've recently switched from the BSV to BH syntax. I am stubbing my toe against the StmtFSM library though as I can't seem to figure out how to create sequences. Is the BSV parser adding syntax support to make this library easier to use? Are there public examples of the use of StmtFSM in BH syntax? If not, would someone be willing to write and post a few snippets?


 

开云体育

I think what you may be looking for is `actionSeq`




Yehowshua


 

For many use cases (mostly test benches) the ActionSeq package is indeed appropriate and I may go with that. But when testing in-the-middle producer/consumer-style modules the par function of StmtFSM lets you write a single FSM with both the producer and consumer instruction sequences which then naturally terminates when both are done. I was hoping to preserve that ability :)


 

The BSV parser does provide special syntax, which de-sugars into calls into the StmtFSM library.? It would be a reasonable enhancement to add similar syntax to BH, but I've heard from people who use StmtFSM in BH that it can be done fairly straightforwardly -- though I think they may have written a library of small utilities for some things.? Hopefully they can post some links or examples.? The only example I can find on GitHub is this one, but it's barely using any features:?

J


On Tue, Mar 4, 2025 at 10:15?PM Arjen Roodselaar via <groupsio=[email protected]> wrote:

[Edited Message Follows]

I've recently switched from the BSV to BH syntax. I am stubbing my toe against the StmtFSM library though as I can't seem to figure out how to create sequences. Is the BSV parser adding syntax support to make this library easier to use? Are there public examples of the use of StmtFSM in BH syntax? If not, would someone be willing to write and post a few snippets?


 

Ah thank you! I realize I missed the do to chain statements together. I'll experiment with this a bit and see what some helper functions can do.


 

Hi Arjen,

I spoke with folks that had been using StmtFSM in BH.? They had written a wrapper library that provided abstracted functions for seq, par, for-loops, delays etc.? They no longer have this library, but said it was straightforward to make, by reading the StmtFSM library.? The reason they no longer have this, is because they switched away from StmtFSM to their own simpler SequenceRules library.? They were only using statically-timed constructs (no conditionals, breaks, etc) and StmtFSM was not scaling well for them.? So they wrote a library that just constructs up a list of actions, and then instantiates a single counter register and indexes through the list.? They've graciously agreed to contribute the library (although they note that it's only 150 lines of code) and it's currently in a PR to the "bsc-contrib" library, if you're interested:


Julie


 

Ha, thanks Charlie! He and I actually work for the same company (causing me to adopt the BH syntax), and I've certainly seen this library in our repo. I really like what it does, but have some existing test benches which need a slightly less strict scheduler (wait until this thing eventually becomes true). Having said that, I may be able to add that using an alternative constructor which doesn't count cycles but executes steps instead.

And I see there are some other goodies which came along with this donation (MList, some of our rule syntax) which is useful.


 

Glad to see BH syntax adoption in industry! I think BSV syntax is truly awful..
?
Trying to document BH here:
?
Also, modeling RiscV with a Formal model before implementing it in ULX3S with BH here:
?
I had wanted to add language server support to BSC for BH. I started by looking at CPackage, but never really committed to seeing it through. Perhaps if there are other BH users, I may give it another go.


 

Also, do you by chance use the ECP5 FPGA with BH? I linked to some examples in my previous reply although they were basic. I'm going to see how BH fares when it comes to IO PHYs however. I have some simple PCIe over ECP5 SERDES experiments queued up.