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+.


2512
2513
2514
2515
2516
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2512

def initialize(type,name)
  @type = type.to_type
  @name = name.to_sym
  # @content = nil # The content is the Ruby value, not the HW description one!
end

Instance Attribute Details

#nameObject (readonly)

, :content


2510
2511
2512
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2510

def name
  @name
end

#typeObject (readonly)

, :content


2510
2511
2512
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2510

def type
  @type
end

Instance Method Details

#array?Boolean

Tell if the signal is an array.

Returns:

  • (Boolean)

2519
2520
2521
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2519

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

#to_fObject

Convert to an float.


2557
2558
2559
2560
2561
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2557

def to_f
  # return @content.to_f
  # return binding.local_variable_get(to_ruby.to_sym).to_f
  return self.value.to_f
end

#to_iObject

Convert to an integer.


2550
2551
2552
2553
2554
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2550

def to_i
  # return @content.to_i
  # return binding.local_variable_get(to_ruby.to_sym).to_i
  return self.value.to_i
end

#to_rubyObject

Convert to ruby code.


2534
2535
2536
2537
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2534

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

#to_sObject

Convert to a string.


2564
2565
2566
2567
2568
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2564

def to_s
  # return @content.to_s
  # return binding.local_variable_get(to_ruby.to_sym).to_s
  return self.value.to_s
end

#valueObject

Gets the value of the signal.


2540
2541
2542
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2540

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

#value=(val) ⇒ Object

Sets the value of the signal.


2545
2546
2547
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2545

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