diff options
author | Ambikeshwar | 2016-05-25 14:20:23 +0530 |
---|---|---|
committer | Ambikeshwar | 2016-05-25 14:20:23 +0530 |
commit | b503d66fcc1e26be28b58cccf888e43f99d35ae2 (patch) | |
tree | 2dbf0c992715e8bd06184f7d6aeb35ef80f50b20 /VHDL/counter.vhdl | |
parent | d0196e42ce0b3bebe9a4a60a974746d57dd93f83 (diff) | |
download | NGHDL-Example-b503d66fcc1e26be28b58cccf888e43f99d35ae2.tar.gz NGHDL-Example-b503d66fcc1e26be28b58cccf888e43f99d35ae2.tar.bz2 NGHDL-Example-b503d66fcc1e26be28b58cccf888e43f99d35ae2.zip |
Samples of VHDL code added for testing
Diffstat (limited to 'VHDL/counter.vhdl')
-rw-r--r-- | VHDL/counter.vhdl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/VHDL/counter.vhdl b/VHDL/counter.vhdl new file mode 100644 index 0000000..8d1d52e --- /dev/null +++ b/VHDL/counter.vhdl @@ -0,0 +1,26 @@ +library ieee ; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity counter is +port( clk: in std_logic_vector(0 downto 0); + reset: in std_logic_vector(0 downto 0); + count: out std_logic_vector(3 downto 0) +); +end counter; + +architecture behav of counter is + signal pre_count: unsigned(3 downto 0); + + begin + process(clk,reset) + begin + if reset = "1" then + pre_count <= "0000"; + elsif (clk= "1" and clk'event) then + pre_count <= pre_count +1; + end if; + end process; + + count <= std_logic_vector(pre_count); +end behav; |