|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
写了个只用正沿触发的3分频电路,不知道有没有问题,请大家给点建议。
下面是源代码和仿真波形:
library ieee;
use ieee.std_logic_1164.all;
entity div3 is port(
clk : in std_logic;
rst : in std_logic;
clk3 : out std_logic);
end div3;
architecture struct of div3 is
signal A : std_logic;
signal B : std_logic;
signal Ain : std_logic;
signal Bin : std_logic;
begin
Ain <= (not A) and (not B);
Bin <= A;
process(clk, rst)
begin
if (rst = '1') then
A <= '0';
B <= '0';
else
if (clk'event and clk = '1') then
A <= Ain;
B <= Bin;
end if;
end if;
end process;
process(clk, A, B)
begin
-- clk3 <= (clk and B and (not A)) or (A and (not B)); -- clk3 has glitch
clk3 <= (clk and Bin and B and (not A)) or Bin or A; -- clk3 no glitch
end process;
end struct;
library ieee;
use ieee.std_logic_1164.all;
entity tb_div3 is
end tb_div3;
architecture behav of tb_div3 is
component div3 port(
clk : in std_logic;
rst : in std_logic;
clk3 : out std_logic);
end component;
constant TCLK : time := 20 ns;
signal clk : std_logic := '0';
signal rst : std_logic := '1';
signal clk3 : std_logic;
begin
process begin
wait for TCLK/2;
clk <= not clk;
end process;
rst <= '0' after TCLK*2;
u1: div3 port map(
clk => clk,
rst => rst,
clk3 => clk3);
end behav; |
-
div3仿真波形
|