Add isolate_assignments to functions

git-svn-id: file://localhost/svn/verilator/trunk/verilator@881 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2007-01-30 15:51:16 +00:00
parent f1a2ee3273
commit ecb938f20e
6 changed files with 27 additions and 6 deletions

View File

@ -9,7 +9,7 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix isolate_assignments when many signals per always. [Mike Shinkarovsky] **** Fix isolate_assignments when many signals per always. [Mike Shinkarovsky]
**** Fix isolate_assignments across task temporaries. [Mike Shinkarovsky] **** Fix isolate_assignments across task/func temporaries. [Mike Shinkarovsky]
* Verilator 3.632 1/17/2007 * Verilator 3.632 1/17/2007

View File

@ -814,10 +814,13 @@ struct AstTask : public AstNodeFTask {
}; };
struct AstFunc : public AstNodeFTask { struct AstFunc : public AstNodeFTask {
bool m_attrIsolateAssign:1;// User isolate_assignments attribute
public:
// A function inside a module // A function inside a module
AstFunc(FileLine* fl, const string& name, AstNode* stmtp, AstNode* fvarsp) AstFunc(FileLine* fl, const string& name, AstNode* stmtp, AstNode* fvarsp)
:AstNodeFTask(fl, name, stmtp) { :AstNodeFTask(fl, name, stmtp) {
addNOp1p(fvarsp); addNOp1p(fvarsp);
m_attrIsolateAssign = false;
} }
virtual ~AstFunc() {} virtual ~AstFunc() {}
virtual AstType type() const { return AstType::FUNC;} virtual AstType type() const { return AstType::FUNC;}
@ -826,6 +829,8 @@ struct AstFunc : public AstNodeFTask {
// op1 = Range output variable (functions only) // op1 = Range output variable (functions only)
AstNode* fvarp() const { return op1p()->castNode(); } AstNode* fvarp() const { return op1p()->castNode(); }
void addFvarp(AstNode* nodep) { addOp1p(nodep); } void addFvarp(AstNode* nodep) { addOp1p(nodep); }
void attrIsolateAssign(bool flag) { m_attrIsolateAssign = flag; }
bool attrIsolateAssign() const { return m_attrIsolateAssign; }
}; };
struct AstTaskRef : public AstNodeFTaskRef { struct AstTaskRef : public AstNodeFTaskRef {

View File

@ -220,6 +220,8 @@ private:
nodep->userp(m_curVarsp); nodep->userp(m_curVarsp);
} }
// Convert the func's range to the output variable // Convert the func's range to the output variable
// This should probably be done in the Parser instead, as then we could
// just attact normal signal attributes to it.
if (AstFunc* funcp = nodep->castFunc()) { if (AstFunc* funcp = nodep->castFunc()) {
if (!funcp->fvarp()->castVar()) { if (!funcp->fvarp()->castVar()) {
AstRange* rangep = funcp->fvarp()->castRange(); AstRange* rangep = funcp->fvarp()->castRange();
@ -228,6 +230,7 @@ private:
newvarp->isSigned(funcp->isSigned()); newvarp->isSigned(funcp->isSigned());
newvarp->funcReturn(true); newvarp->funcReturn(true);
newvarp->trace(false); // Not user visible newvarp->trace(false); // Not user visible
newvarp->attrIsolateAssign(funcp->attrIsolateAssign());
funcp->addFvarp(newvarp); funcp->addFvarp(newvarp);
// Explicit insert required, as the var name shadows the upper level's task name // Explicit insert required, as the var name shadows the upper level's task name
m_curVarsp->insert(newvarp->name(), newvarp); m_curVarsp->insert(newvarp->name(), newvarp);

View File

@ -104,6 +104,7 @@ class AstSenTree;
AstCase* casep; AstCase* casep;
AstCaseItem* caseitemp; AstCaseItem* caseitemp;
AstConst* constp; AstConst* constp;
AstFunc* funcp;
AstFuncRef* funcrefp; AstFuncRef* funcrefp;
AstModule* modulep; AstModule* modulep;
AstPin* pinp; AstPin* pinp;
@ -246,7 +247,9 @@ class AstSenTree;
%type<nodep> idDotted %type<nodep> idDotted
%type<nodep> strAsInt strAsText concIdList %type<nodep> strAsInt strAsText concIdList
%type<nodep> taskDecl %type<nodep> taskDecl
%type<nodep> varDeclList funcDecl funcVarList funcVar %type<nodep> varDeclList
%type<funcp> funcDecl
%type<nodep> funcBody funcVarList funcVar
%type<rangep> funcRange %type<rangep> funcRange
%type<nodep> gateDecl %type<nodep> gateDecl
%type<nodep> gateBufList gateNotList gateAndList gateNandList %type<nodep> gateBufList gateNotList gateAndList gateNandList
@ -713,8 +716,13 @@ taskDecl: yTASK yID ';' stmtBlock yENDTASK { $$ = new AstTask ($1,*
| yTASK yID ';' funcVarList stmtBlock yENDTASK { $$ = new AstTask ($1,*$2,$4); $4->addNextNull($5); } | yTASK yID ';' funcVarList stmtBlock yENDTASK { $$ = new AstTask ($1,*$2,$4); $4->addNextNull($5); }
; ;
funcDecl: yFUNCTION funcRange yID ';' funcVarList stmtBlock yENDFUNCTION { $$ = new AstFunc ($1,*$3,$5,$2); $5->addNextNull($6);} funcDecl: yFUNCTION funcRange yID ';' funcBody yENDFUNCTION { $$ = new AstFunc ($1,*$3,$5,$2); }
| yFUNCTION ySIGNED funcRange yID ';' funcVarList stmtBlock yENDFUNCTION { $$ = new AstFunc ($1,*$4,$6,$3); $6->addNextNull($7); $$->isSigned(true); } | yFUNCTION ySIGNED funcRange yID ';' funcBody yENDFUNCTION { $$ = new AstFunc ($1,*$4,$6,$3); $$->isSigned(true); }
| yFUNCTION funcRange yID yVL_ISOLATE_ASSIGNMENTS ';' funcBody yENDFUNCTION { $$ = new AstFunc ($1,*$3,$6,$2); $$->attrIsolateAssign(true);}
| yFUNCTION ySIGNED funcRange yID yVL_ISOLATE_ASSIGNMENTS ';' funcBody yENDFUNCTION { $$ = new AstFunc ($1,*$4,$7,$3); $$->attrIsolateAssign(true); $$->isSigned(true); }
;
funcBody: funcVarList stmtBlock { $$ = $1;$1->addNextNull($2); }
; ;
funcRange: '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); } funcRange: '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }

View File

@ -82,7 +82,7 @@ module file (/*AUTOARG*/
// Note that while c and b depend on crc, b doesn't depend on c. // Note that while c and b depend on crc, b doesn't depend on c.
casez (crc[3:0]) casez (crc[3:0])
4'b??01: begin 4'b??01: begin
b = {crc[15:0],crc[31:16]}; b = {crc[15:0],get_31_16(crc)};
d = c; d = c;
end end
4'b??00: begin 4'b??00: begin
@ -95,6 +95,11 @@ module file (/*AUTOARG*/
endcase endcase
end end
function [31:16] get_31_16 /* verilator isolate_assignments*/;
input [31:0] t_crc /* verilator isolate_assignments*/;
get_31_16 = t_crc[31:16];
endfunction
task set_b_d; task set_b_d;
`ifdef ISOLATE `ifdef ISOLATE
input [31:0] t_crc /* verilator isolate_assignments*/; input [31:0] t_crc /* verilator isolate_assignments*/;

View File

@ -14,7 +14,7 @@ compile (
); );
if ($Last_Self->{v3}) { if ($Last_Self->{v3}) {
file_grep ($Last_Self->{stats}, qr/Optimizations, isolate_assignments blocks\s+3/i); file_grep ($Last_Self->{stats}, qr/Optimizations, isolate_assignments blocks\s+5/i);
} }
execute ( execute (