Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

$readmemb and $readmemh cannot accept parameters!

I have a design that infers memory and I would like to initialize memory from a file. I used $readmemb and $readmemh and a filename parameter that is passed to the block.

parameter P_MEM_FILE = "mem_ini.txt",

$readmemb( P_MEM_FILE, memory, 0, P_DEPTH-1 );

Quartus complains about the parameter!

Error (10853): Verilog HDL error at cw_memory_sp.v(248): argument 0 to $readmemb must be a string literal File: cw_memory_sp.v Line: 248

If I have a fixed string as the filename in $readmemb, it works fine. I would like to reuse the same code among different synthesis tools and it is frustrating when one vendor does not support this.

Has anyone encountered this? Or do you have any workarounds?

-- Amal

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't like `defines but using a `define instead of a parameter should solve the issue.

    Jake
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't want to define all the different ROM files that we use. I don't like defines either unless they are managed properly, which they are not most often.

    -- Amal