Infrastructure for parsing analog process statements.
Organize the parsing infrastructure for parsing analog processes, including holding them in scopes, and collecting analog statements.
This commit is contained in:
parent
e02d186946
commit
03e306c805
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include "config.h"
|
||||||
|
|
||||||
|
# include "AStatement.h"
|
||||||
|
|
||||||
|
AStatement::~AStatement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AContrib::AContrib()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AContrib::~AContrib()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AProcess::~AProcess()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
#ifndef __AStatement_H
|
||||||
|
#define __AStatement_H
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include <map>
|
||||||
|
# include "StringHeap.h"
|
||||||
|
# include "LineInfo.h"
|
||||||
|
|
||||||
|
class PExpr;
|
||||||
|
|
||||||
|
class AStatement : public LineInfo {
|
||||||
|
|
||||||
|
public:
|
||||||
|
AStatement() { }
|
||||||
|
virtual ~AStatement() =0;
|
||||||
|
|
||||||
|
virtual void dump(ostream&out, unsigned ind) const;
|
||||||
|
|
||||||
|
private: // not implemented
|
||||||
|
AStatement(const AStatement&);
|
||||||
|
AStatement& operator= (const AStatement&);
|
||||||
|
};
|
||||||
|
|
||||||
|
class AContrib : public AStatement {
|
||||||
|
|
||||||
|
public:
|
||||||
|
AContrib();
|
||||||
|
~AContrib();
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
class AProcess : public LineInfo {
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Type { PR_INITIAL, PR_ALWAYS };
|
||||||
|
|
||||||
|
AProcess(Type t, AStatement*st)
|
||||||
|
: type_(t), statement_(st) { }
|
||||||
|
|
||||||
|
~AProcess();
|
||||||
|
|
||||||
|
map<perm_string,PExpr*> attributes;
|
||||||
|
|
||||||
|
// Dump the analog process
|
||||||
|
void dump(ostream&out, unsigned ind) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type type_;
|
||||||
|
AStatement*statement_;
|
||||||
|
|
||||||
|
private: // not implemented
|
||||||
|
AProcess(const AProcess&);
|
||||||
|
AProcess& operator= (const AProcess&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -107,12 +107,13 @@ load_module.o netlist.o netmisc.o net_assign.o \
|
||||||
net_design.o net_event.o net_expr.o net_force.o net_func.o \
|
net_design.o net_event.o net_expr.o net_force.o net_func.o \
|
||||||
net_link.o net_modulo.o net_nex_input.o net_nex_output.o \
|
net_link.o net_modulo.o net_nex_input.o net_nex_output.o \
|
||||||
net_proc.o net_scope.o net_tran.o net_udp.o pad_to_width.o \
|
net_proc.o net_scope.o net_tran.o net_udp.o pad_to_width.o \
|
||||||
parse.o parse_misc.o pform.o pform_disciplines.o pform_dump.o pform_types.o \
|
parse.o parse_misc.o pform.o pform_analog.o pform_disciplines.o \
|
||||||
|
pform_dump.o pform_types.o \
|
||||||
set_width.o symbol_search.o sync.o sys_funcs.o \
|
set_width.o symbol_search.o sync.o sys_funcs.o \
|
||||||
verinum.o verireal.o target.o targets.o \
|
verinum.o verireal.o target.o targets.o \
|
||||||
Attrib.o HName.o LineInfo.o Module.o PDelays.o PEvent.o \
|
Attrib.o HName.o LineInfo.o Module.o PDelays.o PEvent.o \
|
||||||
PExpr.o PGate.o PGenerate.o PScope.o PSpec.o \
|
PExpr.o PGate.o PGenerate.o PScope.o PSpec.o \
|
||||||
PTask.o PUdp.o PFunction.o PWire.o Statement.o StringHeap.o \
|
PTask.o PUdp.o PFunction.o PWire.o Statement.o AStatement.o StringHeap.o \
|
||||||
$(FF) $(TT)
|
$(FF) $(TT)
|
||||||
|
|
||||||
Makefile: Makefile.in config.h.in config.status
|
Makefile: Makefile.in config.h.in config.status
|
||||||
|
|
|
||||||
8
PScope.h
8
PScope.h
|
|
@ -24,6 +24,7 @@
|
||||||
# include <map>
|
# include <map>
|
||||||
|
|
||||||
class PEvent;
|
class PEvent;
|
||||||
|
class AProcess;
|
||||||
class PProcess;
|
class PProcess;
|
||||||
class PWire;
|
class PWire;
|
||||||
|
|
||||||
|
|
@ -50,6 +51,10 @@ class LexicalScope {
|
||||||
map<perm_string,PWire*>wires;
|
map<perm_string,PWire*>wires;
|
||||||
PWire* wires_find(perm_string name);
|
PWire* wires_find(perm_string name);
|
||||||
|
|
||||||
|
// Behaviors (processes) in this scope
|
||||||
|
list<PProcess*> behaviors;
|
||||||
|
list<AProcess*> analog_behaviors;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -74,9 +79,6 @@ class PScope : public LexicalScope {
|
||||||
// Named events in the scope.
|
// Named events in the scope.
|
||||||
map<perm_string,PEvent*>events;
|
map<perm_string,PEvent*>events;
|
||||||
|
|
||||||
// Behaviors (processes) in this scope
|
|
||||||
list<PProcess*> behaviors;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dump_wires_(ostream&out, unsigned indent) const;
|
void dump_wires_(ostream&out, unsigned indent) const;
|
||||||
|
|
||||||
|
|
|
||||||
6
parse.y
6
parse.y
|
|
@ -180,6 +180,7 @@ static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2)
|
||||||
PEventStatement*event_statement;
|
PEventStatement*event_statement;
|
||||||
Statement*statement;
|
Statement*statement;
|
||||||
svector<Statement*>*statement_list;
|
svector<Statement*>*statement_list;
|
||||||
|
AStatement*astatement;
|
||||||
|
|
||||||
PTaskFuncArg function_type;
|
PTaskFuncArg function_type;
|
||||||
|
|
||||||
|
|
@ -302,6 +303,8 @@ static PECallFunction*make_call_function(perm_string tn, PExpr*arg1, PExpr*arg2)
|
||||||
%type <statement> statement statement_or_null
|
%type <statement> statement statement_or_null
|
||||||
%type <statement_list> statement_list
|
%type <statement_list> statement_list
|
||||||
|
|
||||||
|
%type <astatement> analog_statement
|
||||||
|
|
||||||
%type <letter> spec_polarity
|
%type <letter> spec_polarity
|
||||||
%type <perm_strings> specify_path_identifiers
|
%type <perm_strings> specify_path_identifiers
|
||||||
|
|
||||||
|
|
@ -2078,6 +2081,7 @@ module_item
|
||||||
}
|
}
|
||||||
|
|
||||||
| attribute_list_opt K_analog analog_statement
|
| attribute_list_opt K_analog analog_statement
|
||||||
|
{ pform_make_analog_behavior(@2, AProcess::PR_ALWAYS, $3); }
|
||||||
|
|
||||||
/* The task declaration rule matches the task declaration
|
/* The task declaration rule matches the task declaration
|
||||||
header, then pushes the function scope. This causes the
|
header, then pushes the function scope. This causes the
|
||||||
|
|
@ -3724,7 +3728,7 @@ statement_or_null
|
||||||
|
|
||||||
analog_statement
|
analog_statement
|
||||||
: branch_probe_expression K_CONTRIBUTE expression ';'
|
: branch_probe_expression K_CONTRIBUTE expression ';'
|
||||||
{ yyerror(@1, "sorry: Analog contribution statements not supported."); }
|
{ $$ = pform_contribution_statement(@2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Task items are, other than the statement, task port items and
|
/* Task items are, other than the statement, task port items and
|
||||||
|
|
|
||||||
11
pform.cc
11
pform.cc
|
|
@ -192,6 +192,17 @@ static void pform_put_behavior_in_scope(PProcess*pp)
|
||||||
lexical_scope->behaviors.push_back(pp);
|
lexical_scope->behaviors.push_back(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pform_put_behavior_in_scope(AProcess*pp)
|
||||||
|
{
|
||||||
|
if (pform_cur_generate)
|
||||||
|
if (pform_cur_generate->lexical_scope)
|
||||||
|
pform_cur_generate->lexical_scope->analog_behaviors.push_back(pp);
|
||||||
|
else
|
||||||
|
pform_cur_generate->analog_behaviors.push_back(pp);
|
||||||
|
else
|
||||||
|
lexical_scope->analog_behaviors.push_back(pp);
|
||||||
|
}
|
||||||
|
|
||||||
void pform_set_default_nettype(NetNet::Type type,
|
void pform_set_default_nettype(NetNet::Type type,
|
||||||
const char*file, unsigned lineno)
|
const char*file, unsigned lineno)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
9
pform.h
9
pform.h
|
|
@ -24,6 +24,7 @@
|
||||||
# include "named.h"
|
# include "named.h"
|
||||||
# include "Module.h"
|
# include "Module.h"
|
||||||
# include "Statement.h"
|
# include "Statement.h"
|
||||||
|
# include "AStatement.h"
|
||||||
# include "PGate.h"
|
# include "PGate.h"
|
||||||
# include "PExpr.h"
|
# include "PExpr.h"
|
||||||
# include "PTask.h"
|
# include "PTask.h"
|
||||||
|
|
@ -179,6 +180,7 @@ extern PTask*pform_push_task_scope(char*name);
|
||||||
extern PFunction*pform_push_function_scope(char*name);
|
extern PFunction*pform_push_function_scope(char*name);
|
||||||
extern PBlock*pform_push_block_scope(char*name, PBlock::BL_TYPE tt);
|
extern PBlock*pform_push_block_scope(char*name, PBlock::BL_TYPE tt);
|
||||||
|
|
||||||
|
extern void pform_put_behavior_in_scope(AProcess*proc);
|
||||||
|
|
||||||
extern verinum* pform_verinum_with_size(verinum*s, verinum*val,
|
extern verinum* pform_verinum_with_size(verinum*s, verinum*val,
|
||||||
const char*file, unsigned lineno);
|
const char*file, unsigned lineno);
|
||||||
|
|
@ -389,4 +391,11 @@ extern void pform_attach_discipline(const struct vlltype&loc,
|
||||||
extern void pform_dump(ostream&out, const nature_t*);
|
extern void pform_dump(ostream&out, const nature_t*);
|
||||||
extern void pform_dump(ostream&out, const discipline_t*);
|
extern void pform_dump(ostream&out, const discipline_t*);
|
||||||
|
|
||||||
|
/* ** pform_analog.cc
|
||||||
|
*/
|
||||||
|
extern void pform_make_analog_behavior(const struct vlltype&loc,
|
||||||
|
AProcess::Type type, AStatement*st);
|
||||||
|
|
||||||
|
extern AStatement*pform_contribution_statement(const struct vlltype&loc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
# include "config.h"
|
||||||
|
# include "compiler.h"
|
||||||
|
# include "pform.h"
|
||||||
|
# include "parse_misc.h"
|
||||||
|
# include "AStatement.h"
|
||||||
|
|
||||||
|
AStatement* pform_contribution_statement(const struct vlltype&loc)
|
||||||
|
{
|
||||||
|
AContrib*tmp = new AContrib;
|
||||||
|
FILE_NAME(tmp, loc);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pform_make_analog_behavior(const struct vlltype&loc, AProcess::Type pt,
|
||||||
|
AStatement*statement)
|
||||||
|
{
|
||||||
|
AProcess*proc = new AProcess(pt, statement);
|
||||||
|
FILE_NAME(proc, loc);
|
||||||
|
|
||||||
|
pform_put_behavior_in_scope(proc);
|
||||||
|
}
|
||||||
|
|
@ -531,6 +531,16 @@ void Statement::dump(ostream&out, unsigned ind) const
|
||||||
<< " */ ;" << endl;
|
<< " */ ;" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AStatement::dump(ostream&out, unsigned ind) const
|
||||||
|
{
|
||||||
|
/* I give up. I don't know what type this statement is,
|
||||||
|
so just print the C++ typeid and let the user figure
|
||||||
|
it out. */
|
||||||
|
out << setw(ind) << "";
|
||||||
|
out << "/* " << get_fileline() << ": " << typeid(*this).name()
|
||||||
|
<< " */ ;" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
void PAssign::dump(ostream&out, unsigned ind) const
|
void PAssign::dump(ostream&out, unsigned ind) const
|
||||||
{
|
{
|
||||||
out << setw(ind) << "";
|
out << setw(ind) << "";
|
||||||
|
|
@ -840,6 +850,32 @@ void PProcess::dump(ostream&out, unsigned ind) const
|
||||||
statement_->dump(out, ind+2);
|
statement_->dump(out, ind+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AProcess::dump(ostream&out, unsigned ind) const
|
||||||
|
{
|
||||||
|
switch (type_) {
|
||||||
|
case AProcess::PR_INITIAL:
|
||||||
|
out << setw(ind) << "" << "analog initial";
|
||||||
|
break;
|
||||||
|
case AProcess::PR_ALWAYS:
|
||||||
|
out << setw(ind) << "" << "analog";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
out << " /* " << get_fileline() << " */" << endl;
|
||||||
|
|
||||||
|
for (map<perm_string,PExpr*>::const_iterator idx = attributes.begin()
|
||||||
|
; idx != attributes.end() ; idx++ ) {
|
||||||
|
|
||||||
|
out << setw(ind+2) << "" << "(* " << (*idx).first;
|
||||||
|
if ((*idx).second) {
|
||||||
|
out << " = " << *(*idx).second;
|
||||||
|
}
|
||||||
|
out << " *)" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
statement_->dump(out, ind+2);
|
||||||
|
}
|
||||||
|
|
||||||
void PSpecPath::dump(std::ostream&out, unsigned ind) const
|
void PSpecPath::dump(std::ostream&out, unsigned ind) const
|
||||||
{
|
{
|
||||||
out << setw(ind) << "" << "specify path ";
|
out << setw(ind) << "" << "specify path ";
|
||||||
|
|
@ -937,6 +973,11 @@ void PGenerate::dump(ostream&out, unsigned indent) const
|
||||||
(*idx)->dump(out, indent+2);
|
(*idx)->dump(out, indent+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (list<AProcess*>::const_iterator idx = analog_behaviors.begin()
|
||||||
|
; idx != analog_behaviors.end() ; idx++) {
|
||||||
|
(*idx)->dump(out, indent+2);
|
||||||
|
}
|
||||||
|
|
||||||
for (list<PGenerate*>::const_iterator idx = generate_schemes.begin()
|
for (list<PGenerate*>::const_iterator idx = generate_schemes.begin()
|
||||||
; idx != generate_schemes.end() ; idx++) {
|
; idx != generate_schemes.end() ; idx++) {
|
||||||
(*idx)->dump(out, indent+2);
|
(*idx)->dump(out, indent+2);
|
||||||
|
|
@ -1122,6 +1163,11 @@ void Module::dump(ostream&out) const
|
||||||
(*behav)->dump(out, 4);
|
(*behav)->dump(out, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (list<AProcess*>::const_iterator idx = analog_behaviors.begin()
|
||||||
|
; idx != analog_behaviors.end() ; idx++) {
|
||||||
|
(*idx)->dump(out, 4);
|
||||||
|
}
|
||||||
|
|
||||||
for (list<PSpecPath*>::const_iterator spec = specify_paths.begin()
|
for (list<PSpecPath*>::const_iterator spec = specify_paths.begin()
|
||||||
; spec != specify_paths.end()
|
; spec != specify_paths.end()
|
||||||
; spec ++ ) {
|
; spec ++ ) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue