+ Post New Thread
Results 1 to 11 of 11
  1. #1
    Newbie level 6
    Points: 394, Level: 4

    Join Date
    Feb 2011
    Posts
    13
    Helped
    0 / 0
    Points
    394
    Level
    4

    readmemh in verilog and xilinx

    ive used the following statement in verilog but im not able to synthesize using xilinx ise 11

    $readmemh("water.txt",mem_RGB);

    the error messeage is as follows

    Value 184321292 found at line 1 is not hexadecimal in call of system task $readmemh.


    pls help..


    thank you.

  2. #2
    Full Member level 6
    Points: 4,262, Level: 15
    Achievements:
    7 years registered

    Join Date
    May 2007
    Location
    Canada
    Posts
    339
    Helped
    98 / 98
    Points
    4,262
    Level
    15

    Re: readmemh in verilog and xilinx

    $readmemh is not synthesizeable. It is used for simulation or behavioural code only.

    r.b.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Newbie level 6
    Points: 394, Level: 4

    Join Date
    Feb 2011
    Posts
    13
    Helped
    0 / 0
    Points
    394
    Level
    4

    Re: readmemh in verilog and xilinx

    what other option can i use??



  4. #4
    Full Member level 6
    Points: 4,262, Level: 15
    Achievements:
    7 years registered

    Join Date
    May 2007
    Location
    Canada
    Posts
    339
    Helped
    98 / 98
    Points
    4,262
    Level
    15

    Re: readmemh in verilog and xilinx

    If you are intializing a memory, you can specify a .coe file when you generate the memory core and the memory. Once implemented, will power up with the values in the .coe file. Refer to Xilinx documentation for information on how to do that.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  5. #5
    Advanced Member level 3
    Points: 5,700, Level: 17

    Join Date
    Jul 2010
    Posts
    923
    Helped
    294 / 294
    Points
    5,700
    Level
    17

    Re: readmemh in verilog and xilinx

    for FPGAs, readmemh is synthesizable. Xilinx has slightly better support than Altera. Xilinx allows any generic/constant/literal to be used for a filename, while Altera only allows hard-coded literals. But both XST and quartus support readmem.

    readmemh is simply placed in an initial begin-end block.

    I suspect the issue is the invalid data width or such. I don't know the declaration of mem_RGB, nor the first line of "water.txt"


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  6. #6
    Newbie level 6
    Points: 394, Level: 4

    Join Date
    Feb 2011
    Posts
    13
    Helped
    0 / 0
    Points
    394
    Level
    4

    Re: readmemh in verilog and xilinx

    this is apart of of my code.

    reg [8:0] mem_RGB [0:767];
    wire[8:0] mem_Y [0:255];
    reg [8:0] mem_WATERMARKED [0:255];
    initial
    begin
    $readmemh("water.txt",mem_RGB);
    end

    ive attached the water.txt file


    water.txt



  7. #7
    Advanced Member level 3
    Points: 7,585, Level: 20

    Join Date
    Dec 2004
    Posts
    759
    Helped
    113 / 113
    Points
    7,585
    Level
    20

    Re: readmemh in verilog and xilinx

    Again initial statement is not synthesisable so is readmemh.

    Use BlockRAM for initialization.



  8. #8
    Advanced Member level 3
    Points: 5,700, Level: 17

    Join Date
    Jul 2010
    Posts
    923
    Helped
    294 / 294
    Points
    5,700
    Level
    17

    Re: readmemh in verilog and xilinx

    Quote Originally Posted by Jack// ani View Post
    Again initial statement is not synthesisable so is readmemh.

    Use BlockRAM for initialization.
    No, it works. I've used it several times. Both Xilinx and Altera provide documentation that shows how to use it.

    @prat:
    water.txt is not in the correct format. readmemh expects 1 datapoint per line. you have all of the datapoints on the same line.


    1 members found this post helpful.

  9. #9
    Advanced Member level 3
    Points: 7,585, Level: 20

    Join Date
    Dec 2004
    Posts
    759
    Helped
    113 / 113
    Points
    7,585
    Level
    20

    Re: readmemh in verilog and xilinx

    Quote Originally Posted by permute View Post
    No, it works. I've used it several times. Both Xilinx and Altera provide documentation that shows how to use it.
    Good to know, it will make things easy! Can you please post links to those documentation?



  10. #10
    Advanced Member level 3
    Points: 5,700, Level: 17

    Join Date
    Jul 2010
    Posts
    923
    Helped
    294 / 294
    Points
    5,700
    Level
    17

    Re: readmemh in verilog and xilinx

    it is in the sections about inferring block rams. Also, Altera's tools are a bit dangerous in that in some cases they will fail silently. Eg, some use cases of inferred block ram will not use the readmemh line, but will not show any info/warning/error. Ironically, it becomes easier to mis-size (widths or depth) the entries in the readmem file as these conditions are warnings and will show that the RAM is initialized in synthesis.

    http://www.xilinx.com/support/docume...1/xst_v6s6.pdf
    This is described in the XST (13.1, v6s6) user manual on pages 86 and 221. The Quartus manual also shows how to use readmem. Just be sure to read the sections about all of the HDL issues with inferring specific hardware features, as they can be device dependent or non-obvious or benefit from additional synthesizer attributes. For example, many of Xilinx's non-slice registers only have synchronous resets, if any reset at all. Likewise, RAMs may need to register the address, but might not provide that registered signal back into fabric.

    If you want to see something really interesting, look at the example of a true dual port inferred block ram starting on page 188 -- it uses VHDL's "shared variables".


    2 members found this post helpful.

    •   AltAdvertisement

        
       

  11. #11
    Newbie level 6
    Points: 394, Level: 4

    Join Date
    Feb 2011
    Posts
    13
    Helped
    0 / 0
    Points
    394
    Level
    4

    Re: readmemh in verilog and xilinx

    @permute::Thanks a ton... my synthesis is successful:D



--[[ ]]--