Class: RubyHDL::High::Ruby

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

Overview

Describes arbitrary code.

Constant Summary collapse

@@ruby_blocks =
[]

Instance Attribute Summary

Attributes inherited from Expression

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#<=, #[], #mux, #sdownto, #seach, #stimes, #supto, #to_value

Constructor Details

#initialize(&ruby_block) ⇒ Ruby

Create a new ruby code block for +ruby_block+.


2117
2118
2119
2120
2121
2122
2123
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2117

def initialize(&ruby_block)
  # puts "ruby_block=#{ruby_block}"
  # Create the id for the block.
  @id = @@ruby_blocks.size
  # Adds the block.
  @@ruby_blocks << ruby_block
end

Class Method Details

.call(id) ⇒ Object

Execute a ruby code block for +ruby_block+.


2134
2135
2136
2137
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2134

def self.call(id)
  # puts "id=#{id}"
  @@ruby_blocks[id].call
end

Instance Method Details

#to_exprObject

Convert to expression: does not change but remove from the statement list.


2127
2128
2129
2130
2131
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2127

def to_expr
  # Remove the transmit from the top SW block.
  RubyHDL::High.top_sblock.delete(self)
  return self
end

#to_rubyObject

Convert to ruby code.


2140
2141
2142
2143
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2140

def to_ruby
  puts caller[0]
  return "RubyHDL::High::Ruby.call(#{@id})"
end