origen 0.34.3 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/origen +1 -231
- data/config/application.rb +12 -3
- data/config/boot.rb +2 -7
- data/config/commands.rb +3 -74
- data/config/rubocop/easy_disabled.yml +4 -0
- data/config/rubocop/easy_enabled.yml +0 -4
- data/config/rubocop/strict_disabled.yml +4 -0
- data/config/rubocop/strict_enabled.yml +0 -4
- data/config/version.rb +2 -3
- data/lib/origen.rb +27 -14
- data/lib/origen/application.rb +88 -2
- data/lib/origen/application/deployer.rb +3 -1
- data/lib/origen/application/release.rb +2 -2
- data/lib/origen/application/runner.rb +35 -20
- data/lib/origen/boot.rb +302 -0
- data/lib/origen/boot/api.rb +13 -0
- data/lib/origen/boot/app.rb +284 -0
- data/lib/origen/code_generators.rb +30 -10
- data/lib/origen/code_generators/actions.rb +244 -34
- data/lib/origen/code_generators/base.rb +9 -2
- data/lib/origen/code_generators/block.rb +203 -0
- data/lib/origen/code_generators/block_common.rb +100 -0
- data/lib/origen/code_generators/dut.rb +62 -0
- data/lib/origen/code_generators/feature.rb +50 -0
- data/lib/origen/code_generators/klass.rb +41 -0
- data/lib/origen/code_generators/model.rb +60 -0
- data/lib/origen/code_generators/module.rb +92 -0
- data/lib/origen/commands.rb +30 -13
- data/lib/origen/commands/archive.rb +175 -0
- data/lib/origen/commands/extract.rb +43 -0
- data/lib/origen/commands/generate.rb +1 -0
- data/lib/origen/commands/lint.rb +6 -1
- data/lib/origen/commands/new.rb +48 -24
- data/lib/origen/commands/new_resource.rb +41 -0
- data/lib/origen/commands/site.rb +52 -0
- data/lib/origen/commands/web.rb +11 -6
- data/lib/origen/commands_global.rb +9 -7
- data/lib/origen/core_ext/numeric.rb +20 -0
- data/lib/{option_parser → origen/core_ext/option_parser}/optparse.rb +0 -0
- data/lib/origen/dependencies.rb +0 -0
- data/lib/origen/file_handler.rb +18 -6
- data/lib/origen/generator.rb +19 -10
- data/lib/origen/generator/comparator.rb +2 -1
- data/lib/origen/generator/flow.rb +3 -1
- data/lib/origen/generator/job.rb +60 -16
- data/lib/origen/generator/pattern.rb +132 -72
- data/lib/origen/generator/pattern_finder.rb +3 -3
- data/lib/origen/generator/pattern_sequence.rb +201 -0
- data/lib/origen/generator/pattern_sequencer.rb +99 -0
- data/lib/origen/generator/pattern_thread.rb +175 -0
- data/lib/origen/loader.rb +381 -0
- data/lib/origen/log.rb +250 -108
- data/lib/origen/model.rb +22 -1
- data/lib/origen/model/exporter.rb +50 -10
- data/lib/origen/model_initializer.rb +5 -1
- data/lib/origen/operating_systems.rb +4 -0
- data/lib/origen/parameters.rb +96 -4
- data/lib/origen/parameters/set.rb +4 -3
- data/lib/origen/pins.rb +10 -8
- data/lib/origen/pins/pin.rb +61 -46
- data/lib/origen/ports/port.rb +5 -0
- data/lib/origen/registers.rb +5 -0
- data/lib/origen/registers/bit.rb +57 -53
- data/lib/origen/registers/bit_collection.rb +100 -43
- data/lib/origen/registers/msb0_delegator.rb +47 -0
- data/lib/origen/registers/reg.rb +114 -99
- data/lib/origen/revision_control.rb +1 -1
- data/lib/origen/revision_control/git.rb +23 -3
- data/lib/origen/site_config.rb +251 -60
- data/lib/origen/site_config/config.rb +217 -0
- data/lib/origen/sub_blocks.rb +106 -31
- data/lib/origen/top_level.rb +11 -0
- data/lib/origen/users/user.rb +3 -2
- data/lib/origen/utility/mailer.rb +42 -9
- data/lib/origen/value/bin_str_val.rb +1 -1
- data/lib/origen/value/hex_str_val.rb +1 -1
- data/lib/origen/version_string.rb +6 -1
- data/lib/tasks/gem.rake +6 -1
- data/origen_app_generators/Gemfile +19 -0
- data/origen_app_generators/Gemfile.lock +152 -0
- data/origen_app_generators/LICENSE +21 -0
- data/origen_app_generators/README.md +368 -0
- data/{templates/code_generators/rakefile.rb → origen_app_generators/Rakefile} +0 -0
- data/origen_app_generators/bin/boot.rb +39 -0
- data/origen_app_generators/config/application.rb +153 -0
- data/origen_app_generators/config/boot.rb +1 -0
- data/origen_app_generators/config/commands.rb +63 -0
- data/origen_app_generators/config/shared_commands.rb +177 -0
- data/origen_app_generators/config/version.rb +8 -0
- data/origen_app_generators/doc/history +223 -0
- data/origen_app_generators/lbin/bundle +105 -0
- data/origen_app_generators/lbin/byebug +29 -0
- data/origen_app_generators/lbin/coderay +29 -0
- data/origen_app_generators/lbin/htmldiff +29 -0
- data/origen_app_generators/lbin/httparty +29 -0
- data/origen_app_generators/lbin/httpclient +29 -0
- data/origen_app_generators/lbin/kramdown +29 -0
- data/origen_app_generators/lbin/ldiff +29 -0
- data/origen_app_generators/lbin/nanoc +29 -0
- data/origen_app_generators/lbin/nokogiri +29 -0
- data/origen_app_generators/lbin/origen +62 -0
- data/origen_app_generators/lbin/pry +29 -0
- data/origen_app_generators/lbin/rackup +29 -0
- data/origen_app_generators/lbin/rake +29 -0
- data/origen_app_generators/lbin/rspec +29 -0
- data/origen_app_generators/lbin/rubocop +29 -0
- data/origen_app_generators/lbin/ruby-parse +29 -0
- data/origen_app_generators/lbin/ruby-rewrite +29 -0
- data/origen_app_generators/lbin/thor +29 -0
- data/origen_app_generators/lbin/tilt +29 -0
- data/origen_app_generators/lbin/yard +29 -0
- data/origen_app_generators/lbin/yardoc +29 -0
- data/origen_app_generators/lbin/yri +29 -0
- data/origen_app_generators/lib/origen_app_generators.rb +125 -0
- data/origen_app_generators/lib/origen_app_generators/application.rb +62 -0
- data/origen_app_generators/lib/origen_app_generators/base.rb +257 -0
- data/origen_app_generators/lib/origen_app_generators/empty_application.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/empty_plugin.rb +15 -0
- data/origen_app_generators/lib/origen_app_generators/new.rb +170 -0
- data/origen_app_generators/lib/origen_app_generators/new_app_tests.rb +4 -0
- data/origen_app_generators/lib/origen_app_generators/origen_infrastructure/app_generator_plugin.rb +107 -0
- data/origen_app_generators/lib/origen_app_generators/plugin.rb +55 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/common.rb +29 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/stand_alone_application.rb +64 -0
- data/origen_app_generators/lib/origen_app_generators/test_engineering/test_block.rb +61 -0
- data/origen_app_generators/origen_app_generators.gemspec +33 -0
- data/{templates/code_generators → origen_app_generators/spec}/spec_helper.rb +0 -0
- data/origen_app_generators/target/debug.rb +8 -0
- data/origen_app_generators/target/default.rb +8 -0
- data/origen_app_generators/target/production.rb +0 -0
- data/origen_app_generators/templates/app_generators/application/.gitignore +37 -0
- data/origen_app_generators/templates/app_generators/application/.irbrc +9 -0
- data/origen_app_generators/templates/app_generators/application/.rspec +1 -0
- data/origen_app_generators/templates/app_generators/application/.travis.yml +11 -0
- data/origen_app_generators/templates/app_generators/application/Gemfile +34 -0
- data/origen_app_generators/templates/app_generators/application/Rakefile +7 -0
- data/origen_app_generators/templates/app_generators/application/app/blocks/top_level.rb +12 -0
- data/origen_app_generators/templates/app_generators/application/app/lib/module.rb +6 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/index.md.erb +19 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/layouts/_basic.html.erb +13 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/partials/_navbar.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/application/app/templates/web/release_notes.md.erb +5 -0
- data/origen_app_generators/templates/app_generators/application/config/application.rb +121 -0
- data/origen_app_generators/templates/app_generators/application/config/boot.rb +4 -0
- data/origen_app_generators/templates/app_generators/application/config/commands.rb +79 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_dev.txt +4 -0
- data/origen_app_generators/templates/app_generators/application/config/maillist_prod.txt +3 -0
- data/origen_app_generators/templates/app_generators/application/config/version.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/doc/history +0 -0
- data/origen_app_generators/templates/app_generators/application/dot_keep +0 -0
- data/origen_app_generators/templates/app_generators/application/origen_core_session +2 -0
- data/origen_app_generators/templates/app_generators/application/spec/spec_helper.rb +44 -0
- data/origen_app_generators/templates/app_generators/application/target/debug.rb +8 -0
- data/origen_app_generators/templates/app_generators/application/target/default.rb +1 -0
- data/origen_app_generators/templates/app_generators/application/target/production.rb +4 -0
- data/origen_app_generators/templates/app_generators/new/generator.rb +102 -0
- data/origen_app_generators/templates/app_generators/new/info.md.erb +9 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/application.rb +54 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/base.rb +55 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/module.rb +28 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/app/lib/plugin.rb +64 -0
- data/origen_app_generators/templates/app_generators/origen_infrastructure/app_generator_plugin/config/load_generators.rb +6 -0
- data/origen_app_generators/templates/app_generators/plugin/Gemfile +32 -0
- data/origen_app_generators/templates/app_generators/plugin/Rakefile +10 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/index.md.erb +37 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_external.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/plugin/app/templates/web/partials/_navbar_internal.html.erb +20 -0
- data/origen_app_generators/templates/app_generators/plugin/config/boot.rb +24 -0
- data/origen_app_generators/templates/app_generators/plugin/gemspec.rb +43 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/j750.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/uflex.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/environment/v93k.rb +1 -0
- data/origen_app_generators/templates/app_generators/test_engineering/stand_alone_application/.keep +0 -0
- data/origen_app_generators/templates/app_generators/test_engineering/test_block/.keep +0 -0
- data/origen_site_config.yml +55 -5
- data/templates/code_generators/attributes.rb +20 -0
- data/templates/code_generators/class.rb +9 -0
- data/templates/code_generators/controller.rb +87 -0
- data/templates/code_generators/model.rb +21 -0
- data/templates/code_generators/module.rb +4 -0
- data/templates/code_generators/parameters.rb +19 -0
- data/templates/code_generators/pins.rb +28 -0
- data/templates/code_generators/registers.rb +20 -0
- data/templates/code_generators/sub_blocks.rb +24 -0
- data/templates/code_generators/timesets.rb +24 -0
- data/templates/code_generators/version.rb +0 -1
- data/templates/git/gitignore.erb +0 -1
- data/vendor/lib/models/origen/export1.rb +77 -0
- data/vendor/lib/models/origen/export1/block1.rb +13 -0
- data/vendor/lib/models/origen/export1/block1/x.rb +36 -0
- data/vendor/lib/models/origen/non_origen_meta_data.md +1 -0
- metadata +149 -68
- data/bin/fix_my_workspace +0 -100
- data/lib/c99/ate_interface.rb +0 -77
- data/lib/c99/nvm.rb +0 -110
- data/lib/c99/target/mock2.rb +0 -1
- data/lib/c99/target/subdir/mock3.rb +0 -1
- data/lib/origen/code_generators/bundler.rb +0 -17
- data/lib/origen/code_generators/gem_setup.rb +0 -49
- data/lib/origen/code_generators/rake.rb +0 -13
- data/lib/origen/code_generators/rspec.rb +0 -12
- data/lib/origen/commands/add.rb +0 -12
- data/lib/tasks/private/build.rake +0 -8
- data/templates/code_generators/gemfile_app.rb +0 -4
- data/templates/code_generators/gemfile_plugin.rb +0 -6
- data/templates/code_generators/gemspec.rb +0 -33
@@ -27,7 +27,14 @@ module Origen
|
|
27
27
|
# Sets the base_name taking into account the current class namespace.
|
28
28
|
def self.name
|
29
29
|
@name ||= begin
|
30
|
-
to_s.split('::').last.sub(/(CodeGenerator|Generator)$/, '').underscore
|
30
|
+
name = to_s.split('::').last.sub(/(CodeGenerator|Generator)$/, '').underscore
|
31
|
+
if name == 'klass'
|
32
|
+
'class'
|
33
|
+
elsif name == 'mod'
|
34
|
+
'module'
|
35
|
+
else
|
36
|
+
name
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
@@ -50,7 +57,7 @@ module Origen
|
|
50
57
|
end
|
51
58
|
|
52
59
|
def self.banner
|
53
|
-
"origen
|
60
|
+
"origen new #{namespace == 'origen' ? '' : namespace + ':'}#{name} [options]"
|
54
61
|
end
|
55
62
|
end
|
56
63
|
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Block < Origen::CodeGenerators::Base
|
4
|
+
include BlockCommon
|
5
|
+
|
6
|
+
# class_option :duts, type: :boolean, desc: 'Instantiate the new sub-block in all DUT models', default: true
|
7
|
+
# class_option :instance, desc: 'The main NAME argument will be the name given to the model and the instantiated sub-block, optionally provide a different name for the instance'
|
8
|
+
|
9
|
+
def self.banner
|
10
|
+
'origen new block [TYPE/]DERIVATIVE [BLOCK]'
|
11
|
+
end
|
12
|
+
|
13
|
+
desc <<-END
|
14
|
+
This generator creates a block (e.g. to represent RAM, ATD, Flash, DAC, etc.) and all of the associated
|
15
|
+
resources for it, e.g. a model, controller, timesets, parameters, etc.
|
16
|
+
|
17
|
+
The TYPE and DERIVATIVE names should be given in lower case (e.g. flash/flash2kb, atd/atd16), optionally with
|
18
|
+
additional parent sub-block names after the initial type.
|
19
|
+
|
20
|
+
Alternatively, a reference to an existing BLOCK can be added, in which case a nested block will be created
|
21
|
+
within that block's sub_blocks directory, rather than a primary block.
|
22
|
+
Note that nested blocks do not support derivatives or inheritance and should therefore only be used for
|
23
|
+
relatively simple entities which are tightly coupled to a parent block.
|
24
|
+
|
25
|
+
Any parent block(s) will be created if they don't exist, but they will not be modified if they do.
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
origen new block atd/atd8bit # Creates app/blocks/atd/derivatives/atd8bit/...
|
29
|
+
origen new block atd/atd16bit # Creates app/blocks/atd/derivatives/atd16bit/...
|
30
|
+
origen new block nvm/flash/flash2kb # Creates app/blocks/nvm/derivatives/flash/derivatives/flash2kb/...
|
31
|
+
|
32
|
+
# Example of creating a nested sub-block
|
33
|
+
origen new block nvm/flash/flash2kb bist # Creates app/blocks/nvm/derivatives/flash/derivatives/flash2kb/sub_blocks/bist/...
|
34
|
+
END
|
35
|
+
|
36
|
+
def validate_args
|
37
|
+
if args.size > 2 || args.size == 0
|
38
|
+
msg = args.size == 0 ? 'At least one argument is' : 'No more than two arguments are'
|
39
|
+
msg << " expected by the block generator, e.g. 'origen new block atd/atd16bit', 'origen new block sampler app/blocks/atd/derivatives/atd16bit"
|
40
|
+
puts msg
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
if args.size == 2
|
45
|
+
validate_args_common(args.last)
|
46
|
+
else
|
47
|
+
validate_args_common
|
48
|
+
end
|
49
|
+
|
50
|
+
@nested = args.size == 2
|
51
|
+
if !@nested && args.first.split('/').size == 1
|
52
|
+
msg = "You must supply a leading type to the name of the block, e.g. 'origen new block atd/atd16bit'"
|
53
|
+
puts msg
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
if @nested && args.last.split('/').size != 1
|
57
|
+
msg = "No leading type is allowed when generating a nested block, e.g. 'origen new block sampler app/blocks/atd/derivatives/atd16bit"
|
58
|
+
puts msg
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup
|
64
|
+
@generate_model = true
|
65
|
+
@generate_pins = false
|
66
|
+
@generate_timesets = !@nested
|
67
|
+
@generate_parameters = !@nested
|
68
|
+
if @nested
|
69
|
+
@final_name = args.last
|
70
|
+
@fullname = resource_path_to_class(args.first)
|
71
|
+
@dir = resource_path_to_blocks_dir(args.first).join('sub_blocks', @final_name)
|
72
|
+
@namespaces = add_type_to_namespaces(@fullname.split('::').map(&:underscore))
|
73
|
+
else
|
74
|
+
extract_model_name
|
75
|
+
end
|
76
|
+
create_files
|
77
|
+
end
|
78
|
+
|
79
|
+
def instantiate_sub_block
|
80
|
+
if @nested
|
81
|
+
# First create the parent's sub_blocks.rb file if it doesn't exist
|
82
|
+
f = "#{@dir.parent}.rb"
|
83
|
+
unless File.exist?(f)
|
84
|
+
@nested = false
|
85
|
+
orig_fullname = @fullname
|
86
|
+
orig_resouce_path = @resource_path
|
87
|
+
@fullname = @fullname.split('::')
|
88
|
+
@fullname.pop
|
89
|
+
@fullname = @fullname.join('::')
|
90
|
+
@resource_path = @resource_path.split('/')
|
91
|
+
@resource_path.pop
|
92
|
+
@resource_path = @resource_path.join('/')
|
93
|
+
template 'templates/code_generators/sub_blocks.rb', f
|
94
|
+
@fullname = orig_fullname
|
95
|
+
@resource_path = orig_resouce_path
|
96
|
+
@nested = true
|
97
|
+
end
|
98
|
+
|
99
|
+
line = "sub_block :#{@final_name}, class_name: '#{@fullname}'#, base_address: 0x4000_0000"
|
100
|
+
append_to_file f, "\n#{line}"
|
101
|
+
else
|
102
|
+
@line = "sub_block :#{@final_namespaces[1]}, class_name: '#{class_name}'#, base_address: 0x4000_0000"
|
103
|
+
|
104
|
+
unless duts.empty?
|
105
|
+
puts
|
106
|
+
@dut_index = [nil]
|
107
|
+
index = 1
|
108
|
+
duts.each do |name, children|
|
109
|
+
index = print_dut(name, index, children, 0)
|
110
|
+
end
|
111
|
+
puts
|
112
|
+
puts 'DO YOU WANT TO INSTANTIATE THIS SUB-BLOCK IN YOUR DUT MODELS?'
|
113
|
+
puts
|
114
|
+
puts 'If so enter the number(s) of the DUT(s) you wish to add it to from the list above, separating multiple entries with a space'
|
115
|
+
puts '(note that adding it to a parent DUT in the hierarchy will already be adding it to all of its children).'
|
116
|
+
puts
|
117
|
+
response = ask 'Enter the DUT number(s), or just press return to skip:'
|
118
|
+
|
119
|
+
done = []
|
120
|
+
response.strip.split(/\s+/).each do |index|
|
121
|
+
index = index.to_i
|
122
|
+
target = @dut_index[index]
|
123
|
+
if target
|
124
|
+
# Don't add the sub-block to children if we've already added it to the parent, this will
|
125
|
+
# cause an already defined sub-block error since it will be added by both instantiations
|
126
|
+
unless done.any? { |c| target =~ /^#{c}::/ }
|
127
|
+
done << target
|
128
|
+
sub_blocks = class_name_to_blocks_dir(target).join('sub_blocks.rb')
|
129
|
+
unless sub_blocks.exist?
|
130
|
+
orig = @fullname
|
131
|
+
@fullname = target
|
132
|
+
template 'templates/code_generators/sub_blocks.rb', sub_blocks
|
133
|
+
@fullname = orig
|
134
|
+
end
|
135
|
+
@sub_block_instantiated = true
|
136
|
+
append_to_file sub_blocks, "\n#{@line}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def completed
|
145
|
+
add_acronyms
|
146
|
+
puts
|
147
|
+
if @nested
|
148
|
+
puts 'New sub-block created and instantiated.'.green
|
149
|
+
else
|
150
|
+
if @sub_block_instantiated
|
151
|
+
puts 'New sub-block created and instantiated within your DUT(s) as:'.green + " dut.#{@final_namespaces[1]}"
|
152
|
+
else
|
153
|
+
puts 'New sub-block created, you can instantiate it within your blocks like this:'.green
|
154
|
+
puts
|
155
|
+
puts " #{@line}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
puts
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def print_dut(name, index, children, offset)
|
164
|
+
@dut_index << name
|
165
|
+
puts "#{index}".ljust(2) + ': ' + (' ' * offset) + name
|
166
|
+
index += 1
|
167
|
+
children.each do |name, children|
|
168
|
+
index = print_dut(name, index, children, offset + 1)
|
169
|
+
end
|
170
|
+
index
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns a look up table for all dut blocks defined in this application (only those defined
|
174
|
+
# as blocks, as they all should be now).
|
175
|
+
# This is arranged by hierarchy.
|
176
|
+
def duts
|
177
|
+
@duts ||= begin
|
178
|
+
duts = {}
|
179
|
+
dut_dir = Pathname.new(File.join(Origen.root, 'app', 'blocks', 'dut'))
|
180
|
+
if dut_dir.exist?
|
181
|
+
name = "#{Origen.app.namespace}::DUT"
|
182
|
+
duts[name] = {}
|
183
|
+
add_derivatives(duts[name], name, dut_dir)
|
184
|
+
end
|
185
|
+
duts
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def add_derivatives(duts, name, dir)
|
190
|
+
derivatives = dir.join('derivatives')
|
191
|
+
if derivatives.exist?
|
192
|
+
derivatives.children.each do |item|
|
193
|
+
if item.directory?
|
194
|
+
child_name = "#{name}::#{camelcase(item.basename)}"
|
195
|
+
duts[child_name] = {}
|
196
|
+
add_derivatives(duts[child_name], child_name, item)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
# Base generator for the DUT, block and feature generators
|
4
|
+
module BlockCommon
|
5
|
+
def validate_args_common(arg = nil)
|
6
|
+
validate_resource_name(arg || args.first)
|
7
|
+
end
|
8
|
+
|
9
|
+
def extract_model_name
|
10
|
+
@final_namespaces = args.first.downcase.split('/')
|
11
|
+
|
12
|
+
@final_name = @final_namespaces.pop
|
13
|
+
@final_name.gsub!(/\.rb/, '')
|
14
|
+
|
15
|
+
@final_namespaces.unshift('dut') if @top_level
|
16
|
+
@final_namespaces.unshift(underscored_app_namespace)
|
17
|
+
|
18
|
+
@model_path = @final_namespaces.dup
|
19
|
+
@namespaces = [[:module, @model_path.shift]]
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_files
|
23
|
+
# @summary = ask 'Describe your plugin in a few words:'
|
24
|
+
@block = true
|
25
|
+
@root_class = true
|
26
|
+
|
27
|
+
# Nested sub-blocks do not support inheritance
|
28
|
+
unless @nested
|
29
|
+
dir = File.join(Origen.root, 'app', 'blocks')
|
30
|
+
@fullname = Origen.app.namespace.to_s
|
31
|
+
|
32
|
+
@model_path.each do |path|
|
33
|
+
dir = File.join(dir, path)
|
34
|
+
@name = path
|
35
|
+
@fullname += "::#{camelcase(@name)}"
|
36
|
+
@resource_path = resource_path(dir)
|
37
|
+
|
38
|
+
if @generate_model
|
39
|
+
f = File.join(dir, 'model.rb')
|
40
|
+
template 'templates/code_generators/model.rb', f unless File.exist?(f)
|
41
|
+
f = File.join(dir, 'controller.rb')
|
42
|
+
template 'templates/code_generators/controller.rb', f unless File.exist?(f)
|
43
|
+
end
|
44
|
+
if @generate_pins
|
45
|
+
f = File.join(dir, 'pins.rb')
|
46
|
+
template 'templates/code_generators/pins.rb', f unless File.exist?(f)
|
47
|
+
end
|
48
|
+
if @generate_timesets
|
49
|
+
f = File.join(dir, 'timesets.rb')
|
50
|
+
template 'templates/code_generators/timesets.rb', f unless File.exist?(f)
|
51
|
+
end
|
52
|
+
if @generate_parameters
|
53
|
+
f = File.join(dir, 'parameters.rb')
|
54
|
+
template 'templates/code_generators/parameters.rb', f unless File.exist?(f)
|
55
|
+
end
|
56
|
+
f = File.join(dir, 'registers.rb')
|
57
|
+
template 'templates/code_generators/registers.rb', f unless File.exist?(f)
|
58
|
+
f = File.join(dir, 'sub_blocks.rb')
|
59
|
+
template 'templates/code_generators/sub_blocks.rb', f unless File.exist?(f)
|
60
|
+
f = File.join(dir, 'attributes.rb')
|
61
|
+
template 'templates/code_generators/attributes.rb', f unless File.exist?(f)
|
62
|
+
dir = File.join(dir, 'derivatives')
|
63
|
+
@namespaces << [:class, path]
|
64
|
+
@root_class = false
|
65
|
+
|
66
|
+
@parent_class = @namespaces.map { |type, name| camelcase(name) }.join('::')
|
67
|
+
end
|
68
|
+
|
69
|
+
@parent_class ||= @namespaces.map { |type, name| camelcase(name) }.join('::')
|
70
|
+
end
|
71
|
+
|
72
|
+
@name = @final_name
|
73
|
+
@fullname += "::#{camelcase(@name)}"
|
74
|
+
dir = @dir || File.join(dir, @name)
|
75
|
+
@resource_path = resource_path(dir)
|
76
|
+
|
77
|
+
if @generate_model
|
78
|
+
template 'templates/code_generators/model.rb', File.join(dir, 'model.rb')
|
79
|
+
template 'templates/code_generators/controller.rb', File.join(dir, 'controller.rb')
|
80
|
+
end
|
81
|
+
if @generate_pins
|
82
|
+
template 'templates/code_generators/pins.rb', File.join(dir, 'pins.rb')
|
83
|
+
end
|
84
|
+
if @generate_timesets
|
85
|
+
template 'templates/code_generators/timesets.rb', File.join(dir, 'timesets.rb')
|
86
|
+
end
|
87
|
+
if @generate_parameters
|
88
|
+
template 'templates/code_generators/parameters.rb', File.join(dir, 'parameters.rb')
|
89
|
+
end
|
90
|
+
template 'templates/code_generators/registers.rb', File.join(dir, 'registers.rb')
|
91
|
+
template 'templates/code_generators/sub_blocks.rb', File.join(dir, 'sub_blocks.rb')
|
92
|
+
template 'templates/code_generators/attributes.rb', File.join(dir, 'attributes.rb')
|
93
|
+
end
|
94
|
+
|
95
|
+
def class_name
|
96
|
+
(@final_namespaces + Array(@name)).map { |n| camelcase(n) }.join('::')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Dut < Origen::CodeGenerators::Base
|
4
|
+
include BlockCommon
|
5
|
+
|
6
|
+
def self.banner
|
7
|
+
'origen new dut NAME'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc <<-END
|
11
|
+
This generator creates a top-level (DUT) block and all of the associated resources for it, e.g. a model,
|
12
|
+
controller, target, timesets, pins, etc.
|
13
|
+
|
14
|
+
The NAME of the DUT should be given in lower case, optionally prefixed by parent DUT name(s) separated
|
15
|
+
by a forward slash.
|
16
|
+
|
17
|
+
Any parent DUT(s) will be created if they don't exist, but they will not be modified if they do.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
origen new dut falcon # Creates app/blocks/dut/derivatives/falcon/...
|
21
|
+
origen new dut dsp/falcon # Creates app/blocks/dut/derivatives/dsp/derivatives/falcon/...
|
22
|
+
END
|
23
|
+
|
24
|
+
def validate_args
|
25
|
+
if args.size > 1 || args.size == 0
|
26
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
27
|
+
msg << " argument is expected by the DUT generator, e.g. 'origen new dut my_soc', 'origen new dut my_family/my_soc"
|
28
|
+
puts msg
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
validate_args_common
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
@generate_model = true
|
36
|
+
@generate_pins = true
|
37
|
+
@generate_timesets = true
|
38
|
+
@generate_parameters = true
|
39
|
+
@top_level = true
|
40
|
+
extract_model_name
|
41
|
+
create_files
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_target
|
45
|
+
contents = ''
|
46
|
+
contents << @final_namespaces.map { |n| camelcase(n) }.join('::')
|
47
|
+
contents << "::#{camelcase(@name)}.new\n"
|
48
|
+
|
49
|
+
create_file "#{Origen.root}/target/#{@name}.rb", contents
|
50
|
+
end
|
51
|
+
|
52
|
+
def completed
|
53
|
+
add_acronyms
|
54
|
+
puts
|
55
|
+
puts 'New DUT created, run the following command to target it in your workspace:'.green
|
56
|
+
puts
|
57
|
+
puts " origen t #{@name}"
|
58
|
+
puts
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Feature < Origen::CodeGenerators::Base
|
4
|
+
include BlockCommon
|
5
|
+
|
6
|
+
def self.banner
|
7
|
+
'origen new feature NAME'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc <<-END
|
11
|
+
This generator creates a new feature block, which is similar to a regular block but with no model and controller.
|
12
|
+
Such features can then be loaded (re-used) by multiple blocks within your application code.
|
13
|
+
|
14
|
+
The name of the feature should be given in lower case, optionally prefixed by parent feature name(s) separated
|
15
|
+
by a forward slash.
|
16
|
+
|
17
|
+
Any parent features will be created if they don't exist, but they will not be modified if they do.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
origen new feature my_feature # Creates app/blocks/my_feature/...
|
21
|
+
origen new feature features/my_feature # Creates app/blocks/features/my_feature/...
|
22
|
+
|
23
|
+
The above can then be loaded to models in your application code via:
|
24
|
+
|
25
|
+
my_model.load_block('my_feature')
|
26
|
+
my_model.load_block('features/my_feature')
|
27
|
+
END
|
28
|
+
|
29
|
+
def validate_args
|
30
|
+
if args.size > 1 || args.size == 0
|
31
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
32
|
+
msg << " argument is expected by the feature generator, e.g. 'origen new feature my_feature', 'origen new feature features/my_feature"
|
33
|
+
puts msg
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
validate_args_common
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup
|
40
|
+
@generate_model = false
|
41
|
+
@generate_pins = true
|
42
|
+
@generate_timesets = true
|
43
|
+
@generate_parameters = true
|
44
|
+
extract_model_name
|
45
|
+
create_files
|
46
|
+
add_acronyms
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Origen
|
2
|
+
module CodeGenerators
|
3
|
+
class Klass < Origen::CodeGenerators::Base
|
4
|
+
def self.banner
|
5
|
+
'origen new class NAME'
|
6
|
+
end
|
7
|
+
|
8
|
+
desc <<-END
|
9
|
+
This generator creates a plain old Ruby class within your application's lib directory.
|
10
|
+
|
11
|
+
The NAME of the class should be given, in lower case, optionally indicating the presence
|
12
|
+
of any namespacing you want it to be created under.
|
13
|
+
|
14
|
+
Examples:
|
15
|
+
origen new class counter # Creates app/lib/my_application/counter.rb
|
16
|
+
origen new class helpers/counter # Creates app/lib/my_application/helpers/counter.rb
|
17
|
+
END
|
18
|
+
|
19
|
+
def validate_args
|
20
|
+
if args.size > 1 || args.size == 0
|
21
|
+
msg = args.size > 1 ? 'Only one' : 'One'
|
22
|
+
msg << " argument is expected by the class generator, e.g. 'origen new class counter', 'origen new class helpers/counter'"
|
23
|
+
puts msg
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
validate_resource_name(args.first)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_class_file
|
30
|
+
@resource_path = args.first
|
31
|
+
klass = resource_path_to_class(args.first)
|
32
|
+
@namespaces = klass.split('::').map(&:underscore)
|
33
|
+
@name = @namespaces.pop
|
34
|
+
@namespaces = add_type_to_namespaces(@namespaces)
|
35
|
+
@root_class = true
|
36
|
+
file = class_name_to_lib_file(klass)
|
37
|
+
template 'templates/code_generators/class.rb', file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|