origen 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -311,6 +311,12 @@ module Origen
311
311
  @new_reg_attrs = { meta: bit_info }
312
312
  yield self
313
313
  bit_info = @new_reg_attrs
314
+ else
315
+ # If no block given then init with all writable bits unless bit_info has
316
+ # been supplied
317
+ unless bit_info.any? { |k, v| v.is_a?(Hash) && v[:pos] }
318
+ bit_info = { d: { pos: 0, bits: size }.merge(bit_info) }
319
+ end
314
320
  end
315
321
  if _registers[id] && Origen.config.strict_errors
316
322
  puts ''
@@ -472,7 +478,7 @@ module Origen
472
478
  # Can also be used to define a new register if a block is supplied in which case
473
479
  # it is equivalent to calling add_reg with a block.
474
480
  def reg(*args, &block)
475
- if block_given?
481
+ if block_given? || (args[1].is_a?(Fixnum) && !try(:initialized?))
476
482
  @reg_define_file = define_file(caller[0])
477
483
  add_reg(*args, &block)
478
484
  else
@@ -234,8 +234,12 @@ module Origen
234
234
  # This does not account for any overridding that may have been applied to
235
235
  # this bit specifically however, use the meta method to get that.
236
236
  def default_bit_metadata
237
- Origen::Registers.default_bit_metadata.merge(
238
- Origen::Registers.bit_metadata[owner.owner.class] || {})
237
+ if owner
238
+ Origen::Registers.default_bit_metadata.merge(
239
+ Origen::Registers.bit_metadata[owner.owner.class] || {})
240
+ else
241
+ Origen::Registers.default_bit_metadata
242
+ end
239
243
  end
240
244
 
241
245
  def inspect
@@ -440,7 +444,8 @@ module Origen
440
444
  self
441
445
  end
442
446
 
443
- def respond_to?(sym) # :nodoc:
447
+ def respond_to?(*args) # :nodoc:
448
+ sym = args.first
444
449
  meta_data_method?(sym) || super(sym)
445
450
  end
446
451
 
@@ -10,6 +10,7 @@ module Origen
10
10
  # or a group of Bit objects, the same API can be used as described below.
11
11
  class BitCollection < Array
12
12
  include Origen::SubBlocks::Path
13
+ include Netlist::Connectable
13
14
 
14
15
  DONT_CARE_CHAR = 'X'
15
16
  OVERLAY_CHAR = 'V'
@@ -26,6 +27,10 @@ module Origen
26
27
  [data].flatten.each { |item| self << item }
27
28
  end
28
29
 
30
+ def terminal?
31
+ true
32
+ end
33
+
29
34
  def bind(live_parameter)
30
35
  parent.bind(name, live_parameter)
31
36
  end
@@ -201,7 +206,10 @@ module Origen
201
206
  # reg(:control).data # => 0x55, assuming the reg has the required bits to store that
202
207
  def data
203
208
  data = 0
204
- each_with_index { |bit, i| data |= bit.data << i }
209
+ each_with_index do |bit, i|
210
+ return undefined if bit.is_a?(Origen::UndefinedClass)
211
+ data |= bit.data << i
212
+ end
205
213
  data
206
214
  end
207
215
  alias_method :val, :data
@@ -540,7 +548,8 @@ module Origen
540
548
  end
541
549
 
542
550
  # Recognize that BitCollection responds to some Bit methods via method_missing
543
- def respond_to?(sym) # :nodoc:
551
+ def respond_to?(*args) # :nodoc:
552
+ sym = args.first
544
553
  first.respond_to?(sym) || super(sym)
545
554
  end
546
555
 
@@ -728,6 +737,52 @@ module Origen
728
737
  make_hex_like(str, size / 4)
729
738
  end
730
739
 
