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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [designs/] [leon3-wildcard-xcv300e/] [host_arch.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
--============================================================================--
19
-- Design unit  : Host emulation (architecture declarations)
20
--
21
-- File name    : host_arch.vhd
22
--
23
-- Purpose      : Host emulator for test bench
24
--
25
-- Library      : System
26
--
27
-- Authors      : Mr Sandi Alexander Habinc
28
--                Gaisler Research
29
--
30
-- Contact      : mailto:support@gaisler.com
31
--                http://www.gaisler.com
32
--
33
-- Disclaimer   : All information is provided "as is", there is no warranty that
34
--                the information is correct or suitable for any purpose,
35
--                neither implicit nor explicit.
36
--============================================================================--
37
 
38
--============================== Architecture ================================--
39
 
40
library  Std;
41
use      Std.TextIO.all;
42
 
43
library  IEEE;
44
use      IEEE.Std_Logic_1164.all;
45
use      IEEE.Std_Logic_Arith.all;
46
use      IEEE.Std_Logic_TextIO.all;
47
 
48
library  PE_Lib;
49
use      PE_Lib.PE_Package.all;
50
 
51
library  SYSTEM;
52
use      SYSTEM.Host_Package.all;
53
 
54
architecture Validate of Host is
55
   -----------------------------------------------------------------------------
56
   -- Registers
57
   -----------------------------------------------------------------------------
58
   constant cStat:      DWORD := 16#00000000#;
59
   constant cCtrl:      DWORD := 16#00000004#;
60
   constant cSize:      DWORD := 16#00000008#;
61
   constant cVer:       DWORD := 16#0000000c#;
62
   constant cRAddr:     DWORD := 16#00000010#;
63
   constant cWAddr:     DWORD := 16#00000020#;
64
   constant cRData:     DWORD := 16#00000200#;
65
   constant cWData:     DWORD := 16#00000300#;
66
 
67
   constant cSSRAML:    DWORD := 16#40000000#;
68
   constant cSSRAMR:    DWORD := 16#60000000#;
69
   constant cAHBRam:    DWORD := 16#a0000000#;
70
 
71
begin
72
   -----------------------------------------------------------------------------
73
   --
74
   -----------------------------------------------------------------------------
75
   Main: process
76
      --------------------------------------------------------------------------
77
      --
78
      --------------------------------------------------------------------------
79
      variable device:              WC_DeviceNum   := 0;
80
      variable enable:              Boolean        := False;
81
      variable burstLength:         Integer;
82
      variable fClkFreq:            Float          := 10.0;
83
      variable dwordOffset:         DWORD;
84
      variable dwordCount:          DWORD;
85
      variable regData:             DWORD_array (0 to 255);
86
      variable memData:             DWORD_array (0 to 255);
87
      variable Done:                Boolean;
88
      variable timeoutMilliSeconds: DWORD;
89
      variable data:                DWORD;
90
      variable dv:                  DWORD_array (0 to 255);
91
      variable cv:                  DWORD_array (0 to 255);
92
 
93
      variable ready:               Integer;
94
 
95
      variable L:                   Line;
96
 
97
      procedure wcmd (a: in DWORD; d: in DWORD) is
98
      begin
99
         Write(L, Now, Right, 15);
100
         Write(L, String'(" : Write: addr = "));
101
         HWrite(L, Conv_Std_Logic_Vector(a, 32));
102
         Write(L, String'(" : data = "));
103
         HWrite(L, Conv_Std_Logic_Vector(d, 32));
104
         WriteLine(Output, L);
105
 
106
         dwordOffset       := cWData/4;
107
         dwordCount        := 1;
108
         regData(0)        := d;
109
         WC_PeRegWrite(Cmd_Req,
110
                       Cmd_Ack,
111
                       device,
112
                       dwordOffset,
113
                       dwordCount,
114
                       regData);
115
 
116
         dwordOffset       := cSize/4;
117
         dwordCount        := 1;
118
         regData(0)        := 0;
119
         WC_PeRegWrite(Cmd_Req,
120
                       Cmd_Ack,
121
                       device,
122
                       dwordOffset,
123
                       dwordCount,
124
                       regData);
125
 
126
         dwordOffset       := cWAddr/4;
127
         dwordCount        := 1;
128
         regData(0)        := a;
129
         WC_PeRegWrite(Cmd_Req,
130
                       Cmd_Ack,
131
                       device,
132
                       dwordOffset,
133
                       dwordCount,
134
                       regData);
135
 
136
         ready := 0;
137
         while ready=0 loop
138
            dwordOffset       := cStat/4;
139
            dwordCount        := 1;
140
            WC_PeRegRead(Cmd_Req,
141
                         Cmd_Ack,
142
                         device,
143
                         dwordOffset,
144
                         dwordCount,
145
                         regData);
146
            ready := regData(0) mod 2;
147
         end loop;
148
      end procedure;
149
 
150
      procedure rcmd (a: in DWORD; d: out DWORD) is
151
      begin
152
         dwordOffset       := cSize/4;
153
         dwordCount        := 1;
154
         regData(0)        := 0;
155
         WC_PeRegWrite(Cmd_Req,
156
                       Cmd_Ack,
157
                       device,
158
                       dwordOffset,
159
                       dwordCount,
160
                       regData);
161
 
162
         dwordOffset       := cRAddr/4;
163
         dwordCount        := 1;
164
         regData(0)        := a;
165
         WC_PeRegWrite(Cmd_Req,
166
                       Cmd_Ack,
167
                       device,
168
                       dwordOffset,
169
                       dwordCount,
170
                       regData);
171
 
172
         ready := 0;
173
         while ready=0 loop
174
            dwordOffset       := cStat/4;
175
            dwordCount        := 1;
176
            WC_PeRegRead(Cmd_Req,
177
                         Cmd_Ack,
178
                         device,
179
                         dwordOffset,
180
                         dwordCount,
181
                         regData);
182
            ready := regData(0) mod 2;
183
         end loop;
184
 
185
         dwordOffset       := cRData/4;
186
         dwordCount        := 1;
187
         WC_PeRegRead(Cmd_Req,
188
                      Cmd_Ack,
189
                      device,
190
                      dwordOffset,
191
                      dwordCount,
192
                      regData);
193
         d :=  regData(0);
194
 
195
         Write(L, Now, Right, 15);
196
         Write(L, String'(" : Read:  addr = "));
197
         HWrite(L, Conv_Std_Logic_Vector(a, 32));
198
         Write(L, String'(" : data = "));
199
         HWrite(L, Conv_Std_Logic_Vector(regData(0), 32));
200
         WriteLine(Output, L);
201
      end procedure;
202
 
203
 
204
 
205
      procedure wcmd (a: in DWORD; d: in DWORD_array) is
206
      begin
207
         for i in 0 to d'Length-1 loop
208
            Write(L, Now, Right, 15);
209
            Write(L, String'(" : Write: addr = "));
210
            HWrite(L, Conv_Std_Logic_Vector(a+i*4, 32));
211
            Write(L, String'(" : data = "));
212
            HWrite(L, Conv_Std_Logic_Vector(d(i), 32));
213
            WriteLine(Output, L);
214
         end loop;
215
 
216
         dwordOffset       := cWData/4;
217
         dwordCount        := d'Length;
218
         regData(0 to d'length-1) := d;
219
         WC_PeRegWrite(Cmd_Req,
220
                       Cmd_Ack,
221
                       device,
222
                       dwordOffset,
223
                       dwordCount,
224
                       regData);
225
 
226
         dwordOffset       := cSize/4;
227
         dwordCount        := 1;
228
         regData(0)        := d'Length;
229
         WC_PeRegWrite(Cmd_Req,
230
                       Cmd_Ack,
231
                       device,
232
                       dwordOffset,
233
                       dwordCount,
234
                       regData);
235
 
236
         dwordOffset       := cWAddr/4;
237
         dwordCount        := 1;
238
         regData(0)        := a;
239
         WC_PeRegWrite(Cmd_Req,
240
                       Cmd_Ack,
241
                       device,
242
                       dwordOffset,
243
                       dwordCount,
244
                       regData);
245
 
246
         ready := 0;
247
         while ready=0 loop
248
            dwordOffset       := cStat/4;
249
            dwordCount        := 1;
250
            WC_PeRegRead(Cmd_Req,
251
                         Cmd_Ack,
252
                         device,
253
                         dwordOffset,
254
                         dwordCount,
255
                         regData);
256
            ready := regData(0) mod 2;
257
         end loop;
258
      end procedure;
259
 
260
      procedure rcmd (a: in DWORD; d: out DWORD_array) is
261
      begin
262
 
263
         dwordOffset       := cSize/4;
264
         dwordCount        := 1;
265
         regData(0)        := d'Length;
266
         WC_PeRegWrite(Cmd_Req,
267
                       Cmd_Ack,
268
                       device,
269
                       dwordOffset,
270
                       dwordCount,
271
                       regData);
272
 
273
 
274
         dwordOffset       := cRAddr/4;
275
         dwordCount        := 1;
276
         regData(0)        := a;
277
         WC_PeRegWrite(Cmd_Req,
278
                       Cmd_Ack,
279
                       device,
280
                       dwordOffset,
281
                       dwordCount,
282
                       regData);
283
 
284
         ready := 0;
285
 
286
         while ready=0 loop
287
            dwordOffset       := cStat/4;
288
            dwordCount        := 1;
289
            WC_PeRegRead(Cmd_Req,
290
                         Cmd_Ack,
291
                         device,
292
                         dwordOffset,
293
                         dwordCount,
294
                         regData);
295
            ready := regData(0) mod 2;
296
         end loop;
297
 
298
         dwordOffset       := cRData/4;
299
         dwordCount        := d'Length;
300
         WC_PeRegRead(Cmd_Req,
301
                      Cmd_Ack,
302
                      device,
303
                      dwordOffset,
304
                      dwordCount,
305
                      regData);
306
         d :=  regData(0 to d'Length-1);
307
         for i in 0 to d'Length-1 loop
308
            Write(L, Now, Right, 15);
309
            Write(L, String'(" : Read:  addr = "));
310
            HWrite(L, Conv_Std_Logic_Vector(a+i*4, 32));
311
            Write(L, String'(" : data = "));
312
            HWrite(L, Conv_Std_Logic_Vector(regData(i), 32));
313
            WriteLine(Output, L);
314
         end loop;
315
      end procedure;
316
 
317
      variable burst:   Integer := 0;
318
   begin
319
 
320
      --------------------------------------------------------------------------
321
      -- At first, deassert the command request signal
322
      --------------------------------------------------------------------------
323
      Cmd_Req        <= False;
324
 
325
      --------------------------------------------------------------------------
326
      -- We are using device 0
327
      --------------------------------------------------------------------------
328
      device         := 0;
329
 
330
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
331
      --
332
      -- Step 1: Initialize the simulated CardBus controller.
333
      --
334
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
335
 
336
      --------------------------------------------------------------------------
337
      -- Enable the K_Clk (CardBus/LAD-bus clock) to the device
338
      --------------------------------------------------------------------------
339
      enable         := True;
340
      Debug_Enable_K_Clk(Cmd_Req,
341
                         Cmd_Ack,
342
                         device,
343
                         enable);
344
 
345
      --------------------------------------------------------------------------
346
      --  Enable LAD bus bursts to/from the device
347
      --------------------------------------------------------------------------
348
      enable         := True;
349
      Debug_Enable_Burst(Cmd_Req,
350
                         Cmd_Ack,
351
                         device,
352
                         enable);
353
 
354
      --------------------------------------------------------------------------
355
      -- Set the length of read bursts from the device
356
      --------------------------------------------------------------------------
357
      burstLength    := 4;
358
      Debug_Set_Read_Burst_Length(Cmd_Req,
359
                                  Cmd_Ack,
360
                                  device,
361
                                  burstLength);
362
 
363
      --------------------------------------------------------------------------
364
      -- Set the length of write bursts from the device
365
      --------------------------------------------------------------------------
366
      burstLength    := 32;
367
      Debug_Set_Write_Burst_Length(Cmd_Req,
368
                                    Cmd_Ack,
369
                                    device,
370
                                    burstLength);
371
 
372
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
373
      --
374
      -- Step 2: Configure the memory clock and processing element clock.
375
      --
376
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
377
 
378
      --------------------------------------------------------------------------
379
      --  Set the F_Clk frequency (which will set the M_Clk and P_Clk
380
      --  frequencies to F_CLK and F_CLK/2, respectively)
381
      --------------------------------------------------------------------------
382
      fClkFreq       := 40.0;
383
      WC_ClkSetFrequency(Cmd_Req,
384
                         Cmd_Ack,
385
                         device,
386
                         fClkFreq);
387
 
388
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
389
      --
390
      -- Step 3: Reset the PE, clear any PE interrupts, and enable PE interrupts
391
      --
392
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
393
 
394
      --------------------------------------------------------------------------
395
      -- Set up the PE's interrupt and toggle the reset line
396
      --------------------------------------------------------------------------
397
      enable         := True;
398
      WC_PeReset(Cmd_Req,
399
                 Cmd_Ack,
400
                 device,
401
                 enable);
402
 
403
      WC_IntReset(Cmd_Req,
404
                   Cmd_Ack,
405
                   device);
406
 
407
      enable         := False;
408
      WC_IntEnable(Cmd_Req,
409
                   Cmd_Ack,
410
                   device,
411
                   enable);
412
      wait for 5 us;
413
 
414
      enable         := False;
415
      WC_PeReset(Cmd_Req,
416
                  Cmd_Ack,
417
                  device,
418
                  enable);
419
 
420
      wait for 20 us;
421
 
422
      report "======== PE is now reset and the clocks are running ========"
423
         severity Note;
424
 
425
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
426
      --
427
      --
428
      --
429
      --@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
430
      Write(L, String'(""));
431
      WriteLine(Output, L);
432
      WriteLine(Output, L);
433
 
434
 
435
      WriteLine(Output, L);
436
      Write(L, Now, Right, 15);
437
      Write(L, String'(" : Check burst capability."));
438
      WriteLine(Output, L);
439
      dwordOffset       := cVer/4;
440
      dwordCount        := 1;
441
      WC_PeRegRead(Cmd_Req,
442
                   Cmd_Ack,
443
                   device,
444
                   dwordOffset,
445
                   dwordCount,
446
                   regData);
447
 
448
      Write(L, Now, Right, 15);
449
      Write(L, String'(" : Read:  addr = "));
450
      HWrite(L, Conv_Std_Logic_Vector(cVer, 32));
451
      Write(L, String'(" : data = "));
452
      HWrite(L, Conv_Std_Logic_Vector(regData(0), 32));
453
      WriteLine(Output, L);
454
      burst := regData(0) / 16;
455
 
456
      for i in 0 to 255 loop dv(i) := i; end loop;
457
 
458
      if burst > 1 then
459
         WriteLine(Output, L);
460
         Write(L, Now, Right, 15);
461
         Write(L, String'(" : Test left memory, burst access."));
462
         WriteLine(Output, L);
463
 
464
         wcmd(cSSRAML, dv(0 to burst-1));
465
         rcmd(cSSRAML, cv(0 to burst-1));
466
 
467
         for i in 0 to burst-1 loop
468
            if cv(i) /= dv(i) then
469
               Write(L, Now, Right, 15);
470
               Write(L, String'(" : Error:  read = "));
471
               HWrite(L, Conv_Std_Logic_Vector(cv(i), 32));
472
               Write(L, String'(" : expected = "));
473
               HWrite(L, Conv_Std_Logic_Vector(dv(i), 32));
474
               WriteLine(Output, L);
475
            end if;
476
         end loop;
477
      end if;
478
 
479
      WriteLine(Output, L);
480
      Write(L, Now, Right, 15);
481
      Write(L, String'(" : Test on-chip memory, single access."));
482
      WriteLine(Output, L);
483
      wcmd(cAHBRam, 16#12345678#);
484
      rcmd(cAHBRam, data);
485
 
486
      WriteLine(Output, L);
487
      Write(L, Now, Right, 15);
488
      Write(L, String'(" : Test left memory, single burst."));
489
      WriteLine(Output, L);
490
      wcmd(cSSRAML, dv(255));
491
      rcmd(cSSRAML, cv(255));
492
 
493
      WriteLine(Output, L);
494
      Write(L, Now, Right, 15);
495
      Write(L, String'(" : Test left memory, single access."));
496
      WriteLine(Output, L);
497
      wcmd(cSSRAML, 16#abcd0001#);
498
      rcmd(cSSRAML, data);
499
 
500
      WriteLine(Output, L);
501
      Write(L, Now, Right, 15);
502
      Write(L, String'(" : Test right memory, single access."));
503
      WriteLine(Output, L);
504
      wcmd(cSSRAMR, 16#abcd0002#);
505
      rcmd(cSSRAMR, data);
506
 
507
      WriteLine(Output, L);
508
      WriteLine(Output, L);
509
      wait for 10 us;
510
      --------------------------------------------------------------------------
511
      -- End of the simulated host program
512
      --------------------------------------------------------------------------
513
      report "End of test"
514
         severity Failure;
515
 
516
      wait;
517
   end process Main;
518
end architecture Validate; --=================================================--

powered by: WebSVN 2.1.0

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