Skip to content

Sequential triggers sampled within the conditionals get previous value rather than new triggered value #531

@mkorbel1

Description

@mkorbel1

Describe the bug

For something like an async reset flop, it will trigger sampling on posedge reset but there will be an if(reset) within the sequential logic. In this case, the value of reset for computation should be 1, but instead Sequential treats it like any other signal and finds the "previous" value before the edge and finds 0. This is improper modelling for asynchronous reset, and other use cases that follow a similar pattern.

To Reproduce

  test('async reset samples correct reset value', () async {
    final clk = Logic();
    final reset = Logic();
    final val = Logic();

    reset.inject(0);
    clk.inject(0);

    Sequential.multi(
      [clk, reset],
      reset: reset,
      [
        val < 1,
      ],
    );

    Simulator.registerAction(10, () {
      clk.inject(1);
    });

    Simulator.registerAction(14, () {
      reset.inject(1);
    });

    Simulator.registerAction(15, () {
      expect(val.value.toInt(), 0);
    });

    await Simulator.run();
  });

Expected behavior

If a signal is a trigger that triggered that event change, it should be that value for execution consideration.

Actual behavior

Triggers and non-triggers are treated the same way.

Additional: Dart SDK info

No response

Additional: pubspec.yaml

No response

Additional: Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions