1 |
7 |
jaytang |
/**************************************
|
2 |
|
|
Author: J.W Tang
|
3 |
|
|
Email: jaytang1987@hotmail.com
|
4 |
|
|
Module: LinkRunCCA
|
5 |
|
|
Date: 2016-04-24
|
6 |
|
|
Description: Top level of LinkRunCCA Hardware Module.
|
7 |
|
|
|
8 |
|
|
Copyright (C) 2016 J.W. Tang
|
9 |
|
|
----------------------------
|
10 |
|
|
This file is part of LinkRunCCA.
|
11 |
|
|
|
12 |
|
|
LinkRunCCA is free software: you can redistribute it and/or modify
|
13 |
|
|
it under the terms of the GNU Lesser General Public License as
|
14 |
|
|
published by the Free Software Foundation, either version 3 of
|
15 |
|
|
the License, or (at your option) any later version.
|
16 |
|
|
|
17 |
|
|
LinkRunCCA is distributed in the hope that it will be useful,
|
18 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
|
|
GNU Lesser General Public License for more details.
|
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU Lesser General Public License
|
23 |
|
|
along with LinkRunCCA. If not, see <http://www.gnu.org/licenses/>.
|
24 |
|
|
|
25 |
|
|
By using LinkRunCCA in any or associated publication,
|
26 |
|
|
you agree to cite it as:
|
27 |
|
|
Tang, J. W., et al. "A linked list run-length-based single-pass
|
28 |
|
|
connected component analysis for real-time embedded hardware."
|
29 |
|
|
Journal of Real-Time Image Processing: 1-19. 2016.
|
30 |
|
|
doi:10.1007/s11554-016-0590-2.
|
31 |
|
|
|
32 |
|
|
***************************************/
|
33 |
|
|
|
34 |
|
|
module LinkRunCCA(clk,rst,datavalid,pix_in,datavalid_out,box_out);
|
35 |
|
|
|
36 |
|
|
`include "cca.vh" //parameters file
|
37 |
|
|
|
38 |
|
|
parameter x_bit=$clog2(imwidth);
|
39 |
|
|
parameter y_bit=$clog2(imheight);
|
40 |
|
|
parameter address_bit=x_bit-1;
|
41 |
|
|
parameter data_bit=2*(x_bit+y_bit);
|
42 |
|
|
parameter latency=3; //latency is 3 with holes_filler
|
43 |
|
|
|
44 |
|
|
input clk,rst,datavalid,pix_in;
|
45 |
|
|
output reg datavalid_out;
|
46 |
|
|
output reg [data_bit-1:0]box_out;
|
47 |
|
|
|
48 |
|
|
//rams' wires
|
49 |
|
|
wire [address_bit-1:0]n_waddr,n_wdata,n_raddr,n_rdata;
|
50 |
|
|
wire [address_bit-1:0]h_waddr,h_wdata,h_raddr,h_rdata;
|
51 |
|
|
wire [address_bit-1:0]t_waddr,t_wdata,t_raddr,t_rdata;
|
52 |
|
|
wire [address_bit-1:0]d_raddr,d_waddr;
|
53 |
|
|
wire [data_bit-1:0] d_rdata,d_wdata;
|
54 |
|
|
wire n_we,h_we,t_we,d_we;
|
55 |
|
|
|
56 |
|
|
//connection wires
|
57 |
|
|
wire A,B,C,D,r1,r2,fp,fn,O,HCN,DAC,DMG,CLR,EOC;
|
58 |
|
|
wire [address_bit-1:0]p,hp,tp,np;
|
59 |
|
|
wire [data_bit-1:0]d,dp;
|
60 |
|
|
wire left,hr1,hf_out;
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
//tables
|
64 |
|
|
table_ram#(address_bit,address_bit)
|
65 |
|
|
Next_Table(clk,n_we&datavalid,n_waddr,n_wdata,n_raddr,n_rdata);
|
66 |
|
|
table_ram#(address_bit,address_bit)
|
67 |
|
|
Head_Table(clk,h_we&datavalid,h_waddr,h_wdata,h_raddr,h_rdata);
|
68 |
|
|
table_ram#(address_bit,address_bit)
|
69 |
|
|
Tail_Table(clk,t_we&datavalid,t_waddr,t_wdata,t_raddr,t_rdata);
|
70 |
|
|
table_ram#(data_bit,address_bit)
|
71 |
|
|
Data_Table(clk,d_we&datavalid,d_waddr,d_wdata,d_raddr,d_rdata);
|
72 |
|
|
|
73 |
|
|
//holes filler
|
74 |
|
|
holes_filler HF(clk,datavalid,pix_in,hr1,left,hf_out);
|
75 |
|
|
row_buf#(imwidth-2) RBHF(clk,datavalid,left,hr1);
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
//window & row buffer
|
80 |
|
|
window WIN(clk,datavalid,hf_out,r1,A,B,C,D);
|
81 |
|
|
row_buf#(imwidth-2) RB(clk,datavalid,C,r1,r2);
|
82 |
|
|
|
83 |
|
|
//table reader
|
84 |
|
|
table_reader#(address_bit,data_bit) TR(
|
85 |
|
|
clk,rst,datavalid, //global input
|
86 |
|
|
A,B,r1,r2,d,O,HCN, //input from other modules
|
87 |
|
|
d_we,d_waddr,h_rdata,t_rdata,n_rdata,d_rdata,h_wdata,t_wdata, //input from table
|
88 |
|
|
h_raddr,t_raddr,n_raddr,d_raddr, //output to table
|
89 |
|
|
p,hp,np,tp,dp,fp,fn //output to others module
|
90 |
|
|
);
|
91 |
|
|
|
92 |
|
|
//equivalence resolver
|
93 |
|
|
equivalence_resolver#(address_bit,data_bit) ES(
|
94 |
|
|
clk,rst,datavalid, //global input
|
95 |
|
|
A,B,C,D,p,hp,np,tp,dp,fp,fn,d, //input from other modules
|
96 |
|
|
h_we,t_we,n_we,d_we, //output to table (write enable)
|
97 |
|
|
h_waddr,t_waddr,n_waddr,d_waddr, //output to table (write address)
|
98 |
|
|
h_wdata,t_wdata,n_wdata,d_wdata, //output to table (write data)
|
99 |
|
|
HCN,DAC,DMG,CLR,EOC,O //output to other modules
|
100 |
|
|
);
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
//feature accumulator
|
104 |
|
|
feature_accumulator#(
|
105 |
|
|
.imwidth(imwidth),
|
106 |
|
|
.imheight(imheight),
|
107 |
|
|
.x_bit(x_bit),
|
108 |
|
|
.y_bit(y_bit),
|
109 |
|
|
.address_bit(address_bit),
|
110 |
|
|
.data_bit(data_bit),
|
111 |
|
|
.latency(latency)
|
112 |
|
|
)
|
113 |
|
|
FA(
|
114 |
|
|
clk,rst,datavalid,DAC,DMG,CLR,dp,d
|
115 |
|
|
);
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
//registered data output
|
119 |
|
|
always@(posedge clk or posedge rst)
|
120 |
|
|
if(rst)begin
|
121 |
|
|
datavalid_out<=0;
|
122 |
|
|
end
|
123 |
|
|
else if(datavalid)begin
|
124 |
|
|
datavalid_out<=0;
|
125 |
|
|
box_out<=dp;
|
126 |
|
|
if(EOC)
|
127 |
|
|
datavalid_out<=1;
|
128 |
|
|
end
|
129 |
|
|
|
130 |
|
|
endmodule
|