Class: RubyHDL::High::SfunctionT
- Inherits:
-
Object
- Object
- RubyHDL::High::SfunctionT
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a sequencer function.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, sblock, *args) ⇒ SfunctionT
constructor
Create a new named +name+ with arguments +args+ and executing the content of block +sblock+.
-
#make_return_type(sblock) ⇒ Object
Compute the return type from current sblock +sblock+.
-
#to_c ⇒ Object
Convert to C code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
Constructor Details
#initialize(name, sblock, *args) ⇒ SfunctionT
Create a new named +name+ with arguments +args+ and executing the content of block +sblock+
3746 3747 3748 3749 3750 3751 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3746 def initialize(name,sblock,*args) @name = name.to_sym @args = args @blk = sblock @type = self.make_return_type(@blk) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3743 3744 3745 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3743 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3743 3744 3745 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3743 def type @type end |
Instance Method Details
#make_return_type(sblock) ⇒ Object
Compute the return type from current sblock +sblock+
3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3754 def make_return_type(sblock) # Locate a return statement. sblock.each_statement_deep do |statement| if statement.is_a?(RubyHDL::High::Sreturn) then return statement.value.type end end # No return, so void type. return RubyHDL::High::Void end |
#to_c ⇒ Object
Convert to C code.
3771 3772 3773 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3771 def to_c return "unsigned long long __#{name}(#{@args.map {|arg| "unsigned long long " + arg.to_c}.join(",")} {\n#{@blk.sequencer.clk_up_c}\n#{@blk.to_c}\n}\n" end |
#to_ruby ⇒ Object
Convert to Ruby code.
3766 3767 3768 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3766 def to_ruby return "def __#{name}(#{@args.map {|arg| "__" + arg.to_ruby}.join(",")})\n#{@blk.sequencer.clk_up}\n#{@blk.to_ruby}\nend\n" end |