aboutsummaryrefslogtreecommitdiff
path: root/counter/top.vhd
diff options
context:
space:
mode:
authorBrian Woods2023-02-24 12:17:46 -0500
committerBrian Woods2023-02-24 13:20:19 -0500
commitd7a11e0e8584e088921c9486c4f064eaf5e004f7 (patch)
treed82a56d3c0fc9e1434aa6cc514f7616bc4c5c092 /counter/top.vhd
parent353910fa6f1ef1b1eed5b8c4db6d528e521ce127 (diff)
counter: simple simulation of a countercounter
Diffstat (limited to 'counter/top.vhd')
-rw-r--r--counter/top.vhd51
1 files changed, 51 insertions, 0 deletions
diff --git a/counter/top.vhd b/counter/top.vhd
new file mode 100644
index 0000000..2ae4216
--- /dev/null
+++ b/counter/top.vhd
@@ -0,0 +1,51 @@
+-- SPDX-FileCopyrightText: 2023 Brian Woods
+-- SPDX-License-Identifier: GPL-2.0-or-later
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.numeric_std.all;
+
+entity top is
+ port(
+ set: in std_logic;
+ set_val: in unsigned(7 downto 0);
+ cnt: out unsigned(7 downto 0);
+ en: in std_logic;
+ cnt_auto: out unsigned(7 downto 0);
+ clr: in std_logic;
+ clk: in std_logic
+ );
+end entity;
+
+architecture func of top is
+ component counter is
+ port(
+ set: in std_logic;
+ set_val: in unsigned(7 downto 0);
+ cnt: out unsigned(7 downto 0);
+ en: in std_logic;
+ clr: in std_logic;
+ clk: in std_logic
+ );
+ end component;
+begin
+ -- controlled by the top signals
+ counter01: counter port map(
+ set => set,
+ set_val => set_val,
+ cnt => cnt,
+ en => en,
+ clr => clr,
+ clk => clk
+ );
+
+ -- just counts automatically
+ counter02: counter port map(
+ set => '0',
+ set_val => "00000000",
+ cnt => cnt_auto,
+ en => '1',
+ clr => clr,
+ clk => clk
+ );
+end func;