cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bborko
Contributor
Contributor
3,403 Views
Registered: ‎06-24-2008

Generate contents of array (for rom) programmatically

I am creating a ROM that has a generated lookup table but I am having trouble finding syntax for this. This illustrates the idea of what I want to do:

 

 

  type ram_type is array (2**ADDR_WIDTH-1 downto 0) of std_logic_vector (DATA_WIDTH-1 downto 0);
  constant GRAPH_LOOKUP_TABLE : ram_type := (

    gen_delta_circle: for theta in 0 to 359 generate
      std_logic_vector(to_signed(to_integer(cos(theta)),DX_WIDTH)) & std_logic_vector(to_signed(to_integer(sin(theta)),DY_WIDTH)),
    end generate gen_delta_circle;

    others => std_logic_vector(to_unsigned(0, DATA_WIDTH))
    );

 

 

 --note: data_width == dx_width + dy_width

 

 

Does anyone know how to programmatically generate the contents of an array or rom?

 

thanks!

0 Kudos
1 Reply
barryabrown
Explorer
Explorer
3,396 Views
Registered: ‎09-11-2007

In VHDL, you can initialize a variable with a function, such as.....

 

  subtype int18 is integer range -131072 to 131071;
  type mem_array is array(0 to (2**N_addr)-1) of  int18;   -- 4k x 18
 
  -- function computes contents of cosine lookup ROM
  function init_rom return mem_array is

         (your function here)
  end function init_rom;

 

  constant rom : mem_array := init_rom;

 

 

Barry

 

0 Kudos