Module: HDLRuby::High::SimSignal
Overview
Module for extending signal classes with Ruby-level simulation.
Instance Attribute Summary collapse
-
#c_value ⇒ Object
Access the current and future value.
-
#f_value ⇒ Object
Access the current and future value.
Instance Method Summary collapse
-
#add_anyedge(beh) ⇒ Object
Adds behavior +beh+ activated on a any edge of the signal.
-
#add_negedge(beh) ⇒ Object
Adds behavior +beh+ activated on a negative edge of the signal.
-
#add_posedge(beh) ⇒ Object
Adds behavior +beh+ activated on a positive edge of the signal.
-
#assign(mode, value) ⇒ Object
Assigns +value+ the the reference.
-
#assign_at(mode, value, index) ⇒ Object
Assigns +value+ at +index+ (integer or range).
-
#each_anyedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on any edge.
-
#each_negedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on a negative edge.
-
#each_posedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on a positive edge.
-
#execute(mode) ⇒ Object
Execute the expression.
-
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for +systemT+.
Instance Attribute Details
#c_value ⇒ Object
Access the current and future value.
391 392 393 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 391 def c_value @c_value end |
#f_value ⇒ Object
Access the current and future value.
391 392 393 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 391 def f_value @f_value end |
Instance Method Details
#add_anyedge(beh) ⇒ Object
Adds behavior +beh+ activated on a any edge of the signal.
422 423 424 425 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 422 def add_anyedge(beh) @anyedge_behaviors ||= [] @anyedge_behaviors << beh end |
#add_negedge(beh) ⇒ Object
Adds behavior +beh+ activated on a negative edge of the signal.
416 417 418 419 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 416 def add_negedge(beh) @negedge_behaviors ||= [] @negedge_behaviors << beh end |
#add_posedge(beh) ⇒ Object
Adds behavior +beh+ activated on a positive edge of the signal.
410 411 412 413 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 410 def add_posedge(beh) @posedge_behaviors ||= [] @posedge_behaviors << beh end |
#assign(mode, value) ⇒ Object
Assigns +value+ the the reference.
454 455 456 457 458 459 460 461 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 454 def assign(mode,value) # Set the next value. @f_value = value # Set the mode. @mode = mode # puts "assign #{value.content} (#{value.content.class}) with self.type.width=#{self.type.width} while value.type.width=#{value.type.width}" if self.name.to_s.include?("idx") # @f_value = value.cast(self.type) # Cast inserted by HDLRuby normally end |
#assign_at(mode, value, index) ⇒ Object
Assigns +value+ at +index+ (integer or range).
464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 464 def assign_at(mode,value,index) # @f_value = @f_value.assign_at(mode,value,index) # Sets the next value. if (@f_value.equal?(@c_value)) then # Need to duplicate @f_value to avoid side effect. @f_value = Value.new(@f_value.type,@f_value.content.clone) end @f_value[index] = value # Sets the mode @mode = mode end |
#each_anyedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on any edge.
440 441 442 443 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 440 def each_anyedge(&ruby_block) @anyedge_behaviors ||= [] @anyedge_behaviors.each(&ruby_block) end |
#each_negedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on a negative edge.
434 435 436 437 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 434 def each_negedge(&ruby_block) @negedge_behaviors ||= [] @negedge_behaviors.each(&ruby_block) end |
#each_posedge(&ruby_block) ⇒ Object
Iterates over the behaviors activated on a positive edge.
428 429 430 431 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 428 def each_posedge(&ruby_block) @posedge_behaviors ||= [] @posedge_behaviors.each(&ruby_block) end |
#execute(mode) ⇒ Object
Execute the expression.
447 448 449 450 451 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 447 def execute(mode) # puts "Executing signal=#{self.fullname}" # return mode == :par ? self.c_value : self.f_value return @mode == :seq ? self.f_value : self.c_value end |
#fullname ⇒ Object
Returns the name of the signal with its hierarchy.
479 480 481 482 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 479 def fullname @fullname ||= self.parent.fullname + ":" + self.name.to_s return @fullname end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for +systemT+
394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 394 def init_sim(systemT) if self.value then @c_value = self.value.execute(:par).to_value @f_value = @c_value.to_value # puts "init signal value at=#{@c_value.to_bstr}" # The signal is considered active. systemT.add_sig_active(self) else # @c_value = Value.new(self.type,"x" * self.type.width) # @f_value = Value.new(self.type,"x" * self.type.width) @c_value = Value.new(self.type,"x") @f_value = Value.new(self.type,"x") end end |