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

Subversion Repositories rs_encoder_decoder

[/] [rs_encoder_decoder/] [rtl/] [RS8Encoder_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 RS8Encoder_testbench;
4
 
5
  reg clk_i,rst_i;
6
  reg valid_i;
7
  reg  [7:0]  enc_data_i;
8
  wire [7:0] enc_data_o;
9
  wire parity_o;
10
  wire busy_o;
11
  reg [126*7:0]  path,input_file,output_file;
12
  integer   fd_in, fd_out;
13
 
14
  reg [8:0] wait_cntr;
15
 
16
RS8Encoder8t DUT(.clk_i(clk_i), .rst_i(rst_i),
17
  .encoder_i(enc_data_i),  // Input to the encoder
18
  .valid_i(valid_i),       // set this when input is set
19
  .encoder_o(enc_data_o),  // output of the encoder
20
  .parity_o(parity_o),     // Valid signal is set when the output is available on the output line
21
  .busy_o(busy_o)            // Busy Signal When busy signal is high during the encoding process Please dont 
22
  );                       // give input to the incoder
23
 
24
  // This is an input counter the purpose of this is to set the input to zero in the start 
25
  // of the encoding process
26
 
27
  always @(posedge clk_i) begin
28
    if(rst_i)
29
      wait_cntr <= 0;
30
    else
31
      wait_cntr <= wait_cntr + 1;
32
  end
33
 
34
always
35
#5 clk_i = !clk_i;
36
  initial begin
37
    path = "./";
38
    // These are the input files that can be used in the encoder
39
    // you can select any information bit generation 
40
    input_file = "input_file_RSEncodeData.dat";
41
    output_file = "output_file_RSVerilogEncodedData.dat";
42
    fd_in = $fopen(input_file,"r");
43
    fd_out = $fopen(output_file,"w");
44
 
45
    clk_i = 0;
46
    rst_i = 1;
47
    #10 rst_i = 0;
48
    enc_data_i = 0;
49
 
50
   while(1)
51
     begin
52
       @(posedge clk_i);
53
           if(wait_cntr < 4) begin
54
             valid_i = 0;
55
             enc_data_i = 0;
56
           end
57
           else if((wait_cntr >=4)&&(wait_cntr<=243)) begin // give the input to the encoder when the encoder is not busy
58
             valid_i = 1;
59
             $fscanf(fd_in,"%d\n",enc_data_i); // The input to the encoder should be given at continous clocks and atease 239 packets at a time
60
           end
61
           else if ((wait_cntr>243)&&(wait_cntr <= 259)) begin
62
             valid_i =1;
63
             enc_data_i =0;
64
           end
65
           else if (wait_cntr > 259)  begin
66
             valid_i =0;
67
             enc_data_i =0;
68
           end
69
           if(parity_o)
70
             $fwrite(fd_out,"%d \n",enc_data_o); // Write the output of the encoded data
71
     end
72
  end // initial begin
73
 
74
endmodule

powered by: WebSVN 2.1.0

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