Repository navigation
[LSQ] Remove duplicate signal classes in utils.py - #1048
Conversation
The previous commit converted genWrapper to the shared signal classes but left genWrapperSlave referencing an undefined `ctx`, and dropped the explicit tab levels that OpTab used to take, so assignments inside the clocked processes were emitted at the wrong indentation. - Give genWrapperSlave its own VHDLContext, and flush portInitString after the IO declarations and signalInitString before "begin", matching genWrapper (both buffers are filled lazily by signalInit()). - Raise the context indent around the Op() loops so the generated VHDL keeps the indentation OpTab produced. Generated VHDL is byte-identical to before for master/slave wrappers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
VHDLLogicType, VHDLLogicVecType, VHDLLogicTypeArray and VHDLLogicVecTypeArray were a second copy of Logic, LogicVec, LogicArray and LogicVecArray from core_gen/signals.py, differing only in returning their declarations as strings instead of buffering them in a VHDLContext, and in omitting the _i/_o port suffixes. Now that the LSQ wrapper builds its signals through signals.py with dyn_comp=True, nothing uses them. Drop the four classes and OpTab (superseded by operators.assign.Op), along with the now-unused `re` import and the stale re-exports in core_gen/__init__.py. The remaining helper functions in utils.py are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
getNameWrite computed the dyn_comp-aware suffix and then passed the raw
f'_{i}' to Logic.getNameWrite anyway, so a dyn_comp LogicArray would have
written to <name>_0 where it reads from <name>. LogicVecArray.getNameWrite
already used the computed suffix; make LogicArray match.
Not reachable from the current wrapper code, which indexes these arrays
through __getitem__ rather than calling getNameWrite(i) directly, so the
generated VHDL is unchanged.
Also reformat the touched files with autopep8 --max-line-length 200, which
CI enforces on modified Python files.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
9659f0a to
b4fe8ca
Compare
|
What does dyn comp do? |
|
It modifies the signal names such that they are compatible with what the compiler expects.
This was essentially the only difference between the two signal classes, the now-removed |
|
Shouldn't we always use this "more correct" signal naming instead of adding a separate switch for it? |
|
Personally I prefer the current way of doing it: the The numbering before the last word only works for specific signal names, e.g. it's nice for So I would either keep this flag just to be used in the wrapper, or change dynamatic side to work with the current signals implementation (which I think should be a separate PR) |
|
Okay I've thought about it a bit more and I'm in favor of just keeping the flag, the diff between dyn and the LSQ is that all dynamatic signals are handshake signals, so there it is nice to have the number before the flag (as every signal has a handshake |
|
Isn't it cleaner to let the wrapper handle all the naming differences? Or sometimes we don't instantiate this wrapper...? |
|
How would you go about this? I'm not entirely sure how to move the code for the different naming convention out of the |
|
I think if we really want to emphasize the port type (e.g., if it needs to have suffices like "_o" or "_i"), they should already appear in the signal names For example, i found this line in the code: Here we already had a prefix we could do |
|
In practice this is already happening, here's a snippet from ldq_tail_i = LogicVec(em, "ldq_tail", "i", self.configs.ldqAddrW)
ldq_head_i = LogicVec(em, "ldq_head", "i", self.configs.ldqAddrW)
ldq_empty_i = Logic(em, "ldq_empty", "i")
stq_tail_i = LogicVec(em, "stq_tail", "i", self.configs.stqAddrW)
stq_head_i = LogicVec(em, "stq_head", "i", self.configs.stqAddrW)
stq_empty_i = Logic(em, "stq_empty", "i")
ldq_wen_o = LogicArray(em, "ldq_wen", "o", self.configs.numLdqEntries)
num_loads_o = LogicVec(em, "num_loads", "o", self.configs.ldqAddrW)
num_loads = LogicVec(em, "num_loads", "w", self.configs.ldqAddrW)I suppose we could manually add all the The specific change you're suggesting is one of the interface signals, which I would say "io" is fine for because they're all handshake signals (also I think adding separate "input_" and "output_" on the compiler side will be annoying) Then we still have the number ordering issue, what would you do for that? I'm personally against moving the number before the last word in every single signal name as it feels very unintuitive. |
|
the numbers go before valid|ready everywhere so it is better to just change LSQ |
|
Alright wait maybe another option is to have a new optional parameter called As suffixes are appended after the signal base name, this fixes both problems If that's an okay solution I can implement that? |
|
Isn't it the same as adding the suffix directly into the signal name...? |
|
It's different because if you add suffixes directly to the signal name we still have the numbers-before-last-word issue. E.g. if I have However, internally in the LSQ I would say putting the number before the last word makes no sense at all, e.g. in the |
|
Maybe the easiest is to not use LogicArray for signals that interface with the dataflow circuit and just use a Python array instead: |
|
To be really honest, I think the flag is easier than having to extend every input/output signal name and rewrite the A flag to generate dynamatic compatible names makes sense to me, as it's just a different naming scheme being applied for the wrapper. In addition, having programmed using the current library, I think the current suffixes are nicer than having to write ...("[signal name]_i", "i"...), the extra text doesn't really add readability as you're using the python variable names anyways. But if you've got a strong opinion on this, I could change it :) I would prefer to first merge the full branch though as this will make cherry picking my original changes impossible, if that's not a big issue |
|
So custom suffix is kind of the simplest workaround? Just want to double check: this is only for the wrapper, right? |
|
Yes I believe the custom suffix is cleanest and easiest, and it's only for the wrapper. I'll update the implementation as soon as I have time! |
|
Okay sounds good! Let's go with that |
|
Okay I updated the code! |
|
I think the integration tests failing is a more general issue? I'm personally unable to merge because I don't have the rights |
|
Should rebase first (your branch doesn't have a few commits in the main that improve the performance |
|
Rebased! |
Part of #914
Removes the VHDLSignal classes in
utils.pyand replaces all occurrences with theSignalsclass.The classes are almost the exact same, with exception of a slight difference in the naming convention. So to make this compatible, a
dyn_compflag is added to the Signals classes and enabled for all the replaced signals.This change also requires the introduction of the
Contextclass in the wrapper generator, to be consistent with the remainder of the LSQ generation.As I was unable to cherry pick the changes (the original branch has a different approach order) I've let Claude do the rewrite based on the original branch and checked this
Sorry for the delay in merging this!