Add local_flag syntax to .net and .var statements.
This commit is contained in:
parent
58d3d2f265
commit
931d08a9fc
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __compile_H
|
#ifndef __compile_H
|
||||||
#define __compile_H
|
#define __compile_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2007 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
|
||||||
|
|
@ -18,9 +18,6 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
|
||||||
#ident "$Id: compile.h,v 1.88 2007/04/10 01:26:16 steve Exp $"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <fstream>
|
# include <fstream>
|
||||||
|
|
@ -361,13 +358,14 @@ extern void compile_thread(char*start_sym, char*flag);
|
||||||
* This function is called to create a var vector with the given name.
|
* This function is called to create a var vector with the given name.
|
||||||
*/
|
*/
|
||||||
extern void compile_variable(char*label, char*name,
|
extern void compile_variable(char*label, char*name,
|
||||||
int msb, int lsb, char signed_flag);
|
int msb, int lsb, char signed_flag,
|
||||||
|
bool local_flag);
|
||||||
extern void compile_var_real(char*label, char*name,
|
extern void compile_var_real(char*label, char*name,
|
||||||
int msb, int lsb);
|
int msb, int lsb);
|
||||||
|
|
||||||
extern void compile_net(char*label, char*name,
|
extern void compile_net(char*label, char*name,
|
||||||
int msb, int lsb, bool signed_flag,
|
int msb, int lsb, bool signed_flag,
|
||||||
bool net8_flag,
|
bool net8_flag, bool local_flag,
|
||||||
unsigned argc, struct symb_s*argv);
|
unsigned argc, struct symb_s*argv);
|
||||||
extern void compile_net_real(char*label, char*name,
|
extern void compile_net_real(char*label, char*name,
|
||||||
int msb, int lsb,
|
int msb, int lsb,
|
||||||
|
|
|
||||||
39
vvp/parse.y
39
vvp/parse.y
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2007 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
|
||||||
|
|
@ -18,9 +18,6 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
|
||||||
#ident "$Id: parse.y,v 1.93 2007/04/19 01:19:06 steve Exp $"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include "parse_misc.h"
|
# include "parse_misc.h"
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
|
|
@ -49,6 +46,7 @@ static struct __vpiModPath*modpath_dst = 0;
|
||||||
char*text;
|
char*text;
|
||||||
char **table;
|
char **table;
|
||||||
long numb;
|
long numb;
|
||||||
|
bool flag;
|
||||||
|
|
||||||
comp_operands_t opa;
|
comp_operands_t opa;
|
||||||
|
|
||||||
|
|
@ -92,6 +90,7 @@ static struct __vpiModPath*modpath_dst = 0;
|
||||||
%token <text> T_SYMBOL
|
%token <text> T_SYMBOL
|
||||||
%token <vect> T_VECTOR
|
%token <vect> T_VECTOR
|
||||||
|
|
||||||
|
%type <flag> local_flag
|
||||||
%type <numb> signed_t_number
|
%type <numb> signed_t_number
|
||||||
%type <symb> symbol symbol_opt
|
%type <symb> symbol symbol_opt
|
||||||
%type <symbv> symbols symbols_net
|
%type <symbv> symbols symbols_net
|
||||||
|
|
@ -505,36 +504,36 @@ statement
|
||||||
creates a functor with the same name that acts as the output of
|
creates a functor with the same name that acts as the output of
|
||||||
the variable in the netlist. */
|
the variable in the netlist. */
|
||||||
|
|
||||||
| T_LABEL K_VAR T_STRING ',' signed_t_number signed_t_number ';'
|
| T_LABEL K_VAR local_flag T_STRING ',' signed_t_number signed_t_number ';'
|
||||||
{ compile_variable($1, $3, $5, $6, 0 /* unsigned */ ); }
|
{ compile_variable($1, $4, $6, $7, 0 /* unsigned */, $3); }
|
||||||
|
|
||||||
| T_LABEL K_VAR_S T_STRING ',' signed_t_number signed_t_number ';'
|
| T_LABEL K_VAR_S local_flag T_STRING ',' signed_t_number signed_t_number ';'
|
||||||
{ compile_variable($1, $3, $5, $6, 1 /* signed */ ); }
|
{ compile_variable($1, $4, $6, $7, 1 /* signed */, $3); }
|
||||||
|
|
||||||
| T_LABEL K_VAR_I T_STRING ',' T_NUMBER T_NUMBER ';'
|
| T_LABEL K_VAR_I local_flag T_STRING ',' T_NUMBER T_NUMBER ';'
|
||||||
{ compile_variable($1, $3, $5, $6, 2 /* integer */); }
|
{ compile_variable($1, $4, $6, $7, 2 /* integer */, $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 ';'
|
||||||
{ compile_var_real($1, $3, $5, $6); }
|
{ compile_var_real($1, $3, $5, $6); }
|
||||||
|
|
||||||
/* Net statements are similar to .var statements, except that they
|
/* Net statements are similar to .var statements, except that they
|
||||||
declare nets, and they have an input list. */
|
declare nets, and they have an input list. */
|
||||||
|
|
||||||
| T_LABEL K_NET T_STRING ',' signed_t_number signed_t_number
|
| T_LABEL K_NET local_flag T_STRING ',' signed_t_number signed_t_number
|
||||||
',' symbols_net ';'
|
',' symbols_net ';'
|
||||||
{ compile_net($1, $3, $5, $6, false, false, $8.cnt, $8.vect); }
|
{ compile_net($1, $4, $6, $7, false, false, $3, $9.cnt, $9.vect); }
|
||||||
|
|
||||||
| T_LABEL K_NET_S T_STRING ',' signed_t_number signed_t_number
|
| T_LABEL K_NET_S T_STRING ',' signed_t_number signed_t_number
|
||||||
',' symbols_net ';'
|
',' symbols_net ';'
|
||||||
{ compile_net($1, $3, $5, $6, true, false, $8.cnt, $8.vect); }
|
{ compile_net($1, $3, $5, $6, true, false, false, $8.cnt, $8.vect); }
|
||||||
|
|
||||||
| T_LABEL K_NET8 T_STRING ',' signed_t_number signed_t_number
|
| T_LABEL K_NET8 T_STRING ',' signed_t_number signed_t_number
|
||||||
',' symbols_net ';'
|
',' symbols_net ';'
|
||||||
{ compile_net($1, $3, $5, $6, false, true, $8.cnt, $8.vect); }
|
{ compile_net($1, $3, $5, $6, false, true, false, $8.cnt, $8.vect); }
|
||||||
|
|
||||||
| T_LABEL K_NET8_S T_STRING ',' signed_t_number signed_t_number
|
| T_LABEL K_NET8_S T_STRING ',' signed_t_number signed_t_number
|
||||||
',' symbols_net ';'
|
',' symbols_net ';'
|
||||||
{ compile_net($1, $3, $5, $6, true, true, $8.cnt, $8.vect); }
|
{ compile_net($1, $3, $5, $6, true, true, false, $8.cnt, $8.vect); }
|
||||||
|
|
||||||
| T_LABEL K_NET_R T_STRING ',' signed_t_number signed_t_number
|
| T_LABEL K_NET_R T_STRING ',' signed_t_number signed_t_number
|
||||||
',' symbols_net ';'
|
',' symbols_net ';'
|
||||||
|
|
@ -591,6 +590,10 @@ statement
|
||||||
| ';'
|
| ';'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
local_flag
|
||||||
|
: '*' { $$ = true; }
|
||||||
|
| { $$ = false; }
|
||||||
|
;
|
||||||
|
|
||||||
/* There are a few places where the label is optional. This rule
|
/* There are a few places where the label is optional. This rule
|
||||||
returns the label value if present, or 0 if not. */
|
returns the label value if present, or 0 if not. */
|
||||||
|
|
|
||||||
48
vvp/words.cc
48
vvp/words.cc
|
|
@ -16,9 +16,6 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
|
||||||
#ident "$Id: words.cc,v 1.9 2007/04/10 01:26:16 steve Exp $"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
|
|
@ -43,7 +40,6 @@ static void __compile_var_real(char*label, char*name,
|
||||||
define_functor_symbol(label, net);
|
define_functor_symbol(label, net);
|
||||||
|
|
||||||
vpiHandle obj = vpip_make_real_var(name, net);
|
vpiHandle obj = vpip_make_real_var(name, net);
|
||||||
|
|
||||||
compile_vpi_symbol(label, obj);
|
compile_vpi_symbol(label, obj);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
|
|
@ -77,7 +73,7 @@ void compile_varw_real(char*label, vvp_array_t array,
|
||||||
*/
|
*/
|
||||||
static void __compile_var(char*label, char*name,
|
static void __compile_var(char*label, char*name,
|
||||||
vvp_array_t array, unsigned long array_addr,
|
vvp_array_t array, unsigned long array_addr,
|
||||||
int msb, int lsb, char signed_flag)
|
int msb, int lsb, char signed_flag, bool local_flag)
|
||||||
{
|
{
|
||||||
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
||||||
|
|
||||||
|
|
@ -87,16 +83,19 @@ static void __compile_var(char*label, char*name,
|
||||||
node->fun = vsig;
|
node->fun = vsig;
|
||||||
define_functor_symbol(label, node);
|
define_functor_symbol(label, node);
|
||||||
|
|
||||||
/* Make the vpiHandle for the reg. */
|
vpiHandle obj = 0;
|
||||||
vpiHandle obj = (signed_flag > 1) ?
|
if (! local_flag) {
|
||||||
vpip_make_int(name, msb, lsb, node) :
|
/* Make the vpiHandle for the reg. */
|
||||||
vpip_make_reg(name, msb, lsb, signed_flag!=0, node);
|
obj = (signed_flag > 1) ?
|
||||||
compile_vpi_symbol(label, obj);
|
vpip_make_int(name, msb, lsb, node) :
|
||||||
|
vpip_make_reg(name, msb, lsb, signed_flag!=0, node);
|
||||||
|
compile_vpi_symbol(label, obj);
|
||||||
|
}
|
||||||
// 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);
|
assert(!array);
|
||||||
vpip_attach_to_current_scope(obj);
|
if (obj) vpip_attach_to_current_scope(obj);
|
||||||
schedule_init_vector(vvp_net_ptr_t(node,0), vsig->vec4_value());
|
schedule_init_vector(vvp_net_ptr_t(node,0), vsig->vec4_value());
|
||||||
}
|
}
|
||||||
// If this is an array word, then it does not have a name, and
|
// If this is an array word, then it does not have a name, and
|
||||||
|
|
@ -110,9 +109,9 @@ static void __compile_var(char*label, char*name,
|
||||||
}
|
}
|
||||||
|
|
||||||
void compile_variable(char*label, char*name,
|
void compile_variable(char*label, char*name,
|
||||||
int msb, int lsb, char signed_flag)
|
int msb, int lsb, char signed_flag, bool local_flag)
|
||||||
{
|
{
|
||||||
__compile_var(label, name, 0, 0, msb, lsb, signed_flag);
|
__compile_var(label, name, 0, 0, msb, lsb, signed_flag, local_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -127,7 +126,7 @@ void compile_variablew(char*label, vvp_array_t array,
|
||||||
unsigned long array_addr,
|
unsigned long array_addr,
|
||||||
int msb, int lsb, char signed_flag)
|
int msb, int lsb, char signed_flag)
|
||||||
{
|
{
|
||||||
__compile_var(label, 0, array, array_addr, msb, lsb, signed_flag);
|
__compile_var(label, 0, array, array_addr, msb, lsb, signed_flag, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -144,7 +143,7 @@ void compile_variablew(char*label, vvp_array_t array,
|
||||||
static void __compile_net(char*label, char*name,
|
static void __compile_net(char*label, char*name,
|
||||||
char*array_label, unsigned long array_addr,
|
char*array_label, unsigned long array_addr,
|
||||||
int msb, int lsb,
|
int msb, int lsb,
|
||||||
bool signed_flag, bool net8_flag,
|
bool signed_flag, bool net8_flag, bool local_flag,
|
||||||
unsigned argc, struct symb_s*argv)
|
unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
||||||
|
|
@ -167,15 +166,18 @@ static void __compile_net(char*label, char*name,
|
||||||
/* Connect the source to my input. */
|
/* Connect the source to my input. */
|
||||||
inputs_connect(node, 1, argv);
|
inputs_connect(node, 1, argv);
|
||||||
|
|
||||||
/* Make the vpiHandle for the reg. */
|
vpiHandle obj = 0;
|
||||||
vpiHandle obj = vpip_make_net(name, msb, lsb, signed_flag, node);
|
if (! local_flag) {
|
||||||
/* This attaches the label to the vpiHandle */
|
/* Make the vpiHandle for the reg. */
|
||||||
compile_vpi_symbol(label, obj);
|
obj = vpip_make_net(name, msb, lsb, signed_flag, node);
|
||||||
|
/* This attaches the label to the vpiHandle */
|
||||||
|
compile_vpi_symbol(label, obj);
|
||||||
|
}
|
||||||
/* If this is an array word, then attach it to the
|
/* If this is an array word, then attach it to the
|
||||||
array. Otherwise, attach it to the current scope. */
|
array. Otherwise, attach it to the current scope. */
|
||||||
if (array)
|
if (array)
|
||||||
array_attach_word(array, array_addr, obj);
|
array_attach_word(array, array_addr, obj);
|
||||||
else
|
else if (obj)
|
||||||
vpip_attach_to_current_scope(obj);
|
vpip_attach_to_current_scope(obj);
|
||||||
|
|
||||||
free(label);
|
free(label);
|
||||||
|
|
@ -186,11 +188,11 @@ static void __compile_net(char*label, char*name,
|
||||||
|
|
||||||
void compile_net(char*label, char*name,
|
void compile_net(char*label, char*name,
|
||||||
int msb, int lsb,
|
int msb, int lsb,
|
||||||
bool signed_flag, bool net8_flag,
|
bool signed_flag, bool net8_flag, bool local_flag,
|
||||||
unsigned argc, struct symb_s*argv)
|
unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
__compile_net(label, name, 0, 0,
|
__compile_net(label, name, 0, 0,
|
||||||
msb, lsb, signed_flag, net8_flag,
|
msb, lsb, signed_flag, net8_flag, local_flag,
|
||||||
argc, argv);
|
argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,7 +202,7 @@ void compile_netw(char*label, char*array_label, unsigned long array_addr,
|
||||||
unsigned argc, struct symb_s*argv)
|
unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
__compile_net(label, 0, array_label, array_addr,
|
__compile_net(label, 0, array_label, array_addr,
|
||||||
msb, lsb, signed_flag, net8_flag,
|
msb, lsb, signed_flag, net8_flag, false,
|
||||||
argc, argv);
|
argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue