OpenCores
URL https://opencores.org/ocsvn/fpga-median/fpga-median/trunk

Subversion Repositories fpga-median

[/] [fpga-median/] [trunk/] [rtl/] [node.v] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 joaocarlos
/* --------------------------------------------------------------------------------
2
 This file is part of FPGA Median Filter.
3
 
4
    FPGA Median Filter is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8
 
9
    FPGA Median Filter is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU General Public License for more details.
13
 
14
    You should have received a copy of the GNU General Public License
15
    along with FPGA Median Filter.  If not, see <http://www.gnu.org/licenses/>.
16
-------------------------------------------------------------------------------- */
17
/* +----------------------------------------------------------------------------
18
   Universidade Federal da Bahia
19
  ------------------------------------------------------------------------------
20
   PROJECT: FPGA Median Filter
21
  ------------------------------------------------------------------------------
22
   FILE NAME            : node.v
23
   AUTHOR               : João Carlos Bittencourt
24
   AUTHOR'S E-MAIL      : joaocarlos@ieee.org
25
   -----------------------------------------------------------------------------
26
   RELEASE HISTORY
27
   VERSION  DATE        AUTHOR        DESCRIPTION
28
   1.0      2013-08-13  joao.nunes    initial version
29
   -----------------------------------------------------------------------------
30
   KEYWORDS: comparator, low, hight, median
31
   -----------------------------------------------------------------------------
32
   PURPOSE: Compare two input values and return the low and high values.
33
   ----------------------------------------------------------------------------- */
34 2 joaocarlos
module node
35
#(
36
    parameter DATA_WIDTH = 8,
37
    parameter LOW_MUX = 1, // disable low output
38
    parameter HI_MUX = 1 // disable hight output
39
)(
40
    input [DATA_WIDTH-1:0] data_a,
41
    input [DATA_WIDTH-1:0] data_b,
42
 
43
    output reg [DATA_WIDTH-1:0] data_hi,
44
    output reg [DATA_WIDTH-1:0] data_lo
45
);
46
 
47
 
48
    reg sel0;
49
 
50
    always @(*)
51
    begin : comparator
52
        if(data_a < data_b) begin
53
            sel0 = 1'b0; // data_a : lo / data_b : hi
54
        end else begin
55
            sel0 = 1'b1; // data_b : lo / data_a : hi
56
        end
57
    end
58
 
59
 
60
    always @(*)
61
    begin : mux_lo_hi
62
        case (sel0)
63
            1'b0 :
64
            begin
65
                if(LOW_MUX == 1)
66
                    data_lo = data_a;
67
                if(HI_MUX == 1)
68
                    data_hi = data_b;
69
            end
70
            1'b1 :
71
            begin
72
                if(LOW_MUX == 1)
73
                    data_lo = data_b;
74
                if(HI_MUX == 1)
75
                    data_hi = data_a;
76
            end
77
            default :
78
            begin
79
                data_lo = {DATA_WIDTH{1'b0}};
80
                data_hi = {DATA_WIDTH{1'b0}};
81
            end
82
        endcase
83
    end
84
 
85
endmodule

powered by: WebSVN 2.1.0

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