module RubyRTL
Constants
- VERSION
Public Instance Methods
Bit(val)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 194 def Bit val BitLit.new(val) end
Enum(*elems)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 190 def Enum *elems EnumType.new(elems) end
Memory(size,type)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 171 def Memory size,type p type=build_type(type) MemoryType.new(size,type) end
Record(hash)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 176 def Record hash h={} hash.each do |name,type| type||=$typedefs[type] type=build_type(type) h[name]=type end RecordType.new(h) end
Struct(hash)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 186 def Struct hash Record(hash) # call to method Record end
build_type(arg)
click to toggle source
# File lib/ruby_rtl/dsl.rb, line 6 def build_type arg case arg when Symbol case sym=arg.to_s when "bit" sym="bit" ret=BitType.new when "byte" ret=IntType.new(8) when /\Abv(\d+)/ ret=BitVectorType.new($1.to_i) when /\Auint(\d+)?/ nbits=($1 || 32).to_i ret=UIntType.new(nbits) when /\Aint(\d+)?/ nbits=($1 || 32).to_i ret=IntType.new(nbits) else unless ret=$typedefs[arg] # global var ! raise "DSL syntax error : unknow type '#{sym}'" end end $typedefs||={} $typedefs[sym]||=ret when Integer val=arg if val==1 name="bit" ret=BitType.new if val==1 else name="bv#{val}" ret=BitVectorType.new(val) end $typedefs||={} $typedefs[name]||=ret when Hash ret=arg when IntType,UIntType,BitType,BitVectorType ret=arg else raise "ERROR : DSL syntax error. build_type for #{arg} (#{arg.class})" end ret end