Module: Origen::Location::Map::ClassMethods

Defined in:
lib/origen/location/map.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Provides accessors for all named locations, for example:

$dut.nvm.fmu.ifr_map.probe1_pass


53
54
55
56
57
58
59
60
61
62
# File 'lib/origen/location/map.rb', line 53

def method_missing(method, *args, &block)
  if defining?
    if definitions[method]
      warning "Redefinition of map location: #{method}"
    end
    definitions[method] = { attributes: args.first, x: @x }
  else
    super
  end
end

Instance Method Details

#constructedObject

A hash of constructed location objects, i.e. an entry will be cached here the first time a location is referenced outside of its initial definition, after that it will be served directly from here.



46
47
48
# File 'lib/origen/location/map.rb', line 46

def constructed
  @constructed ||= {}
end

#constructor(&block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/origen/location/map.rb', line 16

def constructor(&block)
  if defining?
    constructors[@x] = block
  else
    constructors[:default] = block
  end
end

#constructorsObject



32
33
34
# File 'lib/origen/location/map.rb', line 32

def constructors
  @constructors ||= {}
end

#default_attributesObject



36
37
38
# File 'lib/origen/location/map.rb', line 36

def default_attributes
  @default_attributes ||= {}
end

#default_constructor(attributes, defaults) ⇒ Object



24
25
26
# File 'lib/origen/location/map.rb', line 24

def default_constructor(attributes, defaults)
  Origen::Location::Base.new(defaults.merge(attributes))
end

#define_locations(defaults = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/origen/location/map.rb', line 8

def define_locations(defaults = {})
  @x = @x ? (@x + 1) : 0  # Provides a unique ID for each define_locations block
  default_attributes[@x] = defaults
  @defining = true
  yield
  @defining = false
end

#defining?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/origen/location/map.rb', line 40

def defining?
  @defining
end

#definitionsObject



28
29
30
# File 'lib/origen/location/map.rb', line 28

def definitions
  @definitions ||= {}
end