OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [toplevel/] [test_top.sv] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//--------------------------------------------------------------
2
// Testbench for the top level design
3
//--------------------------------------------------------------
4
`include "z80.svh"
5
 
6
module test_bench_top(z80_if.tb z);
7
 
8
assign clk = z.CLK;
9
 
10
initial begin : init
11
    $display("Test: Start of test at %d", $time);
12
    z.nWAIT <= `CLR;
13
    z.nINT <= `CLR;
14
    z.nNMI <= `CLR;
15
    z.nBUSRQ <= `CLR;
16
    z.nRESET <= `SET;
17 8 gdevic
#2  repeat (3) @(posedge clk);
18 3 gdevic
    z.nRESET <= `CLR;
19
end : init
20
 
21
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
// Testbench for interrupt testing
23
// Enable one or more interrupt generators and run them with the
24
// 'hello world' code
25
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
 
27
// Infuse a NMI at a certain clock
28
initial begin : nmi_once
29
    repeat (500) @(posedge clk);
30
//    z.nNMI <= `SET;
31
    repeat (1) @(posedge clk);
32
    z.nNMI <= `CLR;
33
end : nmi_once
34
 
35
// Test sending a *periodic* NMI
36
always begin : nmi_rep
37
    repeat (3000) @(posedge clk);
38
//    z.nNMI <= `SET;
39
    repeat (1) @(posedge clk);
40
    z.nNMI <= `CLR;
41
end : nmi_rep
42
 
43
// Infuse an INT at a certain clock
44
initial begin : int_once
45
    repeat (1000) @(posedge clk);
46
//    z.nINT <= `SET;
47
    repeat (300) @(posedge clk);
48
    z.nINT <= `CLR;
49
end : int_once
50
 
51
// Test sending a *periodic* INT
52
always begin : int_rep
53
    repeat (5000) @(posedge clk);
54
//    z.nINT <= `SET;
55
    repeat (300) @(posedge clk);
56
    z.nINT <= `CLR;
57
end : int_rep
58
 
59
// Test WAIT.. inject at will
60
initial begin : wait_once
61
    repeat (1008) @(posedge clk);
62
//    z.nWAIT <= `SET;
63
    repeat (2) @(posedge clk);
64
    z.nWAIT <= `CLR;
65
end : wait_once
66
 
67
// Test BUSRQ / BUSACK
68
initial begin : busrq_once
69
    repeat (10) @(posedge clk);
70
//    z.nBUSRQ <= `SET;
71
    repeat (10) @(posedge clk);
72
    z.nBUSRQ <= `CLR;
73
end : busrq_once
74
 
75
// Test special RESET
76
initial begin : spc_reset
77
    repeat (40) @(posedge clk);
78
//    z.nRESET <= `SET;
79
    repeat (1) @(posedge clk);
80
    z.nRESET <= `CLR;
81
end : spc_reset
82
 
83
endmodule
84
 
85
module test_top();
86
 
87
// Although the clock is going forever, we will stop simulation at some point
88
bit clk = 1;
89
initial forever #1 clk = ~clk;
90
 
91
// Stop after printing "Hello, World!"
92
initial begin : stopme
93
    #70000 $stop();
94
end : stopme
95
 
96
z80_if z80(clk);            // Instantiate the Z80 bus interface
97
z80_top_ifc_n dut(z80);     // Create an instance of our Z80 design
98
test_bench_top tb(z80);     // Create an instance of the test bench
99
 
100
ram  ram( .Address(z80.A), .Data(z80.D), .CS(z80.nMREQ), .WE(z80.nWR), .OE(z80.nRD) );
101
io   io( .Address(z80.A), .Data(z80.D), .CS(z80.nIORQ), .WE(z80.nWR), .OE(z80.nRD) );
102
iorq iorq( .Data(z80.D), .M1(z80.nM1), .IORQ(z80.nIORQ) );
103
 
104
endmodule

powered by: WebSVN 2.1.0

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