1

I am trying to crate a 64 bit ROM type ROM is array (7 downto 0, 7 downto 0) of std_logic;

then I want create constant R :ROM :=.

Where R(0, 7 downto 0 ) would be value of "00010011",

R(0, ) R(1, ) is selected by an 3bit pointer value and then it output by formula :

for i in 0 to 7  loop
      Data_Out(i) <= R(conv_integer(AArray),i);
end loop;.

But which ever way I am trying define the constant value of ROM I get an error, could someone point me to right way of defining constant for this array.

1 Answer 1

4

For more complex initialization values, it is often helpful to make a function that returns the constant value to assign, like:

type ROM is array (7 downto 0, 7 downto 0) of std_logic;

function ROM_init return ROM is
  variable res_v : ROM;
begin
  -- Write code that assigns initial value to res_v
  return res_v;
end function;

constant R : ROM := ROM_init;

If an array of vectors is actually needed, you may consider instead doing:

type ROM is array (7 downto 0) of std_logic_vector(7 downto 0);
function ROM_init return ROM is
  variable res_v : ROM;
begin
  res_v(0) := "00010011";  -- Value from question
  -- Write more code that assigns initial value to res_v;
  return res_v;
end function;
constant R : ROM := ROM_init;

Note that the synthesis tool will probably not implement this as a ROM memory block, but simply as a simple logic network.

Sign up to request clarification or add additional context in comments.

4 Comments

line function ROM_init return ROM is gives error "parse error, unexpected IS, expecting SEMICOLON" . Any idea why I am using ISE 14.7
Would it be because type ROM is in the package?
If the ROM_init function is placed in a package, then the public part of the package (package) should only declare function ROM_init return ROM;, and the implementation of the package (package body) should have the function implementation itself with function ROM_init return ROM is ... end function;.
Yes you are 100% right. I have just find this out and so far so good I will run small test bench and see if it works correctly now, thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.