-
Notifications
You must be signed in to change notification settings - Fork 807
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
[dv,mem_bkdr_util] Separate out flash_bkdr_util #26081
base: master
Are you sure you want to change the base?
Conversation
filesets: | ||
files_dv: | ||
depend: | ||
- lowrisc:opentitan:bus_params_pkg |
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.
Are these dependencies all needed or do the already get pulled in from the mem_bkdr_util? Or is it just a safeguard?
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've dropped a couple but I think the rest are all needed. I would observe that many of our core files appear not to be as minimal as they could be if they relied upon transitivity. I am a bit apprehensive about breaking an untested build, and I'm sure CI is far from complete w.r.t. that.
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.
Looks good with one question.
01b73d5
to
e11ef56
Compare
Separate flash support into another package so that designs such as Darjeeling can employ mem_bkdr_util without depending upon the flash controller/package. Signed-off-by: Adrian Lees <[email protected]>
e11ef56
to
36a1664
Compare
Did you consider the way this same issue was handled for otp_ctrl? It basically moved the complete specialization in otp_ctrl out to hw/ip_templates/otp_ctrl/dv/env: look at https://github.com/lowRISC/opentitan/blob/master/hw/ip_templates/otp_ctrl/dv/env/otp_ctrl_mem_bkdr_util_pkg.sv and https://github.com/lowRISC/opentitan/blob/master/hw/ip_templates/otp_ctrl/dv/env/otp_ctrl_mem_bkdr_util.core.tpl. Perhaps for flash_ctrl the flash_ctrl_mem_bkdr_util_pkg.sv will need to be a template, but at least in the otp_ctrl all specializations are accessed via the top specific pkg files. I think that approach is cleaner since it removes all traces of the flash_ctrl details from mem_bkdr_util, and mem_bkdr_utils simply takes care of reads and writes, which is what it does for a living. |
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 left a comment with my suggestion for how to do this. Also refer to #25891.
I am familiar with the way otp_ctrl was extracted, yes, and I think that makes sense for an ip_template that needs to be specialized for the different top levels. The single additional function required for flash support is a little different, in my opinion, since we're not specializing the flash controller for Darjeeling; it's just not present in the integrated design.
The separation in this PR does achieve that too. mem_bkdr_util no longer contains any reference to the flash package or any flash-specific functionality, which allows the Darjeeling top-level to brought up alongside that of Earl Grey for the first time, and simulations of both are now possible on my local branch without crosstalk between the two environments. If it's felt that the flash_bkdr_util package is too specific to belong in the dv/sv/ directory - and the same argument could apply to ROM- and SRAM-specific behavior - it could always be moved later since it's now self-contained. |
👍 |
I see this is a very simple change, but it adds clutter rather than addressing root causes. Basically this change will need to be undone and done the right way, so this kicks the can down the road hoping someone else will do the real fix, fully knowing what that fix should be. |
Implementing rom_, sram_ and flash_bkdr_util as extended classes of mem_bkdr_util means that they may be accessed without requiring specialized code and without needing to know what type of memory is being accessed, as requested here some time ago:
Also at a few other sites in the top-level DV where you can see things become tidier. This PR only separates the files into different packages and core files and I should have realized that was necessary when the extended classes were introduced; mea culpa. |
Thanks for your feedback, @matutem. If I understand you correctly, your position is that this change should be made in a different way, right now in this PR, but I don't understand how exactly you'd prefer things to be done. You mentioned the templated Could you please elaborate how you'd prefer |
My point is that mem_bkdr_util should just worry about raw reads and writes, and any of the memory specific concerns should be in the dv code for the specific memory to avoid pollution. The otp_ctrl flagged this because of top-specificity, and I am glad it flagged it, since the memory specific code should not have been placed in mem_bkdr_util in the first place. If we did this for flash_ctrl then darjeeling would not have needed to do anything at all since it doesn't use flash_ctrl. The flash_bkdr_util class as it exists is pretty dependent on flash_phy, which is not very generic, and hw/dv/sv is meant for generic stuff. Also notice the code is replicated from the existing one under hw/ip_templates/flash_ctrl/dv/env. As for the implementation of this, the only function affected is flash_write_scrambled, which is from the top dv/env/seq_lib code called as <mem_bjdr_instance>.flash_write_scrambled(...), and this can be changed to flash_write_scrambled(<mem_bkdr_instance>, ...). The function itself can be placed in flash_ctrl_env_pkg, for example. |
Okay, I think we can go further in tidying up mem_bkdr_util than the work already done in #26045, but since this is more work than intended at this stage of Darjeeling bring up, please let's reach agreement first. Firstly I was unaware of the duplication of code between flash_bkdr_util and flash_ctrl; this predates my involvement and I had not looked at flash_ctrl DV in detail. Thanks for drawing attention to that; it is clearly undesirable and should be eliminated. The base class
Perhaps in the above the specialized types of memory model should really be called something like 'rom_model.sv', 'flash_model.sv' rather than '.._bkdr_util.' The test bench code in each top level can then perform read/write acceses to each of the created memory models without having to contain special checks for the memory type; this was clearly the intent of the code here:
and in the other related functions performing backdoor accesses. The intention was to permit direct read/write operations on the Flash Data parititions too, which makes it a bit different from the OTP controller as I understand things.
Whilst Darjeeling does not have flash memory, I understand there has repeatedly been talk of future OpenTitan designs employing 'execute in place' flash in which case we shall need to keep the ability to read/write symbols in the data partitions that the flash controller presents to the host. I would contend that the flash interface has more in common with the ROM and SRAM than with the OTP controller, and that this is exactly the kind of situation for which inheritance exists. @andreaskurth , @matutem , @Razer6 , @rswarbrick - thoughts please? |
Separate flash support into another package so that designs such as Darjeeling can employ mem_bkdr_util without depending upon the flash controller/package.