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
852 B
VHDL
Raw Normal View History

2016-05-23 15:56:00 +02:00
-- File: inc.vhd
-- Generated by MyHDL 1.0dev
-- Date: Sun May 22 18:46:37 2016
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;
2016-05-23 15:56:00 +02:00
use work.pck_myhdl_10.all;
2008-11-22 22:40:25 +01:00
2016-05-23 15:56:00 +02:00
entity inc is
2008-11-22 22:40:25 +01:00
port (
count: inout unsigned(7 downto 0);
enable: in std_logic;
clock: in std_logic;
reset: in std_logic
);
2016-05-23 15:56:00 +02:00
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
2008-11-22 22:40:25 +01:00
2016-05-23 15:56:00 +02:00
architecture MyHDL of inc is
2008-11-22 22:40:25 +01:00
begin
2010-07-02 13:24:04 +02:00
2016-05-23 15:56:00 +02:00
INC_SEQ: process (clock, reset) is
2008-11-22 22:40:25 +01:00
begin
if (reset = '0') then
2016-05-23 15:56:00 +02:00
count <= to_unsigned(0, 8);
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
2012-12-21 15:06:18 +01:00
count <= (count + 1);
2008-11-22 22:40:25 +01:00
end if;
end if;
2016-05-23 15:56:00 +02:00
end process INC_SEQ;
2008-11-22 22:40:25 +01:00
end architecture MyHDL;