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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [sim/] [verilator/] [soc/] [pc_dma/] [main_plugin.cpp] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
#include <cstdio>
2
#include <cstdlib>
3
 
4
#include <dlfcn.h>
5
 
6
#include <sys/mman.h>
7
#include <sys/types.h>
8
#include <sys/stat.h>
9
#include <fcntl.h>
10
#include <unistd.h>
11
 
12
#include "Vpc_dma.h"
13
#include "verilated.h"
14
#include "verilated_vcd_c.h"
15
 
16
#include "shared_mem.h"
17
 
18
//------------------------------------------------------------------------------
19
//------------------------------------------------------------------------------
20
//------------------------------------------------------------------------------
21
 
22
volatile shared_mem_t *shared_ptr = NULL;
23
 
24
//------------------------------------------------------------------------------
25
//------------------------------------------------------------------------------
26
//------------------------------------------------------------------------------
27
 
28
//------------------------------------------------------------------------------
29
 
30
int main(int argc, char **argv) {
31
    //map shared memory
32
    int fd = open("./../../../sim_pc/shared_mem.dat", O_RDWR, S_IRUSR | S_IWUSR);
33
 
34
    if(fd == -1) {
35
        perror("open() failed for shared_mem.dat");
36
        return -1;
37
    }
38
 
39
    shared_ptr = (shared_mem_t *)mmap(NULL, sizeof(shared_mem_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
40
 
41
    if(shared_ptr == MAP_FAILED) {
42
        perror("mmap() failed");
43
        close(fd);
44
        return -2;
45
    }
46
 
47
    Verilated::commandArgs(argc, argv);
48
 
49
    Verilated::traceEverOn(true);
50
    VerilatedVcdC* tracer = new VerilatedVcdC;
51
 
52
    Vpc_dma *top = new Vpc_dma();
53
    top->trace (tracer, 99);
54
    //tracer->rolloverMB(1000000);
55
    tracer->open("pc_dma.vcd");
56
 
57
    bool dump = false;
58
 
59
    //reset
60
    top->clk = 0; top->rst_n = 1; top->eval();
61
    top->clk = 1; top->rst_n = 1; top->eval();
62
    top->clk = 1; top->rst_n = 0; top->eval();
63
    top->clk = 0; top->rst_n = 0; top->eval();
64
    top->clk = 0; top->rst_n = 1; top->eval();
65
 
66
    uint64 cycle = 0;
67
    bool read_cycle = false;
68
 
69
    printf("pc_dma main_plugin.cpp\n");
70
    while(!Verilated::gotFinish()) {
71
 
72
        //----------------------------------------------------------------------
73
 
74
        /*
75
        uint32 combined.io_address;
76
        uint32 combined.io_data;
77
        uint32 combined.io_byteenable;
78
        uint32 combined.io_is_write;
79
        step_t combined.io_step;
80
 
81
        //000h - 00Fh for slave DMA
82
        input       [3:0]   slave_address,
83
        input               slave_read,
84
        output reg  [7:0]   slave_readdata,
85
        input               slave_write,
86
        input       [7:0]   slave_writedata,
87
 
88
        //080h - 08Fh for DMA page
89
        input       [3:0]   page_address,
90
        input               page_read,
91
        output reg  [7:0]   page_readdata,
92
        input               page_write,
93
        input       [7:0]   page_writedata,
94
 
95
        //0C0h - 0DFh for master DMA
96
        input       [4:0]   master_address,
97
        input               master_read,
98
        output reg  [7:0]   master_readdata,
99
        input               master_write,
100
        input       [7:0]   master_writedata,
101
        */
102
 
103
        top->slave_read  = 0;
104
        top->slave_write = 0;
105
 
106
        top->page_read   = 0;
107
        top->page_write  = 0;
108
 
109
        top->master_read = 0;
110
        top->master_write= 0;
111
 
112
        if(shared_ptr->combined.io_step == STEP_REQ && shared_ptr->combined.io_is_write &&
113
            (shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C ||
114
             shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C ||
115
             shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
116
             shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC))
117
        {
118
            if(shared_ptr->combined.io_byteenable != 1 && shared_ptr->combined.io_byteenable != 2 && shared_ptr->combined.io_byteenable != 4 && shared_ptr->combined.io_byteenable != 8) {
119
                printf("Vpc_dma: combined.io_byteenable invalid: %x\n", shared_ptr->combined.io_byteenable);
120
                exit(-1);
121
            }
122
 
123
            top->slave_address = (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 1)?     0 :
124
                                 (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 2)?     1 :
125
                                 (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 4)?     2 :
126
                                 (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 8)?     3 :
127
                                 (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 1)?     4 :
128
                                 (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 2)?     5 :
129
                                 (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 4)?     6 :
130
                                 (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 8)?     7 :
131
                                 (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 1)?     8 :
132
                                 (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 2)?     9 :
133
                                 (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 4)?     10 :
134
                                 (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 8)?     11 :
135
                                 (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 1)?     12 :
136
                                 (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 2)?     13 :
137
                                 (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 4)?     14 :
138
                                                                                                                             15;
139
 
140
            top->page_address  = (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 1)?     0 :
141
                                 (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 2)?     1 :
142
                                 (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 4)?     2 :
143
                                 (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 8)?     3 :
144
                                 (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 1)?     4 :
145
                                 (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 2)?     5 :
146
                                 (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 4)?     6 :
147
                                 (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 8)?     7 :
148
                                 (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 1)?     8 :
149
                                 (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 2)?     9 :
150
                                 (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 4)?     10 :
151
                                 (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 8)?     11 :
152
                                 (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 1)?     12 :
153
                                 (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 2)?     13 :
154
                                 (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 4)?     14 :
155
                                                                                                                             15;
156
 
157
            top->master_address= (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 1)?     0 :
158
                                 (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 2)?     1 :
159
                                 (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 4)?     2 :
160
                                 (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 8)?     3 :
161
                                 (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 1)?     4 :
162
                                 (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 2)?     5 :
163
                                 (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 4)?     6 :
164
                                 (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 8)?     7 :
165
                                 (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 1)?     8 :
166
                                 (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 2)?     9 :
167
                                 (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 4)?     10 :
168
                                 (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 8)?     11 :
169
                                 (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 1)?     12 :
170
                                 (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 2)?     13 :
171
                                 (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 4)?     14 :
172
                                 (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 8)?     15 :
173
                                 (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 1)?     16 :
174
                                 (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 2)?     17 :
175
                                 (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 4)?     18 :
176
                                 (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 8)?     19 :
177
                                 (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 1)?     20 :
178
                                 (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 2)?     21 :
179
                                 (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 4)?     22 :
180
                                 (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 8)?     23 :
181
                                 (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 1)?     24 :
182
                                 (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 2)?     25 :
183
                                 (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 4)?     26 :
184
                                 (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 8)?     27 :
185
                                 (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 1)?     28 :
186
                                 (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 2)?     29 :
187
                                 (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 4)?     30 :
188
                                                                                                                             31;
189
 
190
 
191
            top->slave_writedata = (shared_ptr->combined.io_byteenable == 1)?     shared_ptr->combined.io_data & 0xFF :
192
                                   (shared_ptr->combined.io_byteenable == 2)?     (shared_ptr->combined.io_data >> 8) & 0xFF :
193
                                   (shared_ptr->combined.io_byteenable == 4)?     (shared_ptr->combined.io_data >> 16) & 0xFF :
194
                                                                                  (shared_ptr->combined.io_data >> 24) & 0xFF;
195
 
196
            top->page_writedata =  (shared_ptr->combined.io_byteenable == 1)?     shared_ptr->combined.io_data & 0xFF :
197
                                   (shared_ptr->combined.io_byteenable == 2)?     (shared_ptr->combined.io_data >> 8) & 0xFF :
198
                                   (shared_ptr->combined.io_byteenable == 4)?     (shared_ptr->combined.io_data >> 16) & 0xFF :
199
                                                                                  (shared_ptr->combined.io_data >> 24) & 0xFF;
200
 
201
            top->master_writedata= (shared_ptr->combined.io_byteenable == 1)?     shared_ptr->combined.io_data & 0xFF :
202
                                   (shared_ptr->combined.io_byteenable == 2)?     (shared_ptr->combined.io_data >> 8) & 0xFF :
203
                                   (shared_ptr->combined.io_byteenable == 4)?     (shared_ptr->combined.io_data >> 16) & 0xFF :
204
                                                                                  (shared_ptr->combined.io_data >> 24) & 0xFF;
205
            if(shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C) {
206
                top->slave_read = 0;
207
                top->slave_write = 1;
208
            }
209
            if(shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C) {
210
                top->page_read = 0;
211
                top->page_write = 1;
212
            }
213
            if(shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
214
               shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC)
215
            {
216
                top->master_read = 0;
217
                top->master_write = 1;
218
            }
219
 
220
            shared_ptr->combined.io_step = STEP_ACK;
221
        }
222
 
223
        if(read_cycle == false) {
224
            if(shared_ptr->combined.io_step == STEP_REQ && shared_ptr->combined.io_is_write == 0 &&
225
                (shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C ||
226
                 shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C ||
227
                 shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
228
                 shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC))
229
            {
230
                if(shared_ptr->combined.io_byteenable != 1 && shared_ptr->combined.io_byteenable != 2 && shared_ptr->combined.io_byteenable != 4 && shared_ptr->combined.io_byteenable != 8) {
231
                    printf("Vpc_dma: combined.io_byteenable invalid: %x\n", shared_ptr->combined.io_byteenable);
232
                    exit(-1);
233
                }
234
 
235
                top->slave_address =(shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 1)?     0 :
236
                                    (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 2)?     1 :
237
                                    (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 4)?     2 :
238
                                    (shared_ptr->combined.io_address == 0x0000 && shared_ptr->combined.io_byteenable == 8)?     3 :
239
                                    (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 1)?     4 :
240
                                    (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 2)?     5 :
241
                                    (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 4)?     6 :
242
                                    (shared_ptr->combined.io_address == 0x0004 && shared_ptr->combined.io_byteenable == 8)?     7 :
243
                                    (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 1)?     8 :
244
                                    (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 2)?     9 :
245
                                    (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 4)?     10 :
246
                                    (shared_ptr->combined.io_address == 0x0008 && shared_ptr->combined.io_byteenable == 8)?     11 :
247
                                    (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 1)?     12 :
248
                                    (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 2)?     13 :
249
                                    (shared_ptr->combined.io_address == 0x000C && shared_ptr->combined.io_byteenable == 4)?     14 :
250
                                                                                                                                15;
251
 
252
                top->page_address  =(shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 1)?     0 :
253
                                    (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 2)?     1 :
254
                                    (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 4)?     2 :
255
                                    (shared_ptr->combined.io_address == 0x0080 && shared_ptr->combined.io_byteenable == 8)?     3 :
256
                                    (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 1)?     4 :
257
                                    (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 2)?     5 :
258
                                    (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 4)?     6 :
259
                                    (shared_ptr->combined.io_address == 0x0084 && shared_ptr->combined.io_byteenable == 8)?     7 :
260
                                    (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 1)?     8 :
261
                                    (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 2)?     9 :
262
                                    (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 4)?     10 :
263
                                    (shared_ptr->combined.io_address == 0x0088 && shared_ptr->combined.io_byteenable == 8)?     11 :
264
                                    (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 1)?     12 :
265
                                    (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 2)?     13 :
266
                                    (shared_ptr->combined.io_address == 0x008C && shared_ptr->combined.io_byteenable == 4)?     14 :
267
                                                                                                                                15;
268
 
269
                top->master_address=(shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 1)?     0 :
270
                                    (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 2)?     1 :
271
                                    (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 4)?     2 :
272
                                    (shared_ptr->combined.io_address == 0x00C0 && shared_ptr->combined.io_byteenable == 8)?     3 :
273
                                    (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 1)?     4 :
274
                                    (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 2)?     5 :
275
                                    (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 4)?     6 :
276
                                    (shared_ptr->combined.io_address == 0x00C4 && shared_ptr->combined.io_byteenable == 8)?     7 :
277
                                    (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 1)?     8 :
278
                                    (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 2)?     9 :
279
                                    (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 4)?     10 :
280
                                    (shared_ptr->combined.io_address == 0x00C8 && shared_ptr->combined.io_byteenable == 8)?     11 :
281
                                    (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 1)?     12 :
282
                                    (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 2)?     13 :
283
                                    (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 4)?     14 :
284
                                    (shared_ptr->combined.io_address == 0x00CC && shared_ptr->combined.io_byteenable == 8)?     15 :
285
                                    (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 1)?     16 :
286
                                    (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 2)?     17 :
287
                                    (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 4)?     18 :
288
                                    (shared_ptr->combined.io_address == 0x00D0 && shared_ptr->combined.io_byteenable == 8)?     19 :
289
                                    (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 1)?     20 :
290
                                    (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 2)?     21 :
291
                                    (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 4)?     22 :
292
                                    (shared_ptr->combined.io_address == 0x00D4 && shared_ptr->combined.io_byteenable == 8)?     23 :
293
                                    (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 1)?     24 :
294
                                    (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 2)?     25 :
295
                                    (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 4)?     26 :
296
                                    (shared_ptr->combined.io_address == 0x00D8 && shared_ptr->combined.io_byteenable == 8)?     27 :
297
                                    (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 1)?     28 :
298
                                    (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 2)?     29 :
299
                                    (shared_ptr->combined.io_address == 0x00DC && shared_ptr->combined.io_byteenable == 4)?     30 :
300
                                                                                                                                31;
301
 
302
 
303
                top->slave_writedata = 0;
304
 
305
                top->page_writedata = 0;
306
 
307
                top->master_writedata= 0;
308
 
309
                if(shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C) {
310
                    top->slave_read = 1;
311
                    top->slave_write = 0;
312
                }
313
                if(shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C) {
314
                    top->page_read = 1;
315
                    top->page_write = 0;
316
                }
317
                if(shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
318
                shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC)
319
                {
320
                    top->master_read = 1;
321
                    top->master_write = 0;
322
                }
323
 
324
                read_cycle = true;
325
            }
326
        }
327
        else {
328
            if(shared_ptr->combined.io_step == STEP_REQ && shared_ptr->combined.io_is_write == 0 &&
329
                (shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C ||
330
                 shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C ||
331
                 shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
332
                 shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC))
333
            {
334
                uint32 val = 0;
335
 
336
                if(shared_ptr->combined.io_address == 0x0000 || shared_ptr->combined.io_address == 0x0004 || shared_ptr->combined.io_address == 0x0008 || shared_ptr->combined.io_address == 0x000C) {
337
                    val = top->slave_readdata;
338
                }
339
                if(shared_ptr->combined.io_address == 0x0080 || shared_ptr->combined.io_address == 0x0084 || shared_ptr->combined.io_address == 0x0088 || shared_ptr->combined.io_address == 0x008C) {
340
                    val = top->page_readdata;
341
                }
342
                if(shared_ptr->combined.io_address == 0x00C0 || shared_ptr->combined.io_address == 0x00C4 || shared_ptr->combined.io_address == 0x00C8 || shared_ptr->combined.io_address == 0x00CC ||
343
                   shared_ptr->combined.io_address == 0x00D0 || shared_ptr->combined.io_address == 0x00D4 || shared_ptr->combined.io_address == 0x00D8 || shared_ptr->combined.io_address == 0x00DC)
344
                {
345
                    val = top->master_readdata;
346
                }
347
 
348
                if(shared_ptr->combined.io_byteenable & 1) val <<= 0;
349
                if(shared_ptr->combined.io_byteenable & 2) val <<= 8;
350
                if(shared_ptr->combined.io_byteenable & 4) val <<= 16;
351
                if(shared_ptr->combined.io_byteenable & 8) val <<= 24;
352
 
353
                shared_ptr->combined.io_data = val;
354
 
355
                read_cycle = false;
356
                shared_ptr->combined.io_step = STEP_ACK;
357
            }
358
        }
359
 
360
        //----------------------------------------------------------------------
361
 
362
        //----------------------------------------------------------------------
363
 
364
        if(top->avm_read != 0) {
365
            printf("Error: avm_read : %d\n", top->avm_read);
366
            exit(-1);
367
        }
368
 
369
        if(top->avm_write != 0) {
370
            printf("Error: avm_write : %d\n", top->avm_write);
371
            exit(-1);
372
        }
373
 
374
        if(top->dma_floppy_ack != 0) {
375
            printf("Error: dma_floppy_ack : %d\n", top->dma_floppy_ack);
376
            exit(-1);
377
        }
378
 
379
        if(top->dma_floppy_terminal != 0) {
380
            printf("Error: dma_floppy_terminal : %d\n", top->dma_floppy_terminal);
381
            exit(-1);
382
        }
383
 
384
        if(top->dma_soundblaster_ack != 0) {
385
            printf("Error: dma_soundblaster_ack : %d\n", top->dma_soundblaster_ack);
386
            exit(-1);
387
        }
388
 
389
        if(top->dma_soundblaster_terminal != 0) {
390
            printf("Error: dma_soundblaster_terminal : %d\n", top->dma_soundblaster_terminal);
391
            exit(-1);
392
        }
393
 
394
        //----------------------------------------------------------------------
395
 
396
        top->clk = 0;
397
        top->eval();
398
        if(dump) tracer->dump(cycle++);
399
 
400
        top->clk = 1;
401
        top->eval();
402
        if(dump) tracer->dump(cycle++);
403
 
404
        tracer->flush();
405
 
406
        usleep(1);
407
    }
408
    tracer->close();
409
    delete tracer;
410
    delete top;
411
 
412
    return 0;
413
}
414
 
415
//------------------------------------------------------------------------------
416
 
417
/*
418
    input               clk,
419
    input               rst_n,
420
 
421
    //000h - 00Fh for slave DMA
422
    input       [3:0]   slave_address,
423
    input               slave_read,
424
    output reg  [7:0]   slave_readdata,
425
    input               slave_write,
426
    input       [7:0]   slave_writedata,
427
 
428
    //080h - 08Fh for DMA page
429
    input       [3:0]   page_address,
430
    input               page_read,
431
    output reg  [7:0]   page_readdata,
432
    input               page_write,
433
    input       [7:0]   page_writedata,
434
 
435
    //0C0h - 0DFh for master DMA
436
    input       [4:0]   master_address,
437
    input               master_read,
438
    output reg  [7:0]   master_readdata,
439
    input               master_write,
440
    input       [7:0]   master_writedata,
441
 
442
    //master
443
    output reg  [31:0]  avm_address,
444
    input               avm_waitrequest,
445
    output reg          avm_read,
446
    input               avm_readdatavalid,
447
    input       [7:0]   avm_readdata,
448
    output reg          avm_write,
449
    output reg  [7:0]   avm_writedata,
450
 
451
    //floppy 8-bit dma channel
452
    input               dma_floppy_req,
453
    output reg          dma_floppy_ack,
454
    output reg          dma_floppy_terminal,
455
    output reg  [7:0]   dma_floppy_readdata,
456
    input       [7:0]   dma_floppy_writedata,
457
 
458
    //soundblaster 8-bit dma channel
459
    input               dma_soundblaster_req,
460
    output reg          dma_soundblaster_ack,
461
    output reg          dma_soundblaster_terminal,
462
    output reg  [7:0]   dma_soundblaster_readdata,
463
    input       [7:0]   dma_soundblaster_writedata
464
*/

powered by: WebSVN 2.1.0

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