adjtm has quit [Remote host closed the connection]
adjtm has joined #yosys
<Forty-Bot>
does anyone have suggestions on how to parametrize the number of states in a state machine?
<Forty-Bot>
I am writing a module where some data is read in byte-by-byte, and I'd like to make the number of bytes parametric https://paste.debian.net/1274608/
adjtm has quit [Read error: Connection reset by peer]
<bl0x_>
Forty-Bot: best to use a counter for the current byte and have the destination range depend on the value of the counter. The counter start value would be the parameters you pass in to the module.
<Forty-Bot>
I tried that in the second link
<bl0x_>
Ah, oops didn't read that far .. haha
<Forty-Bot>
I would love to use that approach, but it takes more resources...
<bl0x_>
Hm, what about a one hot counter?
<Forty-Bot>
I think it's because yosys doesn't allow arithmetic to be part of state machines
<Forty-Bot>
so any time you have something like `state_next = state - 1` or whatever, it disables the FSM optimization
<Forty-Bot>
I'll try a 1-hot...
<bl0x_>
What about generating code? Or does it need to be dynamic at run time?
<Forty-Bot>
the rest of the project doesn't use code generation, so ideally I'd like to use parameters
<bl0x_>
I meant to use a generate block. Not some external code generator
<Forty-Bot>
1-hot is better, but still not as good
<Forty-Bot>
a generate block would be pretty awful because there are ~7-8 other (unparametrized) states
<bl0x_>
Could you put in all states and then skip the unnecessary ones based on the parameter?
<Forty-Bot>
yes, that's what happens in the first example when PARAM is set
<bl0x_>
Ok.
<bl0x_>
About the generate blocks: can't you generate only the additional states inside the fsm surrounded with 'generate if ... ' ?
<Forty-Bot>
no
<Forty-Bot>
generates are not allowed in always blocks
<Forty-Bot>
definitely what I would have done given the choice
<bl0x_>
Pretty sure that works in vhdl, no?
<Forty-Bot>
no clue; I've only really used verilog
<tnt>
I mean, this looks like this should be a shift register really ...
<Forty-Bot>
tnt: for size 16 shift registers are larger
<Forty-Bot>
but not by too much
<Forty-Bot>
however, the parametrized version is still larger