-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclkmach.vhd
100 lines (90 loc) · 2.01 KB
/
clkmach.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
library ieee;
use ieee.std_logic_1164.all;
entity otopark is
port
(
-- reset : in std_logic:='1';
clock : in std_logic;
g : in std_logic_vector(1 downto 0):="00";
cikis : out std_logic_vector(6 downto 0)
);
end entity;
architecture rtl of otopark is
type durumlar is (D1, D2, D3, D4);
signal durum: durumlar;
-- Constants
CONSTANT clk_high : time := 5 ns;
CONSTANT clk_low : time := 5 ns;
CONSTANT clk_period : time := 10 ns;
CONSTANT clk_hold : time := 2 ns;
signal clk:std_logic;
signal rst:std_logic:='1';
signal ileri:std_logic:='0';
signal geri:std_logic:='0';
signal giren:integer:=0;
signal cikan:integer:=0;
BEGIN
clk_gen: PROCESS
BEGIN
clk <= '1';
WAIT FOR clk_high;
clk <= '0';
WAIT FOR clk_low;
END PROCESS clk_gen;
process (clk,rst)
begin
if rst='1' then
durum<=D1;
giren<=0;
cikan<=0;
rst<='0';
else
if rising_edge(clk) then
case durum is
when D1 =>
if g="00" then
durum<=D1;
elsif g="10" then
ileri<='1';
geri<='0';
durum<=D2;
elsif g="01" then
durum<=D4;
ileri<='0';
geri<='1';
end if;
when D2 =>
if g="10" then
durum<=D2;
elsif g="11" then
durum<=D3;
elsif g="00" then
durum<=D1;
if geri='1' then
cikan<=cikan+1;
end if;
end if;
when D3 =>
if g="11" then
durum<=D3;
elsif g="10" then
durum<=D2;
elsif g="01" then
durum<=D4;
end if;
when D4 =>
if g="01" then
durum<=D4;
elsif g="00" then
durum<=D1;
if ileri='1' then
giren<=giren+1;
end if;
elsif g="11" then
durum<=D3;
end if;
end case;
end if;
end if;
end process;
end rtl;