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

Subversion Repositories fpga-median

[/] [fpga-median/] [trunk/] [sim/] [tb/] [median_tb_directed.sv] - 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 .
16
-------------------------------------------------------------------------------- */
17 2 joaocarlos
// +----------------------------------------------------------------------------
18
// Universidade Federal da Bahia
19
//------------------------------------------------------------------------------
20
// PROJECT: FPGA Median Filter
21
//------------------------------------------------------------------------------
22
// FILE NAME            : median_tb.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-27  joao.nunes    initial version
29
// 1.1      2013-09-04  laue.rami     modified version
30
// -----------------------------------------------------------------------------
31
// KEYWORDS: median, filter, image processing
32
// -----------------------------------------------------------------------------
33
// PURPOSE: Testbench for Median filter.
34
// -----------------------------------------------------------------------------
35
`define IMG_HEIGHT 'd320
36
`define IMG_WIDTH  'd320
37
module median_tb;
38
 
39
    `include "../tb/driver.sv"
40
 
41
    driver driver_u0;
42
 
43
    localparam PERIOD = 10;
44
    localparam PIXEL_DATA_WIDTH = 8;
45
    localparam LUT_ADDR_WIDTH = 14; // Input LUTs
46
    localparam MEM_ADDR_WIDTH = 14; // Output Memory
47
 
48
    bit clk;
49
 
50
    wire [MEM_ADDR_WIDTH-1:0] raddr_a;
51
    wire [MEM_ADDR_WIDTH-1:0] raddr_b;
52
    wire [MEM_ADDR_WIDTH-1:0] raddr_c;
53
    wire [MEM_ADDR_WIDTH-1:0] waddr_a;
54
    wire [MEM_ADDR_WIDTH-1:0] waddr_b;
55
    wire [MEM_ADDR_WIDTH-1:0] waddr_c;
56
 
57
 
58
    wire [MEM_ADDR_WIDTH-1:0] waddr;
59
 
60
    reg [(PIXEL_DATA_WIDTH*4)-1:0] word0;
61
    reg [(PIXEL_DATA_WIDTH*4)-1:0] word1;
62
    reg [(PIXEL_DATA_WIDTH*4)-1:0] word2;
63
 
64
    wire [31:0] w_data_bram0;
65
    wire [31:0] w_data_bram1;
66
    wire [31:0] w_data_bram2;
67
 
68
    //dut_if interface
69
    dut_if dut_if (clk);
70
 
71
    //driver
72
 
73
    always #(PERIOD/2) clk = ~clk;
74
 
75
    dual_port_ram
76
    #(
77
      .MEMFILE("./memA.hex"),
78
      .DATA_WIDTH('d32),
79
      .ADDR_WIDTH('d14)
80
    )
81
    BRAM0
82
    (
83
      .clk(clk),
84
      .r_ena(1'b1),
85
      .w_ena(1'b0),
86
      .w_data(w_data_bram0),
87
      .w_addr(waddr_a),
88
      .r_addr(raddr_a),
89
      .r_data(dut_if.word0)
90
    );
91
 
92
    dual_port_ram
93
    #(
94
      .MEMFILE("./memB.hex"),
95
      .DATA_WIDTH('d32),
96
      .ADDR_WIDTH('d14)
97
    )
98
    BRAM1
99
    (
100
      .clk(clk),
101
      .r_ena(1'b1),
102
      .w_ena(1'b0),
103
      .w_data(w_data_bram1),
104
      .w_addr(waddr_b),
105
      .r_addr(raddr_b),
106
      .r_data(dut_if.word1)
107
    );
108
 
109
    dual_port_ram
110
    #(
111
      .MEMFILE("./memC.hex"),
112
      .DATA_WIDTH('d32),
113
      .ADDR_WIDTH('d14)
114
    )
115
    BRAM2
116
    (
117
      .clk(clk),
118
      .r_ena(1'b1),
119
      .w_ena(1'b0),
120
      .w_data(w_data_bram2),
121
      .w_addr(waddr_c),
122
      .r_addr(raddr_c),
123
      .r_data(dut_if.word2)
124
    );
125
 
126
    median
127
    #(
128
        .MEM_DATA_WIDTH(PIXEL_DATA_WIDTH*4),
129
        .PIXEL_DATA_WIDTH(PIXEL_DATA_WIDTH),
130
        .LUT_ADDR_WIDTH(LUT_ADDR_WIDTH),
131
        .MEM_ADDR_WIDTH(MEM_ADDR_WIDTH),
132
        .IMG_WIDTH(`IMG_WIDTH),
133
        .IMG_HEIGHT(`IMG_HEIGHT)
134
    ) dut_u0 (
135
        .clk(clk), // Clock
136
        .rst_n(dut_if.rst_n), // Asynchronous reset active low
137
        .word0(dut_if.ch_word0),
138
        .word1(dut_if.ch_word1),
139
        .word2(dut_if.ch_word2),
140
        .pixel1(dut_if.pixel1),
141
        .pixel2(dut_if.pixel2),
142
        .pixel3(dut_if.pixel3),
143
        .pixel4(dut_if.pixel4),
144
        .raddr_a(raddr_a),
145
        .raddr_b(raddr_b),
146
        .raddr_c(raddr_c),
147
        .waddr(dut_if.waddr)
148
    );
149
 
150
    always@(*)begin
151
       dut_if.window_line_counter  = dut_u0.window_contol.window_line_counter;
152
    end
153
 
154
    initial begin
155
        $display("INICIO -------");
156
        driver_u0 = new(dut_if);
157
        driver_u0.init();
158
        driver_u0.receive_data();
159
        driver_u0.reorganize_lines();
160
        wait(dut_if.end_of_operation);
161
        driver_u0.write_file();
162
        #(PERIOD*3)
163
        repeat(100)@(negedge clk);
164
        $stop;
165
    end
166
 
167
endmodule

powered by: WebSVN 2.1.0

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