How to use uvm_mem

Hi all… I am trying to create a a simple memory using uvm_mem. My question is : can I use this memory in isolation,i.e. without putting it in reg model?

For eg : I defined a memory in the following way

class spi_flash_mem_c extends uvm_mem;
`uvm_object_utils(spi_flash_mem_c)

function new(string name = “spi_flash_mem_c”);
super.new(name, 4’d15, 16, “RW”, UVM_NO_COVERAGE);
endfunction : new

endclass : spi_flash_mem_c

Now, can I use it directly in another class to read and write out of it? Or do I have to add it to reg model and access it from there?

Hi Slashdot,
While you can instantiate a uvm_mem inside of any object, it’s designed to work inside of a register model. The configure() method requires a uvm_reg_block parent reference or a fatal message is produced. And while you may be able to call the write() and read() methods without putting it in a register model, you’ll most likely run into problems. A uvm_mem object expects to be placed inside of a register model’s address mapping, and many of the internal operations and methods (especially backdoor/frontdoor access) reference the internal m_parent variable, which can only be set by configure().

If you really want to by-pass using a register model to access memory, you could just build your own memory object and use the function that uvm_mem uses for backdoor access—uvm_hdl_deposit().

Good luck,
-Doug

In reply to Doug Smith:

Hey Doug,

That exactly is the error I get if I instantiate it directly. It throws an error while executing ‘check_access’ function in uvm_mem. It is unable to execute m_parent.get_default_path()

I ll put it in register model and retry. Thanks for the help and explanation. :).

In reply to Doug Smith:

How can I make the uvm_mem configurable? How can I pass variables to constructor?

In reply to abdulmutaalahmad:

What do you mean with configurable? The arguments of the constructor are fixed, you can not add some Arguments. For Details see the UVM Reference Manual