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
[HW, RV_PLIC] Claim/Complete register behaviour on FPGA #1355
Comments
@msfschaffner @eunchan could you please look into this? |
So from looking at the ILA outputs what's happening is the gateway seems to set the ip and ia flops up correctly (i.e. bit 32 gets set when the TX watermark interrupt is triggered) but something goes wrong in the target presumably in the logic that determines the highest priority. The reg2hw.cc0.q signal reads as 'h1 on the ILA (well I'm actually probing complete_id[0] but it's assigned to reg2hw.cc0.q) but SW cannot read this value for whatever reason. Again from the ILA output I don't think the irq_q flop is getting set in the target module (perhaps this causes CC0 to get masked to 0 somewhere?) |
The SW proof-of-concept code that I have put together lives here |
Thanks for reporting the issue. When @alistair23 reported this, I overlooked the chance of optimized away the logic. Let me and @msfschaffner dig this issue. Thanks! CC: @tjaychen |
Thanks for reporting this issue. Might be a simulation/synthesis mismatch, yes. The fastest way to test your hypothesis would be to build two bitstreams (one with the old and one with the new plic target). I've just kicked these builds off and will test them with the uart test. |
Ok after running the uart test on both versions (i.e. old/new plic target) in simulation as well as on FPGA, I can confirm that we are likely seeing a simulation/synthesis mismatch here. I could not root-cause the mismatch just yet (the synthesis reports do not offer any insight). Will continue digging tomorrow. In the mean time you can use the hotfix Note that synthesis might take considerably longer since that implementation does not scale well to so many interrupt sources (63). Also, please do not yet merge this fix into the main repository if possible. I hope that we will find the actual bug soon such that we can use the new implementation. |
Btwy, I am using Vivado v2018.3. Has anyone tried with a different version than that yet? |
@msfschaffner and @eunchan thank you for looking into this problem, and for the patch.
I use the same version as you. |
@msfschaffner I have tried your temporary patch, and can confirm that I can get TX watermark interrupt to fire on the FPGA. Thank you |
Tried with Vivado 2019.2, synthesis tool just crashes early, there's some messages from a memory allocater reporting large allocs. Looks like it runs out of memory and crashes. However the reported allocs have a suspicious progress of sizes:
So 1 GiB, 2GiB, 4GiB, 8GiB precisely. |
I tried a run with the priority logic commented out of rv_plic_target (the theory being Vivado is doing something wrong with it, in 2018.3 this is a synthesis bug in 2019.2 it causes the large memory allocations and a crash) but same result. |
Update: after closer netlist inspection, it looks like Vivado is dropping the whole target module for some reason in 2018.3. I can reproduce this behavior when synthesizing the Moving to 2019.2 shows no improvement, neither. |
Thanks for the update Michael!
In the meantime, we could add old (not efficient version) version of RV_PLIC to
target and selectable between the BINTREE and MATRIX?
…On Fri, Jan 17, 2020 at 11:38:23AM -0800, Michael Schaffner wrote:
Update: after closer netlist inspection, it looks like Vivado is dropping the whole target module for some reason in 2018.3. I can reproduce this behavior when synthesizing the `rv_plic` in isolation.
Moving to 2019.2 shows no improvement, neither.
I am inclined to file an issue with Xilinx...
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#1355 (comment)
|
I am still bisecting the target module and I think I have found something. If that does not lead anywhere within the next 1-2h I will do what you suggested. |
@GregAC, I think you ran into this (known) issue in 2019.2: https://www.xilinx.com/support/answers/73178.html |
Ok I found the problem, which is likely a bug in Vivado. If you look at the new binary tree implementation of Vivado doesn't seem to like the ternary statements on these lines: opentitan/hw/ip/rv_plic/rtl/rv_plic_target.sv Lines 86 to 92 in de3b010
If I rewrite this with bitwise ops mimicking a multiplexor, the module synthesizes without issues, and I can run the uart test with no problems. I am going to push a patch for this and file a bug report to Xilinx. |
Thanks Michael !
Do you want to send out a general notice? I have to imagine others will run
into this also.
…On Fri, Jan 17, 2020, 12:52 Michael Schaffner ***@***.***> wrote:
Ok I found the problem, which is likely a bug in Vivado.
If you look at the new binary tree implementation of rv_plic_target, it
has two nested generate loops within which the different nodes of the tree
are connected with each other.
Vivado doesn't seem to like the ternary statements on these lines:
https://github.com/lowRISC/opentitan/blob/de3b0108bbaa630a3a005595bdd57ea01f2af1e7/hw/ip/rv_plic/rtl/rv_plic_target.sv#L86-L92
If I rewrite this with bitwise ops mimicking a multiplexor, the module
synthesizes without issues, and I can run the uart tests with no problems.
I am going to make a patch for this and make a bug report to Xilinx.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1355?email_source=notifications&email_token=AAH2RSTTAI2CFPCMJ2B5UVDQ6ILCXA5CNFSM4KHXCWWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJI56KA#issuecomment-575790888>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH2RSVEICQPENDR5ZYTT4TQ6ILCXANCNFSM4KHXCWWA>
.
|
Yes will do. The patch for this issue can be found here: #1364. PTAL |
Great debugging and patience, @msfschaffner ! Let us know what Xilinx has to say. |
Thanks everyone for helping track down this problem. In the meanwhile, the hotfix for this problem has been merged. |
That's great, thank you @msfschaffner |
Quick update: This is a tooling issue (a signal gets optimized in the wrong way), and a Xilinx internal issue has been filed to get it fixed. In the meanwhile, follow the guidance provided here: |
With #1364 merged to workaround this, and #1402 to track adding further testing, I think this issue can now be closed? We could rewrite this issue to track the removal of the in-tree workaround but that seems messy/confusing. I propose:
|
Thanks @asb, agreed. I've opened another issue for this. |
Thanks Michael, I like your optimism that this will be the only Vivado synthesis bug we encounter :) |
The purpose of this test is to validate external interrupt delivery from peripheral to the target. The aim is not to test the entire PLIC or entirety of the peripherals, but to ensure that two different IRQs can interrupt the processor and be successfully handled. For the purpose of this test the UART peripheral is used as the origin of the interrupts, and the interrupted target is Ibex (the only target in current Earl Grey implementation). This test ensures (in terms of UART RX Overflow and TX Empty IRQ sources, and Ibex target): * That PLIC getaway receives and handles an IRQ correctly. * That PLIC Core and Target modules handle an IRQ correctly. * That an IRQ can interrupt the target. * That an IRQ can be cleared and a new IRQ can be processed. The reason for introducing this test was an issues we had previously with the IRQ delivery on the FPGA, see issue lowRISC#1355 for more details. This test can be run by CI, and used manually to test the IRQs on an FPGA. Fixes: lowRISC#1402 Signed-off-by: Silvestrs Timofejevs <silvestrst@lowrisc.org>
The purpose of this test is to validate external interrupt delivery from peripheral to the target. The aim is not to test the entire PLIC or entirety of the peripherals, but to ensure that two different IRQs can interrupt the processor and be successfully handled. For the purpose of this test the UART peripheral is used as the origin of the interrupts, and the interrupted target is Ibex (the only target in current Earl Grey implementation). This test ensures (in terms of UART RX Overflow and TX Empty IRQ sources, and Ibex target): * That PLIC getaway receives and handles an IRQ correctly. * That PLIC Core and Target modules handle an IRQ correctly. * That an IRQ can interrupt the target. * That an IRQ can be cleared and a new IRQ can be processed. The reason for introducing this test was an issues we had previously with the IRQ delivery on the FPGA, see issue #1355 for more details. This test can be run by CI, and used manually to test the IRQs on an FPGA. Fixes: #1402 Signed-off-by: Silvestrs Timofejevs <silvestrst@lowrisc.org>
Switch to Vivado 2020.2 as minimum requirement. This version fixes a critical synthesis mismatch bug, as discussed in more detail at https://forums.xilinx.com/t5/Synthesis/Simulation-Synthesis-Mismatch-with-Vivado-2018-3/m-p/1065923#M33849. We did work around this Vivado bug in the past (see lowRISC#1355, lowRISC#1408), but can avoid these workarounds now, as they collide slightly with syntax that is works better for Verilator (lowRISC#6639). Signed-off-by: Philipp Wagner <phw@lowrisc.org>
Switch to Vivado 2020.2 as minimum requirement. This version fixes a critical synthesis mismatch bug, as discussed in more detail at https://forums.xilinx.com/t5/Synthesis/Simulation-Synthesis-Mismatch-with-Vivado-2018-3/m-p/1065923#M33849. We did work around this Vivado bug in the past (see lowRISC#1355, lowRISC#1408), but can avoid these workarounds now, as they collide slightly with syntax that is works better for Verilator (lowRISC#6639). Signed-off-by: Philipp Wagner <phw@lowrisc.org>
Switch to Vivado 2020.2 as minimum requirement. This version fixes a critical synthesis mismatch bug, as discussed in more detail at https://forums.xilinx.com/t5/Synthesis/Simulation-Synthesis-Mismatch-with-Vivado-2018-3/m-p/1065923#M33849. We did work around this Vivado bug in the past (see #1355, #1408), but can avoid these workarounds now, as they collide slightly with syntax that is works better for Verilator (#6639). Signed-off-by: Philipp Wagner <phw@lowrisc.org>
Switch to Vivado 2020.2 as minimum requirement. This version fixes a critical synthesis mismatch bug, as discussed in more detail at https://forums.xilinx.com/t5/Synthesis/Simulation-Synthesis-Mismatch-with-Vivado-2018-3/m-p/1065923#M33849. We did work around this Vivado bug in the past (see lowRISC#1355, lowRISC#1408), but can avoid these workarounds now, as they collide slightly with syntax that is works better for Verilator (lowRISC#6639). Signed-off-by: Philipp Wagner <phw@lowrisc.org>
Interrupts are firing in verilator but not FPGA. This issue has been first discovered by @alistair23 working on Tock. I have also ran into this issue when doing some proof-of-concept work, related to #1330 .
After examining the netlist, it seems that portions of RV_PLIC are optimised by the FPGA synthesis tool (rv_plic_target, as well as cc0 in rv_plic_reg_top). One of the hypothesis is that parts of PLIC have been optimised out by the synthesis tool, possibly as result of @msfschaffner PLIC rework.
We have set up a set of relevant UART and PLIC signals in the Integrated Logic Analyser, and triggered an UART TX watermark interrupt. Thus, we would expect to read a value of 33 from CC0 (the interrupt claim register). However, we observed the following results:
Thank you @GregAC for setting up ILA, and @vogelpi for going through RTL with me.
The text was updated successfully, but these errors were encountered: