Skip to content

Commit f9c1c02

Browse files
author
steve
committed
Add support for -v flag in command file.
1 parent 26f47c2 commit f9c1c02

File tree

10 files changed

+98
-23
lines changed

10 files changed

+98
-23
lines changed

Module.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1818
*/
1919
#ifdef HAVE_CVS_IDENT
20-
#ident "$Id: Module.cc,v 1.25 2004/10/04 01:10:51 steve Exp $"
20+
#ident "$Id: Module.cc,v 1.26 2007/04/19 02:52:53 steve Exp $"
2121
#endif
2222

2323
# include "config.h"
@@ -31,6 +31,7 @@
3131
Module::Module(perm_string n)
3232
: name_(n)
3333
{
34+
library_flag = false;
3435
default_nettype = NetNet::NONE;
3536
}
3637

@@ -150,6 +151,9 @@ const list<PProcess*>& Module::get_behaviors() const
150151

151152
/*
152153
* $Log: Module.cc,v $
154+
* Revision 1.26 2007/04/19 02:52:53 steve
155+
* Add support for -v flag in command file.
156+
*
153157
* Revision 1.25 2004/10/04 01:10:51 steve
154158
* Clean up spurious trailing white space.
155159
*

Module.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2020
*/
2121
#ifdef HAVE_CVS_IDENT
22-
#ident "$Id: Module.h,v 1.41 2006/09/23 04:57:19 steve Exp $"
22+
#ident "$Id: Module.h,v 1.42 2007/04/19 02:52:53 steve Exp $"
2323
#endif
2424

2525
# include <list>
@@ -68,6 +68,12 @@ class Module : public LineInfo {
6868
explicit Module(perm_string name);
6969
~Module();
7070

71+
/* Initially false. This is set to true if the module has been
72+
declared as a library module. This makes the module
73+
ineligible for being chosen as an implicit root. It has no
74+
other effect. */
75+
bool library_flag;
76+
7177
NetNet::Type default_nettype;
7278

7379
/* The module has parameters that are evaluated when the
@@ -176,6 +182,9 @@ class Module : public LineInfo {
176182

177183
/*
178184
* $Log: Module.h,v $
185+
* Revision 1.42 2007/04/19 02:52:53 steve
186+
* Add support for -v flag in command file.
187+
*
179188
* Revision 1.41 2006/09/23 04:57:19 steve
180189
* Basic support for specify timing.
181190
*

compiler.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2020
*/
2121
#ifdef HAVE_CVS_IDENT
22-
#ident "$Id: compiler.h,v 1.32 2007/03/07 04:24:59 steve Exp $"
22+
#ident "$Id: compiler.h,v 1.33 2007/04/19 02:52:53 steve Exp $"
2323
#endif
2424

2525
# include <list>
@@ -117,13 +117,20 @@ extern char*ivlpp_string;
117117

118118
extern map<perm_string,unsigned> missing_modules;
119119

120+
/* Files that are library files are in this map. The lexor compares
121+
file names as it processes `line directives, and if the file name
122+
matches an entry in this table, it will turn on the
123+
library_active_flag so that modules know that they are in a
124+
library. */
125+
extern map<string,bool> library_file_map;
126+
120127
/*
121128
* the lex_strings are perm_strings made up of tokens from the source
122129
* file. Identifiers are so likely to be used many times that it makes
123130
* much sense to use a StringHeapLex to hold them.
124131
*/
125132
extern StringHeapLex lex_strings;
126-
133+
extern StringHeap misc_strings;
127134

128135
/*
129136
* system task/function listings.
@@ -145,6 +152,9 @@ extern int load_sys_func_table(const char*path);
145152

146153
/*
147154
* $Log: compiler.h,v $
155+
* Revision 1.33 2007/04/19 02:52:53 steve
156+
* Add support for -v flag in command file.
157+
*
148158
* Revision 1.32 2007/03/07 04:24:59 steve
149159
* Make integer width controllable.
150160
*

driver/cfparse.y

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1919
*/
2020
#ifdef HAVE_CVS_IDENT
21-
#ident "$Id: cfparse.y,v 1.11 2007/03/07 04:24:59 steve Exp $"
21+
#ident "$Id: cfparse.y,v 1.12 2007/04/19 02:52:53 steve Exp $"
2222
#endif
2323

2424

@@ -84,7 +84,7 @@ item
8484
: TOK_STRING
8585
{ char*tmp = substitutions($1);
8686
translate_file_name(tmp);
87-
process_file_name(tmp);
87+
process_file_name(tmp, 0);
8888
free($1);
8989
free(tmp);
9090
}
@@ -99,9 +99,7 @@ item
9999
| TOK_Dv TOK_STRING
100100
{ char*tmp = substitutions($2);
101101
translate_file_name(tmp);
102-
process_file_name(tmp);
103-
fprintf(stderr, "%s:%u: Ignoring -v in front of %s\n",
104-
@1.text, @1.first_line, $2);
102+
process_file_name(tmp, 1);
105103
free($2);
106104
free(tmp);
107105
}

driver/globals.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2020
*/
2121
#ifdef HAVE_CVS_IDENT
22-
#ident "$Id: globals.h,v 1.20 2007/03/07 04:24:59 steve Exp $"
22+
#ident "$Id: globals.h,v 1.21 2007/04/19 02:52:53 steve Exp $"
2323
#endif
2424

2525
# include <stddef.h>
@@ -56,7 +56,7 @@ extern unsigned integer_width;
5656
extern char* substitutions(const char*str);
5757

5858
/* Add the name to the list of source files. */
59-
extern void process_file_name(const char*name);
59+
extern void process_file_name(const char*name, int lib_flag);
6060

6161
/* Add the name to the list of library directories. */
6262
extern void process_library_switch(const char*name);
@@ -80,6 +80,9 @@ extern char* library_flags2;
8080

8181
/*
8282
* $Log: globals.h,v $
83+
* Revision 1.21 2007/04/19 02:52:53 steve
84+
* Add support for -v flag in command file.
85+
*
8386
* Revision 1.20 2007/03/07 04:24:59 steve
8487
* Make integer width controllable.
8588
*

driver/main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1818
*/
1919
#ifdef HAVE_CVS_IDENT
20-
#ident "$Id: main.c,v 1.74 2007/04/18 03:23:38 steve Exp $"
20+
#ident "$Id: main.c,v 1.75 2007/04/19 02:52:53 steve Exp $"
2121
#endif
2222

2323
# include "config.h"
@@ -403,14 +403,16 @@ void process_define(const char*name)
403403
* .sft suffix, and if so pass that as a sys_func file. Otherwise, it
404404
* is a Verilog source file to be written into the file list.
405405
*/
406-
void process_file_name(const char*name)
406+
void process_file_name(const char*name, int lib_flag)
407407
{
408408
if (strlen(name) > 4 && strcasecmp(".sft", name+strlen(name)-4) == 0) {
409409
fprintf(iconfig_file,"sys_func:%s\n", name);
410410

411411
} else {
412412
fprintf(source_file, "%s\n", name);
413413
source_count += 1;
414+
if (lib_flag)
415+
fprintf(iconfig_file,"library_file:%s\n", name);
414416
}
415417
}
416418

@@ -707,7 +709,7 @@ int main(int argc, char **argv)
707709
/* Finally, process all the remaining words on the command
708710
line as file names. */
709711
for (idx = optind ; idx < argc ; idx += 1)
710-
process_file_name(argv[idx]);
712+
process_file_name(argv[idx], 0);
711713

712714

713715
fclose(source_file);
@@ -785,6 +787,9 @@ int main(int argc, char **argv)
785787

786788
/*
787789
* $Log: main.c,v $
790+
* Revision 1.75 2007/04/19 02:52:53 steve
791+
* Add support for -v flag in command file.
792+
*
788793
* Revision 1.74 2007/04/18 03:23:38 steve
789794
* Add support for multiple command files. (Cary R.)
790795
*

lexor.lex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2222
*/
2323
#ifdef HAVE_CVS_IDENT
24-
#ident "$Id: lexor.lex,v 1.94 2007/02/09 05:19:04 steve Exp $"
24+
#ident "$Id: lexor.lex,v 1.95 2007/04/19 02:52:53 steve Exp $"
2525
#endif
2626

2727
# include "config.h"
@@ -53,6 +53,7 @@ extern YYLTYPE yylloc;
5353
struct file_name_cell {
5454
const char*text;
5555
struct file_name_cell*next;
56+
bool library_flag;
5657
};
5758

5859
static struct file_name_cell*file_names = 0;
@@ -72,6 +73,13 @@ static const char* set_file_name(char*text)
7273
cur = new struct file_name_cell;
7374
cur->text = text;
7475
cur->next = file_names;
76+
77+
/* Check this file name with the list of library file
78+
names. If there is a match, then turn on the
79+
pform_library_flag. This is how the parser knows that
80+
modules declared in this file are library modules. */
81+
cur->library_flag = library_file_map[cur->text];
82+
pform_library_flag = cur->library_flag;
7583
return text;
7684
}
7785

main.cc

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const char COPYRIGHT[] =
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2020
*/
2121
#ifdef HAVE_CVS_IDENT
22-
#ident "$Id: main.cc,v 1.94 2007/03/07 04:24:59 steve Exp $"
22+
#ident "$Id: main.cc,v 1.95 2007/04/19 02:52:53 steve Exp $"
2323
#endif
2424

2525
# include "config.h"
@@ -94,6 +94,7 @@ map<string,const char*> flags;
9494
char*vpi_module_list = 0;
9595

9696
map<perm_string,unsigned> missing_modules;
97+
map<string,bool> library_file_map;
9798

9899
list<const char*> library_suff;
99100

@@ -283,6 +284,11 @@ static void parm_to_flagmap(const string&flag)
283284
* This specifies the width of integer variables. (that is,
284285
* variables declared using the "integer" keyword.)
285286
*
287+
* library_file:<path>
288+
* This marks that a source file with the given path is a
289+
* library. Any modules in that file are marked as library
290+
* modules.
291+
*
286292
* module:<name>
287293
* Load a VPI module.
288294
*
@@ -376,6 +382,10 @@ static void read_iconfig_file(const char*ipath)
376382
} else if (strcmp(buf, "iwidth") == 0) {
377383
integer_width = strtoul(cp,0,10);
378384

385+
} else if (strcmp(buf, "library_file") == 0) {
386+
const char* path = strdup(cp);
387+
library_file_map[path] = true;
388+
379389
} else if (strcmp(buf,"module") == 0) {
380390
if (vpi_module_list == 0) {
381391
vpi_module_list = strdup(cp);
@@ -643,11 +653,20 @@ int main(int argc, char*argv[])
643653
for (mod = pform_modules.begin()
644654
; mod != pform_modules.end()
645655
; mod++) {
646-
if (mentioned_p[(*mod).second->mod_name()] == false) {
647-
if (verbose_flag)
648-
cout << " " << (*mod).second->mod_name();
649-
roots.push_back((*mod).second->mod_name());
650-
}
656+
657+
/* Don't choose library modules. */
658+
if ((*mod).second->library_flag)
659+
continue;
660+
661+
/* Don't choose modules instantiated in other
662+
modules. */
663+
if (mentioned_p[(*mod).second->mod_name()])
664+
continue;
665+
666+
/* What's left might as well be chosen as a root. */
667+
if (verbose_flag)
668+
cout << " " << (*mod).second->mod_name();
669+
roots.push_back((*mod).second->mod_name());
651670
}
652671
if (verbose_flag)
653672
cout << endl;
@@ -796,6 +815,9 @@ int main(int argc, char*argv[])
796815

797816
/*
798817
* $Log: main.cc,v $
818+
* Revision 1.95 2007/04/19 02:52:53 steve
819+
* Add support for -v flag in command file.
820+
*
799821
* Revision 1.94 2007/03/07 04:24:59 steve
800822
* Make integer width controllable.
801823
*

pform.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1818
*/
1919
#ifdef HAVE_CVS_IDENT
20-
#ident "$Id: pform.cc,v 1.143 2007/04/13 02:34:35 steve Exp $"
20+
#ident "$Id: pform.cc,v 1.144 2007/04/19 02:52:53 steve Exp $"
2121
#endif
2222

2323
# include "config.h"
@@ -50,6 +50,9 @@ extern int VLparse();
5050
exactly one module currently being parsed, since verilog does not
5151
allow nested module definitions. */
5252
static Module*pform_cur_module = 0;
53+
54+
bool pform_library_flag = false;
55+
5356
/* increment this for generate schemes within a module, and set it
5457
to zero when a new module starts. */
5558
static unsigned scope_generate_counter = 1;
@@ -242,6 +245,7 @@ void pform_startmodule(const char*name, const char*file, unsigned lineno,
242245

243246
pform_cur_module->set_file(file);
244247
pform_cur_module->set_lineno(lineno);
248+
pform_cur_module->library_flag = pform_library_flag;
245249

246250
/* The generate scheme numbering starts with *1*, not
247251
zero. That's just the way it is, thanks to the standard. */
@@ -1765,6 +1769,9 @@ int pform_parse(const char*path, FILE*file)
17651769

17661770
/*
17671771
* $Log: pform.cc,v $
1772+
* Revision 1.144 2007/04/19 02:52:53 steve
1773+
* Add support for -v flag in command file.
1774+
*
17681775
* Revision 1.143 2007/04/13 02:34:35 steve
17691776
* Parse edge sensitive paths without edge specifier.
17701777
*

pform.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
2020
*/
2121
#ifdef HAVE_CVS_IDENT
22-
#ident "$Id: pform.h,v 1.89 2007/04/13 02:34:35 steve Exp $"
22+
#ident "$Id: pform.h,v 1.90 2007/04/19 02:52:53 steve Exp $"
2323
#endif
2424

2525
# include "netlist.h"
@@ -69,6 +69,12 @@ extern enum MIN_TYP_MAX { MIN, TYP, MAX } min_typ_max_flag;
6969
extern unsigned min_typ_max_warn;
7070
PExpr* pform_select_mtm_expr(PExpr*min, PExpr*typ, PExpr*max);
7171

72+
/*
73+
* This flag is true if the lexor thinks we are in a library source
74+
* file.
75+
*/
76+
extern bool pform_library_flag;
77+
7278
/*
7379
* These type are lexical types -- that is, types that are used as
7480
* lexical values to decorate the parse tree during parsing. They are
@@ -334,6 +340,9 @@ extern void pform_dump(ostream&out, Module*mod);
334340

335341
/*
336342
* $Log: pform.h,v $
343+
* Revision 1.90 2007/04/19 02:52:53 steve
344+
* Add support for -v flag in command file.
345+
*
337346
* Revision 1.89 2007/04/13 02:34:35 steve
338347
* Parse edge sensitive paths without edge specifier.
339348
*

0 commit comments

Comments
 (0)