Forum Discussion

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

Error (10779): VHDL error at memory.vhd(30): expression is not constant

Hello, i have an issue on this vhdl code, i need to increment the index of my vector to fill up a memory. the problem is that quartus reports me this error when i try to put a variable as an index like ( A downto B) where A and B are variables...

thank you for the help!

here is the code:

  1. LIBRARY ieee;

  2. use IEEE.STD_LOGIC_1164.ALL;

  3. use IEEE.STD_LOGIC_SIGNED.ALL;

  4. USE ieee.numeric_std.all;

  5. USE std.standard;

  6. entity memory is

  7. Port ( Clk : in std_logic; -- processing clock

  8. wr : in std_logic; -- write enable signal

  9. cs : in std_logic ;-- select memory

  10. rd : in std_logic; -- enable reading from memory

  11. add : in std_logic_vector(9 downto 0); -- write address to store the data into ram

  12. data_in : in signed(7 downto 0); -- input data to store into ram

  13. data_out : out signed(7 downto 0)); -- output data from memory

  14. end memory;

  15. architecture Behaviour of memory is

  16. signal tmp: integer range 0 to 1023 := 0 ;

  17. signal tmp1,tmp2: integer range 0 to 8184:= 0;

  18. signal storage: signed (8184 downto 0);

  19. begin

  20. tmp <= to_integer(unsigned(add));

  21. tmp1 <= 7+ tmp*8;

  22. tmp2 <= tmp*8;

  23. process(Clk)

  24. begin

  25. if Clk'event and Clk = '1' then

  26. if (wr = '1' and cs='1') then -- In this process writing the input data into memory

  27. storage(tmp1 downto tmp2) <= data_in;

  28. end if;

  29. if (cs='1' and rd='1') then

  30. data_out <= storage(tmp1 downto tmp2) ;

  31. end if;

  32. end if;

  33. end process; -- asynchronous reading from memory

  34. end Behaviour;

4 Replies

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

    Which line is line 30?

    Could you edit your post so it is using code tags so the formatting isa bit better?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Why have you got such a large signed number? if you are intending on using a ram you should use an array of signed, not a single signed, and then index to a single element on any given clock cycle.

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

    According to VHDL rules, you should use this straightforward coding

    storage(7+ tmp*8 downto tmp*8) <= data_in;
    …
    data_out <= storage(7+ tmp*8 downto tmp*8);

    Even more straightforward, an array 1024x8.