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_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.
3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 3007 def to_c return "" if @arguments.empty? # Create the format. format = @arguments.each do |arg| if arg.is_a?(Expression) then arg.type.signed? ? "%lld" : "%llu" else "%s" end end.join return "printf(\"#{format}\"," + @arguments.each do |arg| if arg.is_a?(::String) then "\"#{arg}\"" else arg.to_c end end.join(",") end |
#to_ruby ⇒ Object
Convert to Ruby code.
2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2992 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 end res << ")\n" return res end |