annotate modules/bluespec/Pygar/lab4/ProcessorSystem.cpp @ 71:86360c5ae9f2 pygar svn.72

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