-
Notifications
You must be signed in to change notification settings - Fork 58
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
Consider arrays in Records #222
Comments
I don't think this syntax is viable. It is bad enough to have a tuple in a |
What are the use cases for this feature? Submitting an MCVE for a bug is an excellent practice that I appreciate, but submitting an "MCVE" for a feature is not so good because I don't have the context that you presumably do, and so it is not possible for me to see if the use case truly warrants the increase in complexity. |
I use homogeneous ndim arrays of signals and would like to see operations such as transpose or reshape. But imo arrays don't need to appear as a special case within a record. All the operations that I'm interested would probably be covered by (1) the transpose, flatten/ravel and reshape family of methods and (2) making lists of signals synonymous to their |
In my use case, I'm building a Z80 core with formal verification. To do that, I need to record what an instruction does as it executes, and how many cycles it spends doing various tasks. See the So an instruction might do 2 reads of memory and 2 writes of memory, or maybe 4 reads of memory. Each of those memory accesses has an address and data. So such a Each read or write takes a variable number of cycles, since the instruction may need to do some additional work. So we need to store the cycle type, and the number of sub-cycles spent in that cycle, for up to six cycles. Why a |
To me it sounds like you want something like a generalization of a matrix instead. (I'm not sure what the term for this entity is.) That's doesn't even need to be in core nMigen, as you can make anything |
@RobertBaruch I think this is is, in itself, a reasonable request. However, the existing As such, I don't think there is a good way to add this functionality to I would suggest that as a workaround with better quality of life, you use Python facilities, something like: @property
def data(self):
return list(self.data0, self.data1, self.data2) or perhaps an In fact, you could also go ahead and use |
It's not a generalization of matrix to me (certainly not in the mathematical sense which is the one that numpy uses for a some 2d arrays). Transpose happens when re-framing data words or when casting parallel data in serdes applications. Reshape is what you do on wide memory or bus data when looking at a byte granularity write ena le. Those ops to me are genuinely associated with multi-bit signals themselves. And they would also be how I would tackle the use case described at the top. |
I don't understand what transpose does, then.
Do you mean something like |
|
Oh I see. That seems pretty orthogonal to me here, since if you're OK with reshape you could also define an accessor like I suggested earlier. |
Instead of having to do this for 4 elements of 8-bit values:
Maybe:
or
("data", 4, 8, DIR_FANOUT)
depending on how you would like your inner monologue to go: "data is 4 elements of 8 bits each, fanning out" probably makes more sense than "data is 8 bits for each of 4 elements, fanning out".All elements in the array are assumed to have the same direction. If they don't, then you don't want an array, or at least you want two separate arrays.
Access should be like
record.data[0]
,record.data[1]
, etc. I'm not sure what the names of the signals end up as. I've seen thatArray
ends up with$n
as a subscript, so that would be fine as well.The text was updated successfully, but these errors were encountered: