Class: RubyHDL::High::SignalI

Inherits:
Expression show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes a SW implementation of a signal.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#<=, #[], #mux, #sdownto, #seach, #stimes, #supto, #to_expr, #to_value

Constructor Details

#initialize(type, name) ⇒ SignalI

Create a new signal with type +type+ and name +name+.



3110
3111
3112
3113
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3110

def initialize(type,name)
  @type = type.to_type
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

, :content



3108
3109
3110
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3108

def name
  @name
end

#typeObject (readonly)

, :content



3108
3109
3110
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3108

def type
  @type
end

Instance Method Details

#array?Boolean

Tell if the signal is an array.



3116
3117
3118
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3116

def array?
  return @type.base.is_a?(TypeVector)
end

#to_fObject

Convert to an float.



3149
3150
3151
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3149

def to_f
  return self.value.to_f
end

#to_iObject

Convert to an integer.



3144
3145
3146
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3144

def to_i
  return self.value.to_i
end

#to_rubyObject Also known as: to_c

Convert to Ruby code.



3121
3122
3123
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3121

def to_ruby
  return "__" + self.name.to_s
end

#to_sObject

Convert to a string.



3154
3155
3156
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3154

def to_s
  return self.value.to_s
end

#valueObject

Gets the value of the signal.



3134
3135
3136
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3134

def value
  return TOPLEVEL_BINDING.eval(self.to_ruby)
end

#value=(val) ⇒ Object

Sets the value of the signal.



3139
3140
3141
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3139

def value=(val)
  return TOPLEVEL_BINDING.eval("#{self.to_ruby} = #{val}")
end

#value?Boolean

Check if a value is defined for the signal.



3129
3130
3131
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3129

def value?
  return TOPLEVEL_BINDING.local_variable_defined?(self.to_ruby)
end