Esempio n. 1
0
int FliVariableObjHdl::initialise(std::string &name)
{
    /* Pre allocte buffers on signal type basis */
    m_fli_type = mti_GetTypeKind(mti_GetVarType(m_fli_hdl));

    switch (m_fli_type) {
        case MTI_TYPE_ENUM:
            m_val_len = 1;
            break;
        case MTI_TYPE_SCALAR:
        case MTI_TYPE_PHYSICAL:
            m_val_len = 32;
            break;
        case MTI_TYPE_ARRAY:
            m_val_len  = mti_TickLength(mti_GetVarType(m_fli_hdl));
            m_mti_buff = (mtiInt32T*)malloc(sizeof(*m_mti_buff) * m_val_len);
            if (!m_mti_buff) {
                LOG_CRITICAL("Unable to alloc mem for signal mti read buffer: ABORTING");
            }
            break;
        default:
            LOG_ERROR("Unable to handle object type for %s (%d)",
                         name.c_str(), m_fli_type);
    }

    m_val_buff = (char*)malloc(m_val_len+1);
    if (!m_val_buff) {
        LOG_CRITICAL("Unable to alloc mem for signal read buffer: ABORTING");
    }
    m_val_buff[m_val_len] = '\0';

    GpiObjHdl::initialise(name);

    return 0;
}
Esempio n. 2
0
/* 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);
    }
}
Esempio n. 3
0
GpiObjHdl *FliImpl::create_gpi_obj_from_handle(void *hdl, std::string &name, std::string &fq_name, int accType, int accFullType)
{
    GpiObjHdl *new_obj = NULL;

    LOG_DEBUG("Attepmting to create GPI object from handle (Type=%d, FullType=%d).", accType, accFullType);
    if (!VS_TYPE_IS_VHDL(accFullType)) {
        LOG_DEBUG("Handle is not a VHDL type.");
        return NULL;
    }

    if (!isTypeValue(accType)) {
        /* Need a Pseudo-region to handle generate loops in a consistent manner across interfaces
         * and across the different methods of accessing data.
         */
        std::string rgn_name = mti_GetRegionName(static_cast<mtiRegionIdT>(hdl));
        if (name != rgn_name) {
            LOG_DEBUG("Found pseudo-region %s -> %p", fq_name.c_str(), hdl);
            new_obj = new FliObjHdl(this, hdl, GPI_GENARRAY, accType, accFullType);
        } else {
            LOG_DEBUG("Found region %s -> %p", fq_name.c_str(), hdl);
            new_obj = new FliObjHdl(this, hdl, GPI_MODULE, accType, accFullType);
        }
    } else {
        bool is_var;
        bool is_const;
        mtiTypeIdT valType;
        mtiTypeKindT typeKind;

        if (isTypeSignal(accType, accFullType)) {
            LOG_DEBUG("Found a signal %s -> %p", fq_name.c_str(), hdl);
            is_var   = false;
            is_const = false;
            valType  = mti_GetSignalType(static_cast<mtiSignalIdT>(hdl));
        } else {
            LOG_DEBUG("Found a variable %s -> %p", fq_name.c_str(), hdl);
            is_var   = true;
            is_const = isValueConst(accFullType);
            valType  = mti_GetVarType(static_cast<mtiVariableIdT>(hdl));
        }

        typeKind = mti_GetTypeKind(valType);

        switch (typeKind) {
            case MTI_TYPE_ENUM:
                if (isValueLogic(valType)) {
                    new_obj = new FliLogicObjHdl(this, hdl, GPI_REGISTER, is_const, accType, accFullType, is_var, valType, typeKind);
                } else if (isValueBoolean(valType) || isValueChar(valType)) {
                    new_obj = new FliIntObjHdl(this, hdl, GPI_INTEGER, is_const, accType, accFullType, is_var, valType, typeKind);
                } else {
                    new_obj = new FliEnumObjHdl(this, hdl, GPI_ENUM, is_const, accType, accFullType, is_var, valType, typeKind);
                }
                break;
            case MTI_TYPE_SCALAR:
            case MTI_TYPE_PHYSICAL:
                new_obj = new FliIntObjHdl(this, hdl, GPI_INTEGER, is_const, accType, accFullType, is_var, valType, typeKind);
                break;
            case MTI_TYPE_REAL:
                new_obj = new FliRealObjHdl(this, hdl, GPI_REAL, is_const, accType, accFullType, is_var, valType, typeKind);
                break;
            case MTI_TYPE_ARRAY: {
                    mtiTypeIdT   elemType     = mti_GetArrayElementType(valType);
                    mtiTypeKindT elemTypeKind = mti_GetTypeKind(elemType);

                    switch (elemTypeKind) {
                        case MTI_TYPE_ENUM:
                            if (isValueLogic(elemType)) {
                                new_obj = new FliLogicObjHdl(this, hdl, GPI_REGISTER, is_const, accType, accFullType, is_var, valType, typeKind); // std_logic_vector
                            } else if (isValueChar(elemType)) {
                                new_obj = new FliStringObjHdl(this, hdl, GPI_STRING, is_const, accType, accFullType, is_var, valType, typeKind);
                            } else {
                                new_obj = new FliValueObjHdl(this, hdl, GPI_ARRAY, false, accType, accFullType, is_var, valType, typeKind); // array of enums
                            }
                            break;
                        default:
                            new_obj = new FliValueObjHdl(this, hdl, GPI_ARRAY, false, accType, accFullType, is_var, valType, typeKind);// array of (array, Integer, Real, Record, etc.) 
                    }
                }
                break;
            case MTI_TYPE_RECORD:
                new_obj = new FliValueObjHdl(this, hdl, GPI_STRUCTURE, false, accType, accFullType, is_var, valType, typeKind);
                break;
            default:
                LOG_ERROR("Unable to handle object type for %s (%d)", name.c_str(), typeKind);
                return NULL;
        }
    }

    if (NULL == new_obj) {
        LOG_DEBUG("Didn't find anything named %s", fq_name.c_str());
        return NULL;
    }

    if (new_obj->initialise(name,fq_name) < 0) {
        LOG_ERROR("Failed to initialise the handle %s", name.c_str());
        delete new_obj;
        return NULL;
    }

    return new_obj;
}