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 17

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 8 gdevic
assign iff1_sig = interrupts_inst.iff1;
31 3 gdevic
wire iff2_sig;
32
wire im1_sig;
33
wire im2_sig;
34
wire in_nmi_sig;
35
wire in_intr_sig;
36
 
37
// ----------------- TEST -------------------
38
initial begin
39
    // Init / reset
40
    `T  nreset = 1;
41
        // Test interrupt modes
42
        db_sig = 2'b10;             // IM1
43
        ctl_im_we_sig = 1;
44
    `T  assert(im1_sig==1 && im2_sig==0);
45
        db_sig = 2'b11;             // IM2
46
    `T  assert(im1_sig==0 && im2_sig==1);
47
        db_sig = 2'b00;             // IM0
48
    `T  assert(im1_sig==0 && im2_sig==0);
49
 
50
        // Test IFF state flags
51
        assert(iff1_sig==0 && iff2_sig==0);
52
        ctl_iff1_iff2_sig = 1;
53
        ctl_iffx_we_sig = 1;
54
        ctl_iffx_bit_sig = 1;
55
    `T  assert(iff1_sig==0 && iff2_sig==1);
56
    `T  assert(iff1_sig==1 && iff2_sig==1);
57
        ctl_iff1_iff2_sig = 0;
58
        ctl_iffx_we_sig = 0;
59
        ctl_iffx_bit_sig = 0;
60
 
61
        // Simulate NMI triggering
62
        nmi_sig = 1;
63
    `T  setM1_sig = 1;
64
    `T  assert(iff1_sig==0 && iff2_sig==1);
65
 
66
    `T  $display("End of test");
67
end
68
 
69
//--------------------------------------------------------------
70
// Instantiate interrupts
71
//--------------------------------------------------------------
72
 
73
interrupts interrupts_inst
74
(
75
    .ctl_iff1_iff2(ctl_iff1_iff2_sig) , // input  ctl_iff1_iff2_sig
76
    .nmi(nmi_sig) ,                     // input  nmi_sig
77
    .setM1(setM1_sig) ,                 // input  setM1_sig
78
    .intr(intr_sig) ,                   // input  intr_sig
79
    .ctl_iffx_we(ctl_iffx_we_sig) ,     // input  ctl_iffx_we_sig
80
    .ctl_iffx_bit(ctl_iffx_bit_sig) ,   // input  ctl_iffx_bit_sig
81
    .ctl_im_we(ctl_im_we_sig) ,         // input  ctl_im_we_sig
82
    .db(db_sig) ,                       // input [1:0] db_sig
83
    .clk(clk) ,                         // input  clk
84
    .ctl_no_ints(ctl_no_ints_sig) ,     // input  ctl_no_ints_sig
85
    .nreset(nreset) ,                   // input  nreset
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.