예제 #1
0
파일: gates.c 프로젝트: alexohn/ece327
void do_and( void * param )
{
    inst_rec * ip = (inst_rec *)param;
    mtiInt32T  val1, val2;
    mtiInt32T  result;

    val1   = mti_GetSignalValue( ip->in1 );
    val2   = mti_GetSignalValue( ip->in2 );
    result = val1 & val2;
    mti_ScheduleDriver( ip->out1, result, 0, MTI_INERTIAL );
}
예제 #2
0
const char* FliLogicObjHdl::get_signal_value_binstr(void)
{
    switch (m_fli_type) {
    case MTI_TYPE_ENUM:
        if (m_is_var) {
            m_val_buff[0] = m_value_enum[mti_GetVarValue(get_handle<mtiVariableIdT>())][1];
        } else {
            m_val_buff[0] = m_value_enum[mti_GetSignalValue(get_handle<mtiSignalIdT>())][1];
        }
        break;
    case MTI_TYPE_ARRAY: {
        if (m_is_var) {
            mti_GetArrayVarValue(get_handle<mtiVariableIdT>(), m_mti_buff);
        } else {
            mti_GetArraySignalValue(get_handle<mtiSignalIdT>(), m_mti_buff);
        }

        for (int i = 0; i < m_num_elems; i++ ) {
            m_val_buff[i] = m_value_enum[(int)m_mti_buff[i]][1];
        }
    }
    break;
    default:
        LOG_CRITICAL("Object type is not 'logic' for %s (%d)", m_name.c_str(), m_fli_type);
        return NULL;
    }

    LOG_DEBUG("Retrieved \"%s\" for value object %s", m_val_buff, m_name.c_str());

    return m_val_buff;
}
예제 #3
0
/**
 * convert_logic_vector_to_int() - Convert a multibit signal into the
 *                                 corresponding numerical value
 *
 * @vec: std_logic_vector signal to convert
 *
 * Return: 32-bit integer equivalent to the input signal
 */
