diff modules/bluespec/Pygar/lab4/ProcessorSystem.cpp @ 8:74716e9a81cc pygar svn.9

[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author rlm
date Fri, 23 Apr 2010 02:32:05 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/bluespec/Pygar/lab4/ProcessorSystem.cpp	Fri Apr 23 02:32:05 2010 -0400
     1.3 @@ -0,0 +1,69 @@
     1.4 +#include <stdio.h>
     1.5 +#include <pthread.h>
     1.6 +#include <semaphore.h>
     1.7 +
     1.8 +#include "asim/provides/connected_application.h"
     1.9 +#include "asim/provides/stats_device.h"
    1.10 +
    1.11 +
    1.12 +using namespace std;
    1.13 +
    1.14 +// constructor
    1.15 +CONNECTED_APPLICATION_CLASS::CONNECTED_APPLICATION_CLASS(VIRTUAL_PLATFORM vp) :
    1.16 +  clientStub(new PROCESSORSYSTEMRRR_CLIENT_STUB_CLASS(this))
    1.17 +{
    1.18 +  
    1.19 +}
    1.20 +
    1.21 +// destructor
    1.22 +CONNECTED_APPLICATION_CLASS::~CONNECTED_APPLICATION_CLASS()
    1.23 +{
    1.24 +}
    1.25 +
    1.26 +// init
    1.27 +void
    1.28 +CONNECTED_APPLICATION_CLASS::Init()
    1.29 +{
    1.30 +
    1.31 +  // enable stats 
    1.32 +  STATS_DEVICE_SERVER_CLASS::GetInstance()->SetupStats();
    1.33 +
    1.34 +}
    1.35 +
    1.36 +
    1.37 +// main
    1.38 +void
    1.39 +CONNECTED_APPLICATION_CLASS::Main()
    1.40 +{
    1.41 +  int sleepCount = 0;
    1.42 +  int result = 0;
    1.43 +
    1.44 +  fflush(stdout); 
    1.45 +
    1.46 +  while ((result = clientStub->ReadCPUToHost(0)) != 1) {
    1.47 +    sleep(1);
    1.48 +    //printf("System controller sleeps with result: %d\n", result);
    1.49 +    sleepCount++;
    1.50 +    if(sleepCount == 100) {
    1.51 +      printf("Failed to get response from hardware, bailing\n\n");
    1.52 +      printf("This means that either your hardware is hanging\n");
    1.53 +      printf("or that the software hasn't given it enough time\n");
    1.54 +      printf("to complete.  If you think it needs more time, then\n");
    1.55 +      printf("edit CONNECTED_APPLICATION_CLASS::Main() in ProcessorSystem.cpp\n");
    1.56 +      printf("(connected_application)\n");
    1.57 +      exit(0);
    1.58 +    }
    1.59 +  }
    1.60 + 
    1.61 +  if(result == 1) {
    1.62 +    printf("\n***PASSED***\n");
    1.63 +  }
    1.64 +
    1.65 +  // Dump the stats file
    1.66 +
    1.67 +  STATS_DEVICE_SERVER_CLASS::GetInstance()->DumpStats();
    1.68 +  STATS_DEVICE_SERVER_CLASS::GetInstance()->EmitFile();
    1.69 +
    1.70 +  fflush(stdout); 
    1.71 +  exit(0);
    1.72 +}