OpenCores
URL https://opencores.org/ocsvn/linkruncca/linkruncca/trunk

Subversion Repositories linkruncca

[/] [linkruncca/] [trunk/] [src/] [equivalence_resolver.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jaytang
/**************************************
2
Author: J.W Tang
3
Email: jaytang1987@hotmail.com
4
Module: equivalence_resolver
5
Date: 2016-04-24
6
 
7
Copyright (C) 2016 J.W. Tang
8
----------------------------
9
This file is part of LinkRunCCA.
10
 
11
LinkRunCCA is free software: you can redistribute it and/or modify
12
it under the terms of the GNU Lesser General Public License as
13
published by the Free Software Foundation, either version 3 of
14
the License, or (at your option) any later version.
15
 
16
LinkRunCCA is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
GNU Lesser General Public License for more details.
20
 
21
You should have received a copy of the GNU Lesser General Public License
22
along with LinkRunCCA. If not, see <http://www.gnu.org/licenses/>.
23
 
24
By using LinkRunCCA in any or associated publication,
25
you agree to cite it as:
26
Tang, J. W., et al. "A linked list run-length-based single-pass
27
connected component analysis for real-time embedded hardware."
28
Journal of Real-Time Image Processing: 1-19. 2016.
29
doi:10.1007/s11554-016-0590-2.
30
 
31
***************************************/
32
 
33 2 jaytang
module equivalence_resolver(
34
        clk,rst,datavalid, //global input
35
        A,B,C,D,p,hp,np,tp,dp,fp,fn,dd, //input from other modules
36
        h_we,t_we,n_we,d_we, //output to table (write enable)
37
        h_waddr,t_waddr,n_waddr,d_waddr, //output to table (write address)
38
        h_wdata,t_wdata,n_wdata,d_wdata, //output to table (write data)
39
        HCN,DAC,DMG,CLR,EOC,O //output to other modules
40
);
41
parameter address_bit=9;
42
parameter data_bit=38;
43
 
44
input clk,rst,datavalid,A,B,C,D,fp,fn;
45
input [address_bit-1:0]p,hp,np,tp;
46
input [data_bit-1:0]dp,dd;
47
 
48
output reg h_we,t_we,n_we,d_we;
49
output reg[address_bit-1:0]h_waddr,t_waddr,n_waddr,d_waddr;
50
output reg[address_bit-1:0]h_wdata,t_wdata,n_wdata;
51
output reg[data_bit-1:0]d_wdata;
52
output HCN,DAC,DMG,CLR,O;
53
output reg EOC;
54
 
55
reg [address_bit-1:0]cc,h;
56
reg f,HBF;
57
wire Ec,Ep;
58
 
59
assign DMG=O&~(f&hp==h);
60
assign DAC=D;
61
 
62
/////events
63
assign Ec=(C&~D);
64
assign Ep=(A&~B);
65
assign O=(B&D&(~A|~C));
66
assign CLR=Ec;
67
assign HCN=HBF&(np==p);
68
 
69
 
70
////cache cc,h,f
71
always@(posedge clk or posedge rst)
72
        if(rst)begin
73
                cc<=0;h<=0;f<=0;
74
        end
75
        else if(datavalid)
76
                if(Ec)begin
77
                        cc<=cc+1; //INC
78
                        f<=0;    //CLR
79
                end
80
                else if(O)begin
81
                        h<=h_wdata;f<=1; //ET1,ET2,ET3
82
                end
83
 
84
/////table update
85
always@*begin
86
        h_we=0;h_waddr={address_bit{1'bx}};h_wdata={address_bit{1'bx}};
87
        t_we=0;t_waddr={address_bit{1'bx}};t_wdata={address_bit{1'bx}};
88
        n_we=0;n_waddr={address_bit{1'bx}};n_wdata={address_bit{1'bx}};
89
        d_we=0;d_waddr={address_bit{1'bx}};d_wdata={data_bit{1'bx}};
90
        EOC=0;HBF=0;
91
        if(Ec)begin
92
                n_we=1;n_waddr=cc;n_wdata=cc; //CLR
93
                h_we=1;h_waddr=cc;h_wdata=cc; //CLR
94
                case(f)
95
                0:begin d_we=1;d_waddr=cc;d_wdata=dd;end //DUC
96
                1:begin d_we=1;d_waddr=h;d_wdata=dd;end //DUH
97
                endcase
98
        end
99
        else if(Ep)begin
100
                case(fp)
101
                0:begin  d_we=1;d_waddr=np;d_wdata=dp; //DBF
102
                        if(fn)EOC=1;    end       //EOC
103
                1:begin h_we=1;h_waddr=np;h_wdata=hp;HBF=1;end  //HBF
104
                endcase
105
        end
106
        else if(O)
107
                case({f,fp})
108
                2'b00:begin
109
                        h_we=1;h_waddr=np;h_wdata=cc;   //ET1
110
                        t_we=1;t_waddr=h_wdata;t_wdata=cc;
111
                end
112
                2'b01:begin
113
                        h_we=1;h_waddr=np;h_wdata=hp;   //ET3
114
                        t_we=1;t_waddr=h_wdata;t_wdata=cc;
115
                        n_we=1;n_waddr=tp;n_wdata=cc;   //EM1
116
                end
117
                2'b10:begin
118
                        h_we=1;h_waddr=np;h_wdata=h;    //ET2
119
                        t_we=1;t_waddr=h_wdata;t_wdata=cc;
120
                end
121
                2'b11:begin
122
                        h_we=1;h_waddr=np;h_wdata=hp;   //ET3
123
                        t_we=1;t_waddr=h_wdata;t_wdata=cc;
124
                        n_we=1;n_waddr=tp;n_wdata=h;    //EM2
125
                end
126
                endcase
127
end
128
 
129
 
130
endmodule
131
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.