class Vertigo::Compiler

Attributes

ast[RW]
options[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/vertigo/compiler.rb, line 14
def initialize options={}
  @options=options
end

Public Instance Methods

compile(filename) click to toggle source
# File lib/vertigo/compiler.rb, line 18
def compile filename
  begin
    parse(filename)
    puts "=> parsed successfully. Good" unless options[:mute]
    dump_ast if options[:dump_ast]
    pretty_print if options[:pp] or options[:pp_to_file]
    return true
  rescue Exception => e
    puts e.backtrace unless options[:mute]
    puts e unless options[:mute]
    raise
  end
end
dump_ast() click to toggle source
# File lib/vertigo/compiler.rb, line 38
def dump_ast
  pp @ast
end
gen_tb(filename) click to toggle source
# File lib/vertigo/compiler.rb, line 56
def gen_tb filename
  parse filename
  TestBenchGenerator.new(options).generate_from(ast)
end
parse(filename) click to toggle source
# File lib/vertigo/compiler.rb, line 32
def parse filename
  puts "=> parsing VHDL file : #{filename}" unless options[:mute]
  @basename=File.basename(filename,File.extname(filename))
  @ast=Parser.new(options).parse filename
end
pretty_print() click to toggle source
# File lib/vertigo/compiler.rb, line 42
def pretty_print
  puts "=> pretty printing" unless options[:mute]
  begin
    code=PrettyPrinter.new.print(ast)
    file=code.save_as "#{@basename}_pp.vhd" if options[:pp_to_file]
    puts "   - saved as #{file}" if options[:pp_to_file] unless options[:mute]
    puts code.finalize if options[:pp]
  rescue Exception => e
    puts e.backtrace if options[:pp]
    puts e if options[:pp]
    raise "pp error"
  end
end