Add support for generate loops w/ wires and gates.
This commit is contained in:
parent
d365c144a8
commit
ca72e22437
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CVS_IDENT
|
||||||
|
#ident "$Id: PGenerate.cc,v 1.1 2006/04/10 02:40:18 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include "PGenerate.h"
|
||||||
|
# include "PWire.h"
|
||||||
|
|
||||||
|
PGenerate::PGenerate(unsigned id)
|
||||||
|
: id_number(id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PGenerate::~PGenerate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PWire* PGenerate::add_wire(PWire*wire)
|
||||||
|
{
|
||||||
|
PWire*&ep = wires[wire->path()];
|
||||||
|
if (ep) return ep;
|
||||||
|
|
||||||
|
assert(ep == 0);
|
||||||
|
ep = wire;
|
||||||
|
return wire;
|
||||||
|
}
|
||||||
|
|
||||||
|
PWire* PGenerate::get_wire(const hname_t&name) const
|
||||||
|
{
|
||||||
|
map<hname_t,PWire*>::const_iterator obj = wires.find(name);
|
||||||
|
if (obj == wires.end())
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return (*obj).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PGenerate::add_gate(PGate*gate)
|
||||||
|
{
|
||||||
|
gates.push_back(gate);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
#ifndef __PGenerate_H
|
||||||
|
#define __PGenerate_H
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CVS_IDENT
|
||||||
|
#ident "$Id: PGenerate.h,v 1.1 2006/04/10 02:40:18 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include "LineInfo.h"
|
||||||
|
# include "StringHeap.h"
|
||||||
|
# include "HName.h"
|
||||||
|
# include <list>
|
||||||
|
# include <map>
|
||||||
|
|
||||||
|
class Design;
|
||||||
|
class NetScope;
|
||||||
|
class PExpr;
|
||||||
|
class PGate;
|
||||||
|
class PWire;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This represents a generate scheme.
|
||||||
|
*/
|
||||||
|
class PGenerate : public LineInfo {
|
||||||
|
|
||||||
|
public:
|
||||||
|
PGenerate(unsigned id_number);
|
||||||
|
~PGenerate();
|
||||||
|
|
||||||
|
// Generate schemes have an ID number, for when the scope is
|
||||||
|
// implicit.
|
||||||
|
const unsigned id_number;
|
||||||
|
perm_string scope_name;
|
||||||
|
|
||||||
|
enum scheme_t {GS_NONE, GS_LOOP, GS_CONDIT};
|
||||||
|
scheme_t scheme_type;
|
||||||
|
|
||||||
|
// generate loops have an index variable and three
|
||||||
|
// expressions: for (index = <init>; <test>; index=<step>)
|
||||||
|
perm_string loop_index;
|
||||||
|
PExpr*loop_init;
|
||||||
|
PExpr*loop_test;
|
||||||
|
PExpr*loop_step;
|
||||||
|
|
||||||
|
map<hname_t,PWire*>wires;
|
||||||
|
PWire* add_wire(PWire*);
|
||||||
|
PWire* get_wire(const hname_t&name) const;
|
||||||
|
|
||||||
|
list<PGate*> gates;
|
||||||
|
void add_gate(PGate*);
|
||||||
|
|
||||||
|
// This method is called by the elaboration of a module to
|
||||||
|
// generate scopes. the container is the scope that is to
|
||||||
|
// contain the generated scope.
|
||||||
|
bool generate_scope(Design*des, NetScope*container);
|
||||||
|
|
||||||
|
bool elaborate_sig(Design*des) const;
|
||||||
|
bool elaborate(Design*des) const;
|
||||||
|
|
||||||
|
void dump(ostream&out) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool generate_scope_loop_(Design*des, NetScope*container);
|
||||||
|
|
||||||
|
// These are the scopes created by generate_scope.
|
||||||
|
list<NetScope*>scope_list_;
|
||||||
|
// internal function called on each scope generated by this scheme.
|
||||||
|
bool elaborate_sig_(Design*des, NetScope*scope) const;
|
||||||
|
bool elaborate_(Design*des, NetScope*scope) const;
|
||||||
|
|
||||||
|
private: // not implemented
|
||||||
|
PGenerate(const PGenerate&);
|
||||||
|
PGenerate& operator= (const PGenerate&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue