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_python(l = "") ⇒ Object
Convert to Python code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
-
#to_tf(l = "") ⇒ Object
Convert to Python code.
Constructor Details
#initialize(name, sblock, *args) ⇒ SfunctionT
Create a new named +name+ with arguments +args+ and executing the content of block +sblock+
4734 4735 4736 4737 4738 4739 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4734 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.
4731 4732 4733 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4731 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4731 4732 4733 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4731 def type @type end |
Instance Method Details
#make_return_type(sblock) ⇒ Object
Compute the return type from current sblock +sblock+
4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4742 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.
4759 4760 4761 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4759 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_python(l = "") ⇒ Object
Convert to Python code.
4764 4765 4766 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4764 def to_python(l = "") return "#{l}def __#{name}(#{@args.map {|arg| "__" + arg.to_ruby}.join(",")}):\n#{@blk.sequencer.clk_python(l + " ")}\n#{@blk.to_python(l + " ")}\n" end |
#to_ruby ⇒ Object
Convert to Ruby code.
4754 4755 4756 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4754 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 |
#to_tf(l = "") ⇒ Object
Convert to Python code.
4769 4770 4771 4772 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 4769 def to_tf(l = "") return "#{l}@tf.function\n" + "#{l}def __#{name}(#{@args.map {|arg| "__" + arg.to_ruby}.join(",")}):\n#{@blk.to_tf(l + " ")}\n" end |