Sha256: b94124b528cb72e7356d4803a2bb6188acd57c0f22d6af2ec195009a6e56b4ab

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 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}"
      PatSeq.reserve :jtag do
        # This is redundant, but added as a test that if an embedded reservation is made to the same
        # resource then the end of the inner block does not release the reservation before completion
        # of the outer block
        PatSeq.reserve :jtag do
          # Verify that no command is currently running
          status.read!(0)
        end

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

        status.busy.read!(1)
      end

      # 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

8 entries across 8 versions & 1 rubygems

Version Path
origen_sim-0.20.7 lib/origen_sim_dev/ip.rb
origen_sim-0.20.6 lib/origen_sim_dev/ip.rb
origen_sim-0.20.5 lib/origen_sim_dev/ip.rb
origen_sim-0.20.4 lib/origen_sim_dev/ip.rb
origen_sim-0.20.3 lib/origen_sim_dev/ip.rb
origen_sim-0.20.2 lib/origen_sim_dev/ip.rb
origen_sim-0.20.1 lib/origen_sim_dev/ip.rb
origen_sim-0.20.0 lib/origen_sim_dev/ip.rb