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

Subversion Repositories linkruncca

[/] [linkruncca/] [trunk/] [src/] [table_reader.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: table_reader
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 this component in any 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 table_reader(
34
        clk,rst,datavalid, //global input
35
        A,B,r1,r2,d,O,HCN, //input from other modules
36
        d_we,d_waddr,h_rdata,t_rdata,n_rdata,d_rdata,h_wdata,t_wdata, //input from table
37
        h_raddr,t_raddr,n_raddr,d_raddr, //output to table
38
        p,hp,np,tp,dp,fp,fn //output to others module
39
);
40
 
41
parameter address_bit=9;
42
parameter data_bit=38;
43
 
44
input clk,rst,datavalid,A,B,r1,r2,O,HCN,d_we;
45
input [address_bit-1:0]d_waddr,h_rdata,t_rdata,n_rdata,h_wdata,t_wdata;
46
input [data_bit-1:0]d,d_rdata;
47
output [address_bit-1:0]n_raddr,h_raddr,t_raddr,d_raddr;
48
output reg [address_bit-1:0]p,hp,np;
49
output [address_bit-1:0]tp;
50
output [data_bit-1:0]dp;
51
output reg fp,fn;
52
 
53
reg [address_bit-1:0]Rtp;
54
reg [data_bit-1:0]Rdp;
55
 
56
////label counter p
57
reg [address_bit-1:0]pc;
58
always@(posedge clk or posedge rst)
59
        if(rst)begin
60
                pc<=0;p<=0;
61
        end
62
        else if(datavalid)begin
63
                p<=pc;
64
                if(r1&~r2)begin
65
                        pc<=pc+1;
66
                end
67
        end
68
 
69
//////primary tables
70
assign n_raddr=pc;
71
assign h_raddr=pc;
72
 
73
//////secondary tables
74
assign t_raddr=(HCN)?h_wdata:h_rdata;
75
assign d_raddr=(HCN)?h_wdata:h_rdata;
76
 
77
//////previous row run cache
78
wire DCN;
79
assign DCN=(d_we)&(d_waddr==hp);
80
 
81
assign tp=(~A&B)?t_rdata:Rtp;
82
assign dp=(~A&B)?d_rdata:Rdp;
83
always@(posedge clk or posedge rst)
84
        if(rst)begin
85
                np<=0;hp<=0;fp<=0;fn<=0;Rtp<=0;Rdp<=0;
86
        end
87
        else if(datavalid)begin
88
                Rtp<=tp;Rdp<=dp;
89
                if(DCN)
90
                        Rdp<=d;
91
                if(~B&r1)begin
92
                        hp<=t_raddr;
93
                        fp<=~(t_raddr==p);
94
                        np<=n_rdata;
95
                        fn<=(n_rdata==p);
96
                end
97
                else if(O)begin
98
                        Rtp<=t_wdata;
99
                        fp<=1;
100
                        hp<=h_wdata;
101
                end
102
        end
103
 
104
endmodule

powered by: WebSVN 2.1.0

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