1 / 23

Co-modeling Seminar

Co-modeling Seminar. Co-modeling Seminar: Contents. The Routed Design What the design does System Hierarchy The Hardware The Bridge The DUT and Transactors The ClockAdvancer The Software The System Testbench Top Level, Interconnect of SystemC Models The sc_main() Function

osman
Download Presentation

Co-modeling Seminar

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Co-modeling Seminar CoModelSeminar.ppt - johnS

  2. Co-modeling Seminar: Contents • The Routed Design • What the design does • System Hierarchy • The Hardware • The Bridge • The DUT and Transactors • The ClockAdvancer • The Software • The System • Testbench Top Level, Interconnect of SystemC Models • The sc_main() Function • The Testbench • Abstract Ports, Autonomous Threads, Slave Threads • Master Control Loop • The Scheduler - Interfacing with message port proxies • The Calendar – Interfacing with the ClockAdvancer • The SceMiDispatcher – Servicing the SceMi • Error Handling CoModelSeminar.ppt - johnS

  3. What the design does • Small design that simulates passengers air traveling from Origin’s to Destination’s by traversing various interconnected Pipe’s and Hub’s in a RouteMap. • The "world" consists of these Origin’s, • Anchorage, Cupertino, Noida, SealBeach, UK, Waltham, and these Destination's, • Anchorage, Cupertino, Maui, SealBeach, UK. • Travel from any of the Origin’s to any of the Destination’s is possible by traversing the RouteMap containing the following Pipe interconnected Hub’s, • Chicago, Dallas, Newark, SanFran, Seattle. • The RouteMap is initialized by injecting TeachRoute transactions for the entire system through the WalthamOrigin. • Each hub is progressively taught its routes so that it may, in turn pass additional TeachRoute tokens to hubs more distant from Waltham. • This process continues until the entire mesh is initialized, at which point it is ready to accommodate travel. • After running the route configuration, the testbench then executes the itineraries of 4 passengers over a period of 22 days. • Each itinerary consists of several legs each with scheduled departure from a specified Origin and each with a specified Destination. CoModelSeminar.ppt - johnS

  4. What the design does (cont’d) – The RouteMap CoModelSeminar.ppt - johnS

  5. System Hierarchy • Testbench Hierarchy System Testbench Calendar <--> ClockAdvancer Scheduler <--> OrigDest, Origin, Destination RouteConfig SceMiDispatcher • VLE Hierarchy Vle Bridge SceMiClockPort OrigDest anchorage, cupertino, sealBeach, UK Origin SceMiMessageInPort, SceMiClockControl Destination SceMiMessageOutPort, SceMiClockControl Origin noida, waltham Destination maui RouteMap Hub chicagoHub, dallasHub, newarkHub, sanFranHub, seattleHub Funnel Nozzle RouteTable Pipe* ClockAdvancer SceMiMessageInPort, SceMiMessageOutPort, SceMiClockControl • The OrigDest, Origin, and Destination modules are the transactors. • The RouteMap is the DUT. CoModelSeminar.ppt - johnS

  6. The Hardware: The Bridge CoModelSeminar.ppt - johnS

  7. The DUT and Transactors - Connections CoModelSeminar.ppt - johnS

  8. The DUT and Transactors - Components CoModelSeminar.ppt - johnS

  9. module Destination ( TokenIn ); input [31:0] TokenIn; // { wire [3:0] destID; reg [31:0] message; reg transmitReady, readyForCclock; assign destID = TokenIn[7:4]; SceMiMessageOutPort #32 messageOutPort( //Input Output //------------------------- --------------------------- .TransmitReady(transmitReady), .ReceiveReady(receiveReady), .Message(message) ); SceMiClockControl clockControl( //Input Output //------------------------- --------------------------- .Uclock(uclock), .Ureset(ureset), .ReadyForCclock(readyForCclock), .CclockEnabled(cclockEnabled) ) always@( posedge uclock ) begin // { if( ureset == 1 ) begin readyForCclock <= 1; message <= 0; transmitReady <= 0; end else begin // { // if( DUT clock has been disabled ) // It means that this destination transactor is waiting to // unload its pending token and does not want to re-enable the // DUT until that token has been off-loaded or else it might // lose arriving tokens in subsequent DUT clocks. if( readyForCclock == 0 ) begin // When the MessageOutPort portal finally signals acceptance // of the token, we can re-enable the DUT clock. if( receiveReady ) begin readyForCclock <= 1; transmitReady <= 0; end end else if( cclockEnabled && destID != 0 ) begin message <= TokenIn; transmitReady <= 1; // if( token arrives but portal is not ready ) // Stop the assembly line ! (a.k.a. disable the DUT) if( receiveReady == 0 readyForCclock <= 0; end end // } end // } endmodule // } The DUT and Transactors – Transactor Interface and Implementation CoModelSeminar.ppt - johnS

  10. The ClockAdvancer • Used for tight control of DUT clock advance. • Standalone transactor – no interface to DUT. • Used in Routed design to, • advance a 1 clock between each TeachRoute message, • advance 1 or more days at a time (1 day = 24 clocks) during travel simulation. • Our 1st General purpose, reusable transactor – now distributed with the release. CoModelSeminar.ppt - johnS

  11. The System – Testbench Top Level CoModelSeminar.ppt - johnS

  12. #include <systemc.h> #include <SceMi00.hxx> sc_clock UTick; #include "Routed.hxx" #include "Testbench.hxx" #include "Calendar.hxx" #include "Scheduler.hxx" #include "RouteConfig.hxx" #include "SceMiDispatcher.hxx" SC_MODULE( System ){ sc_link_mp<unsigned> newDay; sc_link_mp<const Routed::ArrivalRecord *> announceArrival; sc_link_mp<unsigned> advanceCalendar; sc_link_mp<const Routed::Itinerary *> scheduleLeg; sc_link_mp<> loadRouteMap; sc_link_mp<> done; sc_link_mp<> advanceClock; sc_link_mp<Routed::Date> todaysDate; sc_link_mp<const Routed::Route *> loadRoute; //------------------------------------------------------- // Module declarations Testbench *testbench; Calendar *calendar; Scheduler *scheduler; RouteConfig *routeConfig; SceMiDispatcher *dispatcher; SC_CTOR( System ){ … } }; SC_CTOR( System ){ testbench = new Testbench( "testbench" ); testbench->NewDay( newDay ); testbench->AnnounceArrival( announceArrival ); testbench->AdvanceCalendar( advanceCalendar ); testbench->ScheduleLeg( scheduleLeg ); testbench->LoadRouteMap( loadRouteMap ); testbench->Done( done ); calendar = new Calendar( "calendar" ); calendar->AdvanceCalendar( advanceCalendar ); calendar->AdvanceClock( advanceClock ); calendar->NewDay( newDay ); calendar->TodaysDate( todaysDate ); scheduler = new Scheduler( "scheduler" ); scheduler->TodaysDate( todaysDate ); scheduler->ScheduleLeg( scheduleLeg ); scheduler->LoadRoute( loadRoute ); scheduler->AnnounceArrival( announceArrival ); routeConfig = new RouteConfig( "routeConfig" ); routeConfig->LoadRouteMap( loadRouteMap ); routeConfig->LoadRoute( loadRoute ); routeConfig->AdvanceClock( advanceClock ); dispatcher = new SceMiDispatcher( "dispatcher" ); dispatcher->Done( done ); } }; The System – Testbench Top Level, Interconnect of SystemC Models CoModelSeminar.ppt - johnS

  13. The System – The sc_main() Function int sc_main( int argc, char *argv[] ){ SceMi00::RegisterErrorHandler( errorHandler, NULL ); SceMi00 *mSceMi = NULL; try { SceMiInitParms00 parameters( "./params.mSceMi" ); mSceMi = SceMi00::Init( 1, &parameters ); //--------------------------------------------------------- // Instantiate the system here. Autonomous threads nested // inside the DispatcherDriver and the Testbench will advance // untimed activity. Such threads are senstitive to UTick defined // at the top of this file. // -- johnS 8-29-00 System system( "system" ); //--------------------------------------------------------- // Establish proper bindings between the SceMi and the modules // modules that directly interact with it. system.dispatcher->Bind( mSceMi ); system.calendar-> Bind( mSceMi ); system.scheduler-> Bind( mSceMi ); //------------------------------------------------- // Kick off SystemC kernel ... cerr << "Let 'er rip !" << endl; sc_start(-1); } catch( string message ) { … return -1; } catch(...) { … return -1; } return 0; } CoModelSeminar.ppt - johnS

  14. The Testbench - Abstract Ports, Autonomous Threads, Slave Threads SC_MODULE( Testbench ){ // Abstract port declarations sc_master<> LoadRouteMap; sc_master<> Done; sc_outmaster<unsigned> AdvanceCalendar; sc_inslave<unsigned> NewDay; sc_outmaster<const Routed::Itinerary *> ScheduleLeg; sc_inslave<const Routed::ArrivalRecord *> AnnounceArrival; private: // Context declarations unsigned dNumMauiArrivals; unsigned dDayNum; const Routed::Itinerary *dItineraries[Routed::NumPassengers]; private: // Thread declarations void driverThread(); // Autonomous "master" thread. void newDayThread() { dDayNum = NewDay; } void announceArrivalThread(); public: SC_CTOR( Testbench ) : dNumMauiArrivals(0), dDayNum(0) { SC_THREAD( driverThread ); sensitive << UTick; SC_SLAVE( newDayThread, NewDay ); SC_SLAVE( announceArrivalThread, AnnounceArrival ); // Initialize itinerary pointers. dItineraries[0] = Routed::BugsesTrip; dItineraries[1] = Routed::DaffysTrip; dItineraries[2] = Routed::ElmersTrip; dItineraries[3] = Routed::SylvestersTrip; } }; CoModelSeminar.ppt - johnS

  15. The Testbench - Master Control Loop void Testbench::driverThread(){ LoadRouteMap(); unsigned dayNum = dDayNum; AdvanceCalendar = 1; // Advance to day 1. for(;;){ wait(); // Wait for day to advance (i.e. 'NewDay' arrives. if( dayNum != dDayNum ){ unsigned date, minDate = 1000; // Check itineraries to see if any passengers are // traveling today. If so, advance calendar to tomorrow // in case next leg of itinerary is tomorrow. for( int i=0; i<Routed::NumPassengers; i++ ){ if( (date=dItineraries[i]->DateOfTravel) ){ if( date == dDayNum ){ cout << "On day " << setw(2) << dDayNum << " at " << setw(2) << dItineraries[i]->TimeOfDeparture << ":00 hrs, " << passengerNames[dItineraries[i]->PassengerID] << " departs " << locationNames[dItineraries[i]->OriginID] << " enroute to " << locationNames[dItineraries[i]->DestinationID] << endl; ScheduleLeg = dItineraries[i]++; minDate = dDayNum+1; } else if( date < minDate ) minDate = date; } } dayNum = dDayNum; AdvanceCalendar = minDate - dDayNum; } } } CoModelSeminar.ppt - johnS

  16. The Scheduler– Interfacing with message port proxies – Binding Ports void Scheduler::Bind( SceMi00 *mSceMi ){ // Establish message input portals. dOriginAnchorage = mSceMi->BindMessageInputPort( "anchorage", "TokenIn" ); dOriginCupertino = mSceMi->BindMessageInputPort( "cupertino", "TokenIn" ); dOriginNoida = mSceMi->BindMessageInputPort( "noida", "TokenIn" ); dOriginSealBeach = mSceMi->BindMessageInputPort( "sealBeach", "TokenIn" ); dOriginUK = mSceMi->BindMessageInputPort( "uk", "TokenIn" ); dOriginWaltham = mSceMi->BindMessageInputPort( "waltham", "TokenIn" ); // Establish message output portals. MessageOutputPortBinding binding = { this, replyCallback, NULL }; dDestinationAnchorage = mSceMi->BindMessageOutputPort( "anchorage", "TokenOut", &binding ); dDestinationCupertino = mSceMi->BindMessageOutputPort( "cupertino", "TokenOut", &binding ); dDestinationMaui = mSceMi->BindMessageOutputPort( "maui", "TokenOut", &binding ); dDestinationSealBeach = mSceMi->BindMessageOutputPort( "sealBeach", "TokenOut", &binding ); dDestinationUK = mSceMi->BindMessageOutputPort( "uk", "TokenOut", &binding ); } CoModelSeminar.ppt - johnS

  17. The Scheduler– Interfacing with message port proxies – Sending Messages void Scheduler::scheduleLegThread(){ const Routed::Itinerary *leg = ScheduleLeg; // Read inslave port. // Form a 'Passenger Departure' token based on the contents of the given // 'Itinerary' record. SceMiU32 passengerDepartureToken = leg->PassengerID | (leg->DestinationID << 4) | (leg->OriginID << 12) | (leg->TimeOfDeparture << 16); dSendData.Set( 0, passengerDepartureToken ); switch( leg->OriginID ){ case Routed::Anchorage: dOriginAnchorage->Send( dSendData ); break; case Routed::Cupertino: dOriginCupertino->Send( dSendData ); break; case Routed::Noida: dOriginNoida ->Send( dSendData ); break; case Routed::SealBeach: dOriginSealBeach->Send( dSendData ); break; case Routed::UK: dOriginUK ->Send( dSendData ); break; case Routed::Waltham: dOriginWaltham ->Send( dSendData ); break; default: assert(0); } } void Scheduler::loadRouteThread(){ const Routed::Route *route = LoadRoute; // Form a 'TeachRoute' token based on the contents of the given // 'Route' record. SceMiU32 addRouteToken = (route->RouterID << 4) | (route->DestinationID << 8) | (route->PortID <<12); dSendData.Set( 0, addRouteToken ); dOriginWaltham->Send( dSendData ); } CoModelSeminar.ppt - johnS

  18. The Scheduler–Interfacing with message port proxies –Receiving Messages void Scheduler::replyCallback( void *context, const MessageData &data ){ ((Scheduler *)context)->announceArrival( data.CycleStamp(), data.Get(0) ); } void Scheduler::announceArrival( SceMiU64 cycleStamp, SceMiU32 arrivalToken ){ Routed::Date todaysDate = dSystem->TodaysDate(); dArrivalRecord.DateOfArrival = todaysDate.Day; dArrivalRecord.TimeOfArrival = cycleStamp - todaysDate.CycleStamp; dArrivalRecord.PassengerID = (Routed::PassengerIDs)( arrivalToken & 0xf ); dArrivalRecord.DestinationID = (Routed::LocationIDs) ( (arrivalToken >> 4) & 0xf ); dArrivalRecord.OriginID = (Routed::LocationIDs) ( (arrivalToken >> 12) & 0xf ); dArrivalRecord.LayoverCount = (arrivalToken >> 8) & 0xf ; assert( dArrivalRecord.LayoverCount < 5 ); arrivalToken >>= 16; for( unsigned i=0; i<dArrivalRecord.LayoverCount; i++ ){ dArrivalRecord.LayoverIDs[i] = (Routed::LocationIDs)( arrivalToken & 0xf ); arrivalToken >>= 4; } AnnounceArrival = &dArrivalRecord; } CoModelSeminar.ppt - johnS

  19. The Calendar– Interfacing with the ClockAdvancer void Calendar::advanceCalendarThread(){ unsigned numberOfDaysToAdvance = AdvanceCalendar; // In hardware, 1 clock corresponds to 1 hr of travel. // So, we multiply the number of days to advance by 24. dSendData.Set( 2, 24 * numberOfDaysToAdvance ); dInputPort->Send( dSendData ); // Pend until the cycle stamp gets updated by the port // proxy reply callback. SceMiU64 currentCycleStamp = dCycleStamp; while( dCycleStamp == currentCycleStamp ) dSceMi->ServiceLoop(); dTodaysDate += numberOfDaysToAdvance; SceMiU64 delta = dCycleStamp - currentCycleStamp; // After the first update, delta better be an integer multiple of 24 // or something is wrong ! assert( (dTodaysDate > 1) ? (delta/24) * 24 == delta : 1 ); NewDay = dTodaysDate; } void Calendar::advanceClockThread(){ dSendData.Set( 2, 1 ); dInputPort->Send( dSendData ); // Pend until the cycle stamp gets updated by the port // proxy reply callback. SceMiU64 currentCycleStamp = dCycleStamp; while( dCycleStamp == currentCycleStamp ) wait(); } void Calendar::replyCallback( void *context, const MessageData &data ){ ((Calendar *)context)->dCycleStamp = data.CycleStamp(); } CoModelSeminar.ppt - johnS

  20. The SceMiDispatcher – Servicing the SceMi SC_MODULE( SceMiDispatcher ){ sc_slave<> Done; void dispatchThread(); // Autonomous SceMi dispatcher thread void doneThread(); private: SceMi00 *dSceMi; public: void Bind( SceMi00 *mSceMi ){ dSceMi = mSceMi; }; SC_CTOR( SceMiDispatcher ){ //-------------------------------------- // Thread bindings SC_THREAD( dispatchThread ); sensitive << UTick; SC_SLAVE( doneThread, Done ); } }; void SceMiDispatcher::dispatchThread() { // This is all the dispatcher does !! Deceptively simple, eh ? // It just calls the SceMi dispatcher poll function and returns. for(;;){ wait(); dSceMi->ServiceLoop(); } } void SceMiDispatcher::doneThread() { delete dSceMi; exit(0); } CoModelSeminar.ppt - johnS

  21. Error Handling • SceMi error handling is designed to be simple and flexible, set up to minimize the menial details of error status checking and message processing. • “Conventional” error handling can be done by creating an SceMiEC object, passing it to each call, then checking its status on function return. • Alternatively, in the interest of code cleanliness, an error handler can be defined that gets called by by the erroneous SceMi function when an error occurs. To use it in this mode this case, no SceMiEC argument needs to be passed to each function call (defaults to NULL). • When an error occurs in a function that is passed no SceMiEC, if a user defined error handler exists, it is called, otherwise a default error handler is called. • The SceMiEC struct contains an error type, a detailed UMS compliant message, and an additional string called the ‘culprit’ which identifies the erroneous function by name. • The application can use all this information to process the message it its own way. • Distinct error types are kept to a minimum – only major categories. All detailed info is built into the message itself which is UMS compliant. • C++ exceptions are not deployed inside the SceMi code, however, the nice thing about the way error handlers can be defined is that exceptions can be thrown from the handler. This is what is done in the Routed design. CoModelSeminar.ppt - johnS

  22. Error Handling – In Routed Design int sc_main( int argc, char *argv[] ){ SceMi00::RegisterErrorHandler( errorHandler, NULL ); SceMi00 *mSceMi = NULL; try { … } catch( string message ) { cerr << message << endl; cerr << "Fatal Error: Program aborting." << endl; if( mSceMi ) delete mSceMi; return -1; } catch(...) { cerr << "Error: Unclassified exception." << endl; cerr << "Fatal Error: Program aborting." << endl; if( mSceMi ) delete mSceMi; return -1; } return 0; } static void errorHandler( void */*context*/, SceMiEC *ec ) { char buf[32]; sprintf( buf, "%d", (int)ec->Type ); string messageText( "SceMi Error[" ); messageText += buf; messageText += "]: Function: "; messageText += ec->Culprit; messageText += "\n"; messageText += ec->Message; throw messageText; } CoModelSeminar.ppt - johnS

  23. Contents of SCE-MI Example SceMi/ README VERSION include/ SceMi.hxx - Main SceMi include file. SceMiParameters.hxx - SceMi initialization parameters object. SceMiMessagePortProxy.hxx - MessagePortProxy interfaces. SceMiMessageData.hxx - MessageData header SceMiTypes.hxx - Misc SceMi support types, error handling types.   src/ params.SceMi - Sample template file for user specified parameters file that is used to construct SceMiParameters object. ChannelParameters.v - Sample template file used to specify channel dimensions. This file must be provided by the user as it is included by the Bridge netlists. lib/solaris_gnu/ libSceMi.a - SceMi main library. hdl/ ClockAdvancer.v - Reusable ClockAdvancer transactor implementation. Buffer.v - Reusable buffer component for insertion between message ports and transactors. CoModelSeminar.ppt - johnS

More Related