Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `timescale 1ns / 1ps
- module tug_of_war_testbench;
- reg left_button; // deklaracja zmiennych (inputy to registers a outputy to wires w symulacjach)
- reg right_button;
- reg clock;
- wire [6:0] leds_out; // [6:0] to tablica 7-bitowa (od 0 do 6)
- always #10 clock <= ~clock; // przelacza zegar co 10 jednostek czasu
- initial begin // All initial statements start from the same time, t=0.
- clock=0; left_button=0; right_button=0; // inicjalizacja zmiennych
- @(posedge clock); // kiedy otrzyma sygnal z zegara...
- #50; // po 50 jednostkach czasu...
- left_button = 0; right_button = 1; // lewy nie jest klikniety, prawy jest // itd... rozne opcje po prostu, mozna tu sie pobawic jak sie chce,
- #100; // tylko wystarczy zachowac wzor, wazne zebys to umial robic, bo profesor
- left_button = 0; // moze chciec zebys pokazal jakas inna symulacje, to wtedy tutaj zmieniasz wlasnie
- #100;
- right_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; right_button = 1;
- #100; left_button = 1;
- #100; right_button = 0;
- #100; left_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; left_button = 1;
- #100; left_button = 0;
- #100; right_button = 1;
- #100; right_button = 0;
- #100; left_button = 0; right_button = 1;
- #5; left_button = 1; right_button= 0;
- #1000;
- $finish;
- end
- // zawsze wyswietlamy statement ile jest aktualnie na ledach (tu podane jest w dziesietnym, ledy sa w dwojkowym, trzeba sobie zamienic)
- always @(posedge clock) $display("Aktualny stan: ", $time, leds_out);
- // trzeba dac input do modułu głównego (tug_of_war)
- tug_of_war tug_of_war_instance(.clock(clock), .left_button(left_button), .right_button(right_button), .leds_out(leds_out));
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement