amaranth icon indicating copy to clipboard operation
amaranth copied to clipboard

Driver-Driver conflict causes unclear error message [regression from 0.4]

Open ECP5-PCIe opened this issue 1 year ago • 3 comments

The following code warns that the hierarchy will be flattened: DriverConflict: Signal '(sig signal)' is driven from multiple fragments: top, top.test; hierarchy will be flattened

proceeds with Yosys, yielding a syntax error: ERROR: Parser error in line 126: syntax error

The line in question: connect \D None

from amaranth import *
from amaranth_boards import versa_ecp5_5g as FPGA
from amaranth.vendor import LatticeECP5Platform
import os
from amaranth.lib.fifo import AsyncFIFOBuffered

class TestElaboratable(Elaboratable):
	def __init__(self):
		self.signal = Signal()

	def elaborate(self, platform) -> Module:
		m = Module()

		m.d.comb += self.signal.eq(0)
		# Uncommenting this causes driver-driver conflict error
		#m.d.sync += self.signal.eq(0)

		return m

class MCVE(Elaboratable):
	def elaborate(self, platform):
		m = Module()

		m.submodules.test = test = TestElaboratable()
		m.d.sync += test.signal.eq(0)

		return m


os.environ["AMARANTH_verbose"] = "Yes"
FPGA.VersaECP55GPlatform().build(MCVE())

Presumably this is supposed to cause a driver-driver conflict error (as it does when I tried to further simplify it)

ECP5-PCIe avatar Feb 17 '24 17:02 ECP5-PCIe

This doesn't seem to reproduce on current main:

amaranth.hdl._ir.DriverConflict: Signal (sig signal) driven from domain None at ('/home/mwk/amaranth/amaranth/hdl/_xfrm.py', 667) and domain <amaranth.hdl._cd.ClockDomain object at 0x7f1b23891f50> at ('/home/mwk/amaranth/amaranth/hdl/_xfrm.py', 667)

The error message isn't the best (and improving it is on my list), but the error is definitely thrown. What version were you testing on?

wanda-phi avatar Feb 25 '24 11:02 wanda-phi

I was on 0.4.1.dev61+g115954b, indeed on 0.4.1.dev116+ga586df8 it is solved, thank you! Although as you said it now causes amaranth.hdl._ir.DriverConflict: Signal (sig signal) driven from domain None at ('/home/user/FPGA/venv-fpga/lib/python3.11/site-packages/amaranth/hdl/_xfrm.py', 667) and domain <amaranth.hdl._cd.ClockDomain object at 0x7fa671718110> at ('/home/user/FPGA/venv-fpga/lib/python3.11/site-packages/amaranth/hdl/_xfrm.py', 667) compared to amaranth.hdl._dsl.SyntaxError: Driver-driver conflict: trying to drive (sig signal) from d.sync, but it is already driven from d.comb when the error is in the same Elaboratable

ECP5-PCIe avatar Feb 26 '24 15:02 ECP5-PCIe

This message is improved in #1158 to: amaranth.hdl._ir.DriverConflict: Signal (sig signal) driven from domain comb at ('/home/mwk/amaranth/amaranth/hdl/_xfrm.py', 667) and domain sync at ('/home/mwk/amaranth/amaranth/hdl/_xfrm.py', 667)

An unrelated upcoming change (removing AssignmentLegalizer) will also fix up the wrong filename currently reported.

wanda-phi avatar Feb 27 '24 03:02 wanda-phi

In #1173 this changes to: amaranth.hdl._ir.DriverConflict: Signal (sig signal) driven from domain comb at ('/home/mwk/amaranth/t.py', 14) and domain sync at ('/home/mwk/amaranth/t.py', 25)

wanda-phi avatar Feb 28 '24 14:02 wanda-phi