forked from steveicarus/iverilog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new base class for all named items that can be added to a scope.
Provide a helper function to identify the derived classes when reporting errors.
- Loading branch information
1 parent
269ec2f
commit b88d91c
Showing
26 changed files
with
330 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1998-2017 Stephen Williams ([email protected]) | ||
* Copyright (c) 1998-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -122,3 +122,13 @@ const list<PGate*>& Module::get_gates() const | |
{ | ||
return gates_; | ||
} | ||
|
||
PNamedItem::SymbolType Module::symbol_type() const | ||
{ | ||
if (program_block) | ||
return PROGRAM; | ||
if (is_interface) | ||
return INTERFACE; | ||
|
||
return MODULE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_Module_H | ||
#define IVL_Module_H | ||
/* | ||
* Copyright (c) 1998-2017 Stephen Williams ([email protected]) | ||
* Copyright (c) 1998-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -28,7 +28,7 @@ | |
# include "HName.h" | ||
# include "named.h" | ||
# include "PScope.h" | ||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "netlist.h" | ||
# include "pform_types.h" | ||
class PExpr; | ||
|
@@ -54,7 +54,7 @@ class NetScope; | |
* these containers as well. | ||
*/ | ||
|
||
class Module : public PScopeExtra, public LineInfo { | ||
class Module : public PScopeExtra, public PNamedItem { | ||
|
||
/* The module ports are in general a vector of port_t | ||
objects. Each port has a name and an ordered list of | ||
|
@@ -160,6 +160,8 @@ class Module : public PScopeExtra, public LineInfo { | |
|
||
bool elaborate_sig(Design*, NetScope*scope) const; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
private: | ||
void dump_specparams_(ostream&out, unsigned indent) const; | ||
list<PGate*> gates_; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2012 Stephen Williams ([email protected]) | ||
* Copyright (c) 2012-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -28,3 +28,8 @@ PClass::PClass(perm_string name, LexicalScope*parent) | |
PClass::~PClass() | ||
{ | ||
} | ||
|
||
PNamedItem::SymbolType PClass::symbol_type() const | ||
{ | ||
return CLASS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_PClass_H | ||
#define IVL_PClass_H | ||
/* | ||
* Copyright (c) 2012-2014 Stephen Williams ([email protected]) | ||
* Copyright (c) 2012-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -20,7 +20,7 @@ | |
*/ | ||
|
||
# include "PScope.h" | ||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "StringHeap.h" | ||
# include <iostream> | ||
|
||
|
@@ -32,14 +32,16 @@ class PChainConstructor; | |
* collected. | ||
*/ | ||
|
||
class PClass : public PScopeExtra, public LineInfo { | ||
class PClass : public PScopeExtra, public PNamedItem { | ||
|
||
public: | ||
explicit PClass (perm_string name, LexicalScope*parent); | ||
~PClass(); | ||
|
||
void dump(std::ostream&out, unsigned indent) const; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
public: | ||
class_type_t*type; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2004 Stephen Williams ([email protected]) | ||
* Copyright (c) 2004-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -35,3 +35,7 @@ perm_string PEvent::name() const | |
return name_; | ||
} | ||
|
||
PNamedItem::SymbolType PEvent::symbol_type() const | ||
{ | ||
return EVENT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_PEvent_H | ||
#define IVL_PEvent_H | ||
/* | ||
* Copyright (c) 2000-2014 Stephen Williams ([email protected]) | ||
* Copyright (c) 2000-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -19,7 +19,7 @@ | |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "StringHeap.h" | ||
# include <string> | ||
|
||
|
@@ -31,7 +31,7 @@ class NetScope; | |
* are declared in Verilog as ``event foo;'' The name passed to the | ||
* constructor is the "foo" part of the declaration. | ||
*/ | ||
class PEvent : public LineInfo { | ||
class PEvent : public PNamedItem { | ||
|
||
public: | ||
// The name is a perm-allocated string. It is the simple name | ||
|
@@ -43,6 +43,8 @@ class PEvent : public LineInfo { | |
|
||
void elaborate_scope(Design*des, NetScope*scope) const; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
private: | ||
perm_string name_; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1999-2013 Stephen Williams ([email protected]) | ||
* Copyright (c) 1999-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -83,3 +83,8 @@ PChainConstructor* PFunction::extract_chain_constructor() | |
|
||
return res; | ||
} | ||
|
||
PNamedItem::SymbolType PFunction::symbol_type() const | ||
{ | ||
return FUNCTION; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 1999-2013 Stephen Williams ([email protected]) | ||
* Copyright (c) 1999-2019 Stephen Williams ([email protected]) | ||
* | ||
* 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,6 +117,11 @@ unsigned PGate::delay_count() const | |
return delay_.delay_count(); | ||
} | ||
|
||
PNamedItem::SymbolType PGate::symbol_type() const | ||
{ | ||
return INSTANCE; | ||
} | ||
|
||
PGAssign::PGAssign(list<PExpr*>*pins) | ||
: PGate(perm_string(), pins) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_PGate_H | ||
#define IVL_PGate_H | ||
/* | ||
* Copyright (c) 1998-2014 Stephen Williams ([email protected]) | ||
* Copyright (c) 1998-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -22,7 +22,7 @@ | |
# include "svector.h" | ||
# include "StringHeap.h" | ||
# include "named.h" | ||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "PDelays.h" | ||
# include "netlist.h" | ||
# include <map> | ||
|
@@ -47,7 +47,7 @@ class Module; | |
* single strength pair. There is a strength of the 0 drive, and a | ||
* strength of the 1 drive. | ||
*/ | ||
class PGate : public LineInfo { | ||
class PGate : public PNamedItem { | ||
|
||
public: | ||
explicit PGate(perm_string name, list<PExpr*>*pins, | ||
|
@@ -88,6 +88,8 @@ class PGate : public LineInfo { | |
virtual void elaborate_scope(Design*des, NetScope*sc) const; | ||
virtual bool elaborate_sig(Design*des, NetScope*scope) const; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
protected: | ||
const vector<PExpr*>& get_pins() const { return pins_; } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2006-2011 Stephen Williams ([email protected]) | ||
* Copyright (c) 2006-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -112,3 +112,8 @@ ostream& operator << (ostream&out, PGenerate::scheme_t type) | |
} | ||
return out; | ||
} | ||
|
||
PNamedItem::SymbolType PGenerate::symbol_type() const | ||
{ | ||
return GENBLOCK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_PGenerate_H | ||
#define IVL_PGenerate_H | ||
/* | ||
* Copyright (c) 2006-2014 Stephen Williams ([email protected]) | ||
* Copyright (c) 2006-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -19,7 +19,7 @@ | |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "StringHeap.h" | ||
# include "HName.h" | ||
# include "PScope.h" | ||
|
@@ -50,7 +50,7 @@ class PWire; | |
* The parent points to the GS_CASE that contains this item. | ||
* the loop_test is compared with the parent->loop_test expression. | ||
*/ | ||
class PGenerate : public LineInfo, public LexicalScope { | ||
class PGenerate : public PNamedItem, public LexicalScope { | ||
|
||
public: | ||
explicit PGenerate(LexicalScope*parent, unsigned id_number); | ||
|
@@ -107,6 +107,8 @@ class PGenerate : public LineInfo, public LexicalScope { | |
|
||
void dump(ostream&out, unsigned indent) const; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
private: | ||
bool generate_scope_loop_(Design*des, NetScope*container); | ||
bool generate_scope_condit_(Design*des, NetScope*container, bool else_flag); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2015 Stephen Williams ([email protected]) | ||
* Copyright (c) 2015-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -29,3 +29,8 @@ PModport::PModport(perm_string n) | |
PModport::~PModport() | ||
{ | ||
} | ||
|
||
PNamedItem::SymbolType PModport::symbol_type() const | ||
{ | ||
return MODPORT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#ifndef IVL_PModport_H | ||
#define IVL_PModport_H | ||
/* | ||
* Copyright (c) 2015 Stephen Williams ([email protected]) | ||
* Copyright (c) 2015-2019 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -19,7 +19,7 @@ | |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
# include "LineInfo.h" | ||
# include "PNamedItem.h" | ||
# include "PScope.h" | ||
# include "StringHeap.h" | ||
# include "netlist.h" | ||
|
@@ -28,7 +28,7 @@ | |
/* | ||
* The PModport class represents a parsed SystemVerilog modport list. | ||
*/ | ||
class PModport : public LineInfo { | ||
class PModport : public PNamedItem { | ||
|
||
public: | ||
// The name is a perm-allocated string. It is the simple name | ||
|
@@ -41,6 +41,8 @@ class PModport : public LineInfo { | |
typedef pair <NetNet::PortType,PExpr*> simple_port_t; | ||
map<perm_string,simple_port_t> simple_ports; | ||
|
||
SymbolType symbol_type() const; | ||
|
||
private: | ||
perm_string name_; | ||
|
||
|
Oops, something went wrong.