-
Notifications
You must be signed in to change notification settings - Fork 0
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
How should collections like pins, regs, sub_blocks be accessed? #22
Comments
I agree, except I'm okay with having both a singleton and pluralized method name. For example: dut.reg(..) #=> return a single reg.
dut.regs[...] #=> Indexed from a dictionary (or dictionary-like) class. I think its clear that Python also has some 'close but not exactly the same' methods we can justify the above with. For example, if you do reg("blah") #=> None
reg("blah") #=> Raises KeyError (from underlying dictionary/dictionary-like) |
…ts ensuring pin API is available on subblocks as well as the DUT.
OK, that sounds good. Just to clarify, this is what you mean for the missing item case: reg("blah") #=> None
regs["blah"] #=> Raises KeyError (from underlying dictionary/dictionary-like) That's quite nice and means that we don't need to add a if dut.pin("tdo"):
# ...
else:
#... |
I'd love to have the consistency across object types (pins, regs, etc). I recall being very confused about not being able to I'm neither for nor against having multiple aliases for the same functionality. I like the simplicity of a single way to do it. But, I also see the value of allowing a different dialect like |
@pderouen Just a side note: we can't use I've got |
I'd also say that I'm on board with reverting it if that's the consensus. Just something I threw in for now since as it occurred to me. |
This seems pretty self-explanatory: reg.write
reg.verify
reg.capture
pin.write
pin.verify
pin.capture |
Late to the discussion, but is anything related to access mechanisms for reg/regs tied to how one can iterate on them? I frequently have to iterate on a block's (and recursively through a block's sub-blocks) registers, but O1's nesting access for registers isn't very friendly to nested iteration (IMO). It leads to this below - regblk.regs(reg[0]).addr, instead of something direct like "regblk.reg(reg).address":
I'll take this to a separate issue if the two aren't tied together. I'm very much a fan of a singular access method for each type - singular and plural. |
Hi @chrishume, is the problem that you are treating regblk.regs.each do |name, reg|
puts "The address of #{name} is: #{reg.address}"
end I expect O2 to be similar in this respect, but perhaps better by being more consistent - sub_blocks, regs and pins will all behave like this, whereas I think that may not have been true for O1. |
That's entirely possible, @ginty. I'll mess around with it while doing the other updates (spec testing would be a good place to test the iteration) and see how things work. |
In O1 we had various ways of accessing items from a collection, e.g. for a reg I think all of these worked:
While that's quite nice from the pov of making whatever a user might guess have a good chance of working, I also think there's a lot to be said for Python's "one way of doing things" mantra and that perhaps removing all the aliases would make things less confusing to novice eyes.
I think there's also an argument that you wouldn't feel like you need to guess if there's only one style that you would ever see being used and it was consistent across all APIs.
So for O2, should we select a single one of the above and then consistently use that style only across all APIs (regs, pins, sub_blocks, specs, etc.)?
Pesonally, I think we should and I vote for the pluralalized square-bracket variant:
The text was updated successfully, but these errors were encountered: