24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Compiling Verilog files UM-121<br />

The following code fragment <strong>and</strong> compiler invocation show how two different modules<br />

that have the same name can be instantiated within the same design:<br />

module top;<br />

`uselib dir=/h/vendorA libext=.v<br />

NAND2 u1(n1, n2, n3);<br />

`uselib dir=/h/vendorB libext=.v<br />

NAND2 u2(n4, n5, n6);<br />

endmodule<br />

vlog -compile_uselibs top<br />

This allows the NAND2 module to have different definitions in the vendorA <strong>and</strong> vendorB<br />

libraries.<br />

`uselib is persistent<br />

As mentioned above, the appearance of a `uselib directive in the source code explicitly<br />

defines how instantiations that follow it are resolved. This may result in unexpected<br />

consequences. For example, consider the following compile comm<strong>and</strong>:<br />

vlog -compile_uselibs dut.v srtr.v<br />

Assume that dut.v contains a `uselib directive. Since srtr.v is compiled after dut.v, the<br />

`uselib directive is still in effect. When srtr is loaded it is using the `uselib directive from<br />

dut.v to decide where to locate modules. If this is not what you intend, then you need to put<br />

an empty `uselib at the end of dut.v to "close" the previous `uselib statement.<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!