Class: OrigenTesters::Timing::Timeset

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_testers/timing/timeset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Timeset

Returns a new instance of Timeset.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/origen_testers/timing/timeset.rb', line 10

def initialize(attrs = {})
  @cycled = false
  @locked = false
  @called = false

  attrs.each do |name, value|
    send("#{name}=", value)
  end

  self.period_in_ns = attrs[:period_in_ns]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



107
108
109
110
111
112
113
# File 'lib/origen_testers/timing/timeset.rb', line 107

def method_missing(m, *args, &block)
  if dut_timeset && (dut_timeset.methods.include?(m) || dut_timeset.private_methods.include?(m))
    dut_timeset.send(m, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#calledObject

Returns the value of attribute called.



7
8
9
# File 'lib/origen_testers/timing/timeset.rb', line 7

def called
  @called
end

#cycledObject

Returns the value of attribute cycled.



7
8
9
# File 'lib/origen_testers/timing/timeset.rb', line 7

def cycled
  @cycled
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/origen_testers/timing/timeset.rb', line 7

def name
  @name
end

#period_in_nsObject

Returns the value of attribute period_in_ns.



8
9
10
# File 'lib/origen_testers/timing/timeset.rb', line 8

def period_in_ns
  @period_in_ns
end

Instance Method Details

#_period_in_ns_=(p) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/origen_testers/timing/timeset.rb', line 116

def _period_in_ns_=(p)
  if locked?
    Origen.app.fail(
      exception_class: InvalidModification,
      message:         "Timeset :#{@name}'s period_in_ns is locked to #{@period_in_ns} ns!"
    )
  end

  # Adding this causes examples in Origen (not OrigenTesters) to fail.
  # Needs further discussion and potentially an Origen examples change.
  # if cycled? && p != period_in_ns
  #  Origen.app!.fail(
  #    exception_class: InvalidModification,
  #    message:         [
  #      "Timeset :#{name}'s period_in_ns cannot be changed after a cycle has occurred using this timeset!",
  #      "  period_in_ns change occurred at #{caller[0]}",
  #      "  Attempted to change period from #{@period_in_ns} to #{p}"
  #    ].join("\n")
  #  )
  # end
  @period_in_ns = p
  @period_in_ns
end

#called?true, false

Indicates whether this timeset is or has been set as the current timeset.

Returns:

  • (true, false)

    true if this timeset is or has beent he current timeset, false otherwise.



94
95
96
# File 'lib/origen_testers/timing/timeset.rb', line 94

def called?
  @called
end

#current_timeset?true, false

Indicates whether this timeset is the current timeset.

Returns:

  • (true, false)

    true if this timeset is the current timeset, false otherwise.



88
89
90
# File 'lib/origen_testers/timing/timeset.rb', line 88

def current_timeset?
  OrigenTesters::Timing.timeset == self
end

#cycled?true, false

Returns true if tester.cycle has been called while this timeset was the current timeset.

Returns:

  • (true, false)

    true if this timeset has been cycled, false otherwise.



30
31
32
# File 'lib/origen_testers/timing/timeset.rb', line 30

def cycled?
  @cycled
end

#dut_timesetObject



103
104
105
# File 'lib/origen_testers/timing/timeset.rb', line 103

def dut_timeset
  dut.timesets[id]
end

#idObject

Alias for the #name attr_reader.



99
100
101
# File 'lib/origen_testers/timing/timeset.rb', line 99

def id
  name.to_sym
end

#lock!true, false Also known as: lock_period!, lock_period_in_ns!

Locks the current value of the timeset's period_in_ns. Attempts to further adjust the period_in_ns will results in an exception.

Returns:

  • (true, false)

    true if the period_in_ns has been locked, false otherwise.



45
46
47
# File 'lib/origen_testers/timing/timeset.rb', line 45

def lock!
  @locked = true
end

#locked?Boolean Also known as: period_in_ns_locked?, period_locked?, locked

Returns true if this timeset does not allow changes to its period_in_ns

Returns:

  • (Boolean)


35
36
37
# File 'lib/origen_testers/timing/timeset.rb', line 35

def locked?
  @locked
end

#period_in_ns?true, false

Indicates whether a period_in_ns has been defined for this timeset.

Returns:

  • (true, false)

    true if the period_in_ns has been set, false otherwise.



73
74
75
# File 'lib/origen_testers/timing/timeset.rb', line 73

def period_in_ns?
  !@period_in_ns.nil?
end

#period_in_secsFloat Also known as: period_in_seconds

Returns the current timeset in seconds

Returns:

  • (Float)

    Current period in seconds



79
80
81
82
83
# File 'lib/origen_testers/timing/timeset.rb', line 79

def period_in_secs
  if period_in_ns
    period_in_ns * (10**-9)
  end
end

#shorter_period_than?(timeset) ⇒ Boolean

Returns true if the timeset has a shorter period than the supplied timeset

Returns:

  • (Boolean)


23
24
25
# File 'lib/origen_testers/timing/timeset.rb', line 23

def shorter_period_than?(timeset)
  period_in_ns < timeset.period_in_ns
end