|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
VHDL的设计文件如下:(就是一个最简单的分频器)
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
entity fenpin is
generic (DWIDTH: integer:=3);
port(
clk:in std_logic;
en: in std_logic;
clk_out: out std_logic
);
end fenpin;
architecture rtl of fenpin is
signal temp: std_logic_vector(DWIDTh-1 downto 0);
begin
process(clk,en)
begin
if en='1' then
if clk'event and clk='1' then
temp<=temp+'1';
else
NULL;
end if;
end if;
end process;
clk_out<=temp(DWIDTH-1);
end rtl;
-------------------------------------------
testbench如下:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY fenpin_vhd_tst IS
END fenpin_vhd_tst;
ARCHITECTURE fenpin_arch OF fenpin_vhd_tst IS
SIGNAL clk : STD_LOGIC:='0';
SIGNAL clk_out : STD_LOGIC;
SIGNAL en : STD_LOGIC:='1';
COMPONENT fenpin
PORT (
clk : IN STD_LOGIC;
clk_out : OUT STD_LOGIC;
en : IN STD_LOGIC
);
END COMPONENT;
BEGIN
i1 : fenpin
PORT MAP
(
clk => clk,
clk_out => clk_out,
en => en
);
PROCESS
BEGIN
wait for 10 ns;
clk<='1';
wait for 10 ns;
clk<='0';
END PROCESS;
END fenpin_arch;
点了EDA RTL simulation后出来moderlsim界面,然后点击run 1us后出现全是红线,不知道怎么回事啊? |
|