Sha256: 2b47684dd87ca7592eb1b96b0738ff873d2d2f3f064f0ef9681c858a3e8f7256

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module OrigenAhb
  class Driver
    attr_reader :owner

    def initialize(owner, options = {})
      @owner = owner
    end

    def read_register(reg_or_val, options = {})
      options = {
        haddr:     reg_or_val.address,
        hdata:     reg_or_val.data,
        hwrite:    0,
        hsize:     get_hsize(reg_or_val.size),
        hburst:    0,
        hmastlock: 0,
        hprot:     0xF
      }.merge(options)
      $dut.ahb_trans(options)
    end

    def write_register(reg_or_val, options = {})
      options = {
        haddr:     reg_or_val.address,
        hdata:     reg_or_val.data,
        hwrite:    1,
        hsize:     get_hsize(reg_or_val.size),
        hburst:    0,
        hmastlock: 0,
        hprot:     0xF
      }.merge(options)
      $dut.ahb_trans(options)
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
origen_ahb-0.2.0.pre3 lib/origen_ahb/driver.rb
origen_ahb-0.2.0.pre2 lib/origen_ahb/driver.rb