1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/example/manual/Inc.vhd

49 lines
895 B
VHDL
Raw Normal View History

2008-11-22 22:40:25 +01:00
-- File: Inc.vhd
2012-12-21 14:36:07 +01:00
-- Generated by MyHDL 0.8dev
-- Date: Fri Dec 21 14:32:36 2012
2008-11-22 22:40:25 +01:00
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use std.textio.all;
2012-12-21 14:36:07 +01:00
use work.pck_myhdl_08.all;
2008-11-22 22:40:25 +01:00
entity Inc is
port (
count: inout unsigned(7 downto 0);
enable: in std_logic;
clock: in std_logic;
reset: in std_logic
);
end entity Inc;
2010-07-02 13:24:04 +02:00
-- Incrementer with enable.
--
-- count -- output
-- enable -- control input, increment when 1
-- clock -- clock input
-- reset -- asynchronous reset input
-- n -- counter max value
2008-11-22 22:40:25 +01:00
architecture MyHDL of Inc is
begin
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
INC_INCLOGIC: process (clock, reset) is
begin
if (reset = '0') then
2012-12-21 14:36:07 +01:00
count <= (others => '0');
2008-11-22 22:40:25 +01:00
elsif rising_edge(clock) then
2012-12-21 14:36:07 +01:00
if bool(enable) then
2008-11-22 22:40:25 +01:00
count <= ((count + 1) mod 256);
end if;
end if;
end process INC_INCLOGIC;
end architecture MyHDL;