en
tity led_water is
port(
clk : in std_logic;
rst : in std_logic;
led : out std_logic_vector(7 downto 0)
);
end led_water;
architecture Behavioral of led_water is
signal clk1 : std_logic; --建立中间时钟信号
begin
P1: process(clk,rst) --进程1 对时钟信号进行N分频
variable count : integer range 0 to 50000000 := 0;
variable count1 : std_logic := '0';
begin
if (rst = '1') then --如果有复位信号
count := 0;
elsif(clk'event and clk = '1') then --如果clk上升沿到来
count := count + 1;
if(count = 50000000) then
count := 0;
end if;
count1 := not count1; --时钟信号翻转
clk1 <= count1;
end if;
end process;
P2: process(clk1) --对分频信号进行计数,进而控制LED灯亮灭
variable count2 : integer range 0 to 8 := 0;
begin
if(clk1'event and clk1 = '1') then
count2 := count2 + 1;
if (count2 = 8) then
count2 := 0;
end if;
end if;
case count2 is
when 0 => led <= "00000001";
when 1 => led <= "00000010";
when 2 => led <= "00000100";
when 3 => led <= "00001000";
when 4 => led <= "00010000";
when 5 => led <= "00100000";
when 6 => led <= "01000000";
when 7 => led <= "10000000";
when others => led <= (others => 'Z');
end case;
end process;
end Behavioral;
请大神们帮我看看错误
一周热门 更多>