-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmelody_player_tb.v
More file actions
64 lines (50 loc) · 1.17 KB
/
Copy pathmelody_player_tb.v
File metadata and controls
64 lines (50 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
`timescale 1ns/1ns // time-unit, precision
`default_nettype none
module MelodyPlayer_tb();
parameter CLOCK_HZ = 10_000_000;
parameter HALF_PERIOD_NS = 1_000_000_000 / (2 * CLOCK_HZ);
// Clock generator
reg Clock = 1'b1;
always begin
#HALF_PERIOD_NS;
Clock = !Clock;
end
// Variables
reg Reset = 1'b0;
reg Play = 1'b0;
reg Stop = 1'b0;
wire SoundWave;
// Instantiate device under test
MelodyPlayer #(
.CLOCK_HZ(CLOCK_HZ)
) DUT(
.Clock(Clock),
.Reset(Reset),
.Play_i(Play),
.Stop_i(Stop),
.SoundWave_o(SoundWave)
);
// Variable dump
initial begin
$dumpfile("melody_player.vcd");
$dumpvars(0, MelodyPlayer_tb);
end
// Test sequence
initial begin
$timeformat(-6, 3, "us", 12);
$display("===== START =====");
$display(" Time Durat HaPer Freq");
#1 Reset <= 1'b1;
repeat(9) @(posedge Clock);
@(posedge Clock)
Play <= 1'b1;
@(posedge Clock)
Play <= 1'b0;
repeat(10) @(posedge Clock);
wait(DUT.State == DUT.IDLE);
repeat(10) @(posedge Clock);
$display("====== END ======");
$finish;
end
endmodule
`default_nettype wire