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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

SystemC: instantiating VHDL UM-219<br />

Following the example shown above (UM-218), let’s see the generic information that would<br />

be passed to the SystemC foreign module declaration. The generic parameters passed to the<br />

constructor are shown in magenta color:<br />

class counter : public sc_foreign_module {<br />

public:<br />

sc_in clk;<br />

...<br />

counter(sc_midule_name nm, char* hdl_name<br />

int num_generics, const char* generic_list)<br />

: sc_foreign_module(nm, hdl_name, num_generics,<br />

generic_list),<br />

{}<br />

};<br />

The instantiation is:<br />

Example of generic use<br />

dut = new counter ("dut", "work.counter", 9, generic_list);<br />

Here is another example, a ring buffer, complete with all files necessary for the simulation.<br />

// ringbuf.h<br />

#ifndef INCLUDED_RINGBUF<br />

#define INCLUDED_RINGBUF<br />

class ringbuf : public sc_foreign_module {<br />

public:<br />

sc_in clk;<br />

...<br />

counter(sc_midule_name nm, char* hdl_name<br />

int num_generics, const char* generic_list)<br />

: sc_foreign_module(nm, hdl_name, num_generics,<br />

generic_list),<br />

{}<br />

};<br />

#endif<br />

---------------------------------------------------------------------------<br />

// test_ringbuf.h<br />

#ifndef INCLUDED_TEST_RINGBUF<br />

#define INCLUDED_TEST_RINGBUF<br />

#include "ringbuf.h"<br />

SC_MODULE(test_ringbuf)<br />

{<br />

sc_signal iclock;<br />

...<br />

...<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!