Fix formatting vars in protect-lib wrapper

This commit is contained in:
Wilson Snyder 2021-02-27 20:06:46 -05:00
parent 5489bbcc41
commit 05e5fb04ed
3 changed files with 22 additions and 23 deletions

View File

@ -17,7 +17,7 @@ module secret_impl
logic [31:0] accum_q = 0;
logic [31:0] secret_value = 9;
initial $display("%m: initialized");
initial $display("[%0t] %m: initialized", $time);
always @(posedge clk) begin
accum_q <= accum_q + a;

View File

@ -310,13 +310,15 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
}
virtual void visit(AstNodeFor* nodep) override {
putfs(nodep, "for (");
m_suppressSemi = true;
iterateAndNextNull(nodep->initsp());
puts(";");
iterateAndNextNull(nodep->condp());
puts(";");
iterateAndNextNull(nodep->incsp());
m_suppressSemi = false;
{
VL_RESTORER(m_suppressSemi);
m_suppressSemi = true;
iterateAndNextNull(nodep->initsp());
puts(";");
iterateAndNextNull(nodep->condp());
puts(";");
iterateAndNextNull(nodep->incsp());
}
puts(") begin\n");
iterateAndNextNull(nodep->bodysp());
putqs(nodep, "end\n");
@ -381,9 +383,13 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
}
virtual void visit(AstTextBlock* nodep) override {
visit(VN_CAST(nodep, NodeSimpleText));
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
iterate(childp);
if (nodep->commas() && childp->nextp()) puts(", ");
{
VL_RESTORER(m_suppressSemi);
m_suppressVarSemi = nodep->commas();
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
iterate(childp);
if (nodep->commas() && childp->nextp()) puts(", ");
}
}
}
virtual void visit(AstScopeName* nodep) override {}
@ -659,11 +665,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
puts(cvtToStr(unpackp->rangep()->rightConst()));
puts("]");
}
if (!m_suppressVarSemi) {
puts(";\n");
} else {
puts("\n");
}
puts(m_suppressVarSemi ? "\n" : ";\n");
}
virtual void visit(AstActive* nodep) override {
m_sensesp = nodep->sensesp();
@ -711,12 +713,10 @@ class EmitVFileVisitor final : public EmitVBaseVisitor {
virtual void putsNoTracking(const string& str) override { ofp()->putsNoTracking(str); }
public:
EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp, bool trackText, bool suppressVarSemi,
bool suppressUnknown)
EmitVFileVisitor(AstNode* nodep, V3OutFile* ofp, bool trackText, bool suppressUnknown)
: EmitVBaseVisitor{suppressUnknown, nullptr} {
m_ofp = ofp;
m_trackText = trackText;
m_suppressVarSemi = suppressVarSemi;
iterate(nodep);
}
virtual ~EmitVFileVisitor() override = default;
@ -840,7 +840,7 @@ void V3EmitV::emitvFiles() {
V3OutVFile of(vfilep->name());
of.puts("// DESCR"
"IPTION: Verilator generated Verilog\n");
EmitVFileVisitor visitor(vfilep->tblockp(), &of, true, true, false);
EmitVFileVisitor visitor(vfilep->tblockp(), &of, true, false);
}
}
}
@ -849,5 +849,5 @@ void V3EmitV::debugEmitV(const string& stage) {
UINFO(2, __FUNCTION__ << ": " << endl);
string filename = v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v";
V3OutVFile of(filename);
EmitVFileVisitor visitor(v3Global.rootp(), &of, true, false, true);
EmitVFileVisitor visitor(v3Global.rootp(), &of, true, true);
}

View File

@ -263,7 +263,7 @@ private:
m_seqAssignsp = new AstTextBlock(fl, "if (last_seq_seqnum__V > "
"last_combo_seqnum__V) begin\n");
txtp->addNodep(m_seqAssignsp);
m_comboAssignsp = new AstTextBlock(fl, "end else begin\n");
m_comboAssignsp = new AstTextBlock(fl, "end\nelse begin\n");
txtp->addNodep(m_comboAssignsp);
txtp->addText(fl, "end\n");
} else {
@ -437,7 +437,6 @@ private:
AstVar* newVarp
= new AstVar(varp->fileline(), AstVarType::VAR, varp->name() + suffix, varp->dtypep());
textp->addNodep(newVarp);
textp->addText(varp->fileline(), ";\n");
}
void handleOutput(AstVar* varp) {