void and_gate_init( mtiRegionIdT region, char *param, mtiInterfaceListT *generics, mtiInterfaceListT *ports ) { inst_rec *ip; mtiSignalIdT outp; mtiProcessIdT proc; ip = (inst_rec *)mti_Malloc( sizeof(inst_rec) ); ip->in1 = mti_FindPort( ports, "in1" ); ip->in2 = mti_FindPort( ports, "in2" ); outp = mti_FindPort( ports, "out1" ); ip->out1 = mti_CreateDriver( outp ); proc = mti_CreateProcess( "p1", do_and, ip ); mti_Sensitize( proc, ip->in1, MTI_EVENT ); mti_Sensitize( proc, ip->in2, MTI_EVENT ); }
/* this function is called once at startup and configures testbench interface */ void testbench_init( mtiRegionIdT region, char *param, mtiInterfaceListT *generics, mtiInterfaceListT *ports ) { // printf( "INFO testbench global variable pointer %p, global variable size %.2fMByte\n", (void *) &gv, sizeof(gv)/(1024*1024.0) ); /* connect the vhdl inputs and outputs to the ip struct */ testbench_t *ip; ip = (testbench_t *) mti_Malloc( sizeof( testbench_t) ); ip->clk = mti_FindPort( ports, "clk" ); ip->rst = mti_CreateDriver( mti_FindPort( ports, "rst" ) ); ip->set = mti_CreateDriver( mti_FindPort( ports, "set" ) ); ip->inc = mti_CreateDriver( mti_FindPort( ports, "inc" ) ); ip->dec = mti_CreateDriver( mti_FindPort( ports, "dec" ) ); ip->load = mti_CreateDriver( mti_FindPort( ports, "load" ) ); ip->result = mti_FindPort( ports, "result" ); ip->cmp = mti_FindPort( ports, "cmp" ); ip->read_data = mti_FindPort( ports, "read_data" ); mtiProcessIdT testbench_process = mti_CreateProcess( "testbench_p", testbench, ip ); mti_Sensitize( testbench_process, ip->clk, MTI_EVENT); /* start also a housekeeping process that handles non testbench related issues */ mtiProcessIdT housekeeping_process = mti_CreateProcess( "housekeeping_p", housekeeping, ip ); mti_Sensitize( housekeeping_process, ip->clk, MTI_EVENT); /* start the thread which allows us to connect on the socket */ pthread_t socket_thread; pthread_mutex_init(&gv_mutex_lock, NULL); int return_code = pthread_create( &socket_thread, NULL, server, NULL ); if( return_code != 0 ) { printf( "ERROR: return code thread 0 with %d\n", return_code ); } fflush(stdout); }