740
+ # Shifts the data in the collection left by one place. The data held
741
+ # by the rightmost bit will be set to the given value (0 by default).
742
+ #
743
+ # @example
744
+ # myreg.data # => 0b1111
745
+ # myreg.shift_left
746
+ # myreg.data # => 0b1110
747
+ # myreg.shift_left
748
+ # myreg.data # => 0b1100
749
+ # myreg.shift_left(1)
750
+ # myreg.data # => 0b1001
751
+ # myreg.shift_left(1)
752
+ # myreg.data # => 0b0011
753
+ def shift_left(data = 0)
754
+ prev_bit = nil
755
+ reverse_each do |bit|
756
+ prev_bit.write(bit.data) if prev_bit
757
+ prev_bit = bit
758
+ end
759
+ prev_bit.write(data)
760
+ self
761
+ end
762
+
763
+ # Shifts the data in the collection right by one place. The data held
764
+ # by the leftmost bit will be set to the given value (0 by default).
765
+ #
766
+ # @example
767
+ # myreg.data # => 0b1111
768
+ # myreg.shift_right
769
+ # myreg.data # => 0b0111
770
+ # myreg.shift_right
771
+ # myreg.data # => 0b0011
772
+ # myreg.shift_right(1)
773
+ # myreg.data # => 0b1001
774
+ # myreg.shift_right(1)
775
+ # myreg.data # => 0b1100
776
+ def shift_right(data = 0)
777
+ prev_bit = nil
778
+ each do |bit|
779
+ prev_bit.write(bit.data) if prev_bit
780
+ prev_bit = bit
781
+ end
782
+ prev_bit.write(data)
783
+ self
784
+ end
785
+
731
786
  private
732
787
 
733
788
  # Converts a binary-like representation of a data value into a hex-like version.
@@ -1122,8 +1122,8 @@ module Origen
1122
1122
 
1123
1123
  # Recognize that Reg responds to all BitCollection methods methods based on
1124
1124
  # application-specific meta data properties
1125
- def respond_to?(sym) # :nodoc:
1126
- sym = sym.to_sym
1125
+ def respond_to?(*args) # :nodoc:
1126
+ sym = args.first.to_sym
1127
1127
  meta_data_method?(sym) || has_bits?(sym) || super(sym) || BitCollection.instance_methods.include?(sym)
1128
1128
  end
1129
1129
 
@@ -35,6 +35,43 @@ module Origen
35
35
  FileUtils.rm_rf(scratch)
36
36
  end
37
37
 
38
+ # Import a file to the local workspace from another vault, where the first
39
+ # argument must include the full path to the requested file in the vault. You can optionally
40
+ # supply a destination for where you want the file to end up via the :local option, if no destination
41
+ # is supplied the file will end up in the PWD.
42
+ #
43
+ # This is a DesignSync only API and can be used in cases where you would to fetch a file
44
+ # directly from a vault without setting up an association between a local directory and the
45
+ # vault. i.e. it will not create or modify an existing .SYNC in the local destination directory.
46
+ #
47
+ # ==== Example
48
+ #
49
+ # # Import this file and save it in RGen.root
50
+ # file = "sync://sync-15088:15088/Projects/common_tester_blocks/rgen/lib/sys/design_sync.rb"
51
+ # version = "v0.1.0" # Version can be any valid DS identifier, e.g. a version number or tag
52
+ #
53
+ # import(file, version: version, local: RGen.root)
54
+ def self.import(path_to_file_in_vault, options = {})
55
+ options = {
56
+ verbose: true,
57
+ version: 'Latest'
58
+ }.merge(options)
59
+ if options[:verbose]
60
+ puts 'Importing from DesignSync...'
61
+ puts "#{path_to_file_in_vault} #{options[:version]}"
62
+ end
63
+ dir = path_to_file_in_vault.split('/')
64
+ file = dir.pop
65
+ dir = dir.join('/')
66
+ cmd = "import -version #{options[:version]} -force #{dir} #{file}"
67
+ dssc(cmd, verbose: false)
68
+ if Origen.os.windows?
69
+ system("move /Y #{file} #{options[:local]}/.") if options[:local]
70
+ else
71
+ system("mv -f #{file} #{options[:local]}/.") if options[:local]
72
+ end
73
+ end
74
+
38
75
  # Recursively remove all .SYNC directories from the given directory
39
76
  def self.remove_dot_syncs!(dir, options = {})
40
77
  dir = Pathname.new(dir)
@@ -261,17 +298,18 @@ module Origen
261
298
  end
262
299
 
263
300
  # Execute a dssc operation, the resultant output is returned in an array
264
- def dssc(command, options = {})
301
+ def self.dssc(command, options = {})
265
302
  options = {
266
303
  check_errors: true,
267
- verbose: true
304
+ verbose: true,
305
+ local: Dir.pwd
268
306
  }.merge(options)
269
307
  output = []
270
308
  if options[:verbose]
271
309
  Origen.log.info "dssc #{command}"
272
310
  Origen.log.info ''
273
311
  end
