B-Lang-org / bsc

Bluespec Compiler (BSC)
Other
954 stars 146 forks source link

bsc ignores `always_ready` when checking for duplicate wires #657

Open mieszko opened 11 months ago

mieszko commented 11 months ago

when bsc checks for duplicate wires (chkDupWires in ACheck) in the examples below, it fails with an ICE because (it claims) the RDY port name will appear twice — but the method is declared to be always_ready, so there shouldn't be a RDY port at all, and indeed if one of the method names is changed no RDY wires appear in the port declaration in the RTL.

example w/ an action method:

package Foo1 where

interface Foo =
    qux :: Bool -> Action {-# prefix = "", always_enabled, always_ready, arg_names = [fooqux] #-}

interface Bar =
    qux :: Bool -> Action {-# prefix = "", always_enabled, always_ready, arg_names = [barqux] #-}

interface Foobar =
    foo :: Foo {-# prefix = "" #-}
    bar :: Bar {-# prefix = "" #-}

{-# synthesize mkFoo1 #-}
mkFoo1 :: Module Foobar
mkFoo1 = return _

output:

acheck:chkDupWires
fromList [RDY_qux[IdPReady]]
Internal Bluespec Compiler Error:
Please report this failure to the BSC developers [...]

example w/ a value method:

package Foo2 where

interface Foo =
    qux :: Bool {-# prefix = "", always_enabled, always_ready, result = fooqux #-}

interface Bar =
    qux :: Bool {-# prefix = "", always_enabled, always_ready, result = barqux #-}

interface Foobar =
    foo :: Foo {-# prefix = "" #-}
    bar :: Bar {-# prefix = "" #-}

{-# synthesize mkFoo2 #-}
mkFoo2 :: Module Foobar
mkFoo2 = return _

output:

acheck:chkDupWires
fromList [RDY_qux[IdPReady]]
Internal Bluespec Compiler Error:
Please report this failure to the BSC developers [...]

interestingly, this doesn't seem to happen with the EN method in the first example, and the arg_names property appears to be respected — the value of all_names in chkDupWires is this:

[WILL_FIRE_bar_qux[IdPWillFire],WILL_FIRE_foo_qux[IdPWillFire],CAN_FIRE_bar_qux[IdPCanFire],CAN_FIRE_foo_qux[IdPCanFire],RDY_qux[IdPReady],RDY_qux[IdPReady],CLK,RST_N,fooqux,barqux]