view modules/bluespec/Pygar/lab4/ProcessorSystem.cpp @ 13:6d461680c6d9 pygar svn.14

[svn r14] more stuff
author punk
date Tue, 27 Apr 2010 09:03:28 -0400
parents 74716e9a81cc
children
line wrap: on
line source
1 #include <stdio.h>
2 #include <pthread.h>
3 #include <semaphore.h>
5 #include "asim/provides/connected_application.h"
6 #include "asim/provides/stats_device.h"
9 using namespace std;
11 // constructor
12 CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) :
13 clientStub(new PROCESSORSYSTEMRRR_CLIENT_STUB_CLASS(this))
14 {
16 }
18 // destructor
19 CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS()
20 {
21 }
23 // init
24 void
25 CONNECTED_APPLICATION_CLASS::Init()
26 {
28 // enable stats
29 STATS_DEVICE_SERVER_CLASS::GetInstance()->SetupStats();
31 }
34 // main
35 void
36 CONNECTED_APPLICATION_CLASS::Main()
37 {
38 int sleepCount = 0;
39 int result = 0;
41 fflush(stdout);
43 while ((result = clientStub->ReadCPUToHost(0)) != 1) {
44 sleep(1);
45 //printf("System controller sleeps with result: %d\n", result);
46 sleepCount++;
47 if(sleepCount == 100) {
48 printf("Failed to get response from hardware, bailing\n\n");
49 printf("This means that either your hardware is hanging\n");
50 printf("or that the software hasn't given it enough time\n");
51 printf("to complete. If you think it needs more time, then\n");
52 printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
53 printf("(connected_application)\n");
54 exit(0);
55 }
56 }
58 if(result == 1) {
59 printf("\n***PASSED***\n");
60 }
62 // Dump the stats file
64 STATS_DEVICE_SERVER_CLASS::GetInstance()->DumpStats();
65 STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile();
67 fflush(stdout);
68 exit(0);
69 }