Exemplo n.º 1
0
static void schedule_testpoint(
    inst_rec_ptr ip,
    int          portnum,
    char        *values,
    int          time,
    int          type
)
{
    static testpoint *last_testpoint;

    int        now;
    testpoint *this_testpoint;

    /* Create a new testpoint. */
    this_testpoint = (testpoint *) mti_Malloc(sizeof(testpoint));
    this_testpoint->type     = type;
    this_testpoint->portnum  = portnum;
	this_testpoint->test_val = (char*)mti_Malloc(strlen(values)+1);
	strcpy(this_testpoint->test_val, values);

    /* Link in the new testpoint on the end of the list. */
    if ( ! testpoints ) {
        testpoints = this_testpoint;
    } else {
        last_testpoint->nxt = this_testpoint;
    }
    this_testpoint->nxt = NULL;
    last_testpoint      = this_testpoint;

    /* Schedule a wakeup at this time to check the value then. */
    now = mti_Now();
    mti_ScheduleWakeup( ip->test_values, abs(time-now) );
}
Exemplo n.º 2
0
/**
 * @name    Get current simulation time
 * @brief   Get current simulation time
 *
 * NB units depend on the simulation configuration
 */
void FliImpl::get_sim_time(uint32_t *high, uint32_t *low)
{
    *high = mti_NowUpper();
    *low = mti_Now();
}
Exemplo n.º 3
0
/*
 * This procedure is called by the simulator as a result of an
 * mti_ScheduleWakeup() call. Its purpose is to process all drive/test
 * data specified for the current timestep. It schedules drivers for
 * drive points by calling mti_ScheduleDriver(). For test points, it
 * reads the port values by calling either mti_GetSignalValue() or
 * mti_GetArraySignalValue(). It then compares the current values with the
 * expected values and prints an error message if they don't match.
 */
static void test_value_proc( void * param )
{
    inst_rec_ptr ip = (inst_rec_ptr)param;
    char       actual_val[MAX_PORT_WIDTH];
    char       buf[100];
    char       expected_val[MAX_PORT_WIDTH];
    char      *sig_array_val;
    int        portnum, i, width, is_array;
    long       now;
    long       sigval;
    testpoint *cur_testpoint;

    now = mti_Now();
    for ( cur_testpoint=testpoints; cur_testpoint;
          cur_testpoint=cur_testpoint->nxt) {
        portnum  = cur_testpoint->portnum;
        width    = tester_ports[portnum].width;
        is_array = tester_ports[portnum].is_array_type;
        if ( cur_testpoint->type == DRIVE ) {
            if ( ! is_array ) {
                if ( ip->verbose ) {
                    sprintf(buf,"TIME %ld: drive signal %s with value %c\n",
                           now, tester_ports[portnum].name,
                           convert_enum_to_mvl9_char(*cur_testpoint->test_val));
                    mti_PrintMessage(buf);
                }
                mti_ScheduleDriver( ip->drivers[portnum],
                                   (mtiLongT) *cur_testpoint->test_val,
                                   0, MTI_INERTIAL );
            } else {
                char tmpstring[MAX_PORT_WIDTH];
                convert_enums_to_mvl9_string( cur_testpoint->test_val,
                                             tmpstring, width );
                if ( ip->verbose ) {
                    sprintf(buf,"TIME %ld: drive signal array %s with value %s\n",
                           now, tester_ports[portnum].name, tmpstring);
                    mti_PrintMessage(buf);
                }
                mti_ScheduleDriver( ip->drivers[portnum],
                                   (mtiLongT)(cur_testpoint->test_val),
                                    0, MTI_INERTIAL );
            }
        } else {
            if ( ! is_array ) {
                char exp, act;
                sigval = mti_GetSignalValue(ip->ports[portnum]);
                exp    = convert_enum_to_mvl9_char(*cur_testpoint->test_val);
                act    = convert_enum_to_mvl9_char(sigval);
                if ( ip->verbose ) {
                    sprintf(buf,"TIME %ld: test signal %s for value %c\n",
                           now, tester_ports[portnum].name, exp);
                    mti_PrintMessage(buf);
                }
                if ( sigval != (long) *cur_testpoint->test_val ) {
                    sprintf( buf,
                            "Miscompare at time %ld, signal %s. "
                            "Expected \'%c\', Actual \'%c\'\n",
                            now, tester_ports[portnum].name, exp, act);
                    mti_PrintMessage(buf);
                }
            } else {
                sig_array_val = mti_GetArraySignalValue(ip->ports[portnum],
                                                        NULL);
                convert_enums_to_mvl9_string(cur_testpoint->test_val,
                                             expected_val, width);
                convert_enums_to_mvl9_string(sig_array_val, actual_val, width);
                if ( ip->verbose ) {
                    sprintf(buf,"TIME %ld: test signal %s for value %s\n",
                           now, tester_ports[portnum].name, expected_val);
                    mti_PrintMessage(buf);
                }
                for ( i = 0; i < width; i++ ) {
                    if ( sig_array_val[i] != cur_testpoint->test_val[i] ) {
                        sprintf( buf,
                                "Miscompare at time %ld, signal %s. "
                                "Expected \"%s\", Actual \"%s\"\n",
                                now, tester_ports[portnum].name,
                                expected_val, actual_val);
                        mti_PrintMessage( buf );
                        break;
                    }
                }
            }
        }
    }
    delete_testpoints();
    read_next_statement(ip);
}