-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClkDiv.vhd
42 lines (39 loc) · 1.14 KB
/
ClkDiv.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
library ieee;
use ieee.std_logic_1164.all;
use ieee.Numeric_std.all;
use ieee.fixed_pkg.all;
use ieee.float_pkg.all;
entity ClkDiv is
port( clk,clr :in std_logic;
DivOut : out std_logic);
end ClkDiv;
architecture RTL of ClkDiv is
signal count: unsigned(3 downto 0); --Counter Varible
begin
clockcountdivide: process(Clk,clr)
begin
if(clr = '1' or count = "1010") then
count<= "0000";
elsif rising_edge(Clk) then
if count< "0101" then
DivOut <= '1';
count <= count + "1";
else
DivOut <= '0';
count <= count + "1";
end if;
end if;
end process clockcountdivide;
end RTL;
-----------------------------------------------------------------------------------------
-- Alternate General Method
-----------------------------------------------------------------------------------------
-- begin
-- if (count = T/2)
count = 0;
-- DivOut = not(DivOut);
-- else
-- DivOut = DivOut;
-- count = count + 1;
-- end if
------------------------------------------------------------------------------------------