From 25cd0827ba9d2c1e346b1dd74d45a4e11678a41f Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 17 Feb 2016 17:20:02 +0100 Subject: [PATCH] vhdlpp: Removed ProcessStatement::rewrite_as_always_edge_() & extract_anyedge_(). Processes sensitive to edges are now handled with $ivlh_{rising,falling}_edge(). --- vhdlpp/architec.h | 3 - vhdlpp/architec_elaborate.cc | 126 ----------------------------------- 2 files changed, 129 deletions(-) diff --git a/vhdlpp/architec.h b/vhdlpp/architec.h index 221092aa8..8a1902b76 100644 --- a/vhdlpp/architec.h +++ b/vhdlpp/architec.h @@ -284,9 +284,6 @@ class ProcessStatement : public StatementList { void dump(ostream&out, int indent =0) const; private: - int rewrite_as_always_edge_(Entity*ent, Architecture*arc); - int extract_anyedge_(Entity*ent, Architecture*arc); - perm_string iname_; std::list sensitivity_list_; }; diff --git a/vhdlpp/architec_elaborate.cc b/vhdlpp/architec_elaborate.cc index 87294ebfb..a538da132 100644 --- a/vhdlpp/architec_elaborate.cc +++ b/vhdlpp/architec_elaborate.cc @@ -186,109 +186,6 @@ int IfGenerate::elaborate(Entity*ent, Architecture*arc) return errors; } -/* - * This method attempts to rewrite the process content as an - * always-@(n-edge ) version of the same statement. This makes - * for a more natural translation to Verilog, if it comes to that. - */ -int ProcessStatement::rewrite_as_always_edge_(Entity*, Architecture*) -{ - // If there are multiple sensitivity expressions, I give up. - if (sensitivity_list_.size() != 1) - return -1; - - // If there are multiple statements, I give up. - if (stmt_list().size() != 1) - return -1; - - Expression*se = sensitivity_list_.front(); - SequentialStmt*stmt_raw = stmt_list().front(); - - // If the statement is not an if-statement, I give up. - IfSequential*stmt = dynamic_cast (stmt_raw); - if (stmt == 0) - return -1; - - // If the "if" statement has a false clause, then give up. - if (stmt->false_size() != 0) - return -1; - - const Expression*ce_raw = stmt->peek_condition(); - - // Here we expect the condition to be - // 'event AND ='1'. - // So if ce_raw is not a logical AND, I give up. - const ExpLogical*ce = dynamic_cast (ce_raw); - if (ce == 0) - return -1; - if (ce->logic_fun() != ExpLogical::AND) - return -1; - - const Expression*op1_raw = ce->peek_operand1(); - const Expression*op2_raw = ce->peek_operand2(); - if (dynamic_cast(op2_raw)) { - const Expression*tmp = op1_raw; - op1_raw = op2_raw; - op2_raw = tmp; - } - - // If operand1 is not an 'event attribute, I give up. - const ExpObjAttribute*op1 = dynamic_cast(op1_raw); - if (op1 == 0) - return -1; - if (op1->peek_attribute() != "event") - return -1; - - const ExpRelation*op2 = dynamic_cast(op2_raw); - if (op2 == 0) - return -1; - if (op2->relation_fun() != ExpRelation::EQ) - return -1; - - const Expression*op2a_raw = op2->peek_operand1(); - const Expression*op2b_raw = op2->peek_operand2(); - - if (dynamic_cast(op2a_raw)) { - const Expression*tmp = op2b_raw; - op2b_raw = op2a_raw; - op2a_raw = tmp; - } - - if (! se->symbolic_compare(op1->peek_base())) - return -1; - - const ExpCharacter*op2b = dynamic_cast(op2b_raw); - if (op2b == 0) - return -1; - if (op2b->value() != '1' && op2b->value() != '0') - return -1; - - // We've matched this pattern: - // process () if ('event and = ) then ... - // And we can convert it to: - // always @(edge ) ... - - // Replace the sensitivity expression with an edge - // expression. The ExpEdge expression signals that this is an - // always-@(edge) statement. - ExpEdge*edge = new ExpEdge(op2b->value()=='1'? ExpEdge::POSEDGE : ExpEdge::NEGEDGE, se); - assert(sensitivity_list_.size() == 1); - sensitivity_list_.pop_front(); - sensitivity_list_.push_front(edge); - - // Replace the statement with the body of the always - // statement, which is the true clause of the top "if" - // statement. There should be no "else" clause. - assert(stmt_list().size() == 1); - stmt_list().pop_front(); - - stmt->extract_true(stmt_list()); - - delete stmt; - - return 0; -} - int StatementList::elaborate(Entity*ent, Architecture*arc) { int errors = 0; @@ -301,33 +198,10 @@ int StatementList::elaborate(Entity*ent, Architecture*arc) return errors; } -/* - * Change the "process () " into "always @() ..." - */ -int ProcessStatement::extract_anyedge_(Entity*, Architecture*) -{ - vector se; - while (! sensitivity_list_.empty()) { - se.push_back(sensitivity_list_.front()); - sensitivity_list_.pop_front(); - } - - for (size_t idx = 0 ; idx < se.size() ; idx += 1) { - ExpEdge*edge = new ExpEdge(ExpEdge::ANYEDGE, se[idx]); - FILE_NAME(edge, se[idx]); - sensitivity_list_.push_back(edge); - } - - return 0; -} - int ProcessStatement::elaborate(Entity*ent, Architecture*arc) { int errors = 0; - if (rewrite_as_always_edge_(ent, arc) >= 0) { - extract_anyedge_(ent, arc); - } StatementList::elaborate(ent, arc);