示例#1
0
文件: testbench.c 项目: andrepool/fli
/* 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);   
}
示例#2
0
文件: tester.c 项目: alexohn/ece327
/* This function is called by the simulator to initialize the
 * tester module. It makes a data structure of the tester's ports
 * (taken from the entity's port list) and creates a process which
 * will handle all the signal changes.
 */
void tester_init(
    mtiRegionIdT       region,
    char              *param,
    mtiInterfaceListT *generics,
    mtiInterfaceListT *ports
)
{
    inst_rec_ptr       ip;
    mtiInterfaceListT *p;
    int                is_array_type;
 
    ip = (inst_rec_ptr)mti_Malloc(sizeof(inst_rec));
    mti_AddRestartCB( mti_Free, ip );

    /* Traverse the list of ports and get port names and widths. */
    num_ports = 0;
    for ( p = ports; p; p = p->nxt ) {
        tester_ports[num_ports].name = p->name;
        is_array_type = (mti_GetTypeKind(p->type) == MTI_TYPE_ARRAY);
        tester_ports[num_ports].is_array_type = is_array_type;
        if ( is_array_type ) {
            tester_ports[num_ports].width = mti_TickLength(p->type);
        } else {
            tester_ports[num_ports].width = 1;
        }
        ip->ports[   num_ports] = p->u.port;
        ip->drivers[ num_ports] = mti_CreateDriver(p->u.port);
        tester_ports[num_ports].number = num_ports;
        num_ports++;
    }
    ip->test_values = mti_CreateProcess("test", test_value_proc, ip);

    /* Check for an optional parameter on the FOREIGN attribute that
     * indicates whether or not to display debug messages.
     */

    if ( param && (strcmp(param, "verbose") == 0) ) {
        ip->verbose = 1;
    } else {
        ip->verbose = 0;
    }

    /* Open the vector file and process the first test/drive statement. */

    if ( open_vector_file(ip) ) {
        read_next_statement(ip);
    }
}
示例#3
0
文件: gates.c 项目: alexohn/ece327
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 );
}