OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [sim/] [iverilog/] [pic/] [tb_pic.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
 
2
module tb_pic();
3
 
4
reg clk;
5
reg rst_n;
6
 
7
reg         master_address      = 1'b0;
8
reg         master_read         = 1'b0;
9
wire [7:0]  master_readdata;
10
reg         master_write        = 1'b0;
11
reg [7:0]   master_writedata    = 8'd0;
12
 
13
reg         slave_address       = 1'b0;
14
reg         slave_read          = 1'b0;
15
wire [7:0]  slave_readdata;
16
reg         slave_write         = 1'b0;
17
reg [7:0]   slave_writedata     = 8'd0;
18
 
19
reg [15:0]  interrupt           = 16'd0;
20
 
21
wire        interrupt_do;
22
wire [7:0]  interrupt_vector;
23
reg         interrupt_done      = 1'b0;
24
 
25
pic pic_inst(
26
    .clk                (clk),
27
    .rst_n              (rst_n),
28
 
29
    //master pic
30
    .master_address     (master_address),     //input
31
    .master_read        (master_read),        //input
32
    .master_readdata    (master_readdata),    //output [7:0]
33
    .master_write       (master_write),       //input
34
    .master_writedata   (master_writedata),   //input [7:0]
35
 
36
    //slave pic
37
    .slave_address      (slave_address),      //input
38
    .slave_read         (slave_read),         //input
39
    .slave_readdata     (slave_readdata),     //output [7:0]
40
    .slave_write        (slave_write),        //input
41
    .slave_writedata    (slave_writedata),    //input [7:0]
42
 
43
    //interrupt input
44
    .interrupt          (interrupt),          //input [15:0]
45
 
46
    //interrupt output
47
    .interrupt_do       (interrupt_do),       //output
48
    .interrupt_vector   (interrupt_vector),   //output [7:0]
49
    .interrupt_done     (interrupt_done)      //input
50
);
51
 
52
initial begin
53
    clk = 1'b0;
54
    forever #5 clk = ~clk;
55
end
56
 
57
integer finished = 0;
58
 
59
`define WRITE_MAS_IMR(data)     \
60
    master_write        = 1'b1; \
61
    master_address      = 1'b1; \
62
    master_writedata    = data; \
63
    #10;                        \
64
    master_write        = 1'b0;
65
 
66
`define WRITE_SLA_IMR(data)     \
67
    slave_write        = 1'b1; \
68
    slave_address      = 1'b1; \
69
    slave_writedata    = data; \
70
    #10;                        \
71
    slave_write        = 1'b0;
72
 
73
`define WRITE_MAS_OCW2_3(data)  \
74
    master_write        = 1'b1; \
75
    master_address      = 1'b0; \
76
    master_writedata    = data; \
77
    #10;                        \
78
    master_write        = 1'b0;
79
 
80
`define WRITE_SLA_OCW2_3(data) \
81
    slave_write        = 1'b1; \
82
    slave_address      = 1'b0; \
83
    slave_writedata    = data; \
84
    #10;                       \
85
    slave_write        = 1'b0;
86
 
87
 
88
reg [255:0] dumpfile_name;
89
initial begin
90
    if( $value$plusargs("dumpfile=%s", dumpfile_name) == 0 ) begin
91
        dumpfile_name = "default.vcd";
92
    end
93
 
94
    $dumpfile(dumpfile_name);
95
    $dumpvars(0);
96
    $dumpon();
97
 
98
    $display("START");
99
 
100
    rst_n = 1'b0;
101
    #10 rst_n = 1'b1;
102
 
103
    //clear mask
104
    `WRITE_MAS_IMR(8'h00)
105
    `WRITE_SLA_IMR(8'h00)
106
 
107
    #10;
108
    interrupt[15:0] = 16'b0100000000000000;
109
 
110
    while(interrupt_do == 1'b0) begin #10; end
111
 
112
    interrupt[15:0] = 16'b0000000000000000;
113
    #10;
114
 
115
    #10;
116
    interrupt_done = 1'b1;
117
    #10;
118
    interrupt_done = 1'b0;
119
 
120
    #40;
121
    `WRITE_MAS_OCW2_3(8'h20)
122
    `WRITE_SLA_OCW2_3(8'h20)
123
 
124
    while(finished == 0) begin
125
        if($time > 50000) $finish_and_return(-1);
126
        #10;
127
 
128
        //$dumpflush();
129
    end
130
 
131
    #60;
132
 
133
    $dumpoff();
134
    $finish_and_return(0);
135
end
136
 
137
endmodule

powered by: WebSVN 2.1.0

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