Module: RubyRTL
- Defined in:
- lib/ruby_rtl/ast.rb,
lib/ruby_rtl/dsl.rb,
lib/ruby_rtl/version.rb,
lib/ruby_rtl/visitor.rb,
lib/ruby_rtl/compiler.rb,
lib/ruby_rtl/ast_builder.rb,
lib/ruby_rtl/ast_printer.rb,
lib/ruby_rtl/dsl_printer.rb,
lib/ruby_rtl/type_checker.rb,
lib/ruby_rtl/sexp_generator.rb,
lib/ruby_rtl/vhdl_generator.rb,
lib/ruby_rtl/contextual_analyzer.rb
Defined Under Namespace
Classes: ASTBuilder, ASTPrinter, Assign, Ast, Binary, BitLit, BitType, BitVectorType, Body, Case, Circuit, CircuitPart, Combinatorial, Comment, CompDecl, Compiler, ContextualAnalyzer, DSLPrinter, Else, Elsif, EnumType, Expr, Fsm, FuncCall, If, Indexed, Input, IntLit, IntType, Literal, MemoryType, Next, Output, Port, RIntLit, RIntType, RType, RUIntLit, RUIntType, RecordType, Root, Sequential, SexpGenerator, Sig, SigDecl, State, Statement, Type, TypeChecker, TypeDecl, UIntLit, UIntType, Unary, VhdlGenerator, Visitor, When
Constant Summary
collapse
- VERSION =
"0.0.1"
Instance Method Summary
collapse
Instance Method Details
#Bit(val) ⇒ Object
194
195
196
|
# File 'lib/ruby_rtl/dsl.rb', line 194
def Bit val
BitLit.new(val)
end
|
#build_type(arg) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# 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] 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
|
#Enum(*elems) ⇒ Object
190
191
192
|
# File 'lib/ruby_rtl/dsl.rb', line 190
def Enum *elems
EnumType.new(elems)
end
|
#Memory(size, type) ⇒ Object
171
172
173
174
|
# File 'lib/ruby_rtl/dsl.rb', line 171
def Memory size,type
p type=build_type(type)
MemoryType.new(size,type)
end
|
#Record(hash) ⇒ Object
176
177
178
179
180
181
182
183
184
|
# 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) ⇒ Object
186
187
188
|
# File 'lib/ruby_rtl/dsl.rb', line 186
def Struct hash
Record(hash) end
|