刚开始学习使用Modelsim,写了一个简单的计数程序和对应的测试程序,但是仿真不出时序图,求助大家!!!
下面是源程序和测试程序代码,请前辈们帮忙看一下。
counter.vhd 如下:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY counter IS
PORT
(
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
count : OUT STD_LOGIC_vector(7 downto 0)
);
END counter;
ARCHITECTURE counter_architecture OF counter IS
signal reg : std_logic_vector(7 downto 0);
begin
process (clk,rst)
begin
if(rst = '0') then
reg <= "00000000";
elsif(clk'event and clk = '1') then
reg <= reg + 1;
end if;
end process;
count <= reg;
END counter_architecture;
counter_tb.vhd 如下:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.all;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY counter IS
PORT
(
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
count : OUT STD_LOGIC_vector(7 downto 0)
);
END counter;
ARCHITECTURE counter_architecture OF counter IS
signal reg : std_logic_vector(7 downto 0);
begin
process (clk,rst)
begin
if(rst = '0') then
reg <= "00000000";
elsif(clk'event and clk = '1') then
reg <= reg + 1;
end if;
end process;
count <= reg;
END counter_architecture;
之后就是直接设置仿真时间200ns,运行后时序图如下:
|