intel / rohd

The Rapid Open Hardware Development (ROHD) framework is a framework for describing and verifying hardware in the Dart programming language.
https://intel.github.io/rohd-website
BSD 3-Clause "New" or "Revised" License
374 stars 67 forks source link

Prevent `Logic` from connecting to itself #316

Closed chykon closed 1 year ago

chykon commented 1 year ago

Describe the bug

Logic can be connected to itself, which is rather odd.

To Reproduce

import 'package:rohd/rohd.dart';

void main() {
  final a = Logic();
  final b = Logic();

  a <= a;
  a <= b; // exception
}

Expected behavior

Connecting Logic to itself is not allowed.

Actual behavior

Connecting Logic to itself is allowed.

Additional: Dart SDK info

No response

Additional: pubspec.yaml

No response

Additional: Context

ROHD v0.4.2

mkorbel1 commented 1 year ago

This represents a trivial case of a combinational loop. It should be quite easy to detect statically, especially given _Wires are shared among connected Logics. I am having trouble thinking of any valid use-case where a ring of wires connected directly to each other (including one to itself) would ever be valuable, so throwing an exception immediately seems fair to me.

Thank you for filing!