Fix handling of bool(bit) vectors with odd widths.
This commit is contained in:
parent
5188fa4a69
commit
e5f52320e6
|
|
@ -48,6 +48,7 @@ EXTERN_C_START
|
||||||
#define vpiIntVar 612
|
#define vpiIntVar 612
|
||||||
#define vpiByteVar 614
|
#define vpiByteVar 614
|
||||||
#define vpiLogicVar vpiReg
|
#define vpiLogicVar vpiReg
|
||||||
|
#define vpiBitVar 620
|
||||||
|
|
||||||
/********* TYPESPECS *************/
|
/********* TYPESPECS *************/
|
||||||
#define vpiEnumTypespec 633
|
#define vpiEnumTypespec 633
|
||||||
|
|
|
||||||
|
|
@ -924,6 +924,20 @@ static const struct __vpirt vpip_byte_rt = {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct __vpirt vpip_bitvar_rt = {
|
||||||
|
vpiBitVar,
|
||||||
|
signal_get,
|
||||||
|
signal_get_str,
|
||||||
|
signal_get_value,
|
||||||
|
signal_put_value,
|
||||||
|
signal_get_handle,
|
||||||
|
signal_iterate,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
static const struct __vpirt vpip_shortint_rt = {
|
static const struct __vpirt vpip_shortint_rt = {
|
||||||
vpiShortIntVar,
|
vpiShortIntVar,
|
||||||
signal_get,
|
signal_get,
|
||||||
|
|
@ -979,6 +993,9 @@ vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Construct a vpi
|
||||||
|
*/
|
||||||
vpiHandle vpip_make_int2(const char*name, int msb, int lsb, vvp_net_t*vec)
|
vpiHandle vpip_make_int2(const char*name, int msb, int lsb, vvp_net_t*vec)
|
||||||
{
|
{
|
||||||
vpiHandle obj = vpip_make_net4(name, msb,lsb, true, vec);
|
vpiHandle obj = vpip_make_net4(name, msb,lsb, true, vec);
|
||||||
|
|
@ -998,7 +1015,10 @@ vpiHandle vpip_make_int2(const char*name, int msb, int lsb, vvp_net_t*vec)
|
||||||
obj->vpi_type = &vpip_longint_rt;
|
obj->vpi_type = &vpip_longint_rt;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
// Every other type of bit vector is a vpiBitVar with
|
||||||
|
// array dimensions.
|
||||||
|
obj->vpi_type = &vpip_bitvar_rt;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
||||||
24
vvp/words.cc
24
vvp/words.cc
|
|
@ -83,10 +83,9 @@ void compile_varw_real(char*label, vvp_array_t array,
|
||||||
* A variable is a special functor, so we allocate that functor and
|
* A variable is a special functor, so we allocate that functor and
|
||||||
* write the label into the symbol table.
|
* write the label into the symbol table.
|
||||||
*/
|
*/
|
||||||
static void __compile_var(char*label, char*name,
|
void compile_variable(char*label, char*name,
|
||||||
vvp_array_t array, unsigned long array_addr,
|
int msb, int lsb, int vpi_type_code,
|
||||||
int msb, int lsb, int vpi_type_code,
|
bool signed_flag, bool local_flag)
|
||||||
bool signed_flag, bool local_flag)
|
|
||||||
{
|
{
|
||||||
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
||||||
|
|
||||||
|
|
@ -108,7 +107,7 @@ static void __compile_var(char*label, char*name,
|
||||||
define_functor_symbol(label, net);
|
define_functor_symbol(label, net);
|
||||||
|
|
||||||
vpiHandle obj = 0;
|
vpiHandle obj = 0;
|
||||||
if (! local_flag && !array) {
|
if (! local_flag) {
|
||||||
/* Make the vpiHandle for the reg. */
|
/* Make the vpiHandle for the reg. */
|
||||||
switch (vpi_type_code) {
|
switch (vpi_type_code) {
|
||||||
case vpiLogicVar:
|
case vpiLogicVar:
|
||||||
|
|
@ -130,7 +129,6 @@ static void __compile_var(char*label, char*name,
|
||||||
// If the signal has a name, then it goes into the current
|
// If the signal has a name, then it goes into the current
|
||||||
// scope as a signal.
|
// scope as a signal.
|
||||||
if (name) {
|
if (name) {
|
||||||
assert(!array);
|
|
||||||
if (obj) vpip_attach_to_current_scope(obj);
|
if (obj) vpip_attach_to_current_scope(obj);
|
||||||
if (!vpip_peek_current_scope()->is_automatic) {
|
if (!vpip_peek_current_scope()->is_automatic) {
|
||||||
vvp_vector4_t tmp;
|
vvp_vector4_t tmp;
|
||||||
|
|
@ -138,23 +136,11 @@ static void __compile_var(char*label, char*name,
|
||||||
schedule_init_vector(vvp_net_ptr_t(net,0), tmp);
|
schedule_init_vector(vvp_net_ptr_t(net,0), tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If this is an array word, then it does not have a name, and
|
|
||||||
// it is attached to the addressed array.
|
|
||||||
if (array) {
|
|
||||||
assert(!name);
|
|
||||||
if (obj) array_attach_word(array, array_addr, obj);
|
|
||||||
}
|
|
||||||
free(label);
|
free(label);
|
||||||
delete[] name;
|
delete[] name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void compile_variable(char*label, char*name,
|
|
||||||
int msb, int lsb, int vpi_type_code,
|
|
||||||
bool signed_flag, bool local_flag)
|
|
||||||
{
|
|
||||||
__compile_var(label, name, 0, 0, msb, lsb, vpi_type_code, signed_flag, local_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
vvp_net_t* create_constant_node(const char*val_str)
|
vvp_net_t* create_constant_node(const char*val_str)
|
||||||
{
|
{
|
||||||
if (c4string_test(val_str)) {
|
if (c4string_test(val_str)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue