1998-11-04 00:28:49 +01:00
|
|
|
#ifndef __pform_H
|
|
|
|
|
#define __pform_H
|
|
|
|
|
/*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com)
|
1998-11-04 00:28:49 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2000-02-23 03:56:53 +01:00
|
|
|
#if !defined(WINNT) && !defined(macintosh)
|
2000-03-12 18:09:40 +01:00
|
|
|
#ident "$Id: pform.h,v 1.37 2000/03/12 17:09:41 steve Exp $"
|
1998-11-04 00:28:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "netlist.h"
|
2000-01-09 06:50:48 +01:00
|
|
|
# include "named.h"
|
1998-11-04 00:28:49 +01:00
|
|
|
# include "Module.h"
|
|
|
|
|
# include "Statement.h"
|
|
|
|
|
# include "PGate.h"
|
|
|
|
|
# include "PExpr.h"
|
1999-07-03 04:12:51 +02:00
|
|
|
# include "PTask.h"
|
1998-11-25 03:35:53 +01:00
|
|
|
# include "PUdp.h"
|
1998-11-04 00:28:49 +01:00
|
|
|
# include "PWire.h"
|
|
|
|
|
# include "verinum.h"
|
|
|
|
|
# include <iostream.h>
|
|
|
|
|
# include <string>
|
|
|
|
|
# include <list>
|
|
|
|
|
# include <stdio.h>
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* These classes implement the parsed form (P-form for short) of the
|
|
|
|
|
* original verilog source. the parser generates the pform for the
|
|
|
|
|
* convenience of later processing steps.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Wire objects represent the named wires (of various flavor) declared
|
|
|
|
|
* in the source.
|
|
|
|
|
*
|
|
|
|
|
* Gate objects are the functional modules that are connected together
|
|
|
|
|
* by wires.
|
|
|
|
|
*
|
|
|
|
|
* Wires and gates, connected by joints, represent a netlist. The
|
|
|
|
|
* netlist is therefore a representation of the desired circuit.
|
|
|
|
|
*/
|
|
|
|
|
class PGate;
|
|
|
|
|
class PExpr;
|
1999-06-02 17:38:46 +02:00
|
|
|
struct vlltype;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* These type are lexical types -- that is, types that are used as
|
|
|
|
|
* lexical values to decorate the parse tree during parsing. They are
|
|
|
|
|
* not in any way preserved once parsing is done.
|
|
|
|
|
*/
|
|
|
|
|
|
1999-05-29 04:36:17 +02:00
|
|
|
/* This is information about port name information for named port
|
|
|
|
|
connections. */
|
2000-01-09 06:50:48 +01:00
|
|
|
|
|
|
|
|
typedef struct named<PExpr*> portname_t;
|
|
|
|
|
|
|
|
|
|
struct parmvalue_t {
|
|
|
|
|
svector<PExpr*>*by_order;
|
2000-01-10 23:16:24 +01:00
|
|
|
svector<portname_t*>*by_name;
|
1999-05-29 04:36:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* The lgate is gate instantiation information. */
|
1998-11-04 00:28:49 +01:00
|
|
|
struct lgate {
|
1999-05-06 06:37:17 +02:00
|
|
|
lgate(int =0)
|
1999-05-29 04:36:17 +02:00
|
|
|
: parms(0), parms_by_name(0), lineno(0)
|
1999-02-15 03:06:15 +01:00
|
|
|
{ range[0] = 0;
|
|
|
|
|
range[1] = 0;
|
|
|
|
|
}
|
1999-01-25 06:45:56 +01:00
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
string name;
|
1999-05-10 02:16:57 +02:00
|
|
|
svector<PExpr*>*parms;
|
1999-05-29 04:36:17 +02:00
|
|
|
svector<portname_t*>*parms_by_name;
|
1999-01-25 06:45:56 +01:00
|
|
|
|
1999-02-15 03:06:15 +01:00
|
|
|
PExpr*range[2];
|
|
|
|
|
|
1999-01-25 06:45:56 +01:00
|
|
|
string file;
|
|
|
|
|
unsigned lineno;
|
1998-11-04 00:28:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The parser uses startmodule and endmodule together to build up a
|
|
|
|
|
* module as it parses it. The startmodule tells the pform code that a
|
|
|
|
|
* module has been noticed in the source file and the following events
|
|
|
|
|
* are to apply to the scope of that module. The endmodule causes the
|
|
|
|
|
* pform to close up and finish the named module.
|
|
|
|
|
*/
|
1999-08-03 06:14:49 +02:00
|
|
|
extern void pform_startmodule(const string&, svector<Module::port_t*>*);
|
1998-11-04 00:28:49 +01:00
|
|
|
extern void pform_endmodule(const string&);
|
|
|
|
|
|
1999-07-10 03:03:18 +02:00
|
|
|
extern void pform_make_udp(const char*name, list<string>*parms,
|
1999-06-12 22:35:27 +02:00
|
|
|
svector<PWire*>*decl, list<string>*table,
|
1998-11-25 03:35:53 +01:00
|
|
|
Statement*init);
|
|
|
|
|
|
1999-06-24 06:24:18 +02:00
|
|
|
/*
|
|
|
|
|
* Enter/exit name scopes.
|
|
|
|
|
*/
|
|
|
|
|
extern void pform_push_scope(const string&name);
|
|
|
|
|
extern void pform_pop_scope();
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
|
|
|
|
* The makewire functions announce to the pform code new wires. These
|
|
|
|
|
* go into a module that is currently opened.
|
|
|
|
|
*/
|
1999-06-02 17:38:46 +02:00
|
|
|
extern void pform_makewire(const struct vlltype&li, const string&name,
|
|
|
|
|
NetNet::Type type = NetNet::IMPLICIT);
|
|
|
|
|
extern void pform_makewire(const struct vlltype&li, const list<string>*names,
|
|
|
|
|
NetNet::Type type);
|
1999-12-30 20:06:14 +01:00
|
|
|
extern void pform_make_reginit(const struct vlltype&li,
|
|
|
|
|
const string&name, PExpr*expr);
|
1998-11-04 00:28:49 +01:00
|
|
|
extern void pform_set_port_type(list<string>*names, NetNet::PortType);
|
1999-05-10 02:16:57 +02:00
|
|
|
extern void pform_set_net_range(list<string>*names, const svector<PExpr*>*);
|
1999-04-19 03:59:36 +02:00
|
|
|
extern void pform_set_reg_idx(const string&name, PExpr*l, PExpr*r);
|
1999-06-06 22:45:38 +02:00
|
|
|
extern void pform_set_reg_integer(list<string>*names);
|
1999-07-03 04:12:51 +02:00
|
|
|
extern void pform_set_task(const string&, PTask*);
|
1999-08-26 00:22:41 +02:00
|
|
|
extern void pform_set_function(const string&, svector<PExpr*>*, PFunction*);
|
1998-11-23 01:20:22 +01:00
|
|
|
extern void pform_set_attrib(const string&name, const string&key,
|
|
|
|
|
const string&value);
|
1998-12-01 01:42:13 +01:00
|
|
|
extern void pform_set_type_attrib(const string&name, const string&key,
|
|
|
|
|
const string&value);
|
1999-02-21 18:01:57 +01:00
|
|
|
extern void pform_set_parameter(const string&name, PExpr*expr);
|
2000-03-12 18:09:40 +01:00
|
|
|
extern void pform_set_localparam(const string&name, PExpr*expr);
|
2000-03-08 05:36:53 +01:00
|
|
|
extern void pform_set_defparam(const string&name, PExpr*expr);
|
1999-01-25 06:45:56 +01:00
|
|
|
extern PProcess* pform_make_behavior(PProcess::Type, Statement*);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-06-12 22:35:27 +02:00
|
|
|
extern svector<PWire*>* pform_make_udp_input_ports(list<string>*);
|
1998-11-25 03:35:53 +01:00
|
|
|
|
1999-05-16 07:08:42 +02:00
|
|
|
extern bool pform_expression_is_constant(const PExpr*);
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
|
|
|
|
* The makegate function creates a new gate (which need not have a
|
|
|
|
|
* name) and connects it to the specified wires.
|
|
|
|
|
*/
|
|
|
|
|
extern void pform_makegates(PGBuiltin::Type type,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*delay,
|
1999-05-06 06:37:17 +02:00
|
|
|
svector<lgate>*gates);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-08-23 18:48:39 +02:00
|
|
|
extern void pform_make_modgates(const string&type,
|
2000-01-09 06:50:48 +01:00
|
|
|
struct parmvalue_t*overrides,
|
1999-08-23 18:48:39 +02:00
|
|
|
svector<lgate>*gates);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
/* Make a continuous assignment node, with optional bit- or part- select. */
|
1999-08-01 18:34:50 +02:00
|
|
|
extern PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval,
|
|
|
|
|
svector<PExpr*>*delays);
|
1999-08-27 17:08:37 +02:00
|
|
|
extern void pform_make_pgassign_list(svector<PExpr*>*alist,
|
|
|
|
|
svector<PExpr*>*del,
|
|
|
|
|
const string& text,
|
|
|
|
|
unsigned lineno);
|
1999-07-24 04:11:19 +02:00
|
|
|
|
|
|
|
|
/* Given a port type and a list of names, make a list of wires that
|
|
|
|
|
can be used as task port information. */
|
|
|
|
|
extern svector<PWire*>*pform_make_task_ports(NetNet::PortType pt,
|
|
|
|
|
const svector<PExpr*>*range,
|
1999-09-10 07:02:09 +02:00
|
|
|
const list<string>*names,
|
|
|
|
|
const string& file,
|
|
|
|
|
unsigned lineno);
|
1999-07-24 04:11:19 +02:00
|
|
|
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/*
|
|
|
|
|
* These are functions that the outside-the-parser code uses the do
|
|
|
|
|
* interesting things to the verilog. The parse function reads and
|
|
|
|
|
* parses the source file and places all the modules it finds into the
|
|
|
|
|
* mod list. The dump function dumps a module to the output stream.
|
|
|
|
|
*/
|
1998-12-09 05:02:47 +01:00
|
|
|
extern int pform_parse(const char*path, map<string,Module*>&mod,
|
1998-12-01 01:42:13 +01:00
|
|
|
map<string,PUdp*>&prim);
|
1998-11-04 00:28:49 +01:00
|
|
|
extern void pform_dump(ostream&out, Module*mod);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: pform.h,v $
|
2000-03-12 18:09:40 +01:00
|
|
|
* Revision 1.37 2000/03/12 17:09:41 steve
|
|
|
|
|
* Support localparam.
|
|
|
|
|
*
|
2000-03-08 05:36:53 +01:00
|
|
|
* Revision 1.36 2000/03/08 04:36:54 steve
|
|
|
|
|
* Redesign the implementation of scopes and parameters.
|
|
|
|
|
* I now generate the scopes and notice the parameters
|
|
|
|
|
* in a separate pass over the pform. Once the scopes
|
|
|
|
|
* are generated, I can process overrides and evalutate
|
|
|
|
|
* paremeters before elaboration begins.
|
|
|
|
|
*
|
2000-02-23 03:56:53 +01:00
|
|
|
* Revision 1.35 2000/02/23 02:56:55 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
2000-01-10 23:16:24 +01:00
|
|
|
* Revision 1.34 2000/01/10 22:16:24 steve
|
|
|
|
|
* minor type syntax fix for stubborn C++ compilers.
|
|
|
|
|
*
|
2000-01-09 06:50:48 +01:00
|
|
|
* Revision 1.33 2000/01/09 05:50:49 steve
|
|
|
|
|
* Support named parameter override lists.
|
|
|
|
|
*
|
1999-12-30 20:06:14 +01:00
|
|
|
* Revision 1.32 1999/12/30 19:06:14 steve
|
|
|
|
|
* Support reg initial assignment syntax.
|
|
|
|
|
*
|
1999-09-10 07:02:09 +02:00
|
|
|
* Revision 1.31 1999/09/10 05:02:09 steve
|
|
|
|
|
* Handle integers at task parameters.
|
|
|
|
|
*
|
1999-08-27 17:08:37 +02:00
|
|
|
* Revision 1.30 1999/08/27 15:08:37 steve
|
|
|
|
|
* continuous assignment lists.
|
|
|
|
|
*
|
1999-08-26 00:22:41 +02:00
|
|
|
* Revision 1.29 1999/08/25 22:22:41 steve
|
|
|
|
|
* elaborate some aspects of functions.
|
|
|
|
|
*
|
1999-08-23 18:48:39 +02:00
|
|
|
* Revision 1.28 1999/08/23 16:48:39 steve
|
|
|
|
|
* Parameter overrides support from Peter Monta
|
|
|
|
|
* AND and XOR support wide expressions.
|
|
|
|
|
*
|
1999-08-03 06:14:49 +02:00
|
|
|
* Revision 1.27 1999/08/03 04:14:49 steve
|
|
|
|
|
* Parse into pform arbitrarily complex module
|
|
|
|
|
* port declarations.
|
|
|
|
|
*
|
1999-08-01 18:34:50 +02:00
|
|
|
* Revision 1.26 1999/08/01 16:34:50 steve
|
|
|
|
|
* Parse and elaborate rise/fall/decay times
|
|
|
|
|
* for gates, and handle the rules for partial
|
|
|
|
|
* lists of times.
|
|
|
|
|
*
|
1999-07-31 21:14:47 +02:00
|
|
|
* Revision 1.25 1999/07/31 19:14:47 steve
|
|
|
|
|
* Add functions up to elaboration (Ed Carter)
|
|
|
|
|
*
|
1999-07-24 04:11:19 +02:00
|
|
|
* Revision 1.24 1999/07/24 02:11:20 steve
|
|
|
|
|
* Elaborate task input ports.
|
|
|
|
|
*
|
1999-07-10 03:03:18 +02:00
|
|
|
* Revision 1.23 1999/07/10 01:03:18 steve
|
|
|
|
|
* remove string from lexical phase.
|
|
|
|
|
*
|
1999-07-03 04:12:51 +02:00
|
|
|
* Revision 1.22 1999/07/03 02:12:52 steve
|
|
|
|
|
* Elaborate user defined tasks.
|
|
|
|
|
*
|
1999-06-24 06:24:18 +02:00
|
|
|
* Revision 1.21 1999/06/24 04:24:18 steve
|
|
|
|
|
* Handle expression widths for EEE and NEE operators,
|
|
|
|
|
* add named blocks and scope handling,
|
|
|
|
|
* add registers declared in named blocks.
|
|
|
|
|
*
|
1999-06-15 05:44:53 +02:00
|
|
|
* Revision 1.20 1999/06/15 03:44:53 steve
|
|
|
|
|
* Get rid of the STL vector template.
|
|
|
|
|
*
|
1999-06-12 22:35:27 +02:00
|
|
|
* Revision 1.19 1999/06/12 20:35:27 steve
|
|
|
|
|
* parse more verilog.
|
|
|
|
|
*
|
1999-06-06 22:45:38 +02:00
|
|
|
* Revision 1.18 1999/06/06 20:45:39 steve
|
|
|
|
|
* Add parse and elaboration of non-blocking assignments,
|
|
|
|
|
* Replace list<PCase::Item*> with an svector version,
|
|
|
|
|
* Add integer support.
|
|
|
|
|
*
|
1999-06-02 17:38:46 +02:00
|
|
|
* Revision 1.17 1999/06/02 15:38:46 steve
|
|
|
|
|
* Line information with nets.
|
|
|
|
|
*
|
1999-05-29 04:36:17 +02:00
|
|
|
* Revision 1.16 1999/05/29 02:36:17 steve
|
|
|
|
|
* module parameter bind by name.
|
|
|
|
|
*
|
1999-05-20 06:31:45 +02:00
|
|
|
* Revision 1.15 1999/05/20 04:31:45 steve
|
|
|
|
|
* Much expression parsing work,
|
|
|
|
|
* mark continuous assigns with source line info,
|
|
|
|
|
* replace some assertion failures with Sorry messages.
|
|
|
|
|
*
|
1999-05-16 07:08:42 +02:00
|
|
|
* Revision 1.14 1999/05/16 05:08:42 steve
|
|
|
|
|
* Redo constant expression detection to happen
|
|
|
|
|
* after parsing.
|
|
|
|
|
*
|
|
|
|
|
* Parse more operators and expressions.
|
|
|
|
|
*
|
1999-05-10 02:16:57 +02:00
|
|
|
* Revision 1.13 1999/05/10 00:16:58 steve
|
|
|
|
|
* Parse and elaborate the concatenate operator
|
|
|
|
|
* in structural contexts, Replace vector<PExpr*>
|
|
|
|
|
* and list<PExpr*> with svector<PExpr*>, evaluate
|
|
|
|
|
* constant expressions with parameters, handle
|
|
|
|
|
* memories as lvalues.
|
|
|
|
|
*
|
|
|
|
|
* Parse task declarations, integer types.
|
|
|
|
|
*
|
1999-05-07 06:26:49 +02:00
|
|
|
* Revision 1.12 1999/05/07 04:26:49 steve
|
|
|
|
|
* Parse more complex continuous assign lvalues.
|
|
|
|
|
*
|
1999-05-06 06:37:17 +02:00
|
|
|
* Revision 1.11 1999/05/06 04:37:17 steve
|
|
|
|
|
* Get rid of list<lgate> types.
|
|
|
|
|
*
|
1999-05-06 06:09:28 +02:00
|
|
|
* Revision 1.10 1999/05/06 04:09:28 steve
|
|
|
|
|
* Parse more constant expressions.
|
|
|
|
|
*
|
1999-04-19 03:59:36 +02:00
|
|
|
* Revision 1.9 1999/04/19 01:59:37 steve
|
|
|
|
|
* Add memories to the parse and elaboration phases.
|
|
|
|
|
*
|
1999-02-21 18:01:57 +01:00
|
|
|
* Revision 1.8 1999/02/21 17:01:57 steve
|
|
|
|
|
* Add support for module parameters.
|
|
|
|
|
*
|
1999-02-15 03:06:15 +01:00
|
|
|
* Revision 1.7 1999/02/15 02:06:15 steve
|
|
|
|
|
* Elaborate gate ranges.
|
|
|
|
|
*
|
1999-01-25 06:45:56 +01:00
|
|
|
* Revision 1.6 1999/01/25 05:45:56 steve
|
|
|
|
|
* Add the LineInfo class to carry the source file
|
|
|
|
|
* location of things. PGate, Statement and PProcess.
|
|
|
|
|
*
|
|
|
|
|
* elaborate handles module parameter mismatches,
|
|
|
|
|
* missing or incorrect lvalues for procedural
|
|
|
|
|
* assignment, and errors are propogated to the
|
|
|
|
|
* top of the elaboration call tree.
|
|
|
|
|
*
|
|
|
|
|
* Attach line numbers to processes, gates and
|
|
|
|
|
* assignment statements.
|
|
|
|
|
*
|
1998-12-09 05:02:47 +01:00
|
|
|
* Revision 1.5 1998/12/09 04:02:47 steve
|
|
|
|
|
* Support the include directive.
|
|
|
|
|
*
|
1998-12-01 01:42:13 +01:00
|
|
|
* Revision 1.4 1998/12/01 00:42:14 steve
|
|
|
|
|
* Elaborate UDP devices,
|
|
|
|
|
* Support UDP type attributes, and
|
|
|
|
|
* pass those attributes to nodes that
|
|
|
|
|
* are instantiated by elaboration,
|
|
|
|
|
* Put modules into a map instead of
|
|
|
|
|
* a simple list.
|
|
|
|
|
*
|
1998-11-25 03:35:53 +01:00
|
|
|
* Revision 1.3 1998/11/25 02:35:53 steve
|
|
|
|
|
* Parse UDP primitives all the way to pform.
|
|
|
|
|
*
|
1998-11-23 01:20:22 +01:00
|
|
|
* Revision 1.2 1998/11/23 00:20:23 steve
|
|
|
|
|
* NetAssign handles lvalues as pin links
|
|
|
|
|
* instead of a signal pointer,
|
|
|
|
|
* Wire attributes added,
|
|
|
|
|
* Ability to parse UDP descriptions added,
|
|
|
|
|
* XNF generates EXT records for signals with
|
|
|
|
|
* the PAD attribute.
|
|
|
|
|
*
|
1998-11-04 00:28:49 +01:00
|
|
|
* Revision 1.1 1998/11/03 23:29:04 steve
|
|
|
|
|
* Introduce verilog to CVS.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#endif
|