Class: HDLRuby::High::SignalI
- Inherits:
-
Low::SignalI
- Object
- Base::SignalI
- Low::SignalI
- HDLRuby::High::SignalI
- Includes:
- HRef, SimSignal, WithFullname
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb,
lib/HDLRuby/hruby_high_fullname.rb
Overview
Extends the SignalI class for hybrid Ruby-C simulation.
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#can_read ⇒ Object
Tells if the signal can be read.
-
#can_write ⇒ Object
Tells if the signal can be written.
-
#dir ⇒ Object
The bounding direction.
-
#rcsignalI ⇒ Object
readonly
Returns the value of attribute rcsignalI.
Attributes included from SimSignal
Attributes inherited from Low::SignalI
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#coerce(obj) ⇒ Object
Coerce by converting signal to an expression.
-
#edge ⇒ Object
Creates an edge event from the signal.
-
#initialize(name, type, dir, value = nil) ⇒ SignalI
constructor
Creates a new signal named +name+ typed as +type+ with +dir+ as bounding direction and possible +value+.
-
#negedge ⇒ Object
Creates a negative edge event from the signal.
-
#posedge ⇒ Object
Creates a positive edge event from the signal.
-
#to_expr ⇒ Object
Converts to a new expression.
-
#to_low(name = self.name) ⇒ Object
Converts the system to HDLRuby::Low and set its +name+.
-
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the signal comming from object whose C description is +rcowner+.
-
#to_ref ⇒ Object
Converts to a new reference.
Methods included from WithFullname
Methods included from SimSignal
#add_anyedge, #add_negedge, #add_posedge, #assign, #assign_at, #each_anyedge, #each_negedge, #each_posedge, #execute, #fullname, #init_sim
Methods included from HRef
Methods inherited from Low::SignalI
#clone, #each_deep, #explicit_types!, #immutable?, #replace_names!, #set_name!, #set_type!, #set_value!, #to_c, #to_c_alias, #to_c_signal, #to_ch, #to_hdr, #to_high, #to_verilog, #to_vhdl, #width
Methods included from Low::Low2Symbol
Methods included from Low::Hparent
#hierarchy, #no_parent!, #scope
Constructor Details
#initialize(name, type, dir, value = nil) ⇒ SignalI
Creates a new signal named +name+ typed as +type+ with +dir+ as bounding direction and possible +value+.
NOTE: +dir+ can be :input, :output, :inout or :inner
3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 |
# File 'lib/HDLRuby/hruby_high.rb', line 3790 def initialize(name,type,dir,value = nil) # Check the value. value = value.to_expr.match_type(type) if value # Initialize the type structure. super(name,type,value) unless name.empty? then # Named signal, set the hdl-like access to the signal. obj = self # For using the right self within the proc High.space_reg(name) { obj } end # Hierarchical type allows access to sub references, so generate # the corresponding methods. if type.struct? then type.each_name do |name| self.define_singleton_method(name) do RefObject.new(self.to_ref, SignalI.new(name,type.get_type(name),dir)) end end end # Check and set the bound. self.dir = dir # Set the read and write authorisations. @can_read = 1.to_expr @can_write = 1.to_expr end |
Instance Attribute Details
#can_read ⇒ Object
Tells if the signal can be read.
3781 3782 3783 |
# File 'lib/HDLRuby/hruby_high.rb', line 3781 def can_read @can_read end |
#can_write ⇒ Object
Tells if the signal can be written.
3784 3785 3786 |
# File 'lib/HDLRuby/hruby_high.rb', line 3784 def can_write @can_write end |
#dir ⇒ Object
The bounding direction.
3778 3779 3780 |
# File 'lib/HDLRuby/hruby_high.rb', line 3778 def dir @dir end |
#rcsignalI ⇒ Object (readonly)
Returns the value of attribute rcsignalI.
415 416 417 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 415 def rcsignalI @rcsignalI end |
Instance Method Details
#coerce(obj) ⇒ Object
Coerce by converting signal to an expression.
3865 3866 3867 |
# File 'lib/HDLRuby/hruby_high.rb', line 3865 def coerce(obj) return [obj,self.to_expr] end |
#edge ⇒ Object
Creates an edge event from the signal.
3850 3851 3852 |
# File 'lib/HDLRuby/hruby_high.rb', line 3850 def edge return Event.new(:edge,self.to_ref) end |
#negedge ⇒ Object
Creates a negative edge event from the signal.
3845 3846 3847 |
# File 'lib/HDLRuby/hruby_high.rb', line 3845 def negedge return Event.new(:negedge,self.to_ref) end |
#posedge ⇒ Object
Creates a positive edge event from the signal.
3840 3841 3842 |
# File 'lib/HDLRuby/hruby_high.rb', line 3840 def posedge return Event.new(:posedge,self.to_ref) end |
#to_expr ⇒ Object
Converts to a new expression.
3860 3861 3862 |
# File 'lib/HDLRuby/hruby_high.rb', line 3860 def to_expr return self.to_ref end |
#to_low(name = self.name) ⇒ Object
Converts the system to HDLRuby::Low and set its +name+.
3870 3871 3872 3873 3874 3875 3876 3877 3878 |
# File 'lib/HDLRuby/hruby_high.rb', line 3870 def to_low(name = self.name) # return HDLRuby::Low::SignalI.new(name,self.type.to_low) valueL = self.value ? self.value.to_low : nil signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL) # # For debugging: set the source high object # signalIL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = signalIL return signalIL end |
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the signal comming from object whose C description is +rcowner+
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 419 def to_rcsim(rcowner) # Create the signal C object. @rcsignalI = RCSim.rcsim_make_signal(self.name.to_s, self.type.to_rcsim) # puts "to_rcsim for signal=(#{self.name})#{self}, @rcsignalI=#{@rcsignalI}" # Set the owner. RCSim.rcsim_set_owner(@rcsignalI,rcowner) # Set the initial value if any. if self.value then RCSim.rcsim_set_signal_value(@rcsignalI,self.value.to_rcsim) end return @rcsignalI end |