UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 59786

Vivado Synthesis - Reading Hex values from external file to initialize a BRAM does not work

Description

Reading Hex values from an external file to initialize a BRAM using the following code does not work.

The BRAM is not initialized correctly by looking at the INIT values of the BRAM instance in the Synthesized design.

impure function InitRamFromFile (RamFileName : in string) return RamType is
FILE RamFile : text is in RamFileName;
variable RamFileLine : line;
variable RAM : RamType;
begin
for I in RamType'range loop
readline (RamFile, RamFileLine);
read (RamFileLine, RAM(I));
end loop;
return RAM;
end function;
signal RAM : RamType := InitRamFromFile("../../amx_build_nb_vss.data");


Solution

To read hexadecimal values the hread function must be used in the ram code.

impure function InitRamFromFile (RamFileName : in string) return RamType is
FILE RamFile : text is in RamFileName;
variable RamFileLine : line;
variable RAM : RamType;
begin
for I in RamType'range loop
readline (RamFile, RamFileLine);
hread (RamFileLine, RAM(I));
end loop;
return RAM;
end function;

signal RAM : RamType := InitRamFromFile("../../amx_build_nb_vss.data");
AR# 59786
Date Created 03/14/2014
Last Updated 09/04/2014
Status Active
Type General Article
Tools
  • Vivado Design Suite