274
- Dir.chdir local do
312
+ Dir.chdir options[:local] do
275
313
  Open3.popen2e("dssc #{command}") do |_stdin, stdout_err, wait_thr|
276
314
  while line = stdout_err.gets
277
315
  Origen.log.info line.strip if options[:verbose]
@@ -293,6 +331,12 @@ module Origen
293
331
  end
294
332
  output
295
333
  end
334
+
335
+ # Execute a dssc operation, the resultant output is returned in an array
336
+ def dssc(command, options = {})
337
+ options[:local] ||= local
338
+ DesignSync.dssc(command, options)
339
+ end
296
340
  end
297
341
  end
298
342
  end
@@ -180,11 +180,20 @@ module Origen
180
180
  root = "#{p.path(options)}."
181
181
  end
182
182
  else
183
- root = ''
183
+ # If a path variable has been set on a top-level object, then we will
184
+ # include that in path, otherwise by default the top-level object is not
185
+ # included in the path
186
+ if p || path_var
187
+ root = ''
188
+ else
189
+ return ''
190
+ end
184
191
  end
185
192
  local = (path_var || name || self.class.to_s.split('::').last).to_s
186
193
  if local == 'hidden'
187
194
  root.chop
195
+ elsif is_a?(Origen::Registers::BitCollection) && parent.path_var == :hidden
196
+ "#{root.chop}#{local}"
188
197
  else
189
198
  "#{root}#{local}"
190
199
  end
@@ -274,8 +283,7 @@ module Origen
274
283
  puts ''
275
284
  fail 'Sub block does not include Origen::Model!'
276
285
  end
277
- block = klass.new(options.merge(parent: self))
278
- block.name = name
286
+ block = klass.new(options.merge(parent: self, name: name))
279
287
  if sub_blocks[name]
280
288
  fail "You have already defined a sub-block named #{name} within class #{self.class}"
281
289
  else
@@ -312,6 +320,7 @@ module Origen
312
320
  # next time, this should be faster for repeated lookups of the same method, e.g. reg
313
321
  def method_missing(method, *args, &block)
314
322
  return regs(method) if self.has_reg?(method)
323
+ return ports(method) if self.has_port?(method)
315
324
  if method.to_s =~ /=$/
316
325
  define_singleton_method(method) do |val|
317
326
  instance_variable_set("@#{method.to_s.sub('=', '')}", val)
@@ -0,0 +1,13 @@
1
+ module Origen
2
+ class UndefinedClass
3
+ include Singleton
4
+
5
+ def inspect
6
+ 'undefined'
7
+ end
8
+
9
+ def undefined?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -114,5 +114,13 @@
114
114
  <script src="http://origen-sdk.org/js/lunr.min.js"></script>
115
115
  <script src="http://origen-sdk.org/js/highlight.js"></script>
116
116
  <script src="http://origen-sdk.org/js/custom.js"></script>
117
+ <% if @item[:gitter_chat] %>
118
+ <script>
119
+ ((window.gitter = {}).chat = {}).options = {
120
+ room: '<%= @item[:gitter_chat] %>'
121
+ };
122
+ </script>
123
+ <script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>
124
+ <% end %>
117
125
  </body>
118
126
  </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -344,14 +344,14 @@ dependencies:
344
344
  requirements:
345
345
  - - '='
346
346
  - !ruby/object:Gem::Version
347
- version: 0.2.1
347
+ version: 0.2.3
348
348
  type: :development
349
349
  prerelease: false
350
350
  version_requirements: !ruby/object:Gem::Requirement
351
351
  requirements:
352
352
  - - '='
353
353
  - !ruby/object:Gem::Version
354
- version: 0.2.1
354
+ version: 0.2.3
355
355
  - !ruby/object:Gem::Dependency
356
356
  name: origen_doc_helpers
357
357
  requirement: !ruby/object:Gem::Requirement
@@ -531,6 +531,12 @@ files:
531
531
  - lib/origen/mode.rb
532
532
  - lib/origen/model.rb
533
533
  - lib/origen/model_initializer.rb
534
+ - lib/origen/models.rb
535
+ - lib/origen/models/mux.rb
536
+ - lib/origen/models/scan_register.rb
537
+ - lib/origen/netlist.rb
538
+ - lib/origen/netlist/connectable.rb
539
+ - lib/origen/netlist/list.rb
534
540
  - lib/origen/operating_systems.rb
535
541
  - lib/origen/parameters.rb
536
542
  - lib/origen/parameters/live.rb
