Class: RubyHDL::High::Print
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of a hardware print statement.
Instance Method Summary collapse
-
#initialize(sequencer, *args) ⇒ Print
constructor
Create a new hprint statement in sequencer +sequencer+ for displaying +args+.
-
#to_c ⇒ Object
Convert to C code.
-
#to_python(l = "") ⇒ Object
Convert to Python code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
Methods inherited from Statement
#each_statement, #each_statement_deep
Constructor Details
Instance Method Details
#to_c ⇒ Object
Convert to C code.
3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3837 def to_c return "" if @arguments.empty? # Create the format. format = @arguments.map do |arg| if arg.is_a?(Expression) then arg.type.signed? ? "%lld" : "%llu" else "%s" end end.join return "printf(\"#{format}\"," + @arguments.map do |arg| if arg.is_a?(::String) then "\"#{arg.gsub(/\n/,"\\n")}\"" else arg.to_c end end.join(",") + ");" end |
#to_python(l = "") ⇒ Object
Convert to Python code.
3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3858 def to_python(l = "") return "" if @arguments.empty? res = "#{l}print(" @arguments.each do |arg| if arg.is_a?(::String) then res << "\"#{arg}\"" else res << arg.to_python end res << "," end res[-1] = ")" res << "\n" return res end |
#to_ruby ⇒ Object
Convert to Ruby code.
3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3820 def to_ruby return "" if @arguments.empty? res = "print(" @arguments.each do |arg| if arg.is_a?(::String) then res << "\"#{arg}\"" else res << arg.to_ruby end res << "," end res[-1] = ")" res << "\n" return res end |