-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FPGA] Automatically dump mmi #1618
Conversation
LGTM |
263bb3b
to
7f08d72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this script @tjaychen and sorry for the delay in review. I have a couple suggestions, please have a look.
puts $fileout "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | ||
puts $fileout "<MemInfo Version=\"1\" Minor=\"0\">" | ||
puts $fileout " <Processor Endianness=\"Little\" InstPath=\"dummy\">" | ||
puts $fileout " <AddressSpace Name=\"brom\" Begin=\"0\" End=\"$space\">" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puts $fileout " <AddressSpace Name=\"brom\" Begin=\"0\" End=\"$space\">" | |
puts $fileout " <AddressSpace Name=\"rom\" Begin=\"0\" End=\"$space\">" |
(For consistency within our code base.)
my i completely forgot about this PR. |
I'd say it's up to you. If we want to keep the splice flow (which we didn't use much in the past, re-synthesizing the whole bitstream seems to be less hassle), I'd appreciate if we can get this PR in. If not, then we can probably close it and remove the splicing if it breaks at one point. |
actually maybe this will be useful at some point... |
The current .tcl changes generate the following MMI map: <?xml version="1.0" encoding="UTF-8"?>
<MemInfo Version="1" Minor="0">
<Processor Endianness="Little" InstPath="dummy">
<AddressSpace Name="brom" Begin="0" End="16895">
<BusBlock>
<BitLane MemType="RAMB32" Placement="X4Y18">
<DataWidth MSB="8" LSB="0"/>
<AddressRange Begin="0" End="4095"/>
<Parity ON="false" NumBits="0"/>
</BitLane>
<BitLane MemType="RAMB32" Placement="X4Y19">
<DataWidth MSB="17" LSB="9"/>
<AddressRange Begin="0" End="4095"/>
<Parity ON="false" NumBits="0"/>
</BitLane>
<BitLane MemType="RAMB32" Placement="X3Y14">
<DataWidth MSB="26" LSB="18"/>
<AddressRange Begin="0" End="4095"/>
<Parity ON="false" NumBits="0"/>
</BitLane>
<BitLane MemType="RAMB32" Placement="X3Y15">
<DataWidth MSB="32" LSB="27"/>
<AddressRange Begin="0" End="4095"/>
<Parity ON="false" NumBits="0"/>
</BitLane>
</BusBlock>
</AddressSpace>
</Processor>
<Config>
<Option Name="Part" Val="xc7a200tsbg484-1"/>
</Config>
</MemInfo> The Unfortunately /tools/xilinx/Vivado/2020.1/bin/rdiArgs.sh: line 286: 1374147 Segmentation fault (core dumped) "$RDI_PROG" "$@" I am using Vivado v2020.1 SW build 2902540. |
Alternative options are being considered in #5751 |
Hey guys, this PR is pretty old but I think it's actually very useful. Therefore, I've rebased it and extended it to re-enable FPGA ROM splicing on boards other than the NexysVideo and more importantly if also boot ROM scrambling is enabled. I've sucessfully tested that on the CW310. If you think it's better to create a new PR I can do that. |
FYI @tjaychen |
a37f9eb
to
0a3c673
Compare
Previously, only the first two BRAM instances were checked, there were only placement rules for the first four banks (with scrambling there are five banks) and the placement seemed to be rather arbitrary (the chosen sites were not available on some FPGAs). With this commit, BRAM sites are chosen that are available on most FPGAs and the placement/checking is also enabled on boards other than the NexysVideo. Note this commit doesn't touch the splicing which currently doesn't work with the scrambling enabled. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This commit causes Vivado to output an MMI file that can be used for boot ROM splicing. Signed-off-by: Timothy Chen <timothytim@google.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM with a couple clarifications around naming. I'd prefer if you can squash the commits together that are fixups for previous commits.
util/fpga/splice_nexysvideo.sh
Outdated
|
||
util/fpga/addr4x.py -i "${TARGET}.brammem" -o "${TARGET}.mem" | ||
# Create the Vivado image for splicing. | ||
hw/ip/rom_ctrl/util/gen_vivado_mem_image.py "${TARGET}.32.vmem" "${TARGET}_vivado.mem" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mem and vmem files are effectively different variations of the same file format; the file extension in itself isn't really describing it. (vmem files as we use them are also given a .mem suffix from time to time). Also, Vivado uses different variations of the file format in different places, with updatemem having its own requirements. (https://www.xilinx.com/support/documentation/sw_manuals/xilinx2020_2/ug898-vivado-embedded-design.pdf#page=165 for the beautiful details).
To reduce confusion, would you mind renaming this file to something like "${TARGET}.updatemem.mem"
(also keeping the use of a dot for further qualifying the file, as we do for .scr.
etc.), and update the comment in the gen_vivado_mem_image.py to better describe this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @imphil for providing some more insight here. I've added some more details + the ref to gen_vivado_mem_image.py
and renamed the files as suggested.
util/fpga/splice_rom.sh
Outdated
./meson_init.sh | ||
ninja -C "${OBJ_DIR}" "${TARGET_EXPORT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid doing the software build in here, and expect the software to be built already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds fair. I've adjusted also the documentation accordingly.
TARGET_EXPORT="${TARGET_PREFIX}/boot_rom_export_fpga_${TARGET_BOARD}" | ||
TARGET="${BIN_DIR}/${TARGET_PREFIX}/boot_rom_fpga_${TARGET_BOARD}" | ||
|
||
FPGA_BUILD_DIR=build/lowrisc_systems_chip_${TARGET_TOP}_${TARGET_BOARD}_0.1/synth-vivado |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these directory paths are meant to be stable, only the paths in build-bin
are. Unfortunately, we don't have a build system that moves the bitstream there itself, we do this manually in CI.
So I'm fine with keeping things like that for now, but we'll need to change this if we want to use this script in CI (which is helpful to reduce CI times and test different ROMs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. The reason for not changing it now was mainly that I didn't want to change too much stuff at once. The main change to this file is the change of its name. But yes, we should change this in a follow up.
Previously, a combination of srec_cat and a custom Python script was was used to generate the Vivado ROM image from a .bin file. The new script directly reads the .vmem file to produce the Vivado .mem file usable for FPGA ROM splicing. But more importantly, this script is also compatible with word widths different to 32 bits. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
It turns out slices declared in the MMI need to be divisble by 8. Otherwise the updatemem tool doing the splicing segfaults. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This script no longer just works for the NexysVideo FPGA board, but it can work for all FPGA platforms instead. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
These placement constraints are no longer needed as the MMI file is now generated automatically. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Thanks for your review @imphil ! I've implemented the suggested changes and retested this locally. I will merge this once CI passes. |
set_property LOC RAMB36_X0Y12 [get_cells -hierarchical -filter { NAME =~ "*u_rom_ctrl*u_rom*rdata_o_reg_2" && PRIMITIVE_TYPE =~ BMEM.*.* }] | ||
set_property LOC RAMB36_X0Y13 [get_cells -hierarchical -filter { NAME =~ "*u_rom_ctrl*u_rom*rdata_o_reg_3" && PRIMITIVE_TYPE =~ BMEM.*.* }] | ||
set_property LOC RAMB36_X0Y14 [get_cells -hierarchical -filter { NAME =~ "*u_rom_ctrl*u_rom*rdata_o_reg_4" && PRIMITIVE_TYPE =~ BMEM.*.* }] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i'm a bit late to the party, but could someone quickly explain for a minute why we don't need the boot rom placement anymore? I thought we needed to find these in order to know where to splice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is: the nice script you wrote some time ago actually extracts the location of the BRAMs in the design. If the script is called late enough (meaning after place and route) these locations are indeed known and there is no point in setting a placement constraint. All that is needed is to verify that the ROM is indeed implemented using BRAM such that your script can extract the locations. This check is performed as part of the opt_design post hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The advantage of not specifying the locations is that the tool is free to place the ROM where suitable. On the CW310, I noted that the ROM logic was usually placed pretty far away from the ROM BRAMs. Also, without LOC constraints there won't be issues e.g. because on a different FPGA, the specified locations do not exist.
If brom sizes are changed in the future, this should be automatically handled.
Signed-off-by: Timothy Chen timothytim@google.com