@@ -544,8 +550,12 @@ files:
544
550
  - lib/origen/pins/pin_clock.rb
545
551
  - lib/origen/pins/pin_collection.rb
546
552
  - lib/origen/pins/pin_common.rb
547
- - lib/origen/pins/port.rb
548
553
  - lib/origen/pins/power_pin.rb
554
+ - lib/origen/ports.rb
555
+ - lib/origen/ports/bit_collection.rb
556
+ - lib/origen/ports/port.rb
557
+ - lib/origen/ports/port_collection.rb
558
+ - lib/origen/ports/section.rb
549
559
  - lib/origen/registers.rb
550
560
  - lib/origen/registers/bit.rb
551
561
  - lib/origen/registers/bit_collection.rb
@@ -575,6 +585,7 @@ files:
575
585
  - lib/origen/specs/version_history.rb
576
586
  - lib/origen/sub_blocks.rb
577
587
  - lib/origen/top_level.rb
588
+ - lib/origen/undefined.rb
578
589
  - lib/origen/users.rb
579
590
  - lib/origen/users/ldap.rb
580
591
  - lib/origen/users/user.rb
@@ -1,268 +0,0 @@
1
- module Origen
2
- module Pins
3
- class Port
4
- attr_accessor :name
5
- attr_reader :id
6
- attr_reader :owner
7
- attr_reader :size
8
- attr_accessor :order
9
-
10
- include Pins
11
-
12
- def initialize(id, owner, options = {})
13
- options = {
14
- name: id.to_s,
15
- endian: :big,
16
- add_pins: true
17
- }.merge(options)
18
- @endian = options.delete(:endian)
19
- @size = options.delete(:size)
20
- @name = options.delete(:name)
21
- @order = options.delete(:order)
22
- @id = id
23
- @owner = owner
24
- add_pins(options) if options[:add_pins]
25
- end
26
-
27
- def name
28
- (Origen.app.pin_names[id] || @name).to_s
29
- end
30
-
31
- def inspect
32
- "<#{self.class}:#{object_id}>"
33
- end
34
-
35
- def add_pins(options)
36
- size.times do |i|
37
- ix = @endian == :big ? @size - i - 1 : i
38
- pin = add_pin(ix, options)
39
- pin.port = self
40
- end
41
- end
42
-
43
- def cycle # :nodoc:
44
- Origen.tester.cycle
45
- end
46
-
47
- def drive_mem
48
- pins.each { |_ix, pin| pin.drive_mem }
49
- end
50
-
51
- def drive_mem!
52
- drive_mem
53
- cycle
54
- end
55
-
56
- def expect_mem
57
- pins.each { |_ix, pin| pin.expect_mem }
58
- end
59
-
60
- def expect_mem!
61
- expect_mem
62
- cycle
63
- end
64
-
65
- # Set the pin to drive a 1 on future cycles
66
- def drive_hi
67
- pins.each { |_ix, pin| pin.drive_hi }
68
- end
69
-
70
- def drive_hi!
71
- drive_hi
72
- cycle
73
- end
74
-
75
- # Set the pin to drive a high voltage on future cycles (if the tester supports it).
76
- # For example on a J750 high-voltage channel the pin state would be set to "2"
77
- def drive_very_hi
78
- pins.each { |_ix, pin| pin.drive_very_hi }
79
- end
80
-
81
- def drive_very_hi!
82
- drive_very_hi
83
- cycle
84
- end
85
-
86
- # Set the pin to drive a 0 on future cycles
87
- def drive_lo
88
- pins.each { |_ix, pin| pin.drive_lo }
89
- end
90
-
91
- def drive_lo!
92
- drive_lo
93
- cycle
94
- end
95
-
96
- # Set the pin to expect a 1 on future cycles
97
- def assert_hi(_options = {})
98
- pins.each { |_ix, pin| pin.assert_hi }
99
- end
100
- alias_method :compare_hi, :assert_hi
101
- alias_method :expect_hi, :assert_hi
102
-
103
- def assert_hi!
104
- assert_hi
105
- cycle
106
- end
107
- alias_method :compare_hi!, :assert_hi!
108
- alias_method :expect_hi!, :assert_hi!
109
-
110
- # Set the pin to expect a 0 on future cycles
111
- def assert_lo(_options = {})
112
- pins.each { |_ix, pin| pin.assert_lo }
113
- end
114
- alias_method :compare_lo, :assert_lo
115
- alias_method :expect_lo, :assert_lo
116
-
117
- def assert_lo!
118
- assert_lo
119
- cycle
120
- end
121
- alias_method :compare_lo!, :assert_lo!
122
- alias_method :expect_lo!, :assert_lo!
123
-
124
- # Set the pin to X on future cycles
125
- def dont_care
126
- pins.each { |_ix, pin| pin.dont_care }
127
- end
128
-
129
- def dont_care!
130
- dont_care
131
- cycle
132
- end
133
-
134
- # Pass in 0 or 1 to have the pin drive_lo or drive_hi respectively.
135
- # This is useful when programatically setting the pin state.
136
- # ==== Example
137
- # [0,1,1,0].each do |level|
138
- # $pin(:d_in).drive(level)
139
- # end
140
- def drive(value)
141
- size.times do |i|
142
- pins[i].drive(value[i])
143
- end
144
- end
145
-
146
- def drive!(value)
147
- drive(value)
148
- cycle
149
- end
150
-
151
- # Pass in 0 or 1 to have the pin expect_lo or expect_hi respectively.
152
- # This is useful when programatically setting the pin state.
153
- # ==== Example
154
- # [0,1,1,0].each do |level|
155
- # $pin(:d_in).assert(level)
156
- # end
157
- def assert(value, _options = {})
158
- size.times do |i|
159
- pins[i].expect(value[i])
160
- end
161
- end
162
- alias_method :compare, :assert
163
- alias_method :expect, :assert
164
-
165
- def assert!(*args)
166
- assert(*args)
167
- cycle
168
- end
169
-
170
- def [](ix)
171
- pins[ix]
172
- end
173
-
174
- # Returns the data value currently assigned to the port
175
- def data
176
- d = 0
177
- size.times do |i|
178
- d |= pins[i].data << i
179
- end
180
- d
181
- end
182
- alias_method :value, :data
183
-
184
- # Returns the inverse of the data value currently assigned to the port
185
- def data_b
186
- # (& operation takes care of Bignum formatting issues)
187
- ~data & ((1 << size) - 1)
188
- end
189
- alias_method :value_b, :data_b
190
-
191
- # Set the data assigned to the port
192
- def data=(val)
193
- size.times do |i|
194
- pins[i].data = val[i]
195
- end
196
- end
197
-
198
- def toggle
199
- self.data = data_b
200
- end
201
-
202
- def toggle!
203
- toggle
204
- cycle
205
- end
206
-
207
- def comparing?
208
- pins.any? { |_ix, pin| pin.comparing? }
209
- end
210
-
211
- def comparing_mem?
212
- pins.any? { |_ix, pin| pin.comparing_mem? }
213
- end
214
-
215
- def driving?
216
- pins.any? { |_ix, pin| pin.driving? }
217
- end
218
-
219
- def driving_mem?
220
- pins.any? { |_ix, pin| pin.driving_mem? }
221
- end
222
-
223
- def high_voltage?
224
- pins.any? { |_ix, pin| pin.high_voltage? }
225
- end
226
-
227
- def repeat_previous=(bool)
228
- pins.each { |_ix, pin| pin.repeat_previous = bool }
229
- end
230
-
231
- # Mark the (data) from the port to be captured
232
- def capture
233
- pins.each { |_ix, pin| pin.capture }
234
- end
235
- alias_method :store, :capture
236
-
237
- # Mark the (data) from the port to be captured and trigger a cycle
238
- def capture!
239
- capture
240
- cycle
241
- end
242
- alias_method :store!, :capture!
243
-
244
- # Returns true if the (data) from the port is marked to be captured
245
- def to_be_captured?
246
- pins.any? { |_ix, pin| pin.to_be_captured? }
247
- end
248
- alias_method :to_be_stored?, :to_be_captured?
249
- alias_method :is_to_be_stored?, :to_be_captured?
250
- alias_method :is_to_be_captured?, :to_be_captured?
251
-
252
- # Restores the state of the port at the end of the given block
253
- # to the state it was in at the start of the block
254
- #
255
- # port(:a).driving? # => true
256
- # port(:a).restore_state do
257
- # port(:a).dont_care
258
- # port(:a).driving? # => false
259
- # end
260
- # port(:a).driving? # => true
261
- def restore_state
262
- pins.each { |_ix, pin| pin.save }
263
- yield
264
- pins.each { |_ix, pin| pin.restore }
265
- end
266
- end
267
- end
268
- end