본문내용
n
if divi'event and divi='1' then
cnt_out <= cnt_out+1;
end if;
else cnt_out <="0000";
end if;
end process;
end behave;
SYNC
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity sync_cnt is
port(
clk0, rst : in std_logic;
out0, out1, out2, out3 : buffer std_logic_vector(3 downto 0)
);
end sync_cnt;
architecture behave of sync_cnt is
component cnt0
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt1
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt2
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt3
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
begin
u0 : cnt0
port map(clk=>clk0, rst=>rst, cnt_out=>out0);
u1 : cnt1
port map(clk=>clk0, rst=>rst, cnt_out=>out1);
u2 : cnt2
port map(clk=>clk0, rst=>rst, cnt_out=>out2);
u3 : cnt3
port map(clk=>clk0, rst=>rst, cnt_out=>out3);
end behave;
tb_SYNC
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity sync_cnt is
port(
clk0, rst : in std_logic;
out0, out1, out2, out3 : buffer std_logic_vector(3 downto 0)
);
end sync_cnt;
architecture behave of sync_cnt is
component cnt0
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt1
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt2
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt3
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
begin
u0 : cnt0
port map(clk=>clk0, rst=>rst, cnt_out=>out0);
u1 : cnt1
port map(clk=>clk0, rst=>rst, cnt_out=>out1);
u2 : cnt2
port map(clk=>clk0, rst=>rst, cnt_out=>out2);
u3 : cnt3
port map(clk=>clk0, rst=>rst, cnt_out=>out3);
end behave;
《 동기 카운터 》
- 비동기 카운터를 이용하여 코딩.
- 분주를 나누는 과정에서 처음 들어가는 클럭에 따라서 각 카운터에 임시신호를 만들어 클럭을 세면서 분주를 나누어서 분주는 되지만 값에서 오류발생
- 첫 10분주는 위의 방법이 맞으나 다음 100분주부터는 10분주한 신호를 임시신호를 하 나 더 선언하여 10분주 신호의 클럭에 따라 다시 10분주
- 1000분주도 마찬가지 방법.
파형
if divi'event and divi='1' then
cnt_out <= cnt_out+1;
end if;
else cnt_out <="0000";
end if;
end process;
end behave;
SYNC
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity sync_cnt is
port(
clk0, rst : in std_logic;
out0, out1, out2, out3 : buffer std_logic_vector(3 downto 0)
);
end sync_cnt;
architecture behave of sync_cnt is
component cnt0
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt1
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt2
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt3
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
begin
u0 : cnt0
port map(clk=>clk0, rst=>rst, cnt_out=>out0);
u1 : cnt1
port map(clk=>clk0, rst=>rst, cnt_out=>out1);
u2 : cnt2
port map(clk=>clk0, rst=>rst, cnt_out=>out2);
u3 : cnt3
port map(clk=>clk0, rst=>rst, cnt_out=>out3);
end behave;
tb_SYNC
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity sync_cnt is
port(
clk0, rst : in std_logic;
out0, out1, out2, out3 : buffer std_logic_vector(3 downto 0)
);
end sync_cnt;
architecture behave of sync_cnt is
component cnt0
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt1
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt2
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
component cnt3
port(
clk, rst : in std_logic;
cnt_out : buffer std_logic_vector(3 downto 0)
);
end component;
begin
u0 : cnt0
port map(clk=>clk0, rst=>rst, cnt_out=>out0);
u1 : cnt1
port map(clk=>clk0, rst=>rst, cnt_out=>out1);
u2 : cnt2
port map(clk=>clk0, rst=>rst, cnt_out=>out2);
u3 : cnt3
port map(clk=>clk0, rst=>rst, cnt_out=>out3);
end behave;
《 동기 카운터 》
- 비동기 카운터를 이용하여 코딩.
- 분주를 나누는 과정에서 처음 들어가는 클럭에 따라서 각 카운터에 임시신호를 만들어 클럭을 세면서 분주를 나누어서 분주는 되지만 값에서 오류발생
- 첫 10분주는 위의 방법이 맞으나 다음 100분주부터는 10분주한 신호를 임시신호를 하 나 더 선언하여 10분주 신호의 클럭에 따라 다시 10분주
- 1000분주도 마찬가지 방법.
파형