-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAF_module.vhd.bak
More file actions
166 lines (136 loc) · 4.25 KB
/
AF_module.vhd.bak
File metadata and controls
166 lines (136 loc) · 4.25 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
----------------------------------------
entity AF is
generic(N : integer := 8);
port(
clk : in STD_LOGIC;
rst : in STD_LOGIC;
dataIn : in STD_LOGIC_VECTOR(N-1 downto 0);
addr : out STD_LOGIC_VECTOR(N-1 downto 0);
readDone : in STD_LOGIC;
direction : out STD_LOGIC;
Move : out STD_LOGIC;
FocusAddr : in STD_LOGIC_VECTOR(11 downto 0);
Start : in STD_LOGIC;
Done : out STD_LOGIC
);
end AF;
architecture AF of AF is
component my_8subtractor IS
GENERIC (n : integer := 8);
PORT(a,b : IN std_logic_vector(n-1 DOWNTO 0);
cin : IN std_logic;
s : OUT std_logic_vector(n-1 DOWNTO 0));
END component;
component my_12adder IS
GENERIC (n : integer := 12);
PORT(
a,b : IN std_logic_vector(n-1 DOWNTO 0);
cin : IN std_logic;
s : OUT std_logic_vector(n-1 DOWNTO 0));
END component;
component my_19adder IS
GENERIC (n : integer := 19);
PORT(a,b : IN std_logic_vector(n-1 DOWNTO 0);
cin : IN std_logic;
s : OUT std_logic_vector(n-1 DOWNTO 0));
END component;
component counter is
generic(N : integer := 4);
port(
en: in STD_LOGIC;
clr : in STD_LOGIC;
clk : in STD_LOGIC;
q : out STD_LOGIC_VECTOR(N-1 downto 0)
);
end component;
component counter256 is
generic(N : integer := 9);
port(
en: in STD_LOGIC;
clr : in STD_LOGIC;
clk : in STD_LOGIC;
q : out STD_LOGIC_VECTOR(N-1 downto 0)
);
end component;
component Algo is
generic(N : integer := 19);
port(
en: in STD_LOGIC; -- When the 256 counter finishes.
clr : in STD_LOGIC;
clk : in STD_LOGIC;
result : in STD_LOGIC_VECTOR(N-1 downto 0);
dir : out STD_LOGIC; -- when '0' => lastmove = '01' and when '1' lastmove = '10'
done : out STD_LOGIC;
move : out std_logic
);
end component;
component addr_Valid IS
PORT( addr: IN std_logic_vector(7 DOWNTO 0);
cnt: IN std_logic_vector(3 DOWNTO 0);
out_fsm : out std_logic_vector(7 DOWNTO 0));
END component;
component n_reg is
Generic(n: integer := 8);
port( d : in std_logic_vector(n-1 downto 0);
q: out std_logic_vector(n-1 downto 0);
rst,clk: in std_logic;
enable: in std_logic);
End component;
component reg_19 is
Generic(n: integer := 19);
port( d : in std_logic_vector(n-1 downto 0);
q: out std_logic_vector(n-1 downto 0);
rst,clk: in std_logic;
enable: in std_logic);
End component;
signal sub8_res : STD_LOGIC_VECTOR(7 downto 0);
signal add12_res : STD_LOGIC_VECTOR(11 downto 0);
signal count_9 : STD_LOGIC_VECTOR (3 downto 0);
signal count_256 : STD_LOGIC_VECTOR (8 downto 0);
signal main_px_data : STD_LOGIC_VECTOR (7 downto 0);
signal out_Addr : STD_LOGIC_VECTOR (7 downto 0);
signal done_algo : STD_LOGIC;
signal dir_algo : STD_LOGIC;
signal result : STD_LOGIC_VECTOR(18 downto 0);
signal add19_res :STD_LOGIC_VECTOR (18 downto 0);
signal c256enabler : std_logic;
signal move_algo : std_logic;
signal activate : std_logic;
signal regreset : std_logic;
signal mainPxEn :std_logic;
signal minicounteren : std_logic;
signal addera : std_logic_vector(18 downto 0);
begin
minicounteren <= '1' when (activate = '1' and move_algo = '0')
else '0';
mainPxEn <= '1'
when ( activate = '1' and count_9 = "0000")
else '0';
addera <= "00000000000" & sub8_res;
c256enabler <= '1' when (count_9(3) = '1' and activate = '1') or move_algo = '1'
else '0';
regreset <= count_256(8) or rst;
my8 : my_8subtractor port map (dataIn,main_px_data,'1',sub8_res);
my19 : my_19adder port map (addera,result,'0',add19_res);
my256 : counter256 port map (c256enabler, rst, clk, count_256);
my9 :counter port map ( minicounteren, rst, clk, count_9 );
myreg :n_reg port map (dataIn, main_px_data, rst, clk, mainPxEn);
my1919: reg_19 port map (add19_res, result, regreset, clk, activate );
myvalid: addr_Valid port map (count_256(7 downto 0), count_9, out_Addr);
myalgo: Algo port map (count_256(8), rst, clk, result, dir_algo, done_algo, move_algo);
process(readDone, move_algo)
begin
if(readDone = '1') then
activate <= '1';
elsif move_algo = '1' or rst = '1' then
activate <= '0';
end if;
end process;
direction <= dir_algo;
Done <= done_algo;
Move <= move_algo;
addr <= out_Addr;
end AF;