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

Subversion Repositories scan_based_serial_communication

[/] [scan_based_serial_communication/] [trunk/] [scan_testbench.perl.v] - Diff between revs 3 and 4

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 19... Line 19...
 
 
       print "`define SCAN_CHAIN_LENGTH $scan_chain_length\n\n";
       print "`define SCAN_CHAIN_LENGTH $scan_chain_length\n\n";
 
 
       for (my $i = 0; $i < scalar @signal_list; $i++) {
       for (my $i = 0; $i < scalar @signal_list; $i++) {
 
 
          my $begin = 0;
          my $name      = $signal_list[$i]{name};
          my $end   = $signal_list[$i]{size} - 1;
          my $size      = $signal_list[$i]{size};
 
          my $addr_bits = $signal_list[$i]{addr_bits};
 
          my $data_bits = $signal_list[$i]{data_bits};
 
 
 
          if ($signal_list[$i]{addr_bits} == 0) {
 
             print "   reg [$size-1:0] ${name};\n";
 
             print "   reg [$size-1:0] ${name}_read;\n";
 
             print "   initial ${name}      = ${size}'d0;\n";
 
             print "   initial ${name}_read = ${size}'d0;\n";
 
          } else {
 
             print "   reg [$addr_bits-1:0] ${name}_addr;\n";
 
             print "   reg [$data_bits-1:0] ${name}_data;\n";
 
             print "   reg [$data_bits-1:0] ${name}_data_read;\n";
 
             print "   initial ${name}_addr      = ${addr_bits}'d0;\n";
 
             print "   initial ${name}_data      = ${data_bits}'d0;\n";
 
             print "   initial ${name}_data_read = ${data_bits}'d0;\n";
 
          }
 
 
         print "   reg [$end:$begin] " . $signal_list[$i]{name} . ";\n";
 
         print "   reg [$end:$begin] " . $signal_list[$i]{name} . "_read;\n";
 
         print "   initial " . $signal_list[$i]{name} . " = " .$signal_list[$i]{size} . "'d0;\n";
 
         print "   initial " . $signal_list[$i]{name} . "_read = " .$signal_list[$i]{size} . "'d0;\n";
 
       }
       }
 
 
       */
       */
   end
   end
 
 
Line 65... Line 77...
            /*
            /*
             DEPERLIFY_INCLUDE(scan_signal_list.pl);
             DEPERLIFY_INCLUDE(scan_signal_list.pl);
 
 
             for (my $i = 0; $i < scalar @signal_list; $i++) {
             for (my $i = 0; $i < scalar @signal_list; $i++) {
 
 
 
                if ($signal_list[$i]{addr_bits} == 0) {
                my $begin = $signal_list[$i]{start};
                my $begin = $signal_list[$i]{start};
                my $end   = $signal_list[$i]{start} + $signal_list[$i]{size} - 1;
                my $end   = $signal_list[$i]{start} + $signal_list[$i]{size} - 1;
 
 
                print "         data_in[$end:$begin] = " . $signal_list[$i]{name} . ";\n";
                print "         data_in[$end:$begin] = " . $signal_list[$i]{name} . ";\n";
 
                } else {
 
                   my $begin = $signal_list[$i]{start};
 
                   my $end   = $signal_list[$i]{start} + $signal_list[$i]{addr_bits} + $signal_list[$i]{data_bits} - 1;
 
 
 
                   print "         data_in[$end:$begin] = {" . $signal_list[$i]{name} . "_data, " . $signal_list[$i]{name} . "_addr};\n";
 
                }
             }
             }
 
 
             */
             */
         end
         end
 
 
Line 90... Line 109...
            /*
            /*
             DEPERLIFY_INCLUDE(scan_signal_list.pl);
             DEPERLIFY_INCLUDE(scan_signal_list.pl);
 
 
             for (my $i = 0; $i < scalar @signal_list; $i++) {
             for (my $i = 0; $i < scalar @signal_list; $i++) {
 
 
 
                if ($signal_list[$i]{addr_bits} == 0) {
                my $begin = $signal_list[$i]{start};
                my $begin = $signal_list[$i]{start};
                my $end   = $signal_list[$i]{start} + $signal_list[$i]{size} - 1;
                my $end   = $signal_list[$i]{start} + $signal_list[$i]{size} - 1;
 
 
                print "         " . $signal_list[$i]{name} . "_read = data_out[$end:$begin];\n";
                print "         " . $signal_list[$i]{name} . "_read = data_out[$end:$begin];\n";
 
                } else {
 
                   my $begin = $signal_list[$i]{start} + $signal_list[$i]{addr_bits};
 
                   my $end   = $signal_list[$i]{start} + $signal_list[$i]{addr_bits} + $signal_list[$i]{data_bits} - 1;
 
 
 
                   print "         " . $signal_list[$i]{name} . "_data_read = data_out[$end:$begin];\n";
 
                }
             }
             }
 
 
             */
             */
         end
         end
      end
      end
