Class: OrigenAhb::Driver
- Inherits:
-
Object
- Object
- OrigenAhb::Driver
- Defined in:
- lib/origen_ahb/driver.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Instance Method Summary collapse
-
#get_hsize(size) ⇒ Object
Convert bit width to HSIZE.
-
#initialize(owner, options = {}) ⇒ Driver
constructor
Initialize owner.
-
#read_register(reg_or_val, options = {}) ⇒ Object
Read register.
-
#write_register(reg_or_val, options = {}) ⇒ Object
Read register.
Constructor Details
#initialize(owner, options = {}) ⇒ Driver
Initialize owner
6 7 8 |
# File 'lib/origen_ahb/driver.rb', line 6 def initialize(owner, = {}) @owner = owner end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner
3 4 5 |
# File 'lib/origen_ahb/driver.rb', line 3 def owner @owner end |
Instance Method Details
#get_hsize(size) ⇒ Object
Convert bit width to HSIZE
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/origen_ahb/driver.rb', line 63 def get_hsize(size) if size <= 8 hsize = 0 elsif size > 8 and size <= 16 hsize = 1 elsif size > 16 and size <= 32 hsize = 2 elsif size > 32 and size <= 64 hsize = 3 elsif size > 64 and size <= 128 hsize = 4 elsif size > 128 and size <= 256 hsize = 5 elsif size > 256 and size <= 512 hsize = 6 elsif size > 512 and size <= 1024 hsize = 7 end get_hsize = hsize end |
#read_register(reg_or_val, options = {}) ⇒ Object
Read register. Handles register model as input or data/address pair. Sets up AHB parameters values and passes along to pin-layer ahb transaction method.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/origen_ahb/driver.rb', line 13 def read_register(reg_or_val, = {}) = { haddr: [:address] || reg_or_val.address, hdata: reg_or_val, hwrite: 0, hsize: get_hsize(reg_or_val.size), hburst: 0, hmastlock: 0, hprot: 0xF }.merge() cc '==== AHB Read Transaction ====' if reg_or_val.respond_to?('data') data = reg_or_val.data name_string = 'Reg: ' + reg_or_val.name.to_s + ' ' else data = reg_or_val [:hsize] = 2 name_string = '' end cc name_string + 'Addr: 0x' + [:haddr].to_s(16) + ' Data: 0x' + data.to_s(16) + ' Size: ' + [:hsize].to_s $dut.ahb_trans() end |
#write_register(reg_or_val, options = {}) ⇒ Object
Read register. Handles register model as input or data/address pair. Sets up AHB parameters values and passes along to pin-layer ahb transaction method.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/origen_ahb/driver.rb', line 39 def write_register(reg_or_val, = {}) = { haddr: [:address] || reg_or_val.address, hdata: reg_or_val, hwrite: 1, hsize: get_hsize(reg_or_val.size), hburst: 0, hmastlock: 0, hprot: 0xF }.merge() cc '==== AHB Write Transaction ====' if reg_or_val.respond_to?('data') data = reg_or_val.data name_string = 'Reg: ' + reg_or_val.name.to_s + ' ' else data = reg_or_val [:hsize] = 2 name_string = '' end cc name_string + 'Addr: 0x' + [:haddr].to_s(16) + ' Data: 0x' + data.to_s(16) + ' Size: ' + [:hsize].to_s $dut.ahb_trans() end |