Module: Origen::SubBlocks::Path

Included in:
Registers::BitCollection, Registers::Reg, Origen::SubBlocks
Defined in:
lib/origen/sub_blocks.rb

Instance Method Summary collapse

Instance Method Details

#abs_pathObject Also known as: full_path



175
176
177
# File 'lib/origen/sub_blocks.rb', line 175

def abs_path
  @abs_path
end

#abs_path=(val) ⇒ Object Also known as: full_path=



170
171
172
# File 'lib/origen/sub_blocks.rb', line 170

def abs_path=(val)
  @abs_path = val
end

#path(options = {}) ⇒ Object Also known as: hdl_path



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/origen/sub_blocks.rb', line 180

def path(options = {})
  return abs_path if abs_path
  if is_a?(Origen::Registers::BitCollection)
    # Special case where path relative to the register has been requested
    if options[:relative_to] == parent
      if size == 1
        return "[#{position}]"
      else
        return "[#{position + size - 1}:#{position}]"
      end
    else
      p = parent.parent
    end
  else
    p = parent
  end
  if p && p != options[:relative_to]
    if p.path(options).empty?
      root = ''
    else
      root = "#{p.path(options)}."
    end
  else
    # If a path variable has been set on a top-level object, then we will
    # include that in path, otherwise by default the top-level object is not
    # included in the path
    if p || path_var
      root = ''
    else
      return ''
    end
  end
  local = (path_var || name || self.class.to_s.split('::').last).to_s
  if local == 'hidden'
    root.chop
  elsif is_a?(Origen::Registers::BitCollection) && parent.path_var == :hidden
    "#{root.chop}#{local}"
  else
    "#{root}#{local}"
  end
end

#path=(val) ⇒ Object



162
163
164
# File 'lib/origen/sub_blocks.rb', line 162

def path=(val)
  @path = val
end

#path_varObject



166
167
168
# File 'lib/origen/sub_blocks.rb', line 166

def path_var
  @path
end