I thought that this code compiled, now it does not?

B

Bob

I thought that this code compiled (old counter thread), now it does
not?
Maybe it never did compile but anyway this is the error I now get.
Have any Ideas?
I am using Xilinx ISE 6.3

ERROR:HDLParsers:808 - C:/projects/PM_CPLD/10186201/counter16bit.vhd
Line 32. + can not have such operands in this context.
ERROR: XST failed

Note: Line 32 is cnt:=cnt+1;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

use IEEE.NUMERIC_STD.ALL;

entity counter16bit is
port (
-- 16-bit synchronous counter,
CLK: in STD_LOGIC;
RESET: in STD_LOGIC;
RESET2: in STD_LOGIC;
FULL: out STD_LOGIC;
COUNT: out STD_LOGIC_VECTOR(15 downto 0)
);
end counter16bit;

architecture Behavioral of counter16bit is

begin
process (CLK, RESET, RESET2)
variable cnt:std_logic_vector(15 downto 0);
variable temp_full:std_logic;

begin
if RESET='1' or RESET2='0' then
COUNT <= (others => '0');
cnt:= (others => '0'); -- occur instantly.
FULL <= '0';
temp_full:= '0'; -- occur instantly.

elsif CLK='1' and CLK'event and temp_full='0' then -- rising
edge of clk!
cnt:=cnt+1; -- occur instantly. THIS IS
LINE 32!
COUNT<=cnt;
temp_full:=cnt(15); -- occur instantly.
FULL <= temp_full;
end if;
end process;

end Behavioral;
 
R

Ralf Hildebrandt

Bob wrote:

ERROR:HDLParsers:808 - C:/projects/PM_CPLD/10186201/counter16bit.vhd
Line 32. + can not have such operands in this context.
ERROR: XST failed

Note: Line 32 is cnt:=cnt+1;

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

use IEEE.NUMERIC_STD.ALL; ....
variable cnt:std_logic_vector(15 downto 0);

Arithmetics are not defined on std_(u)logic_vectors (for a good reason).

With IEEE.numeric_std use

cnt:=std_logic_vector( unsigned(cnt)+1 );

Or define cnt of type unsigned. (For addition you may also choose signed.)

Ralf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top