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.

UM-220 7 - Mixed-language simulation<br />

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

};<br />

#endif<br />

// VHDL module instance<br />

ringbuf* chip;<br />

SC_CTOR(test_ringbuf)<br />

: iclock("iclock"),<br />

...<br />

...<br />

{<br />

const char* generic_list[9];<br />

generic_list[0] = strdup("int_param=4");<br />

generic_list[1] = strdup("real_param=2.6");<br />

generic_list[2] = strdup("str_param=\"Hello\"");<br />

generic_list[3] = strdup("bool_param=false");<br />

generic_list[4] = strdup("char_param=Y");<br />

generic_list[5] = strdup("bit_param=0");<br />

generic_list[6] = strdup("bv_param=010");<br />

generic_list[7] = strdup("logic_param=Z");<br />

generic_list[8] = strdup("lv_param=01XZ");<br />

// Cleanup the memory allocated for the generic list<br />

for (int = 0; i < 9; i++;)<br />

free((char*)generic_list[i]);<br />

// Create VHDL module instance.<br />

chip = new ringbuf("chip", "ringbuf", 9, generic_list);<br />

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

-- test_ringbuf.cpp<br />

#include "test_ringbuf.h"<br />

SC_MODULE_EXPORT(test_ringbuf);<br />

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

-- ringbuf.vhd<br />

LIBRARY ieee;<br />

U<strong>SE</strong> ieee.std_logic_1164.all;<br />

U<strong>SE</strong> std.textio.all;<br />

ENTITY ringbuf IS<br />

generic (<br />

int_param : integer;<br />

real_param : real;<br />

str_param : string;<br />

bool_param : boolean;<br />

char_param : character;<br />

bit_param : bit;<br />

bv_param : bit_vector(0 to 2);<br />

logic_param : std_logic;<br />

lv_param : std_logic_vector(3 downto 0));<br />

PORT (<br />

clock : IN std_logic;<br />

..<br />

...

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

Saved successfully!

Ooh no, something went wrong!