Class: RubyHDL::High::Sync

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

Overview

Describes a SW synchronization of a signal.

Instance Method Summary collapse

Methods inherited from Statement

#each_statement, #each_statement_deep

Constructor Details

#initialize(sequencer) ⇒ Sync

Returns a new instance of Sync.



2562
2563
2564
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2562

def initialize(sequencer)
  @sequencer = sequencer
end

Instance Method Details

#to_cObject

Convert to C code.



2583
2584
2585
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2583

def to_c
  return "yield();"
end

#to_rubyObject

Convert to Ruby code.



2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2567

def to_ruby
  # Update the inputs and outputs.
  res = ""
  RubyHDL::High.global_sblock.each_signal do |signal|
    case signal.dir
    when :input
      res << signal.to_ruby + " = RubyHDL.#{signal.name}\n"
    when :output
      res << "RubyHDL.#{signal.name} = " + signal.to_ruby + "\n"
    end
  end
  res << "Fiber.yield"
  return res
end