memory_libmap: look for ram_style attributes on surrounding signals #4008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One generally accepted way to describe ROMs is through a case statement:
(See https://docs.xilinx.com/r/en-US/ug901-vivado-synthesis/ROM-Using-Block-RAM-Resources-Verilog for a vendor recommending this style.)
Or the corresponding VHDL description:
(Recommended by another vendor: https://www.intel.com/content/www/us/en/docs/programmable/683082/23-1/inferring-rom-functions-from-hdl-code.html)
In this case, the intuitive place to put the ram_style attribute would be on the output register. Verilog is flexible enough to allow attributes on the case statement, which does get successfully handed down through
proc_rom
ormemory_bmux2rom
(forread_verilog
andverific
respectively) to the inferred$mem_v2
cell, but VHDL only allows attributes on named objects so the output signal is the only possible place to put the attribute in the VHDL description. (This is mostly not an issue for RAM inference since there is always an array declaration that is the more natural place to put the attribute, but it should still be supported to put it on the output signal IMO.)This PR makes
memory_libmap
search for attributes on the data and address wires if they aren't found on the memory itself. (The implementation is a bit ugly, happy to take suggestions for improvement.)It also adds
(* no_ram *)
as a synonym for(* ram_style = "logic" *)
since I happened to come across it while browsing vendor documentation.Currently this will fail the verific tests because verific doesn't import the attributes on port signals; don't merge until a fix for that is in. (@mmicko can you have a look at those test cases?)