Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3.  
  4.   module tug_of_war_testbench; 
  5.  
  6.     reg left_button;            // deklaracja zmiennych (inputy to registers a outputy to wires w symulacjach)
  7.     reg right_button;
  8.     reg clock;
  9.     wire [6:0] leds_out;        // [6:0] to tablica 7-bitowa (od 0 do 6)
  10.  
  11.     always #10  clock <= ~clock;    // przelacza zegar co 10 jednostek czasu
  12.  
  13.     initial begin               // All initial statements start from the same time, t=0.
  14.  
  15.         clock=0;  left_button=0; right_button=0;    // inicjalizacja zmiennych 
  16.         @(posedge clock);       // kiedy otrzyma sygnal z zegara...
  17.         #50;                     // po 50 jednostkach czasu...
  18.         left_button = 0; right_button = 1;     // lewy nie jest klikniety, prawy jest     // itd... rozne opcje po prostu, mozna tu sie pobawic jak sie chce,
  19.         #100;                    // tylko wystarczy zachowac wzor, wazne zebys to umial robic, bo profesor
  20.         left_button = 0;        // moze chciec zebys pokazal jakas inna symulacje, to wtedy tutaj zmieniasz wlasnie
  21.         #100;
  22.         right_button = 0;
  23.         #100; right_button = 1;
  24.         #100; right_button = 0;
  25.         #100; right_button = 1;
  26.         #100; left_button = 1;
  27.         #100; right_button = 0;
  28.         #100; left_button = 0;
  29.         #100; right_button = 1;
  30.         #100; right_button = 0;
  31.         #100; left_button = 1;
  32.         #100; left_button = 0;
  33.         #100; left_button = 1;
  34.         #100; left_button = 0;
  35.         #100; left_button = 1;
  36.         #100; left_button = 0;
  37.         #100; left_button = 1;
  38.         #100; left_button = 0;
  39.         #100; left_button = 1;
  40.         #100; left_button = 0;
  41.         #100; right_button = 1;
  42.         #100; right_button = 0;
  43.         #100; right_button = 1;
  44.         #100; right_button = 0;
  45.         #100; right_button = 1;
  46.         #100; right_button = 0;
  47.         #100; left_button = 1;
  48.         #100; left_button = 0;
  49.         #100; left_button = 1;
  50.         #100; left_button = 0;
  51.         #100; right_button = 1;
  52.         #100; right_button = 0;
  53.         #100; left_button = 1;
  54.         #100; left_button = 0;
  55.         #100; right_button = 1;
  56.         #100; right_button = 0;
  57.         #100; left_button = 0; right_button = 1;   
  58.         #5;   left_button = 1; right_button= 0;
  59.         #1000;
  60.  
  61.         $finish;
  62.     end    
  63.  
  64.     // zawsze wyswietlamy statement ile jest aktualnie na ledach (tu podane jest w dziesietnym, ledy sa w dwojkowym, trzeba sobie zamienic)
  65.     always @(posedge clock) $display("Aktualny stan: ", $time, leds_out);
  66.  
  67.  
  68.  
  69.     // trzeba dac input do modułu głównego (tug_of_war)
  70.     tug_of_war tug_of_war_instance(.clock(clock), .left_button(left_button), .right_button(right_button), .leds_out(leds_out));
  71.   endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement