Permalink
Browse files

Fix handling of bool(bit) vectors with odd widths.

  • Loading branch information...
1 parent 9bdc040 commit 7d53ac342fab96dcc90186e850fc5c1c81d99da4 @steveicarus steveicarus committed Apr 2, 2011
Showing with 27 additions and 20 deletions.
  1. +1 −0 sv_vpi_user.h
  2. +21 −1 vvp/vpi_signal.cc
  3. +5 −19 vvp/words.cc
View
@@ -48,6 +48,7 @@ EXTERN_C_START
#define vpiIntVar 612
#define vpiByteVar 614
#define vpiLogicVar vpiReg
+#define vpiBitVar 620
/********* TYPESPECS *************/
#define vpiEnumTypespec 633
View
@@ -924,6 +924,20 @@ static const struct __vpirt vpip_byte_rt = {
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 = {
vpiShortIntVar,
signal_get,
@@ -979,6 +993,9 @@ vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec)
return obj;
}
+/*
+ * Construct a vpi
+ */
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);
@@ -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;
break;
default:
- assert(0);
+ // Every other type of bit vector is a vpiBitVar with
+ // array dimensions.
+ obj->vpi_type = &vpip_bitvar_rt;
+ break;
}
return obj;
View
@@ -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
* write the label into the symbol table.
*/
-static void __compile_var(char*label, char*name,
- vvp_array_t array, unsigned long array_addr,
- int msb, int lsb, int vpi_type_code,
- bool signed_flag, bool local_flag)
+void compile_variable(char*label, char*name,
+ int msb, int lsb, int vpi_type_code,
+ bool signed_flag, bool local_flag)
{
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);
vpiHandle obj = 0;
- if (! local_flag && !array) {
+ if (! local_flag) {
/* Make the vpiHandle for the reg. */
switch (vpi_type_code) {
case vpiLogicVar:
@@ -130,31 +129,18 @@ static void __compile_var(char*label, char*name,
// If the signal has a name, then it goes into the current
// scope as a signal.
if (name) {
- assert(!array);
if (obj) vpip_attach_to_current_scope(obj);
if (!vpip_peek_current_scope()->is_automatic) {
vvp_vector4_t tmp;
vfil->vec4_value(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);
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)
{
if (c4string_test(val_str)) {

0 comments on commit 7d53ac3

Please sign in to comment.