Class: OrigenSimDev::IP

Inherits:
Object
  • Object
show all
Includes:
Origen::Model
Defined in:
lib/origen_sim_dev/ip.rb

Instance Method Summary collapse

Constructor Details

#initializeIP

Returns a new instance of IP.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/origen_sim_dev/ip.rb', line 5

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

Instance Method Details

#communication_testObject



25
26
27
28
29
30
31
32
# File 'lib/origen_sim_dev/ip.rb', line 25

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

#execute_cmd(code) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/origen_sim_dev/ip.rb', line 34

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