B
Blake
Guest
I'm trying to teach myself to work with CPLD's using some of the many good
tutorials on the web. My first project includes a counter that should
continuously count from 0 to 99, in step size that can be selected by
external jumpers.
It sounded easy enough to me, but . . . I normally don't like to ask for
help when I can dig into the books for myself, but this time I've run into
a dead end.
Using the code below, I can't cure a sintax error message - something to the
effect that the TO_UNSIGNED function must have the size specified. (I think
I did specify the size - I wish I had remembered to email myself the exact
message from work). Do any of you experienced programmers have suggestions
to get me straightened out on this one? If so, it would be a big help.
-----------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
entity COUNTER is port (CLOCK: in std_logic;
STEP: in std_logic_vector (5 downto 0);
COUNT: out std_logic_vector (6 downto 0));
end COUNTER;
architecture Behavioral of COUNTER is
begin
constant STEPI: integer range 0 to 63 ;
variable COUNTI: integer range 0 to 127 := 0 ;
STEPI <= TO_INTEGER (TO_UNSIGNED(STEP));
STEP_COUNT: process
begin
loop
wait until CLOCK='1';
COUNTI := (COUNTI + STEPI) mod 100 ;
end loop ;
end process STEP_COUNT;
COUNT <= TO_STDLOGICVECTOR( TO_UNSIGNED ( COUNTI,7 ));
end Behavioral;
tutorials on the web. My first project includes a counter that should
continuously count from 0 to 99, in step size that can be selected by
external jumpers.
It sounded easy enough to me, but . . . I normally don't like to ask for
help when I can dig into the books for myself, but this time I've run into
a dead end.
Using the code below, I can't cure a sintax error message - something to the
effect that the TO_UNSIGNED function must have the size specified. (I think
I did specify the size - I wish I had remembered to email myself the exact
message from work). Do any of you experienced programmers have suggestions
to get me straightened out on this one? If so, it would be a big help.
-----------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
entity COUNTER is port (CLOCK: in std_logic;
STEP: in std_logic_vector (5 downto 0);
COUNT: out std_logic_vector (6 downto 0));
end COUNTER;
architecture Behavioral of COUNTER is
begin
constant STEPI: integer range 0 to 63 ;
variable COUNTI: integer range 0 to 127 := 0 ;
STEPI <= TO_INTEGER (TO_UNSIGNED(STEP));
STEP_COUNT: process
begin
loop
wait until CLOCK='1';
COUNTI := (COUNTI + STEPI) mod 100 ;
end loop ;
end process STEP_COUNT;
COUNT <= TO_STDLOGICVECTOR( TO_UNSIGNED ( COUNTI,7 ));
end Behavioral;