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

Subversion Repositories reed_solomon_decoder

[/] [reed_solomon_decoder/] [trunk/] [simulation/] [RS_dec_tb.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 aelmahmoud
 
2
//`timescale 1 ns / 1 ps
3
module RS_dec_tb;
4
 
5
parameter pclk = 5;     /// period of clk/2 
6
 
7
parameter number = 100;  ///  number of input codewords
8
 
9
 
10
reg clk,reset;
11
reg CE;
12
reg [7:0] input_byte;
13
 
14
wire [7:0] Out_byte;
15
wire CEO;
16
wire Valid_out;
17
 
18
RS_dec  DUT
19
(
20
  .clk(clk), // input clock 
21
  .reset(reset), // active high asynchronous reset
22
  .CE(CE), // chip enable active high flag for one clock with every input byte
23
  .input_byte(input_byte), // input byte
24
 
25
  .Out_byte(Out_byte),   // output byte
26
  .CEO(CEO),  // chip enable for the next block will be active high for one clock , every 8 clks
27
  .Valid_out(Valid_out) /// valid out for every output block (188 byte)
28
);
29
 
30
 
31
 
32
reg [7:0] in_mem [0:(number*204)-1];
33
reg [7:0] out_mem [0:(number*188)-1];
34
 
35
reg enable;
36
reg [7:0]true_out;
37
integer h,k,err;
38
 
39
 
40
initial
41
begin
42
        clk=0;
43
        forever #pclk clk=~clk;
44
end
45
 
46
 
47
 
48
integer ce_t,in_t;
49
integer lim; // minimum  6
50
 
51
initial
52
begin
53
        err=0;
54
        lim=6;
55
        $readmemb("input_RS_blocks",in_mem);
56
        $readmemb("output_RS_blocks",out_mem);
57
end
58
 
59
 
60
initial
61
begin
62
        CE=0;
63
        @(posedge enable);
64
        forever
65
        begin
66
                @(posedge clk);
67
                #2 CE=1;
68
                @(posedge clk);
69
                #2 CE=0;
70
                for(ce_t=0; ce_t<lim; ce_t=ce_t+1)
71
                        @(posedge clk);
72
        end
73
end
74
 
75
initial
76
 
77
begin
78
        h=0;
79
        k=0;
80
        enable = 0;
81
        reset =1;
82
        @(posedge clk); @(posedge clk); @(posedge clk);
83
        @(posedge clk); @(posedge clk); @(posedge clk);
84
        reset=0;
85
        @(posedge clk); @(posedge clk);
86
        enable=1;
87
end
88
 
89
 
90
///////////////////// inputs///////////////
91
 
92
initial
93
begin
94
 
95
        input_byte=0;
96
 
97
        @(posedge enable);
98
 
99
        for(k=0;k<(number*204);k=k+1)
100
        begin
101
 
102
                input_byte=in_mem[k];
103
 
104
                @(posedge clk);@(posedge clk);
105
                for(in_t=0; in_t < lim; in_t=in_t+1)
106
                        @(posedge clk);
107
        end
108
 
109
end
110
 
111
//////////////////////////////outputs////////////////////////
112
always @ (posedge(clk))
113
begin
114
        if(Valid_out && CEO)
115
                begin
116
                        true_out = out_mem[h];
117
 
118
                        if(true_out !== Out_byte)
119
                                begin
120
                                        $display("Error at out no. %d !!!!!!!!!!!!!",h);
121
                                        err=err+1;
122
                                end
123
                        h=h+1;
124
 
125
                        if(h== (number*188) )
126
                                begin
127
                                        if (err == 0)
128
                                                $display("No Errors !!!!!!!!!!!!!");
129
                                        else
130
                                                $display("Total Errors =  %d !!!!!!!!!!!!!",err);
131
 
132
                                        $stop;
133
 
134
                                end
135
 
136
                end
137
end
138
 
139
endmodule

powered by: WebSVN 2.1.0

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