Line 155... Line 181...
   //  Testbench
   //  Testbench
   //-----------------------------------------
   //-----------------------------------------
 
 
   initial begin
   initial begin
 
 
 
      $dumpvars(0, tbench);
 
 
      $display("Starting scan chain test");
      $display("Starting scan chain test");
 
 
      scan_phi  = 0;
      scan_phi  = 0;
      scan_phi_bar = 0;
      scan_phi_bar = 0;
      scan_data_in = 0;
      scan_data_in = 0;
      scan_load_chip = 0;
      scan_load_chip = 0;
      scan_load_chain = 0;
      scan_load_chain = 0;
 
 
 
      scan_reset = 1'b1;
 
 
      rotate_chain();
      rotate_chain();
      load_chip();
      load_chip();
 
 
 
      // Make sure reset worked
 
      if (chip_internal_write_data_array !== 0)
 
        $display("RESET TEST FAILED");
 
      else
 
        $display("RESET TEST PASSED");
 
 
          // Write each variable
          // Write each variable
 
      scan_reset = 1'b0;
 
 
      write_data_1 = 1'd1;
      write_data_1 = 1'd1;
      write_data_2 = 2'd2;
      write_data_2 = 2'd2;
      write_data_3 = 3'd3;
      write_data_3 = 3'd3;
 
 
 
      write_data_array_addr = 2'd2;
 
      write_data_array_data = 4'hA;
 
 
      rotate_chain();
      rotate_chain();
      load_chip();
      load_chip();
 
 
      // Check that the chip sees the new variables
      // Check that the chip sees the new variables
      if (chip_internal_write_data_1 != 1'd1 ||
      if (chip_internal_write_data_1     !== 1'd1 ||
          chip_internal_write_data_2 != 2'd2 ||
          chip_internal_write_data_2     !== 2'd2 ||
          chip_internal_write_data_3 != 3'd3 )
          chip_internal_write_data_3     !== 3'd3 ||
 
          chip_internal_write_data_array !== 15'h0A00) begin
        $display("TEST 1 FAILED");
        $display("TEST 1 FAILED");
      else
         $display("%d %d %d %h",
 
                  chip_internal_write_data_1,
 
                  chip_internal_write_data_2,
 
                  chip_internal_write_data_3,
 
                  chip_internal_write_data_array);
 
      end else
        $display("TEST 1 PASSED");
        $display("TEST 1 PASSED");
 
 
      // Set internal values to read out      
      // Set internal values to read out      
      chip_internal_read_data_1 = 1'd0;  // As if the chip had this value internally
      chip_internal_read_data_1 = 1'd0;  // As if the chip had this value internally
      chip_internal_read_data_2 = 2'd3;
      chip_internal_read_data_2 = 2'd3;
      chip_internal_read_data_3 = 3'd5;
      chip_internal_read_data_3 = 3'd5;
 
 
 
      chip_internal_read_data_array = 16'hABCD;
 
 
      // Read all of the values for both writable and non-writable variables
      // Read all of the values for both writable and non-writable variables
 
      read_data_array_addr = 2'd1;
 
 
 
      rotate_chain();
      load_chain();
      load_chain();
      rotate_chain();
      rotate_chain();
 
 
      // Check to see that we read out all values properly
      // Check to see that we read out all values properly
      if (write_data_1_read != 1'd1 ||
      if (write_data_1_read         !== 1'd1 ||
          write_data_2_read != 2'd2 ||
          write_data_2_read         !== 2'd2 ||
          write_data_3_read != 3'd3 ||
          write_data_3_read         !== 3'd3 ||
          read_data_1_read  != 1'd0 ||
          read_data_1_read          !== 1'd0 ||
          read_data_2_read  != 2'd3 ||
          read_data_2_read          !== 2'd3 ||
          read_data_3_read  != 3'd5 ) begin
          read_data_3_read          !== 3'd5 ||
 
          read_data_array_data_read !== 4'hC) begin
         $display("TEST 2 FAILED");
         $display("TEST 2 FAILED");
         $display("%d %d %d %d %d %d",
         $display("%d %d %d %d %d %d %h",
                  write_data_1_read,
                  write_data_1_read,
                  write_data_2_read,
                  write_data_2_read,
                  write_data_3_read,
                  write_data_3_read,
                  read_data_1_read,
                  read_data_1_read,
                  read_data_2_read,
                  read_data_2_read,
                  read_data_3_read);
                  read_data_3_read,
 
                  read_data_array_data_read);
      end else
      end else
        $display("TEST 2 PASSED");
        $display("TEST 2 PASSED");
 
 
 
 
      $finish;
      $finish;
   end
   end
 
 
   //////////
   //////////
 
 

powered by: WebSVN 2.1.0

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