Open spakin opened 6 years ago
See https://github.com/YosysHQ/yosys/pull/830#issuecomment-468809795 and http://svn.clifford.at/handicraft/2019/vivadoedif: The current behavior is to always use array index 0 for the MSB array element, and to use the name Verilog uses for the bit in the rename clause. This mirrors the exact behavior of Xilinx Vivado.
We can add support for other "EDIF flavors", but for that we would need to know what other tool you want us to emulate and what the exact behavior of that tool is.
We can add support for other "EDIF flavors", but for that we would need to know what other tool you want us to emulate and what the exact behavior of that tool is.
It's my own, custom tool. With some effort, I managed to get it to work with array index 0 for the MSB array element and the name Verilog uses for the bit in the rename clause.
Giving the user the choice of flavors you laid out in https://github.com/YosysHQ/yosys/pull/830#issuecomment-468453251 sounds reasonable to me.
Re-opening as "add supports for flavors wrt numbering of vector bits".
I'm putting together a custom flow that uses Yosys plus the Microchip/Atmel CPLD fitter to target the Microchip/Atmel ATF15xx CPLD family. I have this working well enough to show this is both possible and useful. However, I have fallen foul of this EDIF bit ordering issue, because the Atmel fitter uses the opposite convention to Vivado. i.e. it assumes port array index 0 is the LSB of the array.
I'm just posting to say that I would find the -lsbidx option very useful indeed.
All the work I'm doing on this is in the following git repository: https://github.com/hoglet67/atf15xx_yosys
A test case for this issue is just a simple two-bit counter: https://github.com/hoglet67/atf15xx_yosys/blob/master/examples/counter/counter.v
The fitter equations show currently show counter bits 0 and 1 reversed:
counter_1.D = !counter_1.Q;
counter_0.D = counter_1.Q $ counter_0.Q;
counter_1.C = clock;
counter_0.C = clock;
i.e. counter_1 acts as the LSB and counter_0 acts as the MSB
( $ is the XOR operator - the equations are in CUPL syntax )
I have one futher comment about this....
I'm using an eval copy of the Mentor RTL synthesis tool to understand what the Atmel fitter expects in the EDIF file. What I see in the above two-bit ounter example is two things:
1, A bit reveral in the port ref, just like Yosys does.
(net (rename counter_1_ "counter(1)")
(joined
(portRef (member counter 0))
(portRef Q (instanceRef io_counter_1_ ))))
(interface
(port clock (direction INPUT))
(port (array (rename counter "counter(1:0)") 2 )(direction OUTPUT)))
I think these are acting together to cancel each other out.
The ATF150x series devices are very interesting parts for anyone that wants to use a reasonably capable 5V CPLD device, especially considering they are still active / haven't been NRND'd. They're also programmable over JTAG in OpenOCD. I'd love to see Yosys have better support for generating the EDIF necessary as that's the largest bottleneck to using these outside of the vendor tools.
Reliance on the Vendor fitters (which otherwise accept EDIF from Yosys), is otherwise not a significant problem as the fitter is a command line tool that runs well from Wine.
@hoglet67 Have you seen prjbureau?
@peterzieba I think we're better off ingesting RTLIL and generating EDIF ourselves, to be honest.
With https://github.com/YosysHQ/yosys/pull/1489 being merged, it is now possible to do write_edif -lsbidx
The EDIF code produced by
write_edif
is incorrectly renumbering the bits in multi-bit values.Steps to reproduce the issue
I'm using Yosys 83631555dd5d57e2a3d3b7175f77baf0ad67ccd9 (2018-06-11):
Expected behavior
I would have expected an EDIF
net
to associatein[0]
with port 0 ofin
and with the input to an inverter and anothernet
to associatein[1]
with port 1 ofin
and with port 1 ofout
, as in the following EDIF code:In fact, older versions of Yosys get this right. An example of a good Yosys is the 0.7 release (61f681162754fa170494e567f1a1a9ae2d17eb69):
Actual behavior
What actually happens is that an EDIF
net
associates port 1 ofin
with the input to the inverter (and within[0]
). Another EDIFnet
associates port 0 ofin
directly with port 0 ofout
(and within[1]
)—but no inverter—as in the following EDIF code:That is, the comment strings are correct, but the actual
portRef
s are not. This issue may be similar to #315, but I'm not positive.