Suraj Kurapati wrote:
On Tue, Mar 16, 2010 at 9:46 PM, Robert Smolinski <rsmol...@illinois.edu> wrote:
I have a "reg [79:0] mem[31:0]", I'd like to access mem[0] and such, but I
can't find the specific ruby syntax to do so. Is it even possible to access
it?

The `mem` here is a "reg array" in VPI terminology (see page 393,
section "26.6.7 Regs and reg arrays", of IEEE 1364-2005) because it is
a contiguous block of 32 registers, each 80 bits wide.

You can convert the "reg array" VPI handle it into a Ruby array
(containing new VPI handles that point to the members of the VPI "reg
array") by using the VPI::Handle#to_a() method:

  regs = mem.to_a
  puts regs[0] # do something with first register

  regs.each do |reg|
    # do something with `reg`
    puts reg
  end

Hope this helps.

Thanks Suraj.

I try "puts DUT.mem.to_a.inspect" which prints "[]". DUT.mem.size == 32 and I'm certain that DUT is the module with mem. Any ideas?

Reply via email to