Class: Ecic::Generate

Inherits:
Command show all
Includes:
LibraryCreationHelper
Defined in:
lib/ecic/generate.rb

Instance Method Summary collapse

Methods included from LibraryCreationHelper

#create_library_if_missing, #generate_library, #ok_to_create_library?

Methods inherited from Command

dispatch

Instance Method Details

#design(*names) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ecic/generate.rb', line 63

def design(*names)
  begin
    type = options[:type]
    root_dir = Project::root
    if root_dir.nil?
      shell.error set_color("You must be within an ECIC project before calling this command",Thor::Shell::Color::RED)
      exit(1)
    end
    project = Project.new(root_dir)
    project.load_libraries
  #      p project.libraries

    lib = project.design_library(options[:lib])
    unless lib.already_exists?
      unless ok_to_create_library? lib
        say "Operation aborted!"
        raise SystemExit
      end
    end

    names.each { |design_name|
      incl_types_pkg = options[:types_package]
      if type == 'vhdl'
        incl_types_pkg = yes?("Would you like to include a package for type and constant definitions for '#{design_name}'? [y/N]: ") if incl_types_pkg.nil?
      else
        incl_types_pkg ||= false
        if incl_types_pkg
          shell.error set_color("--types_package option does not apply for Verilog/SystemVerilog generation!",Thor::Shell::Color::RED)
          exit(3)
        end
      end
      if type == 'vhdl'
        generator = DesignGenerator.new
        generator.include_types_pkg = incl_types_pkg
      elsif type == 'sv'
        generator = SvDesignGenerator.new
      else
        shell.error set_color("--type option must be set to either 'vhdl' or 'sv'",Thor::Shell::Color::RED)
        exit(3)
      end
      generator.destination_root = root_dir
      generator.library = lib
      generator.design_name = design_name
      generator.invoke_all
    }
  rescue Exception => exc
    shell.error set_color(exc.message,Thor::Shell::Color::RED)
    exit(3)
  end
  
end

#library(*names) ⇒ Object



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
50
# File 'lib/ecic/generate.rb', line 24

def library(*names)
  begin
    project_root_path = Ecic::Project::root
  #project_root_path = Dir.pwd
  #if false
    if project_root_path.nil?
      shell.error set_color("You must be within an ECIC project before calling this command",Thor::Shell::Color::RED)
      exit(1)
    else
  #        shell.say "Generating library in #{project_root_path}"
      project = Project.new(project_root_path)
      project.load_libraries
      names.each { |lib_name|
        #TBA: Add option to generate a testbench library as well
        new_lib = project.design_library(lib_name)
        if new_lib.already_exists?
          say set_color("Library called '#{lib_name}' already exists",Thor::Shell::Color::GREEN)
        else
          shell.error set_color("Library called '#{lib_name}' could not be generated",Thor::Shell::Color::RED) unless generate_library new_lib
        end
      }
    end
  rescue Exception => exc
    shell.error set_color(exc.message,Thor::Shell::Color::RED)
    exit(3)
  end
end