Add primitive vpiBaseTypespec support for enumerations.
We don't currently have the information needed to correctly provide the base typespec, but in the next() and prev() methods I need to know if the enumeration is two or four state. This patch sets the base typespec for four state enumerations to vpiReg and to vpiBitVar for two state enumerations. This provide enough information to get next() and prev() working correctly.
This commit is contained in:
parent
6a99520fa6
commit
4692756eb9
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __sv_vpi_user_H
|
||||
#define __sv_vpi_user_H
|
||||
/*
|
||||
* Copyright (c) 2010 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2010-2011 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -54,6 +54,9 @@ EXTERN_C_START
|
|||
#define vpiEnumTypespec 633
|
||||
#define vpiEnumConst 634
|
||||
|
||||
/********* One-to-One ***********/
|
||||
#define vpiBaseTypespec 703
|
||||
|
||||
/********* Many-to-One ***********/
|
||||
#define vpiMember 742
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ static struct enumconst_s* enumconst_from_handle(vpiHandle obj)
|
|||
struct __vpiEnumTypespec {
|
||||
struct __vpiHandle base;
|
||||
std::vector<enumconst_s> names;
|
||||
int base_type_code;
|
||||
bool is_signed;
|
||||
};
|
||||
|
||||
|
|
@ -63,6 +64,13 @@ static int enum_type_get(int code, vpiHandle obj)
|
|||
case vpiSize:
|
||||
return ref->names.size();
|
||||
|
||||
/* This is not currently set correctly. We always use vpiReg for
|
||||
* four state variables and vpiBitVar for two state variables.
|
||||
* This minimal functionality is needed to get the next() and
|
||||
* prev() methods to work correctly with invalid values. */
|
||||
case vpiBaseTypespec:
|
||||
return ref->base_type_code;
|
||||
|
||||
case vpiSigned:
|
||||
return ref->is_signed;
|
||||
|
||||
|
|
@ -163,6 +171,7 @@ void compile_enum2_type(char*label, long width, bool signed_flag,
|
|||
spec->base.vpi_type = &enum_type_rt;
|
||||
spec->names = std::vector<enumconst_s> (names->size());
|
||||
spec->is_signed = signed_flag;
|
||||
spec->base_type_code = vpiBitVar;
|
||||
|
||||
size_t idx = 0;
|
||||
for (list<struct enum_name_s>::iterator cur = names->begin()
|
||||
|
|
@ -188,6 +197,7 @@ void compile_enum4_type(char*label, long width, bool signed_flag,
|
|||
spec->base.vpi_type = &enum_type_rt;
|
||||
spec->names = std::vector<enumconst_s> (names->size());
|
||||
spec->is_signed = signed_flag;
|
||||
spec->base_type_code = vpiReg;
|
||||
|
||||
size_t idx = 0;
|
||||
for (list<struct enum_name_s>::iterator cur = names->begin()
|
||||
|
|
|
|||
Loading…
Reference in New Issue