int convert_logic_vector_to_int(mtiSignalIdT vec)
{
    mtiSignalIdT *elems_list;
    mtiTypeIdT sig_type;
    mtiInt32T num_elems;
    int data;
    int i;

    /* Get an handle to the type of the given signal */
    sig_type = mti_GetSignalType(vec);
    /* Get the number of elements that compose the vector */
    num_elems = mti_TickLength(sig_type);

    assert(num_elems <= 25);

    /* Extract the list of individual elements */
    elems_list = mti_GetSignalSubelements(vec, 0);

    data = 0;
    for (i = 0; i < num_elems; ++i) {
	/* If a 1 is received, increment the corresponding bit of the
	   result */
	if (mti_GetSignalValue(elems_list[i]) == STD_LOGIC_1) {
	    data += 1 << (num_elems - i - 1);
	}
    }

    mti_VsimFree(elems_list);
    return data;
}
예제 #4
0
long FliEnumObjHdl::get_signal_value_long(void)
{
    if (m_is_var) {
        return (long)mti_GetVarValue(get_handle<mtiVariableIdT>());
    } else {
        return (long)mti_GetSignalValue(get_handle<mtiSignalIdT>());
    }
}
예제 #5
0
const char* FliEnumObjHdl::get_signal_value_str(void)
{
    if (m_is_var) {
        return m_value_enum[mti_GetVarValue(get_handle<mtiVariableIdT>())];
    } else {
        return m_value_enum[mti_GetSignalValue(get_handle<mtiSignalIdT>())];
    }
}
예제 #6
0
long FliIntObjHdl::get_signal_value_long(void)
{
    mtiInt32T value;

    if (m_is_var) {
        value = mti_GetVarValue(get_handle<mtiVariableIdT>());
    } else {
        value = mti_GetSignalValue(get_handle<mtiSignalIdT>());
    }

    return (long)value;
}
예제 #7
0
파일: FliImpl.cpp 프로젝트: chiggs/cocotb
const char* FliSignalObjHdl::get_signal_value_binstr(void)
{
    switch (m_fli_type) {

        case MTI_TYPE_ENUM:
            m_val_buff[0] = value_enum[mti_GetSignalValue(m_fli_hdl)];
            break;
        case MTI_TYPE_SCALAR:
        case MTI_TYPE_PHYSICAL: {
                std::bitset<32> value((unsigned long)mti_GetSignalValue(m_fli_hdl));
                std::string bin_str = value.to_string<char,std::string::traits_type, std::string::allocator_type>();
                snprintf(m_val_buff, m_val_len+1, "%s", bin_str.c_str());
            }
            break;
        case MTI_TYPE_ARRAY: {
                mti_GetArraySignalValue(m_fli_hdl, m_mti_buff);
                if (m_val_len <= 256) {
                    char *iter = (char*)m_mti_buff;
                    for (int i = 0; i < m_val_len; i++ ) {
                        m_val_buff[i] = value_enum[(int)iter[i]];
                    }
                } else {
                    for (int i = 0; i < m_val_len; i++ ) {
                        m_val_buff[i] = value_enum[m_mti_buff[i]];
                    }
                }
            }
            break;
        default:
            LOG_CRITICAL("Signal %s type %d not currently supported",
                m_name.c_str(), m_fli_type);
            break;
    }

    LOG_DEBUG("Retrieved \"%s\" for signal %s", m_val_buff, m_name.c_str());

    return m_val_buff;
}
예제 #8
0
const char* FliIntObjHdl::get_signal_value_binstr(void)
{
    mtiInt32T val;

    if (m_is_var) {
        val = mti_GetVarValue(get_handle<mtiVariableIdT>());
    } else {
        val = mti_GetSignalValue(get_handle<mtiSignalIdT>());
    }

    std::bitset<32> value((unsigned long)val);
    std::string bin_str = value.to_string<char,std::string::traits_type, std::string::allocator_type>();
    snprintf(m_val_buff, 33, "%s", bin_str.c_str());

    return m_val_buff;
}
예제 #9
0
파일: tester.c 프로젝트: alexohn/ece327
/*
 * 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);
}
예제 #10
0
파일: testbench.c 프로젝트: andrepool/fli
static void testbench( void *param )
{
   _Bool clk, cmp;
   _Bool rst = false;
   _Bool set = false;
   mtiInt32T load = 0;
   mtiInt32T result, read_data;

   static unsigned long long clk_cnt = 0;
   static _Bool inc = false;
   static _Bool dec = false;
   
   testbench_t * ip = (testbench_t *) param;
   clk = mti_GetSignalValue ( ip->clk );
   cmp = mti_GetSignalValue ( ip->cmp );
   result = mti_GetSignalValue (ip->result );
   read_data = mti_GetSignalValue (ip->read_data );
  
   if( clk )
   {
      clk_cnt++;
   }
      
   if( clk_cnt >=3 && clk_cnt <= 7 )
   {
      rst = true;
   }
    
   if( clk_cnt == 9 )
   {
      set = true;
      load = 27;
   }
     
   if( clk_cnt == 12 )
   {
      inc = true;
   }

   if( result > 19 || result < 1 )
   {
      /* in case a force is used and the inc or dec are still active the value can go out of our "visible" test range */
      set = true;
      load = 27;
   }
   else if( result > 18 )
   {
      inc = false;
      dec = true;
   }
   else if( result < 2 )
   {
      inc = true;
      dec = false;
   }
  
   mti_ScheduleDriver( ip->rst, rst, 2, MTI_INERTIAL );
   mti_ScheduleDriver( ip->set, set, 1, MTI_INERTIAL );
   mti_ScheduleDriver( ip->inc, inc, 1, MTI_INERTIAL );
   mti_ScheduleDriver( ip->dec, dec, 1, MTI_INERTIAL );
   mti_ScheduleDriver( ip->load, load, 2, MTI_INERTIAL );
     
#ifdef NONO
   printf( "testbech clk_cnt %llu clk %u, rst %u, set %u, inc %u, dec %u, load %d, result %d, cmp %u\n",
      clk_cnt, clk, rst, set, inc, dec, load, result, cmp );
   fflush(stdout);
#endif

}