1998-11-04 00:28:49 +01:00
|
|
|
#ifndef __PGate_H
|
|
|
|
|
#define __PGate_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)
|
2001-10-19 03:55:32 +02:00
|
|
|
#ident "$Id: PGate.h,v 1.20 2001/10/19 01:55:32 steve Exp $"
|
1998-11-04 00:28:49 +01:00
|
|
|
#endif
|
|
|
|
|
|
1999-05-10 02:16:57 +02:00
|
|
|
# include "svector.h"
|
2000-01-09 06:50:48 +01:00
|
|
|
# include "named.h"
|
1999-01-25 06:45:56 +01:00
|
|
|
# include "LineInfo.h"
|
1999-09-04 21:11:45 +02:00
|
|
|
# include "PDelays.h"
|
1999-12-11 06:45:41 +01:00
|
|
|
# include <map>
|
|
|
|
|
# include <string>
|
1998-11-04 00:28:49 +01:00
|
|
|
class PExpr;
|
1998-12-01 01:42:13 +01:00
|
|
|
class PUdp;
|
1998-11-04 00:28:49 +01:00
|
|
|
class Design;
|
2000-03-08 05:36:53 +01:00
|
|
|
class NetScope;
|
1999-02-15 03:06:15 +01:00
|
|
|
class Module;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A PGate represents a Verilog gate. The gate has a name and other
|
|
|
|
|
* properties, and a set of pins that connect to wires. It is known at
|
|
|
|
|
* the time a gate is constructed how many pins the gate has.
|
|
|
|
|
*
|
|
|
|
|
* This pins of a gate are connected to expressions. The elaboration
|
|
|
|
|
* step will need to convert expressions to a network of gates in
|
|
|
|
|
* order to elaborate expression inputs, but that can easily be done.
|
2000-05-06 17:41:56 +02:00
|
|
|
*
|
|
|
|
|
* The PGate base class also carries the strength0 and strength1
|
|
|
|
|
* strengths for those gates where the driver[s] can be described by a
|
|
|
|
|
* single strength pair. There is a strength of the 0 drive, and a
|
|
|
|
|
* strength of the 1 drive.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
1999-01-25 06:45:56 +01:00
|
|
|
class PGate : public LineInfo {
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
public:
|
2000-05-06 17:41:56 +02:00
|
|
|
enum strength_t { HIGHZ, WEAK, PULL, STRONG, SUPPLY };
|
|
|
|
|
|
1999-08-01 18:34:50 +02:00
|
|
|
explicit PGate(const string&name, svector<PExpr*>*pins,
|
|
|
|
|
const svector<PExpr*>*del);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-08-01 18:34:50 +02:00
|
|
|
explicit PGate(const string&name, svector<PExpr*>*pins,
|
|
|
|
|
PExpr*del);
|
|
|
|
|
|
|
|
|
|
explicit PGate(const string&name, svector<PExpr*>*pins);
|
|
|
|
|
|
|
|
|
|
virtual ~PGate();
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
const string& get_name() const { return name_; }
|
|
|
|
|
|
1999-08-01 23:18:55 +02:00
|
|
|
void eval_delays(Design*des, const string&path,
|
|
|
|
|
unsigned long&rise_time,
|
|
|
|
|
unsigned long&fall_time,
|
|
|
|
|
unsigned long&decay_time) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-05-29 04:36:17 +02:00
|
|
|
unsigned pin_count() const { return pins_? pins_->count() : 0; }
|
|
|
|
|
const PExpr*pin(unsigned idx) const { return (*pins_)[idx]; }
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2000-05-06 17:41:56 +02:00
|
|
|
strength_t strength0() const;
|
|
|
|
|
strength_t strength1() const;
|
|
|
|
|
|
|
|
|
|
void strength0(strength_t);
|
|
|
|
|
void strength1(strength_t);
|
|
|
|
|
|
1999-12-11 06:45:41 +01:00
|
|
|
map<string,string> attributes;
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
virtual void elaborate(Design*des, const string&path) const;
|
2000-03-08 05:36:53 +01:00
|
|
|
virtual void elaborate_scope(Design*des, NetScope*sc) const;
|
2000-05-02 18:27:38 +02:00
|
|
|
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
protected:
|
1999-05-29 04:36:17 +02:00
|
|
|
const svector<PExpr*>* get_pins() const { return pins_; }
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
void dump_pins(ostream&out) const;
|
1999-08-01 18:34:50 +02:00
|
|
|
void dump_delays(ostream&out) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const string name_;
|
1999-09-04 21:11:45 +02:00
|
|
|
PDelays delay_;
|
1999-05-29 04:36:17 +02:00
|
|
|
svector<PExpr*>*pins_;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2000-05-06 17:41:56 +02:00
|
|
|
strength_t str0_, str1_;
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
private: // not implemented
|
|
|
|
|
PGate(const PGate&);
|
|
|
|
|
PGate& operator= (const PGate&);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A continuous assignment has a single output and a single input. The
|
|
|
|
|
input is passed directly to the output. This is different from a
|
|
|
|
|
BUF because elaboration may need to turn this into a vector of
|
|
|
|
|
gates. */
|
|
|
|
|
class PGAssign : public PGate {
|
|
|
|
|
|
|
|
|
|
public:
|
1999-08-01 18:34:50 +02:00
|
|
|
explicit PGAssign(svector<PExpr*>*pins);
|
|
|
|
|
explicit PGAssign(svector<PExpr*>*pins, svector<PExpr*>*dels);
|
|
|
|
|
~PGAssign();
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
void dump(ostream&out) const;
|
|
|
|
|
virtual void elaborate(Design*des, const string&path) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
1999-02-15 03:06:15 +01:00
|
|
|
/*
|
|
|
|
|
* The Builtin class is specifically a gate with one of the builtin
|
|
|
|
|
* types. The parser recognizes these types during parse. These types
|
|
|
|
|
* have special properties that allow them to be treated specially.
|
|
|
|
|
*
|
|
|
|
|
* A PGBuiltin can be grouped into an array of devices. If this is
|
|
|
|
|
* done, the msb_ and lsb_ are set to the indices of the array
|
|
|
|
|
* range. Elaboration causes a gate to be created for each element of
|
|
|
|
|
* the array, and a name will be generated for each gate.
|
|
|
|
|
*/
|
1998-11-04 00:28:49 +01:00
|
|
|
class PGBuiltin : public PGate {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum Type { AND, NAND, OR, NOR, XOR, XNOR, BUF, BUFIF0, BUFIF1,
|
|
|
|
|
NOT, NOTIF0, NOTIF1, PULLDOWN, PULLUP, NMOS, RNMOS,
|
|
|
|
|
PMOS, RPMOS, CMOS, RCMOS, TRAN, RTRAN, TRANIF0,
|
|
|
|
|
TRANIF1, RTRANIF0, RTRANIF1 };
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit PGBuiltin(Type t, const string&name,
|
1999-08-01 18:34:50 +02:00
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
svector<PExpr*>*del);
|
|
|
|
|
explicit PGBuiltin(Type t, const string&name,
|
|
|
|
|
svector<PExpr*>*pins,
|
|
|
|
|
PExpr*del);
|
|
|
|
|
~PGBuiltin();
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
Type type() const { return type_; }
|
1999-02-15 03:06:15 +01:00
|
|
|
void set_range(PExpr*msb, PExpr*lsb);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
virtual void elaborate(Design*, const string&path) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Type type_;
|
1999-02-15 03:06:15 +01:00
|
|
|
|
|
|
|
|
PExpr*msb_;
|
|
|
|
|
PExpr*lsb_;
|
1998-11-04 00:28:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This kind of gate is an instantiation of a module. The stored type
|
1998-12-01 01:42:13 +01:00
|
|
|
* is the name of a module definition somewhere in the pform. This
|
1999-05-29 04:36:17 +02:00
|
|
|
* type also handles UDP devices, because it is generally not known at
|
1998-12-01 01:42:13 +01:00
|
|
|
* parse time whether a name belongs to a module or a UDP.
|
1998-11-04 00:28:49 +01:00
|
|
|
*/
|
|
|
|
|
class PGModule : public PGate {
|
|
|
|
|
|
|
|
|
|
public:
|
1999-05-29 04:36:17 +02:00
|
|
|
// If the binding of ports is by position, this constructor
|
|
|
|
|
// builds everything all at once.
|
|
|
|
|
explicit PGModule(const string&type, const string&name,
|
2000-02-18 06:15:02 +01:00
|
|
|
svector<PExpr*>*pins);
|
1999-05-29 04:36:17 +02:00
|
|
|
|
|
|
|
|
// If the binding of ports is by name, this constructor takes
|
|
|
|
|
// the bindings and stores them for later elaboration.
|
1998-11-04 00:28:49 +01:00
|
|
|
explicit PGModule(const string&type, const string&name,
|
2000-02-18 06:15:02 +01:00
|
|
|
named<PExpr*>*pins, unsigned npins);
|
2000-01-09 06:50:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Parameter overrides can come as an ordered list, or a set
|
|
|
|
|
// of named expressions.
|
2000-02-18 06:15:02 +01:00
|
|
|
void set_parameters(svector<PExpr*>*o);
|
|
|
|
|
void set_parameters(named<PExpr*>*pa, unsigned npa);
|
1999-05-29 04:36:17 +02:00
|
|
|
|
2000-02-18 06:15:02 +01:00
|
|
|
// Modules can be instantiated in ranges. The parser uses this
|
|
|
|
|
// method to pass the range to the pform.
|
|
|
|
|
void set_range(PExpr*msb, PExpr*lsb);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
virtual void dump(ostream&out) const;
|
|
|
|
|
virtual void elaborate(Design*, const string&path) const;
|
2000-03-08 05:36:53 +01:00
|
|
|
virtual void elaborate_scope(Design*des, NetScope*sc) const;
|
2000-05-02 18:27:38 +02:00
|
|
|
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2001-10-19 03:55:32 +02:00
|
|
|
const string get_type();
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
private:
|
|
|
|
|
string type_;
|
1999-08-23 18:48:39 +02:00
|
|
|
svector<PExpr*>*overrides_;
|
2000-01-09 06:50:48 +01:00
|
|
|
named<PExpr*>*pins_;
|
1999-05-29 04:36:17 +02:00
|
|
|
unsigned npins_;
|
1998-12-01 01:42:13 +01:00
|
|
|
|
2000-01-09 06:50:48 +01:00
|
|
|
// These members support parameter override by name
|
|
|
|
|
named<PExpr*>*parms_;
|
|
|
|
|
unsigned nparms_;
|
|
|
|
|
|
2000-02-18 06:15:02 +01:00
|
|
|
// Arrays of modules are give if these are set.
|
|
|
|
|
PExpr*msb_;
|
|
|
|
|
PExpr*lsb_;
|
|
|
|
|
|
1998-12-01 01:42:13 +01:00
|
|
|
void elaborate_mod_(Design*, Module*mod, const string&path) const;
|
2001-04-23 01:09:45 +02:00
|
|
|
void elaborate_udp_(Design*, PUdp *udp, const string&path) const;
|
2000-03-08 05:36:53 +01:00
|
|
|
void elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const;
|
2000-05-02 18:27:38 +02:00
|
|
|
bool elaborate_sig_mod_(Design*des, NetScope*scope, Module*mod) const;
|
1998-11-04 00:28:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: PGate.h,v $
|
2001-10-19 03:55:32 +02:00
|
|
|
* Revision 1.20 2001/10/19 01:55:32 steve
|
|
|
|
|
* Method to get the type_ member
|
|
|
|
|
*
|
2001-04-23 01:09:45 +02:00
|
|
|
* Revision 1.19 2001/04/22 23:09:45 steve
|
|
|
|
|
* More UDP consolidation from Stephan Boettcher.
|
|
|
|
|
*
|
2000-05-06 17:41:56 +02:00
|
|
|
* Revision 1.18 2000/05/06 15:41:56 steve
|
|
|
|
|
* Carry assignment strength to pform.
|
|
|
|
|
*
|
2000-05-02 18:27:38 +02:00
|
|
|
* Revision 1.17 2000/05/02 16:27:38 steve
|
|
|
|
|
* Move signal elaboration to a seperate pass.
|
|
|
|
|
*
|
2000-03-29 06:37:10 +02:00
|
|
|
* Revision 1.16 2000/03/29 04:37:10 steve
|
|
|
|
|
* New and improved combinational primitives.
|
|
|
|
|
*
|
2000-03-08 05:36:53 +01:00
|
|
|
* Revision 1.15 2000/03/08 04:36:53 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.14 2000/02/23 02:56:53 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
2000-02-18 06:15:02 +01:00
|
|
|
* Revision 1.13 2000/02/18 05:15:02 steve
|
|
|
|
|
* Catch module instantiation arrays.
|
|
|
|
|
*
|
2000-01-09 06:50:48 +01:00
|
|
|
* Revision 1.12 2000/01/09 05:50:48 steve
|
|
|
|
|
* Support named parameter override lists.
|
|
|
|
|
*
|
1999-12-11 06:45:41 +01:00
|
|
|
* Revision 1.11 1999/12/11 05:45:41 steve
|
|
|
|
|
* Fix support for attaching attributes to primitive gates.
|
|
|
|
|
*
|
1999-09-04 21:11:45 +02:00
|
|
|
* Revision 1.10 1999/09/04 19:11:46 steve
|
|
|
|
|
* Add support for delayed non-blocking assignments.
|
|
|
|
|
*
|
1999-08-23 18:48:39 +02:00
|
|
|
* Revision 1.9 1999/08/23 16:48:39 steve
|
|
|
|
|
* Parameter overrides support from Peter Monta
|
|
|
|
|
* AND and XOR support wide expressions.
|
|
|
|
|
*
|
1999-08-01 23:18:55 +02:00
|
|
|
* Revision 1.8 1999/08/01 21:18:55 steve
|
|
|
|
|
* elaborate rise/fall/decay for continuous assign.
|
|
|
|
|
*
|
1999-08-01 18:34:50 +02:00
|
|
|
* Revision 1.7 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-05-29 04:36:17 +02:00
|
|
|
* Revision 1.6 1999/05/29 02:36:17 steve
|
|
|
|
|
* module parameter bind by name.
|
|
|
|
|
*
|
1999-05-10 02:16:57 +02:00
|
|
|
* Revision 1.5 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-02-15 03:06:15 +01:00
|
|
|
* Revision 1.4 1999/02/15 02:06:15 steve
|
|
|
|
|
* Elaborate gate ranges.
|
|
|
|
|
*
|
1999-01-25 06:45:56 +01:00
|
|
|
* Revision 1.3 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-01 01:42:13 +01:00
|
|
|
* Revision 1.2 1998/12/01 00:42:13 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-04 00:28:49 +01:00
|
|
|
* Revision 1.1 1998/11/03 23:28:54 steve
|
|
|
|
|
* Introduce verilog to CVS.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#endif
|