Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CheckCombLoops] Handle RWProbeOp #6824

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

prithayan
Copy link
Contributor

Handle the RWProbeOp in CheckCombLoop.
This fixes #6820

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! Glad this generally doesn't look like a big change.

Unsure of some things, gotta run but will circle back.

Please take a look at the examples posted.

@@ -329,8 +345,7 @@ class DiscoverLoops {
auto iter = rwProbeRefersTo.find(*leader);

// This should be found, but for now may not be due to needing
// RWProbeOp support. May cause missed loops involving force for now.
// https://github.com/llvm/circt/issues/6820
// RWProbeOp support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having hard time getting GitHub to let me "suggest" this properly, but this comment, line, before, and if/return can now be deleted.

/// Get FieldRef pointing to the specified inner symbol target, which must be
/// valid. Returns null FieldRef if target points to something with no value,
/// such as a port of an external module.
static FieldRef getRefForIST(const hw::InnerSymTarget &ist) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a utility (this is from InferWidths looks like, hopefully it is).

Not blocking but if not addressed please file an issue and assign to me.

if (!ref)
return;
auto data = rwProbe.getResult();
addDrivenBy({data, 0}, ref);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if the rwprobe target isn't a leaf (multiple FieldRef's)?

(not sure how this works, but do we create edge for all fields connected?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:

FIRRTL version 3.3.0
circuit Bar :
  module Foo :
    input agg : { x: Clock, y : Clock }
    output ref : RWProbe<{ x: Clock, y : Clock }>
    output refx : RWProbe<Clock>

    define ref = rwprobe(agg)
    define refx = rwprobe(agg.x)

  module Bar :
    input clock : Clock

    inst foo of Foo
    connect foo.agg.x, clock
    connect foo.agg.y, clock

    force(clock, UInt<1>(1), foo.ref.x, read(foo.refx))

Which should report a cycle but doesn't.

@@ -421,6 +436,9 @@ class DiscoverLoops {
continue;
}
}
if (!type_isa<RefType>(srcArgType) && sinkPortIsForceable)
recordProbe(srcPort, sinkPort);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you but if you could spare a word for what this does/why that'd be swell. Thank you!

If there's a path from a non-probe to a rwprobe, record a probe edge sink -> source? I'm not sure that's right, consider:

FIRRTL version 3.3.0
circuit Bar :
  module Foo :
    input clock : Clock
    output out : Clock
    output clockProbe_bore : RWProbe<Clock>

    node n = clock

    define clockProbe_bore = rwprobe(n)
    connect out, clock

  module Bar :
    input clock : Clock
    output clockProbe : RWProbe<Clock>

    inst foo of Foo
    connect foo.clock, clock
    define clockProbe = foo.clockProbe_bore

    force(clock, UInt<1>(1), clockProbe, foo.out)

Which reports a cycle but there isn't one, forcing n is unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this, I need to fix the logic to track which ports can be updated by a probe. Working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIRRTL][CheckCombLoops] Missing RWProbeOp support, crashes
2 participants