Sha256: 0a1f1d86f850a241129990c04f619f5a6682e9ac718f756a5e7002276661475c

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

module OrigenSimDev
  class IP
    include Origen::Model

    def initialize
      # Virtual reg to implement the JTAG scan chain
      add_reg :dr, 0x0, size: 49 do |reg|
        reg.bit 48, :write
        reg.bits 47..32, :address
        reg.bits 31..0, :data
      end

      # User regs
      add_reg :cmd, 0x0

      reg :status, 0x4 do |reg|
        reg.bit 2, :error, access: :w1c
        reg.bit 1, :fail, access: :w1c
        reg.bit 0, :busy
      end

      add_reg :data, 0x8
    end

    def communication_test
      ss "Communication test with #{name}"
      data.write!(0x1234)
      data.read!
      data.read!
      data.write!(0x5555_AAAA)
      data.read!
    end

    def execute_cmd(code)
      ss "Execute command #{code}"
      # Verify that no command is currently running
      status.read!(0)

      cmd.write!(code)
      10.cycles
      # Verify that the command has started

      status.busy.read!(1)

      # Wait for the command to complete, a 'command' lasts for
      # 1000 cycles times the command code
      (code * 1000).cycles

      # Verify that the command completed and passed
      status.read!(0)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
origen_sim-0.16.1 lib/origen_sim_dev/ip.rb
origen_sim-0.16.0 lib/origen_sim_dev/ip.rb
origen_sim-0.15.0 lib/origen_sim_dev/ip.rb