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

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [control/] [test_interrupts.sv] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//==============================================================
2
// Test interrupts unit
3
//==============================================================
4
`timescale 100 ns/ 100 ns
5
 
6
module test_interrupts;
7
 
8
// ----------------- CLOCKS AND RESET -----------------
9
// Define one full T-clock cycle delay
10
`define T #2
11
bit clk = 1;
12
initial repeat (20) #1 clk = ~clk;
13
 
14
logic nreset = 0;
15
 
16
// ----------------- CONTROL ----------------
17
logic ctl_iff1_iff2_sig=0;
18
logic ctl_iffx_we_sig=0;
19
logic ctl_iffx_bit_sig=0;
20
logic nmi_sig=0;
21
logic setM1_sig=0;
22
logic intr_sig=0;
23
logic ctl_im_we_sig=0;
24
logic [1:0] db_sig=0;
25
logic clk_sig=0;
26
logic ctl_no_ints_sig=0;
27
 
28
// ----------------- STATES ----------------
29
wire iff1_sig;
30
wire iff2_sig;
31
wire im1_sig;
32
wire im2_sig;
33
wire in_nmi_sig;
34
wire in_intr_sig;
35
 
36
// ----------------- TEST -------------------
37
initial begin
38
    // Init / reset
39
    `T  nreset = 1;
40
        // Test interrupt modes
41
        db_sig = 2'b10;             // IM1
42
        ctl_im_we_sig = 1;
43
    `T  assert(im1_sig==1 && im2_sig==0);
44
        db_sig = 2'b11;             // IM2
45
    `T  assert(im1_sig==0 && im2_sig==1);
46
        db_sig = 2'b00;             // IM0
47
    `T  assert(im1_sig==0 && im2_sig==0);
48
 
49
        // Test IFF state flags
50
        assert(iff1_sig==0 && iff2_sig==0);
51
        ctl_iff1_iff2_sig = 1;
52
        ctl_iffx_we_sig = 1;
53
        ctl_iffx_bit_sig = 1;
54
    `T  assert(iff1_sig==0 && iff2_sig==1);
55
    `T  assert(iff1_sig==1 && iff2_sig==1);
56
        ctl_iff1_iff2_sig = 0;
57
        ctl_iffx_we_sig = 0;
58
        ctl_iffx_bit_sig = 0;
59
 
60
        // Simulate NMI triggering
61
        nmi_sig = 1;
62
    `T  setM1_sig = 1;
63
    `T  assert(iff1_sig==0 && iff2_sig==1);
64
 
65
    `T  $display("End of test");
66
end
67
 
68
//--------------------------------------------------------------
69
// Instantiate interrupts
70
//--------------------------------------------------------------
71
 
72
interrupts interrupts_inst
73
(
74
    .ctl_iff1_iff2(ctl_iff1_iff2_sig) , // input  ctl_iff1_iff2_sig
75
    .nmi(nmi_sig) ,                     // input  nmi_sig
76
    .setM1(setM1_sig) ,                 // input  setM1_sig
77
    .intr(intr_sig) ,                   // input  intr_sig
78
    .ctl_iffx_we(ctl_iffx_we_sig) ,     // input  ctl_iffx_we_sig
79
    .ctl_iffx_bit(ctl_iffx_bit_sig) ,   // input  ctl_iffx_bit_sig
80
    .ctl_im_we(ctl_im_we_sig) ,         // input  ctl_im_we_sig
81
    .db(db_sig) ,                       // input [1:0] db_sig
82
    .clk(clk) ,                         // input  clk
83
    .ctl_no_ints(ctl_no_ints_sig) ,     // input  ctl_no_ints_sig
84
    .nreset(nreset) ,                   // input  nreset
85
    .iff1(iff1_sig) ,                   // output  iff1_sig
86
    .iff2(iff2_sig) ,                   // output  iff2_sig
87
    .im1(im1_sig) ,                     // output  im1_sig
88
    .im2(im2_sig) ,                     // output  im2_sig
89
    .in_nmi(in_nmi_sig) ,               // output  in_nmi_sig
90
    .in_intr(in_intr_sig)               // output  in_intr_sig
91
);
92
 
93
endmodule

powered by: WebSVN 2.1.0

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