Class: Origen::Registers::Bit
Overview
Models bits within Reg objects
Constant Summary collapse
- ACCESS_CODES =
The :access property of registers or bits can be set to any of the following key values. Implemented refers to whether the behaviour is accurately modelled by the Origen register model or not.
{ ro: { implemented: false, description: 'Read-Only' }, rw: { implemented: true, description: 'Read-Write' }, rc: { implemented: false, description: 'Read-only, Clear-on-read' }, rs: { implemented: false, description: "Set-on-read (all bits become '1' on read)" }, wrc: { implemented: false, description: 'Writable, clear-on-read' }, wrs: { implemented: false, description: 'Writable, Sets-on-read' }, wc: { implemented: false, description: 'Clear-on-write' }, ws: { implemented: false, description: 'Set-on-write' }, wsrc: { implemented: false, description: 'Set-on-write, clear-on-read' }, wcrs: { implemented: false, description: 'Clear-on-write, set-on-read' }, w1c: { implemented: false, description: "Write '1' to clear bits" }, w1s: { implemented: false, description: "Write '1' to set bits" }, w1t: { implemented: false, description: "Write '1' to toggle bits" }, w0c: { implemented: false, description: "Write '0' to clear bits" }, w0s: { implemented: false, description: "Write '0' to set bits" }, w0t: { implemented: false, description: "Write '0' to toggle bits" }, w1src: { implemented: false, description: "Write '1' to set and clear-on-read" }, w1crs: { implemented: false, description: "Write '1' to clear and set-on-read" }, w0src: { implemented: false, description: "Write '0' to set and clear-on-read" }, w0crs: { implemented: false, description: "Write '0' to clear and set-on-read" }, wo: { implemented: false, description: 'Write-only' }, woc: { implemented: false, description: "When written sets the field to '0'. Read undeterministic" }, worz: { implemented: false, description: 'Write-only, Reads zero' }, wos: { implemented: false, description: "When written sets all bits to '1'. Read undeterministic" }, w1: { implemented: false, description: 'Write-once. Next time onwards, write is ignored. Read returns the value' }, wo1: { implemented: false, description: 'Write-once. Next time onwards, write is ignored. Read is undeterministic' }, dc: { implemented: false, description: 'RW but no check' }, rowz: { implemented: false, description: 'Read-only, value is cleared on read' } }
Instance Attribute Summary collapse
-
#access ⇒ Object
Returns the access method for the given bit (a symbol), see the ACCESS_CODES constant for the possible values this can have and their meaning.
-
#clr_only ⇒ Object
writeonly
Allow modify of clr_only flag, bit can only be cleared (made 0).
-
#data ⇒ Object
readonly
Current the data value currently held by the bit, 0 or 1.
-
#feature ⇒ Object
readonly
Any feature associated with the bit/bits.
-
#meta ⇒ Object
(also: #meta_data, #metadata)
Returns any application-specific meta-data attatched to the given bit.
-
#nvm_dep ⇒ Object
readonly
Returns true if bit depends on initial state of NVM in some way.
-
#overlay(value) ⇒ Object
readonly
Set the overlay attribute to the supplied value.
-
#owner ⇒ Object
readonly
Returns the Reg object that owns the bit.
-
#position ⇒ Object
readonly
Returns the integer position of the bit within the register.
-
#read_data_matches_write ⇒ Object
readonly
If the bit does not read back with the same data as is written to it then this will return true.
-
#readable ⇒ Object
writeonly
Allow modify of readable flag, bit is readable by read method.
-
#reset_val ⇒ Object
(also: #reset_data, #reset_value)
Returns the reset value of the bit.
-
#set_only ⇒ Object
writeonly
Allow modify of set_only flag, bit can only be set (made 1).
-
#start ⇒ Object
readonly
Returns true if bit is critical to starting an important operation (like a state machine) so that it can be made not writable during basic register checks.
-
#sticky_overlay ⇒ Object
Returns true if this bit has the sticky_overlay flag set, see Reg#sticky_overlay for a full description.
-
#sticky_store ⇒ Object
Returns true if this bit has the sticky_store flag set, see Reg#sticky_store for a full description.
-
#w1c ⇒ Object
Sets or returns the status of “write-one-to-clear”.
-
#writable ⇒ Object
writeonly
Allow modify of writable flag, bit is writeable by write method.
Class Method Summary collapse
-
.null(owner, position) ⇒ Object
Returns a ‘null’ bit object which has value 0 and no other attributes set.
Instance Method Summary collapse
- #abs_path ⇒ Object
-
#clear_flags ⇒ Object
Clears the read, store, overlay and update_required flags of this bit.
-
#clear_read_flag ⇒ Object
Clears the read flag of this bit.
-
#clear_start ⇒ Object
Clears any start bits that are set.
-
#clear_w1c ⇒ Object
Clears any w1c bits that are set.
-
#data_in_position ⇒ Object
Returns the data shifted by the bit position.
-
#default_bit_metadata ⇒ Object
Returns any application specific metadata that has been inherited by the given bit.
-
#delete ⇒ Object
Make this bit disappear, make it unwritable with a data value of 0.
- #enabled? ⇒ Boolean
-
#enabled_by_feature?(name = nil) ⇒ Boolean
(also: #has_feature_constraint?)
Returns true if the bit is constrained by the given/any feature.
- #extract_meta_data(method, *args) ⇒ Object
-
#has_known_value? ⇒ Boolean
Returns true if the value of the bit is known.
-
#has_overlay?(name = nil) ⇒ Boolean
Returns true if the overlay attribute is set, optionally supply an overlay name and this will only return true if the overlay attribute matches that name.
-
#initialize(owner, position, options = {}) ⇒ Bit
constructor
rubocop:disable MethodLength.
- #inspect ⇒ Object
- #is_readable? ⇒ Boolean (also: #readable?)
-
#is_to_be_read? ⇒ Boolean
Returns true if the bit’s read flag is set.
-
#is_to_be_stored? ⇒ Boolean
Returns true if the bit’s store flag is set.
-
#is_writable? ⇒ Boolean
(also: #writable?)
Returns true if the bit is writable.
-
#mask ⇒ Object
Returns a bit mask for this bit, that is a 1 shifted into the position corresponding to this bit’s position.
- #meta_data_method?(method) ⇒ Boolean private
-
#method_missing(method, *args, &block) ⇒ Object
:nodoc:.
-
#overlay_str ⇒ Object
Returns the overlay attribute.
- #path_var ⇒ Object
-
#read(value = nil, _options = {}) ⇒ Object
Will tag all bits for read and if a data value is supplied it will update the expected data for when the read is performed.
-
#reset ⇒ Object
Resets the data value back to the reset value and calls Bit#clear_flags.
-
#respond_to?(sym) ⇒ Boolean
:nodoc:.
-
#set? ⇒ Boolean
Returns true if the bit is set (holds a data value of 1).
- #set_access(value) ⇒ Object
-
#set_access_from_rw ⇒ Object
Set @access based on @readable and @writable.
-
#setting(value) ⇒ Object
Returns the value you would need to write to the register to put the given value in this bit.
-
#shift_out_left {|_self| ... } ⇒ Object
With only one bit it just returns itself.
-
#size ⇒ Object
Always returns 1 when asked for size, a BitCollection on the other hand will return something higher.
-
#store ⇒ Object
Sets the store flag attribute.
-
#undefined? ⇒ Boolean
Returns true if the bit object is a placeholder for bit positions that have not been defined within the parent register.
-
#update_required? ⇒ Boolean
Returns true if the bit’s update_required flag is set, typically this will be the case when a write has changed the data value of the bit but a BitCollection#write! method has not been called yet to apply it to silicon.
-
#write(value, options = {}) ⇒ Object
Set the data value of the bit to the given value (1 or 0) If the bit is read-only, the value of the bit can be forced with ‘force: true’.
Constructor Details
#initialize(owner, position, options = {}) ⇒ Bit
rubocop:disable MethodLength
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/origen/registers/bit.rb', line 88 def initialize(owner, position, = {}) # rubocop:disable MethodLength = { start: false, # whether bit starts a state machine so be careful read_data_matches_write: true, read: false, overlay: false, store: false, sticky_overlay: true, sticky_store: false, nvm_dep: false, # whether is an NVM dependent bit }.merge() @owner = owner @position = position @undefined = .delete(:undefined) @reset_val = (.delete(:res) || .delete(:reset) || .delete(:data) || 0) if @reset_val.is_a?(Symbol) @data = 0 else @reset_val &= 1 unless @reset_val.is_a?(Symbol) @data = @reset_val end access_code = .delete(:access) # If access has been defined then none of these other attributes can be if access_code conflicts = [:readable, :writable, :clr_only, :set_only, :w1c] if conflicts.any? { |k| .key?(k) } puts 'The following attributes cannot be set in combination with :access' puts " #{conflicts.join(', ')}" puts '' puts 'Use :access to defined the required behavior, the above attributes will be deprecated in future.' puts '' fail 'Conflicting access!' end set_access(access_code) else = { writable: true, # whether bit is writable readable: true, # whether bit is readable clr_only: false, # whether bit is clear only set_only: false, # whether bit is set only w1c: false, # whether bit is w1c (when written to 1 immediately becomes 0) }.merge() @readable = .delete(:readable) @writable = .delete(:writable) @clr_only = .delete(:clr_only) @set_only = .delete(:set_only) @w1c = .delete(:w1c) set_access_from_rw end # Would like to get this integrated with access as well @read_data_matches_write = .delete(:read_data_matches_write) @feature = .delete(:feature) if !!feature && @writable @writable = enabled? end @path = .delete(:path) @abs_path = .delete(:abs_path) @start = .delete(:start) @read = .delete(:read) @overlay = .delete(:overlay) @store = .delete(:store) @update_required = false @sticky_store = .delete(:sticky_store) @sticky_overlay = .delete(:sticky_overlay) @nvm_dep = (.delete(:nvm_dep) ? 1 : 0) # Delete some other noise that can be left over... .delete(:bits) .delete(:pos) .delete(:position) .delete(:data) # Whatever is left must be custom application meta-data @meta = ().merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
:nodoc:
469 470 471 472 473 474 475 |
# File 'lib/origen/registers/bit.rb', line 469 def method_missing(method, *args, &block) # :nodoc: if (method) (method, *args) else super end end |
Instance Attribute Details
#access ⇒ Object
Returns the access method for the given bit (a symbol), see the ACCESS_CODES constant for the possible values this can have and their meaning
86 87 88 |
# File 'lib/origen/registers/bit.rb', line 86 def access @access end |
#clr_only=(value) ⇒ Object (writeonly)
Allow modify of clr_only flag, bit can only be cleared (made 0)
72 73 74 |
# File 'lib/origen/registers/bit.rb', line 72 def clr_only=(value) @clr_only = value end |
#data ⇒ Object (readonly)
Current the data value currently held by the bit, 0 or 1
44 45 46 |
# File 'lib/origen/registers/bit.rb', line 44 def data @data end |
#feature ⇒ Object (readonly)
Any feature associated with the bit/bits
60 61 62 |
# File 'lib/origen/registers/bit.rb', line 60 def feature @feature end |
#meta ⇒ Object Also known as: meta_data, metadata
Returns any application-specific meta-data attatched to the given bit
81 82 83 |
# File 'lib/origen/registers/bit.rb', line 81 def @meta end |
#nvm_dep ⇒ Object (readonly)
Returns true if bit depends on initial state of NVM in some way
76 77 78 |
# File 'lib/origen/registers/bit.rb', line 76 def nvm_dep @nvm_dep end |
#overlay(value) ⇒ Object (readonly)
Set the overlay attribute to the supplied value
46 47 48 |
# File 'lib/origen/registers/bit.rb', line 46 def @overlay end |
#owner ⇒ Object (readonly)
Returns the Reg object that owns the bit
40 41 42 |
# File 'lib/origen/registers/bit.rb', line 40 def owner @owner end |
#position ⇒ Object (readonly)
Returns the integer position of the bit within the register
42 43 44 |
# File 'lib/origen/registers/bit.rb', line 42 def position @position end |
#read_data_matches_write ⇒ Object (readonly)
If the bit does not read back with the same data as is written to it then this will return true. This property can be assigned durgin the register instantiation, e.g.
add_reg :control, 0x00, :mode => { :pos => 8, :bits => 8 },
:status => { :pos => 4, :bits => 2, :read_data_matches_write => false }
52 53 54 |
# File 'lib/origen/registers/bit.rb', line 52 def read_data_matches_write @read_data_matches_write end |
#readable=(value) ⇒ Object (writeonly)
Allow modify of readable flag, bit is readable by read method
68 69 70 |
# File 'lib/origen/registers/bit.rb', line 68 def readable=(value) @readable = value end |
#reset_val ⇒ Object Also known as: reset_data, reset_value
Returns the reset value of the bit
62 63 64 |
# File 'lib/origen/registers/bit.rb', line 62 def reset_val @reset_val end |
#set_only=(value) ⇒ Object (writeonly)
Allow modify of set_only flag, bit can only be set (made 1)
74 75 76 |
# File 'lib/origen/registers/bit.rb', line 74 def set_only=(value) @set_only = value end |
#start ⇒ Object (readonly)
Returns true if bit is critical to starting an important operation (like a state machine) so that it can be made not writable during basic register checks
79 80 81 |
# File 'lib/origen/registers/bit.rb', line 79 def start @start end |
#sticky_overlay ⇒ Object
Returns true if this bit has the sticky_overlay flag set, see Reg#sticky_overlay for a full description. This is true by default.
55 56 57 |
# File 'lib/origen/registers/bit.rb', line 55 def @sticky_overlay end |
#sticky_store ⇒ Object
Returns true if this bit has the sticky_store flag set, see Reg#sticky_store for a full description. This is false by default.
58 59 60 |
# File 'lib/origen/registers/bit.rb', line 58 def sticky_store @sticky_store end |
#w1c ⇒ Object
Sets or returns the status of “write-one-to-clear”
70 71 72 |
# File 'lib/origen/registers/bit.rb', line 70 def w1c @w1c end |
#writable=(value) ⇒ Object (writeonly)
Allow modify of writable flag, bit is writeable by write method
66 67 68 |
# File 'lib/origen/registers/bit.rb', line 66 def writable=(value) @writable = value end |
Class Method Details
Instance Method Details
#abs_path ⇒ Object
222 223 224 |
# File 'lib/origen/registers/bit.rb', line 222 def abs_path @abs_path end |
#clear_flags ⇒ Object
Clears the read, store, overlay and update_required flags of this bit. The store and overlay flags will not be cleared if the the bit’s sticky_store or sticky_overlay attributes are set respectively.
375 376 377 378 379 380 381 |
# File 'lib/origen/registers/bit.rb', line 375 def clear_flags @read = false @store = false unless @sticky_store @overlay = false unless @sticky_overlay @update_required = false self end |
#clear_read_flag ⇒ Object
Clears the read flag of this bit.
384 385 386 387 |
# File 'lib/origen/registers/bit.rb', line 384 def clear_read_flag @read = false self end |
#clear_start ⇒ Object
Clears any start bits that are set
435 436 437 438 439 440 |
# File 'lib/origen/registers/bit.rb', line 435 def clear_start if @start && set? @data = 0 end self end |
#clear_w1c ⇒ Object
Clears any w1c bits that are set
427 428 429 430 431 432 |
# File 'lib/origen/registers/bit.rb', line 427 def clear_w1c if @w1c && set? @data = 0 end self end |
#data_in_position ⇒ Object
Returns the data shifted by the bit position
422 423 424 |
# File 'lib/origen/registers/bit.rb', line 422 def data_in_position data << position end |
#default_bit_metadata ⇒ Object
Returns any application specific metadata that has been inherited by the given bit. This does not account for any overridding that may have been applied to this bit specifically however, use the meta method to get that.
236 237 238 239 |
# File 'lib/origen/registers/bit.rb', line 236 def Origen::Registers..merge( Origen::Registers.[owner.owner.class] || {}) end |
#delete ⇒ Object
Make this bit disappear, make it unwritable with a data value of 0
251 252 253 254 255 256 257 258 |
# File 'lib/origen/registers/bit.rb', line 251 def delete @sticky_overlay = false @sticky_store = false clear_flags @data = 0 @writable = false self end |
#enabled? ⇒ Boolean
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/origen/registers/bit.rb', line 496 def enabled? if feature value = false current_owner = self if feature.class == Array feature.each do |f| current_owner = self loop do if current_owner.respond_to?(:owner) current_owner = current_owner.owner if current_owner.respond_to?(:has_feature?) if current_owner.has_feature?(f) value = true break end end else # if current owner does not have a owner value = false break end end # loop end unless value if Origen.top_level && \ Origen.top_level.respond_to?(:has_feature?) && \ Origen.top_level.has_feature?(f) value = true unless value break end end end unless value break # break if feature not found and return false end end # iterated through all features in array return value else # if feature.class != Array loop do if current_owner.respond_to?(:owner) current_owner = current_owner.owner if current_owner.respond_to?(:has_feature?) if current_owner.has_feature?(feature) value = true break end end else # if current owner does not have a owner value = false break end end # loop end unless value if Origen.top_level && \ Origen.top_level.respond_to?(:has_feature?) && \ Origen.top_level.has_feature?(feature) value = true end end return value end else return true end end |
#enabled_by_feature?(name = nil) ⇒ Boolean Also known as: has_feature_constraint?
Returns true if the bit is constrained by the given/any feature
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/origen/registers/bit.rb', line 478 def enabled_by_feature?(name = nil) if !name !!feature else if feature.class == Array feature.each do |f| if f == name return true end end return false else feature == name end end end |
#extract_meta_data(method, *args) ⇒ Object
460 461 462 463 464 465 466 467 |
# File 'lib/origen/registers/bit.rb', line 460 def (method, *args) method = method.to_s.sub('?', '') if method =~ /=/ instance_variable_set("@#{method.sub('=', '')}", args.first) else instance_variable_get("@#{method}") || [method.to_sym] end end |
#has_known_value? ⇒ Boolean
Returns true if the value of the bit is known. The value will be unknown in cases where the reset value is undefined or determined by a memory location and where the bit has not been written or read to a specific value yet.
286 287 288 |
# File 'lib/origen/registers/bit.rb', line 286 def has_known_value? !@reset_val.is_a?(Symbol) || @updated_post_reset end |
#has_overlay?(name = nil) ⇒ Boolean
Returns true if the overlay attribute is set, optionally supply an overlay name and this will only return true if the overlay attribute matches that name
353 354 355 356 357 358 359 |
# File 'lib/origen/registers/bit.rb', line 353 def (name = nil) if name name.to_s == @overlay.to_s else !!@overlay end end |
#inspect ⇒ Object
241 242 243 |
# File 'lib/origen/registers/bit.rb', line 241 def inspect "<#{self.class}:#{object_id}>" end |
#is_readable? ⇒ Boolean Also known as: readable?
367 368 369 |
# File 'lib/origen/registers/bit.rb', line 367 def is_readable? @readable end |
#is_to_be_read? ⇒ Boolean
Returns true if the bit’s read flag is set
342 343 344 |
# File 'lib/origen/registers/bit.rb', line 342 def is_to_be_read? @read end |
#is_to_be_stored? ⇒ Boolean
Returns true if the bit’s store flag is set
347 348 349 |
# File 'lib/origen/registers/bit.rb', line 347 def is_to_be_stored? @store end |
#is_writable? ⇒ Boolean Also known as: writable?
Returns true if the bit is writable
362 363 364 |
# File 'lib/origen/registers/bit.rb', line 362 def is_writable? @writable end |
#mask ⇒ Object
Returns a bit mask for this bit, that is a 1 shifted into the position corresponding to this bit’s position. e.g. A bit with position 4 would return %1_0000
392 393 394 395 |
# File 'lib/origen/registers/bit.rb', line 392 def mask mask_val = 1 mask_val << @position end |
#meta_data_method?(method) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/origen/registers/bit.rb', line 447 def (method) attr_name = method.to_s.gsub(/\??=?/, '').to_sym if .key?(attr_name) if method.to_s =~ /\?/ [true, false].include?([attr_name]) else true end else false end end |
#overlay_str ⇒ Object
Returns the overlay attribute
337 338 339 |
# File 'lib/origen/registers/bit.rb', line 337 def @overlay end |
#path_var ⇒ Object
218 219 220 |
# File 'lib/origen/registers/bit.rb', line 218 def path_var @path end |
#read(value = nil, _options = {}) ⇒ Object
Will tag all bits for read and if a data value is supplied it will update the expected data for when the read is performed.
313 314 315 316 317 318 319 320 321 322 |
# File 'lib/origen/registers/bit.rb', line 313 def read(value = nil, = {}) # First properly assign the args if value is absent... if value.is_a?(Hash) = value value = nil end write(value) if value @read = true if @readable && @read_data_matches_write self end |
#reset ⇒ Object
Resets the data value back to the reset value and calls Bit#clear_flags
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/origen/registers/bit.rb', line 266 def reset if @reset_val.is_a?(Symbol) @data = 0 else @data = @reset_val end @updated_post_reset = false clear_flags self end |
#respond_to?(sym) ⇒ Boolean
:nodoc:
442 443 444 |
# File 'lib/origen/registers/bit.rb', line 442 def respond_to?(sym) # :nodoc: (sym) || super(sym) end |
#set? ⇒ Boolean
Returns true if the bit is set (holds a data value of 1)
261 262 263 |
# File 'lib/origen/registers/bit.rb', line 261 def set? @data == 1 ? true : false end |
#set_access(value) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/origen/registers/bit.rb', line 164 def set_access(value) unless ACCESS_CODES.keys.include?(value) puts 'Invalid access code, must be one of these:' ACCESS_CODES.each do |code, | puts " :#{code}".ljust(10) + " - #{[:description]}" end puts '' fail 'Invalid access code!' end @access = value # Set readable & writable based on access if @access == :ro @readable = true @writable = false elsif @access == :wo || @access == :worz @writable = true @readable = false elsif @access == :w1c @w1c = true @writable = true @readable = true # Is this always valid? elsif @access == :wc @clr_only = true @writable = true @readable = true # Is this always valid? elsif @access == :ws @set_only = true @writable = true @readable = true # Is this always valid? # Catch all for now until the behavior of this class is based around @access else @writable = true @readable = true end end |
#set_access_from_rw ⇒ Object
Set @access based on @readable and @writable
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/origen/registers/bit.rb', line 202 def set_access_from_rw if @w1c @access = :w1c elsif @clr_only @access = :wc elsif @set_only @access = :ws elsif @readable && @writable @access = :rw elsif @readable @access = :ro elsif @writable && @access != :worz @access = :wo end end |
#setting(value) ⇒ Object
Returns the value you would need to write to the register to put the given value in this bit
404 405 406 407 |
# File 'lib/origen/registers/bit.rb', line 404 def setting(value) value = value & 1 # As this bit can only hold one bit of data force it value << @position end |
#shift_out_left {|_self| ... } ⇒ Object
With only one bit it just returns itself
417 418 419 |
# File 'lib/origen/registers/bit.rb', line 417 def shift_out_left yield self end |
#size ⇒ Object
Always returns 1 when asked for size, a BitCollection on the other hand will return something higher
246 247 248 |
# File 'lib/origen/registers/bit.rb', line 246 def size 1 end |
#store ⇒ Object
Sets the store flag attribute
325 326 327 328 |
# File 'lib/origen/registers/bit.rb', line 325 def store @store = true self end |
#undefined? ⇒ Boolean
Returns true if the bit object is a placeholder for bit positions that have not been defined within the parent register
279 280 281 |
# File 'lib/origen/registers/bit.rb', line 279 def undefined? @undefined end |
#update_required? ⇒ Boolean
Returns true if the bit’s update_required flag is set, typically this will be the case when a write has changed the data value of the bit but a BitCollection#write! method has not been called yet to apply it to silicon
412 413 414 |
# File 'lib/origen/registers/bit.rb', line 412 def update_required? @update_required end |
#write(value, options = {}) ⇒ Object
Set the data value of the bit to the given value (1 or 0) If the bit is read-only, the value of the bit can be forced with ‘force: true’
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/origen/registers/bit.rb', line 292 def write(value, = {}) # If an array is written it means a data value and an overlay have been supplied # in one go... if value.is_a?(Array) (value[1]) value = value[0] end if (@data != value & 1 && @writable) || (@data != value & 1 && [:force] == true) if ((set?) && (!@set_only)) || ((!set?) && (!@clr_only)) @data = value & 1 @update_required = true @updated_post_reset = true end end self end |