Advertisement
Guest User

Verilog

a guest
Dec 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module test_bcd2sseg();
  4.  
  5. reg [3:0] t_sw;
  6. wire [6:0] t_seg;
  7.  
  8. artix7_bcd DUT
  9. (
  10.     .sw(t_sw),
  11.     .seg(t_seg)
  12. );
  13.  
  14. initial begin
  15.  
  16.     $display("%0t: Starting TPG.", $time);
  17.    
  18.     //DLA 0
  19.     #10 t_sw = 4'b0000;
  20.    
  21.     // check the results
  22.     #1
  23.     if(t_seg == 7'b0000001)
  24.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  25.     else
  26.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  27.     t_sw, t_seg);
  28.    
  29.     //DLA 1
  30.     #10 t_sw = 4'b0001;
  31.    
  32.     // check the results
  33.     #1
  34.     if(t_seg == 7'b1001111)
  35.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  36.     else
  37.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  38.     t_sw, t_seg);
  39.    
  40.     //DLA 2
  41.     #10 t_sw = 4'b0010;
  42.    
  43.     // check the results
  44.     #1
  45.     if(t_seg == 7'b0010010)
  46.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  47.     else
  48.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  49.     t_sw, t_seg);
  50.    
  51.     //DLA 3
  52.     #10 t_sw = 4'b0011;
  53.    
  54.     // check the results
  55.     #1
  56.     if(t_seg == 7'b0000110)
  57.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  58.     else
  59.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  60.     t_sw, t_seg);
  61.    
  62.     //DLA 4
  63.     #10 t_sw = 4'b0100;
  64.    
  65.     // check the results
  66.     #1
  67.     if(t_seg == 7'b1001100)
  68.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  69.     else
  70.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  71.     t_sw, t_seg);
  72.    
  73.     //DLA 5
  74.     #10 t_sw = 4'b0101;
  75.    
  76.     // check the results
  77.     #1
  78.     if(t_seg == 7'b0100100)
  79.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  80.     else
  81.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  82.     t_sw, t_seg);
  83.    
  84.     //DLA 6
  85.     #10 t_sw = 4'b0110;
  86.    
  87.     // check the results
  88.     #1
  89.     if(t_seg == 7'b0100000)
  90.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  91.     else
  92.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  93.     t_sw, t_seg);
  94.    
  95.     //DLA 7
  96.     #10 t_sw = 4'b0111;
  97.    
  98.     // check the results
  99.     #1
  100.     if(t_seg == 7'b0001111)
  101.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  102.     else
  103.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  104.     t_sw, t_seg);
  105.    
  106.     //DLA 8
  107.     #10 t_sw = 4'b1000;
  108.    
  109.     // check the results
  110.     #1
  111.     if(t_seg == 7'b0000000)
  112.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  113.     else
  114.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  115.     t_sw, t_seg);
  116.    
  117.     //DLA 9
  118.     #10 t_sw = 4'b1001;
  119.    
  120.     // check the results
  121.     #1
  122.     if(t_seg == 7'b0000100)
  123.         $display("%0t Test PASSED for pattern %b", $time, t_sw);
  124.     else
  125.         $display("%0t Test FAILED for pattern %b - result is %b", $time,
  126.     t_sw, t_seg);
  127.  
  128.    
  129.  
  130.      
  131.      #10 $display("%0t: Finished TPG.", $time);
  132.      $stop;
  133.  end
  134.  endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement