aboutsummaryrefslogtreecommitdiff
path: root/src/cntupen_rtl.vhd
diff options
context:
space:
mode:
authorJohann Faerber <johann.faerber@hs-augsburg.de>2022-03-09 09:48:43 +0100
committerJohann Faerber <johann.faerber@hs-augsburg.de>2022-03-09 09:48:43 +0100
commita04bbf15b0f51696894e37f3e566998108aefd74 (patch)
tree35a36178bfb2fa257b0afcddaec29868f6e4fc77 /src/cntupen_rtl.vhd
parentfd7c3d6c1352353f3ee2da9267308a51fd67315d (diff)
added basic design directory structure
Diffstat (limited to 'src/cntupen_rtl.vhd')
-rw-r--r--src/cntupen_rtl.vhd52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cntupen_rtl.vhd b/src/cntupen_rtl.vhd
new file mode 100644
index 0000000..2c68a73
--- /dev/null
+++ b/src/cntupen_rtl.vhd
@@ -0,0 +1,52 @@
+-------------------------------------------------------------------------------
+-- Module : cntupen
+-------------------------------------------------------------------------------
+-- Author : Johann Faerber
+-- Company : University of Applied Sciences Augsburg
+-------------------------------------------------------------------------------
+-- Description: Up-Counter
+-- including a low-active asynchronous reset input rst_ni
+-- and a high-active enable input en_pi
+-------------------------------------------------------------------------------
+-- Revisions : see end of file
+-------------------------------------------------------------------------------
+LIBRARY IEEE;
+USE IEEE.std_logic_1164.ALL;
+USE IEEE.numeric_std.ALL;
+
+ENTITY cntupen IS
+ PORT (clk_i : IN std_ulogic;
+ rst_ni : IN std_ulogic;
+ en_pi : IN std_ulogic;
+ count_o : OUT std_ulogic_vector(3 DOWNTO 0)
+ );
+END cntupen;
+
+ARCHITECTURE rtl OF cntupen IS
+
+ -- datatype unsigned is defined in package numeric_std
+ SIGNAL next_state, current_state : unsigned(3 DOWNTO 0);
+
+BEGIN
+
+ -- package numeric_std overloads operator '+'
+ -- for arguments of different types, here: unsigned and integer
+ incrementer : next_state <= current_state + 1;
+
+
+ -- synthesisable construct of a d-type register with synchronrous enable
+ state_register : current_state <= "0000" WHEN rst_ni = '0' ELSE
+ next_state WHEN rising_edge(clk_i) AND (en_pi = '1');
+
+
+ -- type conversion from unsignd to std_ulogic_vector necessary
+ counter_output : count_o <= std_ulogic_vector(current_state);
+
+END rtl;
+
+-------------------------------------------------------------------------------
+-- Revisions:
+-- ----------
+-- $Id:$
+-------------------------------------------------------------------------------
+