Class: HDLRuby::High::SignalC
- Inherits:
-
Low::SignalC
- Object
- Low::SignalI
- Low::SignalC
- HDLRuby::High::SignalC
- 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
Describes a constant signal.
Constant Summary collapse
Constants included from Low::Low2Symbol
Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#rcsignalC ⇒ Object
readonly
Extends the SignalC class for hybrid Ruby-C simulation.
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.
-
#initialize(name, type, value) ⇒ SignalC
constructor
Creates a new constant signal named +name+ typed as +type+ and +value+.
-
#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, #get_vars_with_fullname, #get_vars_with_idstr, #init_sim, #show_hierarchy
Methods included from HRef
#each, included, #objects, #to_event
Methods included from Enumerable
Methods inherited from Low::SignalC
Methods inherited from Low::SignalI
#add_signal, #clone, #each_deep, #each_signal, #explicit_types!, #get_by_name, #get_signal, #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, value) ⇒ SignalC
Creates a new constant signal named +name+ typed as +type+ and +value+.
4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 |
# File 'lib/HDLRuby/hruby_high.rb', line 4001 def initialize(name,type,value) # Check the value is a constant. value = value.to_expr.match_type(type) unless value.constant? then raise AnyError,"Non-constant value assignment to constant." end # 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, SignalC.new(name,type.get_type(name), value[name])) end end end end |
Instance Attribute Details
#rcsignalC ⇒ Object (readonly)
Extends the SignalC class for hybrid Ruby-C simulation.
456 457 458 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 456 def rcsignalC @rcsignalC end |
Instance Method Details
#coerce(obj) ⇒ Object
Coerce by converting signal to an expression.
4040 4041 4042 |
# File 'lib/HDLRuby/hruby_high.rb', line 4040 def coerce(obj) return [obj,self.to_expr] end |
#to_expr ⇒ Object
Converts to a new expression.
4035 4036 4037 |
# File 'lib/HDLRuby/hruby_high.rb', line 4035 def to_expr return self.to_ref end |
#to_low(name = self.name) ⇒ Object
Converts the system to HDLRuby::Low and set its +name+.
4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 |
# File 'lib/HDLRuby/hruby_high.rb', line 4045 def to_low(name = self.name) # return HDLRuby::Low::SignalC.new(name,self.type.to_low, # self.value.to_low) signalCL = HDLRuby::Low::SignalC.new(name,self.type.to_low, self.value.to_low) # Recurse on the sub signals if any. self.each_signal do |sig| signalCL.add_signal(sig.to_low) end # # For debugging: set the source high object # signalCL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = signalCL return signalCL end |
#to_rcsim(rcowner) ⇒ Object
Generate the C description of the signal comming from object whose C description is +rcowner+
460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 460 def to_rcsim(rcowner) # Create the signal C object. @rcsignalC = RCSim.rcsim_make_signal(self.name.to_s, self.type.to_rcsim) # Set the owner. RCSim.rcsim_set_owner(@rcsignalC,rcowner) # Set the initial value. RCSim.rcsim_set_signal_value(@rcsignalC,self.value.to_rcsim) return @rcsignalC end |