Skip to content
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

Distinguishing pins in multi-bit ports #196

Open
jgoeders opened this issue Mar 18, 2023 · 5 comments
Open

Distinguishing pins in multi-bit ports #196

jgoeders opened this issue Mar 18, 2023 · 5 comments
Labels
resolved? Believed to be resolved and ready to close

Comments

@jgoeders
Copy link
Member

If I have a multi-bit port, how do I distinguish between the various pins?

I have an 8-bit port called Din:

When I iterate over the pins they all look identical. I would expect the InnerPin to have an index property, but I can't find one.

for pin in port.get_pins():
  print(pin)
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>
<class 'spydrnet.ir.InnerPin'; connected to'<class 'spydrnet.ir.Wire'; Contained by Cable.name 'Din' <class 'spydrnet.ir.Cable'; is_downto: True; is_scalar: False; lower index: 0>>'>

Am I missing something?

@ganeshgore
Copy link
Contributor

You can get that using port.pins.index(pin) or pin.port.pins.index(pin) (if you don't have the relevant port in the scope)
Note: this just returns the unique index number in the list (not guaranteed to match with the Verilog index declaration)

@jgoeders
Copy link
Member Author

Thanks @ganeshgore !!!

@emonlux I'm not seeing this in the documentation anywhere? Am I missing it, or it just not documented yet?

Ultimately the behavior I need is given an Instance, I want to find a given OuterPin by string name and (when needed) integer index. Something like:

Instance.get_pin(name)
Instance.get_pin(name, index)

Now that I know how to get the index for a given pin I can build this information myself into a dictionary. I just thought I would ask if this behavior already exists somewhere...

Thanks!

@emonlux
Copy link
Collaborator

emonlux commented Mar 30, 2023

Currently, there is no function built in for this. I will look into adding this functionality and documenting it.

Edit: I was unable to get to this before leaving.

@jacobdbrown4 jacobdbrown4 added this to To Do Soon in Fall 2023 Release Apr 5, 2023
@emonlux emonlux assigned emonlux and unassigned emonlux Apr 19, 2023
@jacobdbrown4
Copy link
Collaborator

OuterPins do not have names, however their ports do. I'm guessing the 'name' in your proposed addition would be the port name and then the index would specify what pin. On the other hand, we can give OuterPins names. Perhaps they could be their port name + "_" + their index.

@wirthlin wirthlin moved this from For the Next Release to In Progress in Fall 2023 Release May 15, 2023
@wirthlin wirthlin moved this from In Progress to For the Next Release in Fall 2023 Release May 15, 2023
@jacobdbrown4
Copy link
Collaborator

jacobdbrown4 commented Oct 31, 2023

I have added an index property to InnerPin and OuterPin and updated _str_() to include index and port information.

I have also implemented the following as requested:

Instance.get_pin(name)
Instance.get_pin(name, index)

The name is the name of the port. The default index is 0. If no pin matching the name and index is found, None will be returned.

These updates can be found on the next_release branch.

@jacobdbrown4 jacobdbrown4 added the resolved? Believed to be resolved and ready to close label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved? Believed to be resolved and ready to close
Projects
Fall 2023 Release
Address Soon
Development

No branches or pull requests

4 participants