Add Dfg cycle breaking support
This commit is contained in:
parent
75027c6712
commit
b62d74a055
|
|
@ -332,12 +332,25 @@ class TraceDriver final : public DfgVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(DfgArraySel* vtxp) override {
|
void visit(DfgArraySel* vtxp) override {
|
||||||
// Only constant select
|
|
||||||
const DfgConst* const idxp = vtxp->bitp()->cast<DfgConst>();
|
|
||||||
if (!idxp) return;
|
|
||||||
// From a variable
|
// From a variable
|
||||||
const DfgVarArray* varp = vtxp->fromp()->cast<DfgVarArray>();
|
const DfgVarArray* varp = vtxp->fromp()->cast<DfgVarArray>();
|
||||||
if (!varp) return;
|
if (!varp) return;
|
||||||
|
|
||||||
|
// If index is not constant, independence was proven only if the 'fromp' is
|
||||||
|
// independent, so no need to trace that
|
||||||
|
if (!vtxp->bitp()->is<DfgConst>()) {
|
||||||
|
DfgArraySel* const resp = make<DfgArraySel>(vtxp, vtxp->width());
|
||||||
|
resp->fromp(vtxp->fromp());
|
||||||
|
resp->bitp(trace(vtxp->bitp(), vtxp->bitp()->width() - 1, 0));
|
||||||
|
DfgSel* const selp = make<DfgSel>(vtxp, m_msb - m_lsb + 1);
|
||||||
|
selp->fromp(resp);
|
||||||
|
selp->lsb(m_lsb);
|
||||||
|
SET_RESULT(selp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trace the relevant driver based on the static index
|
||||||
|
const DfgConst* const idxp = vtxp->bitp()->as<DfgConst>();
|
||||||
UASSERT_OBJ(!varp->isVolatile(), vtxp, "Should not trace through volatile VarArray");
|
UASSERT_OBJ(!varp->isVolatile(), vtxp, "Should not trace through volatile VarArray");
|
||||||
// Skip through intermediate variables
|
// Skip through intermediate variables
|
||||||
while (varp->srcp() && varp->srcp()->is<DfgVarArray>()) {
|
while (varp->srcp() && varp->srcp()->is<DfgVarArray>()) {
|
||||||
|
|
@ -589,6 +602,16 @@ class TraceDriver final : public DfgVisitor {
|
||||||
SET_RESULT(resp);
|
SET_RESULT(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(DfgMatchMasked* vtxp) override {
|
||||||
|
DfgMatchMasked* const resp = make<DfgMatchMasked>(vtxp, vtxp->width());
|
||||||
|
resp->lhsp(trace(vtxp->lhsp(), vtxp->lhsp()->width() - 1, 0));
|
||||||
|
resp->matchp(trace(vtxp->matchp(), vtxp->matchp()->width() - 1, 0));
|
||||||
|
DfgSel* const selp = make<DfgSel>(vtxp, m_msb - m_lsb + 1);
|
||||||
|
selp->fromp(resp);
|
||||||
|
selp->lsb(m_lsb);
|
||||||
|
SET_RESULT(resp);
|
||||||
|
}
|
||||||
|
|
||||||
#undef SET_RESULT
|
#undef SET_RESULT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -721,12 +744,23 @@ class IndependentBits final : public DfgVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(DfgArraySel* vtxp) override {
|
void visit(DfgArraySel* vtxp) override {
|
||||||
// Only constant select
|
|
||||||
const DfgConst* const idxp = vtxp->bitp()->cast<DfgConst>();
|
|
||||||
if (!idxp) return;
|
|
||||||
// From a variable
|
// From a variable
|
||||||
const DfgVarArray* varp = vtxp->fromp()->cast<DfgVarArray>();
|
const DfgVarArray* varp = vtxp->fromp()->cast<DfgVarArray>();
|
||||||
if (!varp) return;
|
if (!varp) return;
|
||||||
|
|
||||||
|
// If index is not constant, independent only if the variable index
|
||||||
|
// is indenpendent and the array is independent. We don't track arrays,
|
||||||
|
// so we will assume an array is only independent if it has no drivers
|
||||||
|
// in the graph. TODO: could check all drivers.
|
||||||
|
if (!vtxp->bitp()->is<DfgConst>()) {
|
||||||
|
if (MASK(vtxp->bitp()).isEqAllOnes() && !varp->srcp() && !varp->defaultp()) {
|
||||||
|
MASK(vtxp).setAllBits1();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trace the relevant driver based on the static index
|
||||||
|
const DfgConst* const idxp = vtxp->bitp()->as<DfgConst>();
|
||||||
// We cannot trace through a volatile variable, so pretend all bits are dependent
|
// We cannot trace through a volatile variable, so pretend all bits are dependent
|
||||||
if (varp->isVolatile()) return;
|
if (varp->isVolatile()) return;
|
||||||
// Skip through intermediate variables
|
// Skip through intermediate variables
|
||||||
|
|
@ -954,6 +988,12 @@ class IndependentBits final : public DfgVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void visit(DfgMatchMasked* vtxp) override {
|
||||||
|
if (MASK(vtxp->lhsp()).isEqAllOnes() && MASK(vtxp->matchp()).isEqAllOnes()) { //
|
||||||
|
MASK(vtxp).setAllBits1();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#undef MASK
|
#undef MASK
|
||||||
|
|
||||||
// Enqueue sinks of vertex to work list for traversal - only called from constructor
|
// Enqueue sinks of vertex to work list for traversal - only called from constructor
|
||||||
|
|
|
||||||
|
|
@ -436,4 +436,86 @@ module t (
|
||||||
assign VOLATILE_ARRAY_IN_CYCLE_1 = volatile_array_in_cycle_1a[1];
|
assign VOLATILE_ARRAY_IN_CYCLE_1 = volatile_array_in_cycle_1a[1];
|
||||||
// verilator lint_on
|
// verilator lint_on
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Match masked
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
logic [63:0] match_masked; // UNOPTFLAT
|
||||||
|
always_comb begin
|
||||||
|
casez (rand_a[31:0])
|
||||||
|
32'b????????_????????_????????_???????1 : match_masked[31:0] = 32'd00;
|
||||||
|
32'b????????_????????_????????_??????1? : match_masked[31:0] = 32'd01;
|
||||||
|
32'b????????_????????_????????_?????1?? : match_masked[31:0] = 32'd02;
|
||||||
|
32'b????????_????????_????????_????1??? : match_masked[31:0] = 32'd03;
|
||||||
|
32'b????????_????????_????????_???1???? : match_masked[31:0] = 32'd04;
|
||||||
|
32'b????????_????????_????????_??1????? : match_masked[31:0] = 32'd05;
|
||||||
|
32'b????????_????????_????????_?1?????? : match_masked[31:0] = 32'd06;
|
||||||
|
32'b????????_????????_????????_1??????? : match_masked[31:0] = 32'd07;
|
||||||
|
32'b????????_????????_???????1_???????? : match_masked[31:0] = 32'd08;
|
||||||
|
32'b????????_????????_??????1?_???????? : match_masked[31:0] = 32'd09;
|
||||||
|
32'b????????_????????_?????1??_???????? : match_masked[31:0] = 32'd10;
|
||||||
|
32'b????????_????????_????1???_???????? : match_masked[31:0] = 32'd11;
|
||||||
|
32'b????????_????????_???1????_???????? : match_masked[31:0] = 32'd12;
|
||||||
|
32'b????????_????????_??1?????_???????? : match_masked[31:0] = 32'd13;
|
||||||
|
32'b????????_????????_?1??????_???????? : match_masked[31:0] = 32'd14;
|
||||||
|
32'b????????_????????_1???????_???????? : match_masked[31:0] = 32'd15;
|
||||||
|
32'b????????_???????1_????????_???????? : match_masked[31:0] = 32'd16;
|
||||||
|
32'b????????_??????1?_????????_???????? : match_masked[31:0] = 32'd17;
|
||||||
|
32'b????????_?????1??_????????_???????? : match_masked[31:0] = 32'd18;
|
||||||
|
32'b????????_????1???_????????_???????? : match_masked[31:0] = 32'd19;
|
||||||
|
32'b????????_???1????_????????_???????? : match_masked[31:0] = 32'd20;
|
||||||
|
32'b????????_??1?????_????????_???????? : match_masked[31:0] = 32'd21;
|
||||||
|
32'b????????_?1??????_????????_???????? : match_masked[31:0] = 32'd22;
|
||||||
|
32'b????????_1???????_????????_???????? : match_masked[31:0] = 32'd23;
|
||||||
|
32'b???????1_????????_????????_???????? : match_masked[31:0] = 32'd24;
|
||||||
|
32'b??????1?_????????_????????_???????? : match_masked[31:0] = 32'd25;
|
||||||
|
32'b?????1??_????????_????????_???????? : match_masked[31:0] = 32'd26;
|
||||||
|
32'b????1???_????????_????????_???????? : match_masked[31:0] = 32'd27;
|
||||||
|
32'b???1????_????????_????????_???????? : match_masked[31:0] = 32'd28;
|
||||||
|
32'b??1?????_????????_????????_???????? : match_masked[31:0] = 32'd29;
|
||||||
|
32'b?1??????_????????_????????_???????? : match_masked[31:0] = 32'd30;
|
||||||
|
32'b1???????_????????_????????_???????? : match_masked[31:0] = 32'd31;
|
||||||
|
default : match_masked[31:0] = '1;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
always_comb begin
|
||||||
|
casez (match_masked[31:0])
|
||||||
|
32'd00 : match_masked[63:32] = 32'b00000000_00000000_00000000_00000001;
|
||||||
|
32'd01 : match_masked[63:32] = 32'b00000000_00000000_00000000_00000010;
|
||||||
|
32'd02 : match_masked[63:32] = 32'b00000000_00000000_00000000_00000100;
|
||||||
|
32'd03 : match_masked[63:32] = 32'b00000000_00000000_00000000_00001000;
|
||||||
|
32'd04 : match_masked[63:32] = 32'b00000000_00000000_00000000_00010000;
|
||||||
|
32'd05 : match_masked[63:32] = 32'b00000000_00000000_00000000_00100000;
|
||||||
|
32'd06 : match_masked[63:32] = 32'b00000000_00000000_00000000_01000000;
|
||||||
|
32'd07 : match_masked[63:32] = 32'b00000000_00000000_00000000_10000000;
|
||||||
|
32'd08 : match_masked[63:32] = 32'b00000000_00000000_00000001_00000000;
|
||||||
|
32'd09 : match_masked[63:32] = 32'b00000000_00000000_00000010_00000000;
|
||||||
|
32'd10 : match_masked[63:32] = 32'b00000000_00000000_00000100_00000000;
|
||||||
|
32'd11 : match_masked[63:32] = 32'b00000000_00000000_00001000_00000000;
|
||||||
|
32'd12 : match_masked[63:32] = 32'b00000000_00000000_00010000_00000000;
|
||||||
|
32'd13 : match_masked[63:32] = 32'b00000000_00000000_00100000_00000000;
|
||||||
|
32'd14 : match_masked[63:32] = 32'b00000000_00000000_01000000_00000000;
|
||||||
|
32'd15 : match_masked[63:32] = 32'b00000000_00000000_10000000_00000000;
|
||||||
|
32'd16 : match_masked[63:32] = 32'b00000000_00000001_00000000_00000000;
|
||||||
|
32'd17 : match_masked[63:32] = 32'b00000000_00000010_00000000_00000000;
|
||||||
|
32'd18 : match_masked[63:32] = 32'b00000000_00000100_00000000_00000000;
|
||||||
|
32'd19 : match_masked[63:32] = 32'b00000000_00001000_00000000_00000000;
|
||||||
|
32'd20 : match_masked[63:32] = 32'b00000000_00010000_00000000_00000000;
|
||||||
|
32'd21 : match_masked[63:32] = 32'b00000000_00100000_00000000_00000000;
|
||||||
|
32'd22 : match_masked[63:32] = 32'b00000000_01000000_00000000_00000000;
|
||||||
|
32'd23 : match_masked[63:32] = 32'b00000000_10000000_00000000_00000000;
|
||||||
|
32'd24 : match_masked[63:32] = 32'b00000001_00000000_00000000_00000000;
|
||||||
|
32'd25 : match_masked[63:32] = 32'b00000010_00000000_00000000_00000000;
|
||||||
|
32'd26 : match_masked[63:32] = 32'b00000100_00000000_00000000_00000000;
|
||||||
|
32'd27 : match_masked[63:32] = 32'b00001000_00000000_00000000_00000000;
|
||||||
|
32'd28 : match_masked[63:32] = 32'b00010000_00000000_00000000_00000000;
|
||||||
|
32'd29 : match_masked[63:32] = 32'b00100000_00000000_00000000_00000000;
|
||||||
|
32'd30 : match_masked[63:32] = 32'b01000000_00000000_00000000_00000000;
|
||||||
|
32'd31 : match_masked[63:32] = 32'b10000000_00000000_00000000_00000000;
|
||||||
|
default: match_masked[63:32] = 32'b00000000_00000000_00000000_00000000;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
`signal(MATCH_MASKED, 64);
|
||||||
|
assign MATCH_MASKED = match_masked;
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue