| library IEEE ;
use IEEE.std_logic_1164.all ;
use IEEE.std_logic_arith.all ;
entity test88 is
port ( clk : in std_logic;
clear : in std_logic;
seg3 : out std_logic_vector (7 downto 0) ;
seg4 : out std_logic_vector (7 downto 0) ;
seg5 : out std_logic_vector (7 downto 0) ;
seg6 : out std_logic_vector (7 downto 0) ;
seg7 : out std_logic_vector (7 downto 0) ;
seg8 : out std_logic_vector (7 downto 0) ;
t_1sec : buffer std_logic ;
t_10sec : buffer std_logic ;
t_1min : buffer std_logic ;
t_10min : buffer std_logic ;
t_1hour : buffer std_logic ;
t_10hour : buffer std_logic ) ;
end test88 ;
architecture arc of test88 is
signal cnt : integer range 0 to 255 ;
signal sec : integer range 0 to 255 ;
signal sec10 : integer range 0 to 255 ;
signal min : integer range 0 to 255 ;
signal min10 : integer range 0 to 255 ;
signal hour : integer range 0 to 255 ;
signal hour10 : integer range 0 to 255 ;
function seg (display : integer range 0 to 255)
return std_logic_vector is variable seg1 : std_logic_vector(7 downto 0) ;
begin
case display is
when 0 => seg1 := 0111111 ;
when 1 => seg1 := 0000110 ;
when 2 => seg1 := 1011011 ;
when 3 => seg1 := 1001111 ;
when 4 => seg1 := 1100110 ;
when 5 => seg1 := 1101101 ;
when 6 => seg1 := 1111101 ;
when 7 => seg1 := 0100111 ;
when 8 => seg1 := 1111111 ;
when 9 => seg1 := 1100111 ;
when others => seg1 := 0000000 ;
end case ;
return seg1 ;
end seg ;
begin
-- 1 sec clock generation
process (clk, clear, cnt)
begin
if (clear = 1) then -- input clock is 100Hz
cnt <= 0 ;
t_1sec <= ;
elsif (clk = 1 and clk event) then
if (cnt >= 2) then
cnt <= 0 ;
t_1sec <= not t_1sec ;
else
cnt <= cnt + 1 ;
end if ;
end if ;
end process ;
-- 1 sec display
process (t_1sec,t_10sec,clear,sec)
begin
if clear = 1 then
sec <= 0 ;
t_10sec <= ;
elsif (t_1secevent and t_1sec = 1) then -- 1 sec
if sec = 9 then
sec <= 0 ;
t_10sec <= 1 ;
else
sec <= sec + 1 ;
t_10sec <= ;
end if ;
end if ;
end process ;
seg8 <= seg (sec) ;
-- 10 sec display
process (t_10sec, t_1min, clear, sec10)
begin
if clear = 1 then
sec10 <= 0 ;
t_1min <= ;
elsif (t_10secevent and t_10sec = 1) then
if sec10 = 5 then
sec10 <= 0 ;
t_1min <= 1 ;
else
sec10 <= sec10 + 1 ;
t_1min <= ;
end if ;
end if ;
end process ;
seg7 <= seg (sec10) ;
-- 1 min display
process (t_1min, t_10min, clear, min)
begin
if clear = 1 then
min <= 0 ;
t_10min <= ;
elsif (t_1minevent and t_1min = 1) then -- 1 min
if min = 9 then
min <= 0 ;
t_10min <= 1 ;
else
min <= min + 1 ;
t_10min <= ;
end if ;
end if ;
end process ;
seg6 <= seg (min) ;
-- 10 min display
process (t_10min, t_1hour, clear, min10)
begin
if clear = 1 then
min10 <= 0 ;
t_1hour <= ;
elsif (t_10minevent and t_10min = 1) then
if min10 = 5 then
min10 <= 0 ;
t_1hour <= 1 ;
else
min10 <= min10 + 1 ;
t_1hour <= ;
end if ;
end if ;
end process ;
seg5 <= seg (min10) ;
-- 1 hour display
process (t_1hour, t_10hour, clear, hour, hour10)
begin
if clear = 1 then
hour <= 0 ;
t_10hour <= ;
elsif (t_1hourevent and t_1hour = 1) then -- 1 hour
if hour = 9 then
hour <= 0 ;
t_10hour <= 1 ;
elsif hour = 3 and hour10 = 2 then
hour <= 0 ;
t_10hour <= 1 ;
else
hour <= hour + 1 ;
t_10hour <= ;
end if ;
end if ;
end process ;
seg4 <= seg (hour) ;
-- 10 hour display
process (t_10hour, clear, hour10)
begin
if clear = 1 then
hour10 <= 0 ;
elsif (t_10hourevent and t_10hour = 1) then
if hour10 = 2 then
hour10 <= 0 ;
else
hour10 <= hour10 + 1 ;
end if ;
end if ;
end process ;
seg3 <= seg (hour10) ;
end arc ;
위에 소스는 알테라 맥스 플러스2로 세그먼트로 디지털시계를 구현하는 건데요.
타겟보드에 돌려 볼려고 하는데 핀번호를 어떻게 주어야 될지 몰르겠네요...
핀번호를 지정 할려고 하면은 세그먼트값이 30~37 40~47 50~57 60~67 70~77 80~87
그리고 clear와 clk 또 버퍼로 지정한 값들이 나오는데요.. 어떻게 해야 될지 몰르겠네요.
부탁드립니다.
타겟보드는 HBE-DTK-20K-240이고요 디바이스는 EPF10K20RC240-4 입니다 |