-
Notifications
You must be signed in to change notification settings - Fork 383
Description
Hello, I'm having an issue when trying to import Verilog generated with Yosys. It leads into a combinatorial cycle that isn't present in the Verilog program.
Here is a simple example of problematic Verilog:
module outline_control_3(output [1:0] result, input arg0);
assign result[1] = arg0;
assign result[0] = result[1];
endmodule
When I import the Verilog into Moore with ./circt-translate --import-verilog test.sv
it generates the following program:
module {
moore.module @outline_control_3(out result : !moore.l2, in %arg0 : !moore.l1) {
%result = moore.net wire : <l2>
%arg0_0 = moore.net name "arg0" wire : <l1>
%0 = moore.extract_ref %result from 1 : <l2> -> <l1>
%1 = moore.read %arg0_0 : <l1>
moore.assign %0, %1 : l1
%2 = moore.extract_ref %result from 0 : <l2> -> <l1>
%3 = moore.read %result : <l2>
%4 = moore.extract %3 from 1 : l2 -> l1
moore.assign %2, %4 : l1
%5 = moore.read %result : <l2>
moore.assign %arg0_0, %arg0 : l1
moore.output %5 : !moore.l2
}
}
But then, when I lower it into the comb/HW dialects with ./circt-translate --import-verilog test.sv | ./circt-opt --moore-lower-concatref --canonicalize --cse --convert-moore-to-core --llhd-sig2reg --canonicalize --cse
. It generates the following program:
module {
hw.module @outline_control_3(out result : i2, in %arg0 : i1) {
%false = hw.constant false
%0 = comb.concat %false, %3 : i1, i1
%1 = comb.concat %arg0, %false : i1, i1
%2 = comb.or %1, %0 : i2
%3 = comb.extract %2 from 1 : (i2) -> i1
hw.output %2 : i2
}
}
My problem here is that %3
depends on %2
, which in turn depends on %0
, which also depends on %3
. As the hw.module contains a graph
region, it doesn't seem to be an invalid MLIR program. But is it the expected behavior? There is a combinatorial cycle that wasn't present in the imported Verilog.