class Origen::Ports::Section
Attributes
Public Class Methods
Source
# File lib/origen/ports/section.rb, line 9 def initialize(port, index) @port = port @index = index end
Public Instance Methods
Source
# File lib/origen/ports/section.rb, line 47 def [](index) Section.new(port, align_to_port(index)) end
Source
# File lib/origen/ports/section.rb, line 35 def drive(value = nil) port.drive(value, index: index) end
Source
# File lib/origen/ports/section.rb, line 39 def drive_value if size == 1 port.drive_values[index] else fail 'drive_value is only supported for a single bit port section' end end
Source
# File lib/origen/ports/section.rb, line 55 def method_missing(method, *args, &block) if BitCollection.instance_methods.include?(method) to_bc.send(method, *args, &block) else super end end
Calls superclass method
Source
# File lib/origen/ports/section.rb, line 26 def parent port.parent end
Also aliased as: owner
Source
# File lib/origen/ports/section.rb, line 18 def path if index.is_a?(Range) port.path + "[#{index.first}:#{index.last}]" else port.path + "[#{index}]" end end
Source
# File lib/origen/ports/section.rb, line 51 def respond_to?(*args) super(*args) || BitCollection.instance_methods.include?(args.first) end
Calls superclass method
Source
# File lib/origen/ports/section.rb, line 63 def to_bc b = BitCollection.new(port, port.id) indexes = index.respond_to?(:to_a) ? index.to_a : [index] indexes.reverse_each do |i| b << netlist.data_bit(port.path, i) end b end
Private Instance Methods
Source
# File lib/origen/ports/section.rb, line 82 def align_to_port(val) if val.is_a?(Range) nlsb = lsb + val.last nmsb = nlsb + size_of(val) - 1 out_of_range(val) if nmsb > msb i = nmsb..nlsb else i = lsb + val out_of_range(val) if i > msb end i end
Source
# File lib/origen/ports/section.rb, line 107 def lsb if index.is_a?(Range) index.last else index end end
Source
# File lib/origen/ports/section.rb, line 99 def msb if index.is_a?(Range) index.first else index end end
Source
# File lib/origen/ports/section.rb, line 95 def out_of_range(val) fail "Requested section index (#{val}) is out of range for a port section of size #{size}" end
Source
# File lib/origen/ports/section.rb, line 74 def size_of(index) if index.is_a?(Range) (index.first - index.last).abs + 1 else 1 end end