A vpiBitVar can have a non-zero LSB and can be unsigned.
The general bit variable can be either signed or unsigned and can have a non-zero LSB.
This commit is contained in:
parent
4f8cace5a9
commit
9fb317a4e1
|
|
@ -682,10 +682,10 @@ statement
|
||||||
| T_LABEL K_VAR_I local_flag T_STRING ',' T_NUMBER T_NUMBER ';'
|
| T_LABEL K_VAR_I local_flag T_STRING ',' T_NUMBER T_NUMBER ';'
|
||||||
{ compile_variable($1, $4, $6, $7, vpiIntegerVar, true, $3); }
|
{ compile_variable($1, $4, $6, $7, vpiIntegerVar, true, $3); }
|
||||||
|
|
||||||
| T_LABEL K_VAR_2S local_flag T_STRING ',' T_NUMBER T_NUMBER ';'
|
| T_LABEL K_VAR_2S local_flag T_STRING ',' signed_t_number signed_t_number ';'
|
||||||
{ compile_variable($1, $4, $6, $7, vpiIntVar, true, $3); }
|
{ compile_variable($1, $4, $6, $7, vpiIntVar, true, $3); }
|
||||||
|
|
||||||
| T_LABEL K_VAR_2U local_flag T_STRING ',' T_NUMBER T_NUMBER ';'
|
| T_LABEL K_VAR_2U local_flag T_STRING ',' signed_t_number signed_t_number ';'
|
||||||
{ compile_variable($1, $4, $6, $7, vpiIntVar, false, $3); }
|
{ compile_variable($1, $4, $6, $7, vpiIntVar, false, $3); }
|
||||||
|
|
||||||
| T_LABEL K_VAR_R T_STRING ',' signed_t_number signed_t_number ';'
|
| T_LABEL K_VAR_R T_STRING ',' signed_t_number signed_t_number ';'
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ extern unsigned vpip_size(__vpiSignal *sig);
|
||||||
extern struct __vpiScope* vpip_scope(__vpiSignal*sig);
|
extern struct __vpiScope* vpip_scope(__vpiSignal*sig);
|
||||||
|
|
||||||
extern vpiHandle vpip_make_int2(const char*name, int msb, int lsb,
|
extern vpiHandle vpip_make_int2(const char*name, int msb, int lsb,
|
||||||
vvp_net_t*vec);
|
bool signed_flag, vvp_net_t*vec);
|
||||||
extern vpiHandle vpip_make_int4(const char*name, int msb, int lsb,
|
extern vpiHandle vpip_make_int4(const char*name, int msb, int lsb,
|
||||||
vvp_net_t*vec);
|
vvp_net_t*vec);
|
||||||
extern vpiHandle vpip_make_var4(const char*name, int msb, int lsb,
|
extern vpiHandle vpip_make_var4(const char*name, int msb, int lsb,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -996,13 +996,20 @@ vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a vpi
|
* Construct the two-state SystemVerilog variables.
|
||||||
*/
|
*/
|
||||||
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, bool signed_flag,
|
||||||
|
vvp_net_t*vec)
|
||||||
{
|
{
|
||||||
vpiHandle obj = vpip_make_net4(name, msb,lsb, true, vec);
|
vpiHandle obj = vpip_make_net4(name, msb, lsb, signed_flag, vec);
|
||||||
|
|
||||||
assert(lsb == 0);
|
// All unsigned 2-state variables are a vpiBitVar. All 2-state
|
||||||
|
// variables with a non-zero lsb are also a vpiBitVar.
|
||||||
|
if ((! signed_flag) || (lsb != 0) ) {
|
||||||
|
obj->vpi_type = &vpip_bitvar_rt;
|
||||||
|
} else {
|
||||||
|
// These could also be bit declarations with matching
|
||||||
|
// information, but for now they get the apparent type.
|
||||||
switch (msb) {
|
switch (msb) {
|
||||||
case 7:
|
case 7:
|
||||||
obj->vpi_type = &vpip_byte_rt;
|
obj->vpi_type = &vpip_byte_rt;
|
||||||
|
|
@ -1022,6 +1029,7 @@ vpiHandle vpip_make_int2(const char*name, int msb, int lsb, vvp_net_t*vec)
|
||||||
obj->vpi_type = &vpip_bitvar_rt;
|
obj->vpi_type = &vpip_bitvar_rt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2003-2011 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -117,7 +117,7 @@ void compile_variable(char*label, char*name,
|
||||||
obj = vpip_make_int4(name, msb, lsb, net);
|
obj = vpip_make_int4(name, msb, lsb, net);
|
||||||
break;
|
break;
|
||||||
case vpiIntVar: // This handles all the atom2 int types
|
case vpiIntVar: // This handles all the atom2 int types
|
||||||
obj = vpip_make_int2(name, msb, lsb, net);
|
obj = vpip_make_int2(name, msb, lsb, signed_flag, net);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "internal error: %s: vpi_type_code=%d\n", name, vpi_type_code);
|
fprintf(stderr, "internal error: %s: vpi_type_code=%d\n", name, vpi_type_code);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue