Class: Origen::Location::Base
Overview
A Location is an abstract object used to represent any NVM location of interest, such as a pass code, security field, etc.
Instance Attribute Summary collapse
-
#address ⇒ Object
(also: #byte_address, #byte_aligned_byte_address)
Returns the value of attribute address.
-
#endian ⇒ Object
(also: #endianess)
Returns the value of attribute endian.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#size_in_bytes ⇒ Object
Returns the value of attribute size_in_bytes.
Instance Method Summary collapse
- #aligned_address(bytes) ⇒ Object
- #big_endian? ⇒ Boolean
- #data(options = {}) ⇒ Object (also: #value, #val)
- #erase! ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #little_endian? ⇒ Boolean
- #program! ⇒ Object
- #read!(*args) ⇒ Object
- #store! ⇒ Object
- #write(data, options = {}) ⇒ Object (also: #set)
- #write! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/origen/location/base.rb', line 12 def initialize( = {}) = { size_in_bytes: 1, word_size_in_bytes: 2, endian: :big, data: 0, nil_state: 0 }.merge() @address = .delete(:address) || .delete(:byte_address) @endian = .delete(:endian) @size_in_bytes = .delete(:size_in_bytes) @nil_state = .delete(:nil_state) @owner = .delete(:owner) write(.delete(:data), size_in_bytes: @size_in_bytes) create_address_methods() end |
Instance Attribute Details
#address ⇒ Object Also known as: byte_address, byte_aligned_byte_address
Returns the value of attribute address.
6 7 8 |
# File 'lib/origen/location/base.rb', line 6 def address @address end |
#endian ⇒ Object Also known as: endianess
Returns the value of attribute endian.
6 7 8 |
# File 'lib/origen/location/base.rb', line 6 def endian @endian end |
#owner ⇒ Object
Returns the value of attribute owner.
6 7 8 |
# File 'lib/origen/location/base.rb', line 6 def owner @owner end |
#size_in_bytes ⇒ Object
Returns the value of attribute size_in_bytes.
6 7 8 |
# File 'lib/origen/location/base.rb', line 6 def size_in_bytes @size_in_bytes end |
Instance Method Details
#aligned_address(bytes) ⇒ Object
29 30 31 32 |
# File 'lib/origen/location/base.rb', line 29 def aligned_address(bytes) f = bytes - 1 (address >> f) << f end |
#big_endian? ⇒ Boolean
34 35 36 |
# File 'lib/origen/location/base.rb', line 34 def big_endian? endian == :big end |
#data(options = {}) ⇒ Object Also known as: value, val
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/origen/location/base.rb', line 49 def data( = {}) data = @current_data nil_val = [:nil_state] || @nil_state shift = 8 * (size_in_bytes - @current_data_size_in_bytes) mask = (1 << shift) - 1 if big_endian? data <<= shift if nil_val == 1 && shift != 0 data |= mask end else if nil_val == 1 data |= (mask << shift) end end data end |
#erase! ⇒ Object
85 86 87 |
# File 'lib/origen/location/base.rb', line 85 def erase! action!(:erase, *args) end |
#little_endian? ⇒ Boolean
38 39 40 |
# File 'lib/origen/location/base.rb', line 38 def little_endian? endian == :little end |
#program! ⇒ Object
81 82 83 |
# File 'lib/origen/location/base.rb', line 81 def program! action!(:program, *args) end |
#read!(*args) ⇒ Object
69 70 71 |
# File 'lib/origen/location/base.rb', line 69 def read!(*args) action!(:read, *args) end |
#store! ⇒ Object
77 78 79 |
# File 'lib/origen/location/base.rb', line 77 def store! action!(:store, *args) end |
#write(data, options = {}) ⇒ Object Also known as: set
42 43 44 45 46 |
# File 'lib/origen/location/base.rb', line 42 def write(data, = {}) @current_data = data @current_data_size_in_bytes = [:size_in_bytes] || size_in_bytes self.data() end |
#write! ⇒ Object
73 74 75 |
# File 'lib/origen/location/base.rb', line 73 def write! action!(:write, *args) end |