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

Subversion Repositories rs_encoder_decoder

[/] [rs_encoder_decoder/] [rtl/] [CompleteChain_testbench.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 farooq21
`timescale 1ns / 10 ps
2
 
3
module CompleteChain_testBench;
4
 
5
  reg clk_i,rst_i;
6
  reg valid_i;
7
  reg gen_i;
8
  wire [7:0] enc_data_i;
9
  wire [7:0] enc_data_o;
10
  wire [7:0] dec_data_o;
11
  wire parity_o;
12
  wire busy_o;
13
  reg [126*7:0]  path,output_file,output_fileDec,output_fileRND;
14
  integer   fd_in, fd_out,fd_out1,fd_out2;
15
 
16
 
17
 
18
GF8lfsr RNDMIZER(.clk_i(clk_i), .rst_i(rst_i),
19
  .en_i(gen_i), // Valid Input Set it to High When giving the input
20
  .lfsr_o(enc_data_i)   // Gallios Field Generic Bit Serial Multiplier output
21
  );
22
 
23
RS8Encoder8t ENC(.clk_i(clk_i), .rst_i(rst_i),
24
  .encoder_i(enc_data_i),  // Input to the encoder
25
  .valid_i(valid_i),       // set this when input is set
26
  .encoder_o(enc_data_o),  // output of the encoder
27
  .parity_o(parity_o),     // Valid signal is set when the output is available on the output line
28
  .busy_o(enc_busy_o)            // Busy Signal When busy signal is high during the encoding process Please dont 
29
  );                       // give input to the incoder
30
 
31
 
32
RS8FreqDecode DEC(.clk_i(clk_i), .rst_i(rst_i),
33
  .valid_i(parity_o),    // input valid signal
34
  .enc_data_i(enc_data_o), // encoded data
35
  .dec_data_o(dec_data_o),  // decoded output
36
  .valid_o(valid_o),      // decoded output
37
  .busy_o(dec_busy_o)
38
  );
39
 
40
 
41
  // This is an input counter the purpose of this is to set the input to zero in the start 
42
  // of the encoding process
43
  reg [10:0] wait_cntr;
44
  always @(posedge clk_i) begin
45
    if(rst_i)
46
      wait_cntr <= 0;
47
    else
48
      wait_cntr <= wait_cntr + 1;
49
  end
50
 
51
always
52
#5 clk_i = !clk_i;
53
  initial begin
54
    path = "./";
55
    // These are the input files that can be used in the encoder
56
    // you can select any information bit generation 
57
 
58
    output_file = "output_file_RSVerilogEncodedData.dat";
59
    output_fileDec = "output_file_RSVerilogDecodedData.dat";
60
    output_fileRND = "output_file_RSVerilogRNDData.data";
61
 
62
    fd_out = $fopen(output_file,"w");
63
    fd_out1 = $fopen(output_fileDec,"w");
64
    fd_out2 = $fopen(output_fileRND,"w");
65
 
66
    clk_i = 0;
67
    rst_i = 1;
68
    #10 rst_i = 0;
69
 
70
   while(1)
71
     begin
72
       @(posedge clk_i);
73
           if(wait_cntr < 4) begin
74
             valid_i = 0;
75
             gen_i = 1;
76
           end
77
           else if((wait_cntr >=4)&&(wait_cntr<=243)) begin // give the input to the encoder when the encoder is not busy
78
             valid_i = 1;
79
             gen_i = 1;
80
           end
81
           else if ((wait_cntr>243)&&(wait_cntr <= 259)) begin
82
             valid_i =1;
83
             gen_i = 0;
84
           end
85
           else if (wait_cntr > 259)  begin
86
             valid_i =0;
87
             gen_i = 0;
88
           end
89
           if(parity_o)
90
             $fwrite(fd_out,"%d \n",enc_data_o); // Write the output of the encoded data
91
           if(valid_o)
92
            $fwrite(fd_out1,"%d \n",dec_data_o); // Write the output of the encoded data
93
           if(gen_i)
94
            $fwrite(fd_out2,"%d \n",enc_data_i); // RandomLy Generated Data
95
 
96
     end
97
  end // initial begin
98
 
99
endmodule

powered by: WebSVN 2.1.0

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