]> rtime.felk.cvut.cz Git - fpga/spartan2/qcounter.git/blobdiff - div_20.vhd
Complete design added.
[fpga/spartan2/qcounter.git] / div_20.vhd
diff --git a/div_20.vhd b/div_20.vhd
new file mode 100644 (file)
index 0000000..a5af207
--- /dev/null
@@ -0,0 +1,35 @@
+library IEEE;
+use IEEE.STD_LOGIC_1164.all;
+use IEEE.STD_LOGIC_ARITH.all;
+use IEEE.STD_LOGIC_UNSIGNED.all;
+
+--------------------------------------------------------------------------------
+-- This module divides the incoming clock by 2^20 and outputs the 20th bit of
+-- the counter as clk_2k.
+--------------------------------------------------------------------------------
+
+entity div_20 is
+  port (
+    clk    : in  std_logic;
+    clk_2k : out std_logic);
+end div_20;
+
+--------------------------------------------------------------------------------
+
+architecture Behavioral of div_20 is
+  
+  signal count : std_logic_vector (19 downto 0);
+  
+begin
+  
+  process(clk)
+  begin
+    if(clk'event and clk = '1') then
+      count <= count + "00000000000000000001";
+    end if;
+  end process;
+
+  clk_2k <= count(19);
+  
+end Behavioral;
+