origen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ctags +0 -0
- data/bin/origen +165 -1
- data/bin/rgen +2 -0
- data/config/application.rb +141 -0
- data/config/commands.rb +72 -0
- data/config/development.rb +7 -0
- data/config/environment.rb +0 -0
- data/config/rgen.policy +7 -0
- data/config/rubocop/easy.yml +620 -0
- data/config/rubocop/easy_disabled.yml +271 -0
- data/config/rubocop/easy_enabled.yml +731 -0
- data/config/rubocop/strict.yml +620 -0
- data/config/rubocop/strict_disabled.yml +247 -0
- data/config/rubocop/strict_enabled.yml +755 -0
- data/config/users.rb +20 -0
- data/config/version.rb +1 -1
- data/helpers/url.rb +68 -0
- data/lib/c99/doc_interface.rb +56 -0
- data/lib/c99/j750_interface.rb +85 -0
- data/lib/c99/nvm.rb +89 -0
- data/lib/c99/target/mock2.rb +1 -0
- data/lib/c99/target/subdir/mock3.rb +1 -0
- data/lib/option_parser/optparse.rb +12 -0
- data/lib/origen/acronyms.rb +60 -0
- data/lib/origen/application/command_dispatcher.rb +12 -0
- data/lib/origen/application/configuration.rb +206 -0
- data/lib/origen/application/configuration_manager.rb +78 -0
- data/lib/origen/application/deployer.rb +367 -0
- data/lib/origen/application/environment.rb +186 -0
- data/lib/origen/application/lsf.rb +145 -0
- data/lib/origen/application/lsf_manager.rb +657 -0
- data/lib/origen/application/plugins_manager.rb +280 -0
- data/lib/origen/application/release.rb +359 -0
- data/lib/origen/application/runner.rb +246 -0
- data/lib/origen/application/statistics.rb +191 -0
- data/lib/origen/application/target.rb +374 -0
- data/lib/origen/application/version_tracker.rb +59 -0
- data/lib/origen/application/workspace_manager.rb +151 -0
- data/lib/origen/application.rb +746 -0
- data/lib/origen/bugs/bug.rb +36 -0
- data/lib/origen/bugs.rb +45 -0
- data/lib/origen/callbacks.rb +35 -0
- data/lib/origen/chip_mode.rb +118 -0
- data/lib/origen/chip_package.rb +461 -0
- data/lib/origen/client.rb +87 -0
- data/lib/origen/code_generators/actions.rb +258 -0
- data/lib/origen/code_generators/base.rb +57 -0
- data/lib/origen/code_generators/bundler.rb +17 -0
- data/lib/origen/code_generators/gem_setup.rb +49 -0
- data/lib/origen/code_generators/rake.rb +13 -0
- data/lib/origen/code_generators/rspec.rb +12 -0
- data/lib/origen/code_generators/semver.rb +39 -0
- data/lib/origen/code_generators/timever.rb +37 -0
- data/lib/origen/code_generators.rb +111 -0
- data/lib/origen/commands/add.rb +12 -0
- data/lib/origen/commands/compile.rb +62 -0
- data/lib/origen/commands/ctags.rb +9 -0
- data/lib/origen/commands/dispatch.rb +22 -0
- data/lib/origen/commands/environment.rb +11 -0
- data/lib/origen/commands/fetch.rb +63 -0
- data/lib/origen/commands/generate.rb +130 -0
- data/lib/origen/commands/interactive.rb +73 -0
- data/lib/origen/commands/lint.rb +82 -0
- data/lib/origen/commands/lsf.rb +93 -0
- data/lib/origen/commands/merge.rb +55 -0
- data/lib/origen/commands/modifications.rb +12 -0
- data/lib/origen/commands/new.rb +113 -0
- data/lib/origen/commands/plugin.rb +105 -0
- data/lib/origen/commands/program.rb +70 -0
- data/lib/origen/commands/rc.rb +442 -0
- data/lib/origen/commands/save.rb +56 -0
- data/lib/origen/commands/target.rb +27 -0
- data/lib/origen/commands/time.rb +127 -0
- data/lib/origen/commands/version.rb +17 -0
- data/lib/origen/commands/web.rb +221 -0
- data/lib/origen/commands.rb +272 -0
- data/lib/origen/commands_global.rb +76 -0
- data/lib/origen/controller.rb +94 -0
- data/lib/origen/core_ext/array.rb +23 -0
- data/lib/origen/core_ext/bignum.rb +36 -0
- data/lib/origen/core_ext/enumerable.rb +76 -0
- data/lib/origen/core_ext/fixnum.rb +46 -0
- data/lib/origen/core_ext/hash.rb +52 -0
- data/lib/origen/core_ext/module.rb +14 -0
- data/lib/origen/core_ext/numeric.rb +126 -0
- data/lib/origen/core_ext/object.rb +13 -0
- data/lib/origen/core_ext/range.rb +7 -0
- data/lib/origen/core_ext/string.rb +124 -0
- data/lib/origen/core_ext.rb +10 -0
- data/lib/origen/database/key_value_store.rb +111 -0
- data/lib/origen/database/key_value_stores.rb +108 -0
- data/lib/origen/database.rb +6 -0
- data/lib/origen/encodings.rb +102 -0
- data/lib/origen/features/feature.rb +22 -0
- data/lib/origen/features.rb +104 -0
- data/lib/origen/file_handler.rb +429 -0
- data/lib/origen/generator/comparator.rb +56 -0
- data/lib/origen/generator/compiler.rb +277 -0
- data/lib/origen/generator/flow.rb +49 -0
- data/lib/origen/generator/job.rb +131 -0
- data/lib/origen/generator/pattern.rb +356 -0
- data/lib/origen/generator/pattern_finder.rb +155 -0
- data/lib/origen/generator/pattern_iterator.rb +55 -0
- data/lib/origen/generator/renderer.rb +113 -0
- data/lib/origen/generator/resources.rb +40 -0
- data/lib/origen/generator/stage.rb +89 -0
- data/lib/origen/generator.rb +85 -0
- data/lib/origen/global_methods.rb +205 -0
- data/lib/origen/import_manager.rb +596 -0
- data/lib/origen/location/base.rb +116 -0
- data/lib/origen/location/map.rb +83 -0
- data/lib/origen/location.rb +6 -0
- data/lib/origen/log.rb +217 -0
- data/lib/origen/logger_methods.rb +56 -0
- data/lib/origen/mode.rb +61 -0
- data/lib/origen/model.rb +267 -0
- data/lib/origen/model_initializer.rb +45 -0
- data/lib/origen/nvm/block_array.rb +72 -0
- data/lib/origen/nvm.rb +6 -0
- data/lib/origen/parameters/live.rb +22 -0
- data/lib/origen/parameters/missing.rb +28 -0
- data/lib/origen/parameters/set.rb +144 -0
- data/lib/origen/parameters.rb +107 -0
- data/lib/origen/pdm.rb +218 -0
- data/lib/origen/pins/function_proxy.rb +36 -0
- data/lib/origen/pins/ground_pin.rb +6 -0
- data/lib/origen/pins/pin.rb +860 -0
- data/lib/origen/pins/pin_bank.rb +349 -0
- data/lib/origen/pins/pin_clock.rb +124 -0
- data/lib/origen/pins/pin_collection.rb +492 -0
- data/lib/origen/pins/pin_common.rb +206 -0
- data/lib/origen/pins/port.rb +268 -0
- data/lib/origen/pins/power_pin.rb +30 -0
- data/lib/origen/pins.rb +696 -0
- data/lib/origen/registers/bit.rb +562 -0
- data/lib/origen/registers/bit_collection.rb +787 -0
- data/lib/origen/registers/container.rb +288 -0
- data/lib/origen/registers/domain.rb +16 -0
- data/lib/origen/registers/reg.rb +1406 -0
- data/lib/origen/registers/reg_collection.rb +24 -0
- data/lib/origen/registers.rb +652 -0
- data/lib/origen/regression_manager.rb +251 -0
- data/lib/origen/remote_manager.rb +340 -0
- data/lib/origen/revision_control/base.rb +257 -0
- data/lib/origen/revision_control/design_sync.rb +276 -0
- data/lib/origen/revision_control/git.rb +243 -0
- data/lib/origen/revision_control/subversion.rb +6 -0
- data/lib/origen/revision_control.rb +44 -0
- data/lib/origen/ruby_version_check.rb +131 -0
- data/lib/origen/site_config.rb +61 -0
- data/lib/origen/specs/checkers.rb +103 -0
- data/lib/origen/specs/creation_info.rb +17 -0
- data/lib/origen/specs/doc_resource.rb +91 -0
- data/lib/origen/specs/exhibit.rb +17 -0
- data/lib/origen/specs/mode_select.rb +16 -0
- data/lib/origen/specs/note.rb +17 -0
- data/lib/origen/specs/override.rb +21 -0
- data/lib/origen/specs/power_supply.rb +13 -0
- data/lib/origen/specs/spec.rb +226 -0
- data/lib/origen/specs/version_history.rb +14 -0
- data/lib/origen/specs.rb +552 -0
- data/lib/origen/sub_blocks.rb +298 -0
- data/lib/origen/tester/api.rb +277 -0
- data/lib/origen/tester/bdm/bdm.rb +25 -0
- data/lib/origen/tester/command_based_tester.rb +46 -0
- data/lib/origen/tester/doc/doc.rb +226 -0
- data/lib/origen/tester/doc/generator/flow.rb +71 -0
- data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
- data/lib/origen/tester/doc/generator/test.rb +68 -0
- data/lib/origen/tester/doc/generator/test_group.rb +66 -0
- data/lib/origen/tester/doc/generator/tests.rb +47 -0
- data/lib/origen/tester/doc/generator.rb +126 -0
- data/lib/origen/tester/doc/model.rb +162 -0
- data/lib/origen/tester/generator/flow_control_api.rb +606 -0
- data/lib/origen/tester/generator/identity_map.rb +25 -0
- data/lib/origen/tester/generator/placeholder.rb +13 -0
- data/lib/origen/tester/generator/test_numberer.rb +25 -0
- data/lib/origen/tester/generator.rb +271 -0
- data/lib/origen/tester/interface.rb +154 -0
- data/lib/origen/tester/j750/files.rb +45 -0
- data/lib/origen/tester/j750/generator/flow.rb +123 -0
- data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
- data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
- data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
- data/lib/origen/tester/j750/generator/patset.rb +111 -0
- data/lib/origen/tester/j750/generator/patsets.rb +41 -0
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
- data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
- data/lib/origen/tester/j750/generator.rb +203 -0
- data/lib/origen/tester/j750/j750.rb +845 -0
- data/lib/origen/tester/j750/j750_hpt.rb +35 -0
- data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
- data/lib/origen/tester/j750/parser/flow.rb +111 -0
- data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
- data/lib/origen/tester/j750/parser/flows.rb +23 -0
- data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
- data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
- data/lib/origen/tester/j750/parser/timeset.rb +15 -0
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/j750/parser.rb +104 -0
- data/lib/origen/tester/jlink/jlink.rb +33 -0
- data/lib/origen/tester/parser/description_lookup.rb +64 -0
- data/lib/origen/tester/parser/searchable_array.rb +32 -0
- data/lib/origen/tester/parser/searchable_hash.rb +32 -0
- data/lib/origen/tester/parser.rb +24 -0
- data/lib/origen/tester/time.rb +338 -0
- data/lib/origen/tester/timing.rb +253 -0
- data/lib/origen/tester/ultraflex/files.rb +45 -0
- data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
- data/lib/origen/tester/ultraflex/generator.rb +200 -0
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
- data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
- data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
- data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/parser.rb +104 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
- data/lib/origen/tester/v93k/generator/flow.rb +63 -0
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
- data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
- data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
- data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
- data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
- data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
- data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
- data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
- data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
- data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
- data/lib/origen/tester/v93k/generator.rb +80 -0
- data/lib/origen/tester/v93k/v93k.rb +420 -0
- data/lib/origen/tester/vector.rb +86 -0
- data/lib/origen/tester/vector_generator.rb +633 -0
- data/lib/origen/tester/vector_pipeline.rb +150 -0
- data/lib/origen/tester.rb +56 -0
- data/lib/origen/top_level.rb +134 -0
- data/lib/origen/users/ldap.rb +65 -0
- data/lib/origen/users/user.rb +149 -0
- data/lib/origen/users.rb +30 -0
- data/lib/origen/utility/block_args.rb +93 -0
- data/lib/origen/utility/csv_data.rb +110 -0
- data/lib/origen/utility/design_sync.rb +494 -0
- data/lib/origen/utility/diff.rb +158 -0
- data/lib/origen/utility/input_capture.rb +121 -0
- data/lib/origen/utility/mailer.rb +143 -0
- data/lib/origen/utility/s_record.rb +205 -0
- data/lib/origen/utility/time_and_date.rb +30 -0
- data/lib/origen/utility.rb +12 -0
- data/lib/origen/version_checker.rb +117 -0
- data/lib/origen/version_string.rb +356 -0
- data/lib/origen.rb +648 -0
- data/lib/tasks/gem.rake +27 -22
- data/origen_site_config.yml +36 -0
- data/source_setup +17 -0
- data/spec/format/rgen_formatter.rb +14 -0
- data/templates/api_doc/README.txt.erb +24 -0
- data/templates/code_generators/gemfile_app.rb +4 -0
- data/templates/code_generators/gemfile_plugin.rb +6 -0
- data/templates/code_generators/gemspec.rb +33 -0
- data/templates/code_generators/rakefile.rb +10 -0
- data/templates/code_generators/spec_helper.rb +49 -0
- data/templates/code_generators/version.rb +8 -0
- data/templates/code_generators/version_time.rb +3 -0
- data/templates/git/gitignore.erb +33 -0
- data/templates/j750/_vt_flow.txt.erb +8 -0
- data/templates/j750/_vt_instances.txt.erb +4 -0
- data/templates/j750/program_sheet.txt.erb +9 -0
- data/templates/nanoc/Rules +74 -0
- data/templates/nanoc/config.yaml +77 -0
- data/templates/nanoc/content/favicon.ico +0 -0
- data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
- data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
- data/templates/nanoc/layouts/freescale.html.erb +79 -0
- data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
- data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
- data/templates/nanoc/lib/default.rb +2 -0
- data/templates/nanoc/lib/gzip_filter.rb +16 -0
- data/templates/nanoc/lib/haml_code_filter.rb +41 -0
- data/templates/nanoc/lib/helpers.rb +1 -0
- data/templates/nanoc/lib/search_filter.rb +62 -0
- data/templates/nanoc_dynamic/content/search.js.erb +92 -0
- data/templates/shared/web/_logo.html +10 -0
- data/templates/test/_inline_sub.txt.erb +2 -0
- data/templates/test/environment.txt.erb +1 -0
- data/templates/test/inline.txt.erb +11 -0
- data/templates/test/inspections.txt.erb +19 -0
- data/templates/test/set1/_sub1.txt.erb +12 -0
- data/templates/test/set1/_sub4.txt.erb +1 -0
- data/templates/test/set1/_sub5.txt.erb +1 -0
- data/templates/test/set1/main.txt.erb +53 -0
- data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
- data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
- data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
- data/templates/test/set2/template_with_no_erb_1.txt +9 -0
- data/templates/test/set2/template_with_no_erb_2.txt +9 -0
- data/templates/test/set3/_layout.html.erb +4 -0
- data/templates/test/set3/content.html.erb +6 -0
- data/templates/time/filter.rb.erb +15 -0
- data/templates/time/rules.rb.erb +45 -0
- metadata +639 -5
@@ -0,0 +1,860 @@
|
|
1
|
+
module Origen
|
2
|
+
module Pins
|
3
|
+
class Pin
|
4
|
+
include PinCommon
|
5
|
+
|
6
|
+
# Any attributes listed here will be looked up for the current function defined
|
7
|
+
# by the current mode and configuration context before falling back to a default
|
8
|
+
FUNCTION_SCOPED_ATTRIBUTES = [:name, :direction, :option, :group, :ip_block, :meta]
|
9
|
+
|
10
|
+
# Any attributes listed here will be looked up for the current package context
|
11
|
+
# before falling back to a default
|
12
|
+
PACKAGE_SCOPED_ATTRIBUTES = [:location, :dib_assignment]
|
13
|
+
|
14
|
+
# Pin Types
|
15
|
+
TYPES = [:analog, :digital]
|
16
|
+
|
17
|
+
attr_accessor :order
|
18
|
+
# Inverts pin states for drive and compare, can be useful if a timing set change requires clocks to drive low for example when all pattern logic has been set up to drive them high.
|
19
|
+
attr_accessor :invert
|
20
|
+
# Attribute used to generate vectors where the pin state is assigned the
|
21
|
+
# repeat_previous opcode, used by Tester#repeat_previous
|
22
|
+
attr_accessor :repeat_previous
|
23
|
+
attr_reader :owner
|
24
|
+
attr_reader :size
|
25
|
+
# If the pin belongs to a port then this will return the port object
|
26
|
+
attr_accessor :port
|
27
|
+
# Returns a hash containing the aliases associated with the given pin
|
28
|
+
attr_reader :aliases
|
29
|
+
# Returns a hash containing the functions associated with the given pin
|
30
|
+
attr_reader :functions
|
31
|
+
# Internal power supply pin is connected to
|
32
|
+
attr_accessor :supply
|
33
|
+
# Boolean on whether pin is open drain
|
34
|
+
attr_accessor :open_drain
|
35
|
+
# Boolean on whether pin has external pull-up
|
36
|
+
attr_accessor :ext_pullup
|
37
|
+
# Boolean on whether pin has external pull-down
|
38
|
+
attr_accessor :ext_pulldown
|
39
|
+
# Pin type, either :analog or :digital
|
40
|
+
attr_accessor :type
|
41
|
+
# Pin RTL name, short term solution for products that do not get full HDL path for pins
|
42
|
+
attr_accessor :rtl_name
|
43
|
+
|
44
|
+
# Should be instantiated through the HasPins macros
|
45
|
+
def initialize(id, owner, options = {}) # :nodoc:
|
46
|
+
options = {
|
47
|
+
reset: :dont_care,
|
48
|
+
invert: false,
|
49
|
+
direction: :io,
|
50
|
+
open_drain: false,
|
51
|
+
ext_pullup: false,
|
52
|
+
ext_pulldown: false,
|
53
|
+
rtl_name: nil
|
54
|
+
}.merge(options)
|
55
|
+
@aliases = {}
|
56
|
+
@functions = {}
|
57
|
+
@direction = sanitize_direction(options[:direction])
|
58
|
+
@invert = options[:invert]
|
59
|
+
@reset = options[:reset]
|
60
|
+
@id = id
|
61
|
+
@name = options[:name]
|
62
|
+
@rtl_name = options[:rtl_name]
|
63
|
+
@suspend = false
|
64
|
+
@order = options[:order]
|
65
|
+
@supply = options[:supply]
|
66
|
+
@open_drain = options[:open_drain]
|
67
|
+
@ext_pullup = options[:ext_pullup]
|
68
|
+
@ext_pulldown = options[:ext_pulldown]
|
69
|
+
@type = options[:type]
|
70
|
+
@dib_assignment = [] # Array to handle multi-site testing
|
71
|
+
@size = 1
|
72
|
+
@value = 0
|
73
|
+
@clock = nil
|
74
|
+
on_init(owner, options)
|
75
|
+
# Assign the initial state from the method so that any inversion is picked up...
|
76
|
+
send(@reset)
|
77
|
+
end
|
78
|
+
|
79
|
+
# When sorting pins do it by ID
|
80
|
+
def <=>(other_pin)
|
81
|
+
@id <=> other_pin.id
|
82
|
+
end
|
83
|
+
|
84
|
+
def name=(val)
|
85
|
+
@name = val
|
86
|
+
end
|
87
|
+
|
88
|
+
def functions=(val)
|
89
|
+
if val.is_a? Hash
|
90
|
+
val.each do |name, _whatever|
|
91
|
+
add_function name
|
92
|
+
end
|
93
|
+
else
|
94
|
+
fail "Attempt to set the functions hash on pin #{@name}. Argument must be a Hash."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# This generates getter methods that will lookup the given attribute within the
|
99
|
+
# scope of the current package and falling back to a default if defined
|
100
|
+
PACKAGE_SCOPED_ATTRIBUTES.each do |attribute|
|
101
|
+
define_method attribute do |options = {}|
|
102
|
+
default = instance_variable_get("@#{attribute}")
|
103
|
+
package_id = options[:package] || current_package_id
|
104
|
+
package_id = package_id.to_sym if package_id
|
105
|
+
if packages[package_id]
|
106
|
+
packages[package_id][attribute] || default
|
107
|
+
elsif packages[:all]
|
108
|
+
packages[:all][attribute] || default
|
109
|
+
else
|
110
|
+
default
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# This generates getter methods that will lookup the given attribute within the
|
116
|
+
# scope of the function enabled by the current mode and configuration attributes
|
117
|
+
# and falling back to a default if defined
|
118
|
+
FUNCTION_SCOPED_ATTRIBUTES.each do |attribute|
|
119
|
+
define_method attribute do |options = {}|
|
120
|
+
default = instance_variable_get("@#{attribute}")
|
121
|
+
if options[:function]
|
122
|
+
v = functions[:ids][options[:function]][attribute]
|
123
|
+
return v if v
|
124
|
+
# else fall back to context-based lookup
|
125
|
+
end
|
126
|
+
mode_id = options[:mode] || current_mode_id
|
127
|
+
mode_id = mode_id.to_sym if mode_id
|
128
|
+
mode = functions[mode_id] || functions[:all]
|
129
|
+
if mode
|
130
|
+
config_id = options[:configuration] || options[:config] || current_configuration
|
131
|
+
config_id = config_id.to_sym if config_id
|
132
|
+
configuration = mode[config_id] || mode[:all]
|
133
|
+
if configuration
|
134
|
+
configuration[attribute] || default
|
135
|
+
else
|
136
|
+
default
|
137
|
+
end
|
138
|
+
else
|
139
|
+
default
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
alias_method :function_scoped_name, :name
|
145
|
+
|
146
|
+
# Returns the name of the pin, if a name has been specifically assigned by the application
|
147
|
+
# (via name=) then this will be returned, otherwise the name of the current function if present
|
148
|
+
# will be returned, and then as a last resort the ID of the pin
|
149
|
+
def name(options = {})
|
150
|
+
# Return a specifically assigned name in preference to a function name
|
151
|
+
(options.empty? ? @name : nil) || function_scoped_name(options) || @id
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns the value held by the pin as a string formatted to the current tester's pattern syntax
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
#
|
158
|
+
# pin.drive_hi
|
159
|
+
# pin.to_vector # => "1"
|
160
|
+
# pin.expect_lo
|
161
|
+
# pin.to_vector # => "L"
|
162
|
+
def to_vector
|
163
|
+
@vector_formatted_value ||= Origen.tester.format_pin_state(self)
|
164
|
+
end
|
165
|
+
|
166
|
+
# @api private
|
167
|
+
def invalidate_vector_cache
|
168
|
+
@vector_formatted_value = nil
|
169
|
+
groups.each { |_name, group| group.invalidate_vector_cache }
|
170
|
+
end
|
171
|
+
|
172
|
+
# Set the pin value and state from a string formatted to the current tester's pattern syntax,
|
173
|
+
# this is the opposite of the to_vector method
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
#
|
177
|
+
# pin.vector_formatted_value = "L"
|
178
|
+
# pin.driving? # => false
|
179
|
+
# pin.value # => 0
|
180
|
+
# pin.vector_formatted_value = "1"
|
181
|
+
# pin.driving? # => true
|
182
|
+
# pin.value # => 1
|
183
|
+
def vector_formatted_value=(val)
|
184
|
+
unless @vector_formatted_value == val
|
185
|
+
Origen.tester.update_pin_from_formatted_state(self, val)
|
186
|
+
@vector_formatted_value = val
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def inspect
|
191
|
+
"<#{self.class}:#{object_id}>"
|
192
|
+
end
|
193
|
+
|
194
|
+
def describe(options = {})
|
195
|
+
desc = ['********************']
|
196
|
+
desc << "Pin id: #{id}"
|
197
|
+
func_aliases = []
|
198
|
+
unless functions.empty?
|
199
|
+
desc << ''
|
200
|
+
desc << 'Functions'
|
201
|
+
desc << '---------'
|
202
|
+
functions.each do |mode, configurations|
|
203
|
+
unless mode == :ids
|
204
|
+
configurations.each do |configuration, attrs|
|
205
|
+
a = ":#{attrs[:name]}".ljust(30)
|
206
|
+
func_aliases << attrs[:name]
|
207
|
+
unless mode == :all
|
208
|
+
a += ":modes => [#{[mode].flatten.map { |id| ':' + id.to_s }.join(', ')}]"
|
209
|
+
prev = true
|
210
|
+
end
|
211
|
+
unless configuration == :all
|
212
|
+
a += ' ; ' if prev
|
213
|
+
a += ":configurations => [#{[configuration].flatten.map { |id| ':' + id.to_s }.join(', ')}]"
|
214
|
+
end
|
215
|
+
desc << a
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
unless aliases.empty?
|
221
|
+
desc << ''
|
222
|
+
desc << 'Aliases'
|
223
|
+
desc << '-------'
|
224
|
+
aliases.each do |name, context|
|
225
|
+
unless func_aliases.include?(name)
|
226
|
+
a = ":#{name}".ljust(30)
|
227
|
+
unless context[:packages].empty? || context[:packages] == [:all]
|
228
|
+
a += ":packages => [#{context[:packages].map { |id| ':' + id.to_s }.join(', ')}]"
|
229
|
+
prev = true
|
230
|
+
end
|
231
|
+
unless context[:modes].empty? || context[:modes] == [:all]
|
232
|
+
a += ' ; ' if prev
|
233
|
+
a += ":modes => [#{context[:modes].map { |id| ':' + id.to_s }.join(', ')}]"
|
234
|
+
prev = true
|
235
|
+
end
|
236
|
+
unless context[:configurations].empty? || context[:configurations] == [:all]
|
237
|
+
a += ' ; ' if prev
|
238
|
+
a += ":configurations => [#{context[:configurations].map { |id| ':' + id.to_s }.join(', ')}]"
|
239
|
+
end
|
240
|
+
desc << a
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
unless Origen.top_level.modes.empty?
|
245
|
+
desc << ''
|
246
|
+
desc << 'Modes'
|
247
|
+
desc << '-------'
|
248
|
+
Origen.top_level.modes.each do |name|
|
249
|
+
unless option(mode: name).nil?
|
250
|
+
a = ":#{name}".ljust(30) + ":mode => #{option(mode: name)}"
|
251
|
+
desc << a
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
unless groups.empty?
|
256
|
+
desc << ''
|
257
|
+
desc << 'Groups'
|
258
|
+
desc << '------'
|
259
|
+
desc << groups.map { |name, _group| ':' + name.to_s }.join(', ')
|
260
|
+
end
|
261
|
+
desc << '********************'
|
262
|
+
if options[:return]
|
263
|
+
desc
|
264
|
+
else
|
265
|
+
puts desc.join("\n")
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
# Returns a hash containing the pin groups that the given pin is a member of
|
270
|
+
def groups
|
271
|
+
# Origen.pin_bank.all_pin_groups.select do |name, group|
|
272
|
+
@groups ||= Origen.pin_bank.pin_groups.select do |_name, group|
|
273
|
+
group.include?(self)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
alias_method :ports, :groups
|
277
|
+
alias_method :pin_groups, :groups
|
278
|
+
|
279
|
+
def invalidate_group_cache
|
280
|
+
@groups = nil
|
281
|
+
end
|
282
|
+
|
283
|
+
# Add a location identifier to the pin, this is a free format field which can be a
|
284
|
+
# pin number or BGA co-ordinate for example.
|
285
|
+
#
|
286
|
+
# @example Adding a location by package
|
287
|
+
# $dut.pin(:pin3).add_location "B3", :package => :p1
|
288
|
+
# $dut.pin(:pin3).add_location "B2", :package => :p2
|
289
|
+
def add_location(str, options = {})
|
290
|
+
packages = resolve_packages(options)
|
291
|
+
if packages.empty?
|
292
|
+
@location = str
|
293
|
+
add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all
|
294
|
+
else
|
295
|
+
packages.each do |package_id|
|
296
|
+
package_id = package_id.respond_to?(:id) ? package_id.id : package_id
|
297
|
+
self.packages[package_id] ||= {}
|
298
|
+
self.packages[package_id][:location] = str
|
299
|
+
add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
alias_method :add_locn, :add_location
|
304
|
+
|
305
|
+
# Add a Device Interface Board (e.g. probecard at wafer probe or loadboard at final package test)
|
306
|
+
# assignment to the pin. Some refer to this as a channel but API name is meant to be generic.
|
307
|
+
def add_dib_assignment(str, options = {})
|
308
|
+
options = {
|
309
|
+
site: 0
|
310
|
+
}.merge(options)
|
311
|
+
packages = resolve_packages(options)
|
312
|
+
if packages.empty?
|
313
|
+
@dib_assignment[options[:site]] = str
|
314
|
+
add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all
|
315
|
+
else
|
316
|
+
packages.each do |package_id|
|
317
|
+
package_id = package_id.respond_to?(:id) ? package_id.id : package_id
|
318
|
+
self.packages[package_id] ||= {}
|
319
|
+
self.packages[package_id][:dib_assignment] ||= []
|
320
|
+
self.packages[package_id][:dib_assignment][options[:site]] = str
|
321
|
+
add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
alias_method :add_dib_info, :add_dib_assignment
|
326
|
+
alias_method :add_channel, :add_dib_assignment
|
327
|
+
|
328
|
+
# Returns the number of test sites enabled for the pin
|
329
|
+
def sites
|
330
|
+
dib_assignment.size
|
331
|
+
end
|
332
|
+
|
333
|
+
def sanitize_direction(val)
|
334
|
+
if val
|
335
|
+
val = val.to_s.downcase.gsub(/\//, '')
|
336
|
+
if val =~ /i.*o/
|
337
|
+
:io
|
338
|
+
elsif val =~ /^i/
|
339
|
+
:input
|
340
|
+
elsif val =~ /^o/
|
341
|
+
:output
|
342
|
+
else
|
343
|
+
fail "Unknown pin direction: #{val}"
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
# Sets the default direction of the pin, :input, :output or :io (default). If a function specific
|
349
|
+
# direction has been specified that will override this value.
|
350
|
+
def direction=(val)
|
351
|
+
@direction = sanitize_direction(val)
|
352
|
+
end
|
353
|
+
|
354
|
+
# Add a function to the pin.
|
355
|
+
#
|
356
|
+
# @example Adding a mode-specific function
|
357
|
+
# pin.add_function :tdi, :direction => :input
|
358
|
+
# pin.add_function :nvm_fail, :mode => :nvmbist, :direction => :output
|
359
|
+
def add_function(id, options = {})
|
360
|
+
id = id.to_sym
|
361
|
+
add_function_attributes(options.merge(name: id, id: id.to_sym))
|
362
|
+
f = FunctionProxy.new(id, self)
|
363
|
+
add_alias id, packages: :all, obj: f
|
364
|
+
end
|
365
|
+
|
366
|
+
def add_function_attributes(options = {})
|
367
|
+
id = options.delete(:id)
|
368
|
+
modes = resolve_modes(options)
|
369
|
+
configurations = resolve_configurations(options)
|
370
|
+
options[:direction] = sanitize_direction(options[:direction]) if options[:direction]
|
371
|
+
if modes.empty?
|
372
|
+
modes = [:all]
|
373
|
+
end
|
374
|
+
if configurations.empty?
|
375
|
+
configurations = [:all]
|
376
|
+
end
|
377
|
+
# Supports newer attribute lookup by function ID
|
378
|
+
if id
|
379
|
+
functions[:ids] ||= {}
|
380
|
+
if functions[:ids][id]
|
381
|
+
functions[:ids][id] = functions[:ids][id].merge!(options)
|
382
|
+
else
|
383
|
+
functions[:ids][id] = options.dup
|
384
|
+
end
|
385
|
+
end
|
386
|
+
# Supports older attribute lookup by mode context
|
387
|
+
modes.each do |mode|
|
388
|
+
configurations.each do |configuration|
|
389
|
+
functions[mode.to_sym] ||= {}
|
390
|
+
if functions[mode.to_sym][configuration.to_sym]
|
391
|
+
functions[mode.to_sym][configuration.to_sym] = functions[mode.to_sym][configuration.to_sym].merge!(options)
|
392
|
+
else
|
393
|
+
functions[mode.to_sym][configuration.to_sym] = options
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
# Add an alias to the given pin.
|
400
|
+
#
|
401
|
+
# If the options contain a package, mode or configuration reference then the alias
|
402
|
+
# will only work under that context.
|
403
|
+
def add_alias(id, options = {})
|
404
|
+
obj = options.delete(:obj) || self
|
405
|
+
if aliases[id]
|
406
|
+
aliases[id][:packages] += resolve_packages(options)
|
407
|
+
aliases[id][:modes] += resolve_modes(options)
|
408
|
+
aliases[id][:configurations] += resolve_configurations(options)
|
409
|
+
aliases[id][:packages].uniq!
|
410
|
+
aliases[id][:modes].uniq!
|
411
|
+
aliases[id][:configurations].uniq!
|
412
|
+
else
|
413
|
+
aliases[id] = {
|
414
|
+
packages: resolve_packages(options),
|
415
|
+
modes: resolve_modes(options),
|
416
|
+
configurations: resolve_configurations(options)
|
417
|
+
}
|
418
|
+
Origen.pin_bank.register_alias(id, obj, options)
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
# Returns true if the pin has the given alias within the given or current context
|
423
|
+
def has_alias?(id, options = {})
|
424
|
+
if aliases[id]
|
425
|
+
if options[:ignore_context]
|
426
|
+
true
|
427
|
+
else
|
428
|
+
packages = resolve_packages(options)
|
429
|
+
modes = resolve_modes(options)
|
430
|
+
configurations = resolve_configurations(options)
|
431
|
+
begin
|
432
|
+
aliases[id][:packages].include?(:all) || aliases[id][:packages].empty? ||
|
433
|
+
packages.any? { |package| aliases[id][:packages].include?(package) }
|
434
|
+
end && begin
|
435
|
+
aliases[id][:modes].include?(:all) || aliases[id][:modes].empty? ||
|
436
|
+
modes.any? { |mode| aliases[id][:modes].include?(mode) }
|
437
|
+
end && begin
|
438
|
+
aliases[id][:configurations].include?(:all) || aliases[id][:configurations].empty? ||
|
439
|
+
configurations.any? { |config| aliases[id][:configurations].include?(config) }
|
440
|
+
end
|
441
|
+
end
|
442
|
+
else
|
443
|
+
false
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
# Returns true if the pin is an alias of the given pin name
|
448
|
+
def is_alias_of?(name)
|
449
|
+
if Origen.pin_bank.find(name)
|
450
|
+
Origen.pin_bank.find(name).id == Origen.pin_bank.find(self).id
|
451
|
+
else
|
452
|
+
false
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
# Returns true if the pin belongs to a port.
|
457
|
+
#
|
458
|
+
# add_port :jtag, :size => 6
|
459
|
+
# add_pin :done
|
460
|
+
# add_pin_alias :fail, :jtag, :pin => 4
|
461
|
+
#
|
462
|
+
# pin(:done).belongs_to_a_port? # => false
|
463
|
+
# pin(:fail).belongs_to_a_port? # => true
|
464
|
+
def belongs_to_a_port?
|
465
|
+
!groups.empty?
|
466
|
+
end
|
467
|
+
alias_method :belongs_to_a_pin_group?, :belongs_to_a_port?
|
468
|
+
|
469
|
+
def value
|
470
|
+
@value
|
471
|
+
end
|
472
|
+
alias_method :data, :value
|
473
|
+
|
474
|
+
def suspend
|
475
|
+
invalidate_vector_cache
|
476
|
+
@suspend = true
|
477
|
+
end
|
478
|
+
|
479
|
+
def suspended?
|
480
|
+
@suspend
|
481
|
+
end
|
482
|
+
|
483
|
+
# Will resume compares on this pin
|
484
|
+
def resume
|
485
|
+
invalidate_vector_cache
|
486
|
+
@suspend = false
|
487
|
+
end
|
488
|
+
|
489
|
+
def repeat_previous=(bool)
|
490
|
+
invalidate_vector_cache
|
491
|
+
@repeat_previous = bool
|
492
|
+
end
|
493
|
+
|
494
|
+
def repeat_previous?
|
495
|
+
@repeat_previous
|
496
|
+
end
|
497
|
+
|
498
|
+
def set_state(state)
|
499
|
+
invalidate_vector_cache
|
500
|
+
@repeat_previous = false
|
501
|
+
@state = state
|
502
|
+
end
|
503
|
+
|
504
|
+
def set_value(val)
|
505
|
+
invalidate_vector_cache
|
506
|
+
# If val is a data bit extract the value of it
|
507
|
+
val = val.respond_to?(:data) ? val.data : val
|
508
|
+
# Assume driving/asserting a nil value means 0
|
509
|
+
val = 0 unless val
|
510
|
+
if val > 1
|
511
|
+
fail "Attempt to set a value of #{val} on pin #{name}"
|
512
|
+
end
|
513
|
+
@repeat_previous = false
|
514
|
+
if inverted?
|
515
|
+
@value = val == 0 ? 1 : 0
|
516
|
+
else
|
517
|
+
@value = val
|
518
|
+
end
|
519
|
+
end
|
520
|
+
alias_method :data=, :set_value
|
521
|
+
|
522
|
+
def cycle # :nodoc:
|
523
|
+
Origen.tester.cycle
|
524
|
+
end
|
525
|
+
|
526
|
+
def state
|
527
|
+
@state
|
528
|
+
end
|
529
|
+
|
530
|
+
def state=(value)
|
531
|
+
invalidate_vector_cache
|
532
|
+
@state = value
|
533
|
+
end
|
534
|
+
|
535
|
+
# Set the pin to drive a 1 on future cycles
|
536
|
+
def drive_hi
|
537
|
+
set_state(:drive)
|
538
|
+
set_value(1)
|
539
|
+
end
|
540
|
+
|
541
|
+
def drive_hi!
|
542
|
+
drive_hi
|
543
|
+
cycle
|
544
|
+
end
|
545
|
+
|
546
|
+
# Set the pin to drive a high voltage on future cycles (if the tester supports it).
|
547
|
+
# For example on a J750 high-voltage channel the pin state would be set to "2"
|
548
|
+
def drive_very_hi
|
549
|
+
set_state(:drive_very_hi)
|
550
|
+
set_value(1)
|
551
|
+
end
|
552
|
+
|
553
|
+
def drive_very_hi!
|
554
|
+
drive_very_hi
|
555
|
+
cycle
|
556
|
+
end
|
557
|
+
|
558
|
+
# Set the pin to drive a 0 on future cycles
|
559
|
+
def drive_lo
|
560
|
+
set_state(:drive)
|
561
|
+
set_value(0)
|
562
|
+
end
|
563
|
+
|
564
|
+
def drive_lo!
|
565
|
+
drive_lo
|
566
|
+
cycle
|
567
|
+
end
|
568
|
+
|
569
|
+
def drive_mem
|
570
|
+
set_state(:drive_mem)
|
571
|
+
end
|
572
|
+
|
573
|
+
def drive_mem!
|
574
|
+
drive_mem
|
575
|
+
cycle
|
576
|
+
end
|
577
|
+
|
578
|
+
def expect_mem
|
579
|
+
set_state(:expect_mem)
|
580
|
+
end
|
581
|
+
|
582
|
+
def expect_mem!
|
583
|
+
expect_mem
|
584
|
+
cycle
|
585
|
+
end
|
586
|
+
|
587
|
+
# Set the pin to expect a 1 on future cycles
|
588
|
+
def assert_hi(_options = {})
|
589
|
+
set_state(:compare)
|
590
|
+
set_value(1)
|
591
|
+
end
|
592
|
+
alias_method :expect_hi, :assert_hi
|
593
|
+
alias_method :compare_hi, :assert_hi
|
594
|
+
|
595
|
+
def assert_hi!
|
596
|
+
assert_hi
|
597
|
+
cycle
|
598
|
+
end
|
599
|
+
alias_method :expect_hi!, :assert_hi!
|
600
|
+
alias_method :compare_hi!, :assert_hi!
|
601
|
+
|
602
|
+
# Set the pin to expect a 0 on future cycles
|
603
|
+
def assert_lo(_options = {})
|
604
|
+
set_state(:compare)
|
605
|
+
set_value(0)
|
606
|
+
# Planning to add the active load logic to the tester instead...
|
607
|
+
# options = { :active => false #if active true means to take tester active load capability into account
|
608
|
+
# }.merge(options)
|
609
|
+
# unless state_to_be_inverted?
|
610
|
+
# self.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_lo) : $tester.pin_state(:dont_care)
|
611
|
+
# else
|
612
|
+
# self.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_hi) : $tester.pin_state(:dont_care)
|
613
|
+
# end
|
614
|
+
end
|
615
|
+
alias_method :expect_lo, :assert_lo
|
616
|
+
alias_method :compare_lo, :assert_lo
|
617
|
+
|
618
|
+
def assert_lo!
|
619
|
+
assert_lo
|
620
|
+
cycle
|
621
|
+
end
|
622
|
+
alias_method :expect_lo!, :assert_lo!
|
623
|
+
alias_method :compare_lo!, :assert_lo!
|
624
|
+
|
625
|
+
# Set the pin to X on future cycles
|
626
|
+
def dont_care
|
627
|
+
set_state(:dont_care)
|
628
|
+
end
|
629
|
+
|
630
|
+
def dont_care!
|
631
|
+
dont_care
|
632
|
+
cycle
|
633
|
+
end
|
634
|
+
|
635
|
+
# Pass in 0 or 1 to have the pin drive_lo or drive_hi respectively.
|
636
|
+
# This is useful when programatically setting the pin state.
|
637
|
+
# ==== Example
|
638
|
+
# [0,1,1,0].each do |level|
|
639
|
+
# $pin(:d_in).drive(level)
|
640
|
+
# end
|
641
|
+
def drive(value)
|
642
|
+
set_state(:drive)
|
643
|
+
set_value(value)
|
644
|
+
end
|
645
|
+
|
646
|
+
def drive!(value)
|
647
|
+
drive(value)
|
648
|
+
cycle
|
649
|
+
end
|
650
|
+
|
651
|
+
# Pass in 0 or 1 to have the pin expect_lo or expect_hi respectively.
|
652
|
+
# This is useful when programatically setting the pin state.
|
653
|
+
# ==== Example
|
654
|
+
# [0,1,1,0].each do |level|
|
655
|
+
# $pin(:d_in).assert(level)
|
656
|
+
# end
|
657
|
+
def assert(value, _options = {})
|
658
|
+
set_state(:compare)
|
659
|
+
set_value(value)
|
660
|
+
end
|
661
|
+
alias_method :compare, :assert
|
662
|
+
alias_method :expect, :assert
|
663
|
+
|
664
|
+
def assert!(*args)
|
665
|
+
assert(*args)
|
666
|
+
cycle
|
667
|
+
end
|
668
|
+
alias_method :compare!, :assert!
|
669
|
+
alias_method :expect!, :assert!
|
670
|
+
|
671
|
+
# Returns the state of invert
|
672
|
+
def inverted?
|
673
|
+
@invert
|
674
|
+
end
|
675
|
+
|
676
|
+
# Returns true if the pin is currently in a compare state
|
677
|
+
def comparing?
|
678
|
+
!@suspend &&
|
679
|
+
state == :compare
|
680
|
+
end
|
681
|
+
|
682
|
+
# Returns true if the pin is currently in a compare mem state
|
683
|
+
def comparing_mem?
|
684
|
+
!@suspend &&
|
685
|
+
state == :expect_mem
|
686
|
+
end
|
687
|
+
|
688
|
+
# Returns true if the pin is currently in a drive state
|
689
|
+
def driving?
|
690
|
+
!@suspend &&
|
691
|
+
(state == :drive || state == :drive_very_hi)
|
692
|
+
end
|
693
|
+
|
694
|
+
# Returns true if the pin is currently in a drive mem state
|
695
|
+
def driving_mem?
|
696
|
+
!@suspend &&
|
697
|
+
state == :drive_mem
|
698
|
+
end
|
699
|
+
|
700
|
+
# Returns true if pin is in high voltage state
|
701
|
+
def high_voltage?
|
702
|
+
!@suspend &&
|
703
|
+
state == :drive_very_hi
|
704
|
+
end
|
705
|
+
|
706
|
+
def toggle
|
707
|
+
unless state == :dont_care
|
708
|
+
set_value(value == 0 ? 1 : 0)
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
def toggle!
|
713
|
+
toggle
|
714
|
+
cycle
|
715
|
+
end
|
716
|
+
|
717
|
+
# Mark the (data) from the pin to be captured
|
718
|
+
def capture
|
719
|
+
set_state(:capture)
|
720
|
+
end
|
721
|
+
alias_method :store, :capture
|
722
|
+
|
723
|
+
# Mark the (data) from the pin to be captured and trigger a cycle
|
724
|
+
def capture!
|
725
|
+
capture
|
726
|
+
cycle
|
727
|
+
end
|
728
|
+
alias_method :store!, :capture!
|
729
|
+
|
730
|
+
# Returns true if the (data) from the pin is marked to be captured
|
731
|
+
def to_be_captured?
|
732
|
+
state == :capture
|
733
|
+
end
|
734
|
+
alias_method :to_be_stored?, :to_be_captured?
|
735
|
+
alias_method :is_to_be_stored?, :to_be_captured?
|
736
|
+
alias_method :is_to_be_captured?, :to_be_captured?
|
737
|
+
|
738
|
+
# Restores the state of the pin at the end of the given block
|
739
|
+
# to the state it was in at the start of the block
|
740
|
+
#
|
741
|
+
# pin(:invoke).driving? # => true
|
742
|
+
# pin(:invoke).restore_state do
|
743
|
+
# pin(:invoke).dont_care
|
744
|
+
# pin(:invoke).driving? # => false
|
745
|
+
# end
|
746
|
+
# pin(:invoke).driving? # => true
|
747
|
+
def restore_state
|
748
|
+
save
|
749
|
+
yield
|
750
|
+
restore
|
751
|
+
end
|
752
|
+
|
753
|
+
def save # :nodoc:
|
754
|
+
@_saved_state = @state
|
755
|
+
@_saved_value = @value
|
756
|
+
@_saved_suspend = @suspend
|
757
|
+
@_saved_invert = @invert
|
758
|
+
@_saved_repeat_previous = @repeat_previous
|
759
|
+
end
|
760
|
+
|
761
|
+
def restore # :nodoc:
|
762
|
+
invalidate_vector_cache
|
763
|
+
@state = @_saved_state
|
764
|
+
@value = @_saved_value
|
765
|
+
@suspend = @_saved_suspend
|
766
|
+
@invert = @_saved_invert
|
767
|
+
@repeat_previous = @_saved_repeat_previous
|
768
|
+
end
|
769
|
+
|
770
|
+
def is_not_a_clock?
|
771
|
+
@clock.nil?
|
772
|
+
end
|
773
|
+
|
774
|
+
def is_a_clock?
|
775
|
+
!(@clock.nil?)
|
776
|
+
end
|
777
|
+
|
778
|
+
def is_a_running_clock?
|
779
|
+
@clock.running?
|
780
|
+
end
|
781
|
+
|
782
|
+
def enable_clock(options = {})
|
783
|
+
@clock = PinClock.new(self, options)
|
784
|
+
end
|
785
|
+
|
786
|
+
def disable_clock(options = {})
|
787
|
+
@clock.stop_clock(options)
|
788
|
+
@clock = nil
|
789
|
+
end
|
790
|
+
|
791
|
+
def update_clock
|
792
|
+
@clock.update_clock
|
793
|
+
end
|
794
|
+
|
795
|
+
def start_clock(options = {})
|
796
|
+
enable_clock(options) if self.is_not_a_clock?
|
797
|
+
@clock.start_clock(options)
|
798
|
+
end
|
799
|
+
alias_method :resume_clock, :start_clock
|
800
|
+
|
801
|
+
def stop_clock(options = {})
|
802
|
+
@clock.stop_clock(options)
|
803
|
+
end
|
804
|
+
alias_method :pause_clock, :stop_clock
|
805
|
+
|
806
|
+
def next_edge
|
807
|
+
@clock.next_edge
|
808
|
+
end
|
809
|
+
|
810
|
+
def half_period
|
811
|
+
@clock.cycles_per_half_period
|
812
|
+
end
|
813
|
+
|
814
|
+
def toggle_clock
|
815
|
+
fail "ERROR: Clock on #{@owner.name} not running." unless is_a_running_clock?
|
816
|
+
@clock.toggle
|
817
|
+
end
|
818
|
+
|
819
|
+
# Delete this pin (self). Used bang in method name to keep same for pins and
|
820
|
+
# pin collections. Pin collections already had a delete method which deletes
|
821
|
+
# a pin from the collection. Needed delete! to indicate it is deleting the
|
822
|
+
# actual pin or pin group calling the method.
|
823
|
+
def delete!
|
824
|
+
owner.delete_pin(self)
|
825
|
+
end
|
826
|
+
|
827
|
+
def type=(value)
|
828
|
+
if TYPES.include? value
|
829
|
+
@type = value
|
830
|
+
else
|
831
|
+
fail "Pin type '#{value}' must be set to one of the following: #{TYPES.join(', ')}"
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
def open_drain=(value)
|
836
|
+
if [true, false].include? value
|
837
|
+
@open_drain = value
|
838
|
+
else
|
839
|
+
fail "Pin open_drain attribute '#{value}' must be either true or false"
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
def ext_pullup=(value)
|
844
|
+
if [true, false].include? value
|
845
|
+
@ext_pullup = value
|
846
|
+
else
|
847
|
+
fail "Pin ext_pullup attribute '#{value}' must be either true or false"
|
848
|
+
end
|
849
|
+
end
|
850
|
+
|
851
|
+
def ext_pulldown=(value)
|
852
|
+
if [true, false].include? value
|
853
|
+
@ext_pulldown = value
|
854
|
+
else
|
855
|
+
fail "Pin ext_pulldown attribute '#{value}' must be either true or false"
|
856
|
+
end
|
857
|
+
end
|
858
|
+
end
|
859
|
+
end
|
860
|
+
end
|