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 7

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 joaocarlos
// +----------------------------------------------------------------------------
2
// Universidade Federal da Bahia
3
//------------------------------------------------------------------------------
4
// PROJECT: FPGA Median Filter
5
//------------------------------------------------------------------------------
6
// FILE NAME            : node.v
7
// AUTHOR               : João Carlos Bittencourt
8
// AUTHOR'S E-MAIL      : joaocarlos@ieee.org
9
// -----------------------------------------------------------------------------
10
// RELEASE HISTORY
11
// VERSION  DATE        AUTHOR        DESCRIPTION
12
// 1.0      2013-08-13  joao.nunes    initial version
13
// -----------------------------------------------------------------------------
14
// KEYWORDS: comparator, low, hight, median
15
// -----------------------------------------------------------------------------
16
// PURPOSE: Compare two input values and return the low and high values.
17
// -----------------------------------------------------------------------------
18
module node
19
#(
20
    parameter DATA_WIDTH = 8,
21
    parameter LOW_MUX = 1, // disable low output
22
    parameter HI_MUX = 1 // disable hight output
23
)(
24
    input [DATA_WIDTH-1:0] data_a,
25
    input [DATA_WIDTH-1:0] data_b,
26
 
27
    output reg [DATA_WIDTH-1:0] data_hi,
28
    output reg [DATA_WIDTH-1:0] data_lo
29
);
30
 
31
 
32
    reg sel0;
33
 
34
    always @(*)
35
    begin : comparator
36
        if(data_a < data_b) begin
37
            sel0 = 1'b0; // data_a : lo / data_b : hi
38
        end else begin
39
            sel0 = 1'b1; // data_b : lo / data_a : hi
40
        end
41
    end
42
 
43
 
44
    always @(*)
45
    begin : mux_lo_hi
46
        case (sel0)
47
            1'b0 :
48
            begin
49
                if(LOW_MUX == 1)
50
                    data_lo = data_a;
51
                if(HI_MUX == 1)
52
                    data_hi = data_b;
53
            end
54
            1'b1 :
55
            begin
56
                if(LOW_MUX == 1)
57
                    data_lo = data_b;
58
                if(HI_MUX == 1)
59
                    data_hi = data_a;
60
            end
61
            default :
62
            begin
63
                data_lo = {DATA_WIDTH{1'b0}};
64
                data_hi = {DATA_WIDTH{1'b0}};
65
            end
66
        endcase
67
    end
68
 
69
endmodule

powered by: WebSVN 2.1.0

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