before to show my vhdl code i thanks you for reply me :))))
this is my work until now:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
ENTITY counter IS
PORT(
clk : in BIT;
upordwn : in STD_LOGIC;
initial : in STD_LOGIC_VECTOR(7 DOWNTO 0);
count : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
LED_1 : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
LED_2 : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
LED_CENT : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
end counter;
ARCHITECTURE prova OF counter IS
SIGNAL totalbit : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL up_four : STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL low_four : STD_LOGIC_VECTOR(4 DOWNTO 0);
BEGIN
PROCESS(clk)
--QUI DEVO INSERIRE IL VALORE INIZIALE
if(clk'EVENT AND clk='1') THEN
if (upordwn='1') THEN
totalbit <= totalbit+1;
else
totalbit <= totalbit-1;
end if;
end if;
END PROCESS;
low_four(0) <= totalbit(0);
low_four(1) <= totalbit(1);
low_four(2) <= totalbit(2);
low_four(3) <= totalbit(3);
up_four(0) <= totalbit(4);
up_four(1) <= totalbit(5);
up_four(2) <= totalbit(6);
up_four(3) <= totalbit(7);
WITH up_four SELECT
--abcdefg
LED_1 <= "00000011" WHEN "1111", -- 0
"10011111" WHEN "1110", -- 1
"00100101" WHEN "1101", -- 2
"00001101" WHEN "1100", -- 3
"10011001" WHEN "1011", -- 4
"01001001" WHEN "1010", -- 5
"01000001" WHEN "1001", -- 6
"00011111" WHEN "1000", -- 7
"00000001" WHEN "0111", -- 8
"00001001" WHEN "0110", -- 9
"00010001" WHEN "0101", -- A
"00000001" WHEN "0100", -- B
"01100011" WHEN "0011", -- C
"00000011" WHEN "0010", -- D
"01100001" WHEN "0001", -- E
"01110001" WHEN "0000", -- F
"00000011" WHEN OTHERS;
--Lower 4 bits
WITH low_four SELECT
--abcdefg
LED_2 <= "00000011" WHEN "1111", -- 0
"10011111" WHEN "1110", -- 1
"00100101" WHEN "1101", -- 2
"00001101" WHEN "1100", -- 3
"10011001" WHEN "1011", -- 4
"01001001" WHEN "1010", -- 5
"01000001" WHEN "1001", -- 6
"00011111" WHEN "1000", -- 7
"00000001" WHEN "0111", -- 8
"00001001" WHEN "0110", -- 9
"00010001" WHEN "0101", -- A
"00000001" WHEN "0100", -- B
"01100011" WHEN "0011", -- C
"00000011" WHEN "0010", -- D
"01100001" WHEN "0001", -- E
"01110001" WHEN "0000", -- F
"00000011" WHEN OTHERS;
count <= totalbit;
end prova;
I have two problems yet!
1. initialing a strart number for the count by 8 switches present in UP2 board;
2. show the result in decimal (not in hexadecimal format) in the 7segment display.
thanks again :D