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 ';'
|
||||
{ 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); }
|
||||
|
||||
| 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); }
|
||||
|
||||
| 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 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,
|
||||
vvp_net_t*vec);
|
||||
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
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -996,31 +996,39 @@ 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);
|
||||
switch (msb) {
|
||||
case 7:
|
||||
obj->vpi_type = &vpip_byte_rt;
|
||||
break;
|
||||
case 15:
|
||||
obj->vpi_type = &vpip_shortint_rt;
|
||||
break;
|
||||
case 31:
|
||||
obj->vpi_type = &vpip_int_rt;
|
||||
break;
|
||||
case 63:
|
||||
obj->vpi_type = &vpip_longint_rt;
|
||||
break;
|
||||
default:
|
||||
// Every other type of bit vector is a vpiBitVar with
|
||||
// array dimensions.
|
||||
// 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;
|
||||
break;
|
||||
} else {
|
||||
// These could also be bit declarations with matching
|
||||
// information, but for now they get the apparent type.
|
||||
switch (msb) {
|
||||
case 7:
|
||||
obj->vpi_type = &vpip_byte_rt;
|
||||
break;
|
||||
case 15:
|
||||
obj->vpi_type = &vpip_shortint_rt;
|
||||
break;
|
||||
case 31:
|
||||
obj->vpi_type = &vpip_int_rt;
|
||||
break;
|
||||
case 63:
|
||||
obj->vpi_type = &vpip_longint_rt;
|
||||
break;
|
||||
default:
|
||||
// Every other type of bit vector is a vpiBitVar with
|
||||
// array dimensions.
|
||||
obj->vpi_type = &vpip_bitvar_rt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
* 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);
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
fprintf(stderr, "internal error: %s: vpi_type_code=%d\n", name, vpi_type_code);
|
||||
|
|
|
|||
Loading…
Reference in New Issue