ZipCPU / wb2axip

Bus bridges and other odds and ends
495 stars 100 forks source link

Interfacing to Xilinx Vivado block design environment #26

Open motylewski opened 4 years ago

motylewski commented 4 years ago

I have reached a point where axim2wbsp and wbm2axisp and wbp2classic integrate well in Xilinx block design with AXI and WB interfaces recognized as bus structure.

Regards, Tomasz

ZipCPU commented 4 years ago

Thank you for the work you've put into this, and your willingness/desire to share back. Please allow for the following critiques:

  1. Regarding the default_nettype. If I understand correct, the problem is that someone else's code is broken and so you wish to adjust this code to compensate. Wouldn't it make more sense to adjust the other (vendor?) code instead? Have you filed bug reports with whatever vendor code has problems with a default_nettype of none? Also, according to the Verilog specification, you should also be able to adjust the synthesis order, placing the default_nettype none items at the end of the synthesis file list in order to get files to pass. Have you tried this?

  2. Also, with respect to default_nettype, Yosys is a part of the problem here as well. The last time I complained, I learned that it was not standards compliant but rather applies the last default nettype given to the whole source file. If you set the default nettype to wire at the end of the file, it reverts default nettype to wire for the entire file. (Not desired. I got burned by that in the past.) It won't work to adjust things at the top of the file with ifdef FORMAL, since 1) I use Yosys for more than formal, and 2) I also want default_nettype none for other build environment (Verilator) which catch errors within my logic. Skipping default_nettype none is also a problem, because some tools (Vivado) are known to automatically define a value as an (incorrectly sized) wire the first time it is seen, and then create a second definition for it if it is created later. default_nettype none helps me avoid these synthesis mistakes, by catching them early. The "correct" answer here should be default_nettype none at the top of the file and nothing more. Designs that fail in a default_nettype none environment are broken and should be fixed. An interim solution might be to go back to the default_nettype wire statement at the end of the file, but only for non-Yosys (i.e. standards compliant) synthesis tools---and with the caution that this tends to hide bugs elsewhere in a design.

  3. Regarding axim2wbsp, it look,s like you want to drive the size of the WB bus using C_AXI_DATA_WIDTH and C_AXI_ADDR_WIDTH. I'm okay with that proposal, I hadn't decided which of the two buses should drive the width of the other. However, if the CAXI parameters drive the bus than the other dependent parameters, the wishbone AW, DW, and even AXI_LSBS, should be declared as localparams in order to keep the design from being built in an invalid fashion, and ideally to cause the design to fail in synthesis if it is being built in an invalid fashion.

  4. I'm not sure I understand your argument regarding why AXI_LSBS should be a localparam vs a parameter and what that has to do with narrow transfers. I have read the article you posted, and it doesn't seem relevant to the issue. These axim*wbsp cores do not adjust the width of the data channel. Data width transformation is handled by a separate transform, if at all. (I have an upsizer that's still being verified, but haven't (yet) built the downsizer.)

  5. Regarding the (* X_INTERFACE_INFO ... *) properties, I'm personally a stickler for 80-column lines. Let's therefore break these lines in two, one with the attributes and one with the declarations. Either way it's not going to be pretty, but if it makes the cores more usable than we can continue with them.

  6. Finally, Wishbone 3 vs Wishbone 4 isn't really the right terminology. Technically, the standards are B3 and B4, as though they were both preliminary--and B4 was never really accepted by the community, despite the fact that I like to use it exclusively. Perhaps the correct terms are Wishbone classic and Wishbone pipeline. I know I've abbreviated these in the past as WBP and WBC, but an argument could be made for better names than those.

I look forward to seeing the above items addressed. Again, thank you for your work on this behalf,

Dan

motylewski commented 4 years ago

Hi Dan, Thanks for thoughtful evaluation.

Regards, Tomasz

motylewski commented 4 years ago

As for naming: I think I slowly start understanding that there are at least following modes:

where busy assertion will differ between reading and writing.

ZipCPU commented 4 years ago

Well, sort of ... WB pipeline is much more capable than that. STALL should be high if you aren't ready to accept a new transfer. ACK should go high when you are complete. In between the two, you might have many requests being processed. Take this SDRAM controller for example. It will allow multiple requests to be in process at the same time.

Also, WB classic is really the same as WB classic synchronous--it's just a matter of whether or not you are taking a clock to do the processing or not. Either way, WB classic often cannot maintain one beat per clock without significantly slowing the clock rate down.

Let's do this: let's apply the version names B3 and B4, and then have two protocol names--something for wb classic and something else for wb pipelined. While I'd like to call WB pipelined just WB, I'll admit that others have been confused by this in the past. Perhaps WBC and WBP? Perhaps WBClassic and WBPipeline? What do you think there?

Also, the AXI_LSBS thing is still not right. Why not, for 8-bit slaves, just let Vivado drop the bus size to 8-bits before switching to WB? This core's purpose is not bus size adjustment.

Dan

motylewski commented 4 years ago

Hi Dan,

I will run Monday some tests to see whether Vivado allows connecting different interfaces, or interfaces with different version IDs.

I tend towards simply using opencores.org : bus : wishbone for both B3 and B4. It might be still versioned on top of that. But I need to first play more with the tools.

Tomasz

ZipCPU commented 4 years ago

Awesome! Please keep me posted.

motylewski commented 4 years ago

OK, it looks that Vivado block design GUI connects interfaces only when the complete name including version matches.

I have decided to use the following names: opencores.org:bus:wishbone:B3 opencores.org:bus:wishbone:B4 (most interfaces)

Therefore it is not possible to connect B3 and B4 interfaces with a bus connection, which might be a good thing. It is still possible to connect them wire-by-wire.

I have seen that Xilinx itself uses the same interface definition/name/version for both AXI and AXI-Lite, so they really have no better solution.

I have tried to pack the (* X_INTERFACE_INFO = "opencores.org:bus:wishbone:B4 M_WBP NAME *) attribute in the `define(NAME), but it did not work,

I have decided to use names like M_WBP for pipelined master and S_WPC for classic slave for example.

This is more or less my final version.

Of course the new wishbone and AXI X_INTERFACE_INFO labels might be added to all other wb2axip cores, I have only added them where I needed.

Best regards,

Tomasz

ZipCPU commented 4 years ago

Just writing back to see the status of this. Looks like I missed the "final version" comment. Should I test this and merge it then?

Dan