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

add_pin_groups does not work as expected for a mix of individual pins and pin groups #69

Dieleman opened this issue Jan 18, 2017 · 7 comments


Copy link

For pin definition:
add_pins :target, size: 2, direction: :input, reset: :drive_lo
add_pin :nadd, direction: :input, reset: :drive_lo
add_pin :ee_n, direction: :input, reset: :drive_hi
add_pin :oscx, direction: :input, reset: :drive_lo
add_pin :prech, direction: :input, reset:

add_pin_group :kalos_all_pins, :nadd, :ee_n, :oscx, :prech
Correctly gives $dut.pins(:kalos_all_pins).size => 4

add_pin_group :kalos_all_pins, :nadd, :ee_n, :oscx, :prech, :target
However gives $dut.pins(:kalos_all_pins).size => 2

So adding another pingroup (:target) somehow resets the master group

Copy link

@Dieleman ... I will be looking at this and will give you an update in about 2 hours.

Copy link

ginty commented Jan 18, 2017

Nice one @welguisz, you may want to use this test case I made which shows the problem:

    it "pins groups can be composed of standalone pins and other groups" do
      $dut.add_pins(:porta, size: 8)
      $dut.add_pins(:portb, size: 16)

      $dut.pins.size.should == 28
      $dut.add_pin_group :jtag, :tdi, :tdo, :tclk, :tms
      $dut.add_pin_group :ports, :porta, :portb
      $dut.add_pin_group :all, :tdi, :tdo, :tclk, :tms, :porta, :portb
      $dut.add_pin_group :all2, :jtag, :ports

      $dut.pins(:jtag).size.should == 4
      $dut.pins(:ports).size.should == 24
      $dut.pins(:all).size.should == 28
      $dut.pins(:all2).size.should == 28

Copy link

welguisz commented Jan 18, 2017

@ginty ... Thanks for the code .. Seeing the error right now

$dut.pins(:all).size.should == 28
# Currently returning 24
`$dut.pins(:all2).size.should == 28
#  Currently return 28

This means that this test is a good test since it is showing that has an error before any fix is done.

Copy link

I found where the bug is at:

   def add_pin_group(id, *pins, &_block)
      if pins.last.is_a?(Hash)
        options = pins.pop
        options = {}
      # check if this is a pin group alias
      found = false
      group = nil
      unless options[:pins_only] == true
        pins.each do |i|
          if pin_groups.include?(i)
            group = add_pin_group_alias(id, i, options)
            found = true  #THIS IS THE BUG (PART 1)
      unless found # not a pin group alias  ... THIS IS THE BUG (PART 2)
        group = Origen.pin_bank.find_or_create_pin_group(id, self, options)
        if block_given?
          yield group
          if options[:endian] == :little
            pins.each { |pin| group.add_pin(pin, options) }
            pins.reverse_each { |pin| group.add_pin(pin, options) }
      # Origen.pin_bank.add_pin_group(group, self, {:pins_exist => true}.merge(options))

For PART1, I think the best action is to change it to
and PART2, I think it should be
unless pins.empty?

Copy link

Just pushed the fix and started a pull Request. @ginty when Coveralls finishes, can you review and merge if everything looks correct.

welguisz pushed a commit that referenced this issue Jan 18, 2017
Copy link

@Dieleman I just release origen 0.7.43 that has this fixed incorporated in it. If everything works, please let us know that this is resolved and we can close this issue.


Copy link

@welguisz Thanks, I tried it and this seems to fix the issue indeed. For me the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants