cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Participant
Participant
1,254 Views
Registered: ‎12-01-2017

Relative path incoherence between project and non-project mode

In my code, some instances of xpm_memory have its MEMORY_INIT_FILE generic set to a relative path towards a .mem.

For example:

        xpm_memory_spram_inst : xpm_memory_spram
            generic map (
                -- Common module generics
                MEMORY_SIZE             => ...,     -- positive integer
                MEMORY_PRIMITIVE        => "block" ,
                MEMORY_INIT_FILE        => "../../../../../file.mem" ...

            )

 

Since our script launches vivado in the same directory, let us call it "workspace", relative to file.mem, I thought the relative path would always work.

While it works in non-project mode, I have noticed that in project mode synthesis, paths are no longer relative to "workspace", but to "workspace/module.runs/synth_1". My MEMORY_INIT_FILE is not longer found, and my memories are initialized to zero.

 

I have tried to fix it by adding a .xdc:

 

    set xpm_memory_inst [get_cells -quiet -hierarchical -filter { REF_NAME =~ "xpm_memory*" || \
                                                                  ORIG_REF_NAME =~ "xpm_memory*" }]
    foreach inst $xpm_memory_inst {
      set init_file [get_property MEMORY_INIT_FILE $inst]
      # Detect if it is a relative path and we are in project mode
      if { [regexp {^\.\./} $init_file] && [llength [get_runs]] } {
        set_property MEMORY_INIT_FILE ../../$init_file $inst
      }
    }

 

However, the .xdc does not work, because it is sourced after the memory initialization is done, even when PROCESSING_ORDER is set to EARLY.

Is there a way to solve this relative path incoherence between project and non-project mode some other way?

 

0 Kudos
3 Replies
Highlighted
Mentor
Mentor
1,226 Views
Registered: ‎02-24-2014

I don't have a solution, but rather a workaround..    One possibility is to create a symbolic link in your synth_1 directory that points to the memory file..    Another workaround is to use behavior code instead of xpm_memory, and then just write a VHDL function that initializes your memory (which is probably impractical, if you have a complex method to generate the memory file).

Don't forget to close a thread when possible by accepting a post as a solution.
0 Kudos
Highlighted
Participant
Participant
1,206 Views
Registered: ‎12-01-2017

I thought about the first option, but it means the MEMORY_INIT_FILE will become "file.mem". That will impact all my simulations and non-project synthesis. Finally, all .mem will be copied to the synthesis/simulation directory.
0 Kudos
Highlighted
Participant
Participant
1,159 Views
Registered: ‎12-01-2017

Finally, I have created a VHDL package that is included by all my xpm_memory wrappers. The script that calls vivado replaces a constant called PROJECT_MODE to true or false according to the type of vivado instantiation in the package. The wrapper adds a "../../" if in project mode.

If you are using a Verilog wrapper, it is probably easier to create a define.

0 Kudos