S
Symon
Guest
I just spent a little time googling, doing and debugging this. Thought I'd
try and save anyone else the bother by posting this as a starting point.
'pos' is the number to display.
'servo_count' just counts.
Cheers, Syms.
Entity extract followed by VHDL process followed by UCF extract
use ieee.numeric_std.all;
entity top is
port (
clock : in std_logic; --system clock
res_n : in std_logic; --system clock
DIGIT_ANODE : out std_logic_vector(3 downto
--system clock
SEGMENT : out std_logic_vector(7 downto
--system clock
);
end top;
led_driver : process(res_n, clock)
begin
if res_n = '0' then
digit <= 0;
input <= 0;
SEGMENT <= (others => '0');
DIGIT_ANODE <= (others => '0');
elsif rising_edge(clock) then
if servo_count mod 256 = 0 then
digit <= (servo_count / 256) mod 4;
case digit is
when 0 =>
DIGIT_ANODE <= "0111";
input <= pos mod 16;
when 1 =>
DIGIT_ANODE <= "1110";
input <= (pos / 16) mod 16;
when 2 =>
DIGIT_ANODE <= "1101";
input <= (pos / 256) mod 16;
when 3 =>
DIGIT_ANODE <= "1011";
input <= (pos / 4096) mod 16;
when others => null;
end case;
case input is
when 0 => SEGMENT <= "00000011"; -- "a b c d e f g DP"
when 1 => SEGMENT <= "10011111";
when 2 => SEGMENT <= "00100101"; -- --a--
when 3 => SEGMENT <= "00001101"; -- | |
when 4 => SEGMENT <= "10011001"; -- f b
when 5 => SEGMENT <= "01001001"; -- | |
when 6 => SEGMENT <= "01000001"; -- |--g--|
when 7 => SEGMENT <= "00011111"; -- | |
when 8 => SEGMENT <= "00000001"; -- e c
when 9 => SEGMENT <= "00011001"; -- | |
when 10 => SEGMENT <= "00010001"; -- --d--DP
when 11 => SEGMENT <= "11000001";
when 12 => SEGMENT <= "01100011";
when 13 => SEGMENT <= "10000101";
when 14 => SEGMENT <= "01100001";
when 15 => SEGMENT <= "01110001";
when others => SEGMENT <= "11111111";
end case;
end if;
end if;
end process;
#
# 7-segement display
#
NET "digit_anode(0)" LOC = "D14";
NET "digit_anode(1)" LOC = "G14";
NET "digit_anode(2)" LOC = "F14";
NET "digit_anode(3)" LOC = "E13";
NET "segment(7)" LOC = "E14";
NET "segment(6)" LOC = "G13";
NET "segment(5)" LOC = "N15";
NET "segment(4)" LOC = "P15";
NET "segment(3)" LOC = "R16";
NET "segment(2)" LOC = "F13";
NET "segment(1)" LOC = "N16";
NET "segment(0)" LOC = "P16";
try and save anyone else the bother by posting this as a starting point.
'pos' is the number to display.
'servo_count' just counts.
Cheers, Syms.
Entity extract followed by VHDL process followed by UCF extract
use ieee.numeric_std.all;
entity top is
port (
clock : in std_logic; --system clock
res_n : in std_logic; --system clock
DIGIT_ANODE : out std_logic_vector(3 downto
--system clock
SEGMENT : out std_logic_vector(7 downto
--system clock
);
end top;
led_driver : process(res_n, clock)
begin
if res_n = '0' then
digit <= 0;
input <= 0;
SEGMENT <= (others => '0');
DIGIT_ANODE <= (others => '0');
elsif rising_edge(clock) then
if servo_count mod 256 = 0 then
digit <= (servo_count / 256) mod 4;
case digit is
when 0 =>
DIGIT_ANODE <= "0111";
input <= pos mod 16;
when 1 =>
DIGIT_ANODE <= "1110";
input <= (pos / 16) mod 16;
when 2 =>
DIGIT_ANODE <= "1101";
input <= (pos / 256) mod 16;
when 3 =>
DIGIT_ANODE <= "1011";
input <= (pos / 4096) mod 16;
when others => null;
end case;
case input is
when 0 => SEGMENT <= "00000011"; -- "a b c d e f g DP"
when 1 => SEGMENT <= "10011111";
when 2 => SEGMENT <= "00100101"; -- --a--
when 3 => SEGMENT <= "00001101"; -- | |
when 4 => SEGMENT <= "10011001"; -- f b
when 5 => SEGMENT <= "01001001"; -- | |
when 6 => SEGMENT <= "01000001"; -- |--g--|
when 7 => SEGMENT <= "00011111"; -- | |
when 8 => SEGMENT <= "00000001"; -- e c
when 9 => SEGMENT <= "00011001"; -- | |
when 10 => SEGMENT <= "00010001"; -- --d--DP
when 11 => SEGMENT <= "11000001";
when 12 => SEGMENT <= "01100011";
when 13 => SEGMENT <= "10000101";
when 14 => SEGMENT <= "01100001";
when 15 => SEGMENT <= "01110001";
when others => SEGMENT <= "11111111";
end case;
end if;
end if;
end process;
#
# 7-segement display
#
NET "digit_anode(0)" LOC = "D14";
NET "digit_anode(1)" LOC = "G14";
NET "digit_anode(2)" LOC = "F14";
NET "digit_anode(3)" LOC = "E13";
NET "segment(7)" LOC = "E14";
NET "segment(6)" LOC = "G13";
NET "segment(5)" LOC = "N15";
NET "segment(4)" LOC = "P15";
NET "segment(3)" LOC = "R16";
NET "segment(2)" LOC = "F13";
NET "segment(1)" LOC = "N16";
NET "segment(0)" LOC = "P16";