kshalle@26: /* kshalle@26: * Copyright 2011 OpenSourceResearchInstitute.org kshalle@26: * Licensed under BSD kshalle@26: * kshalle@26: * author seanhalle@yahoo.com kshalle@26: */ kshalle@26: kshalle@26: #include kshalle@26: #include kshalle@26: kshalle@26: #include "SimParams.h" kshalle@26: #include "HWSim__PingPong__HWDef/HWSim__PingPong__HWDef.h" kshalle@26: #include "ParamHelper/Param.h" kshalle@26: kshalle@26: #include "HWSim_impl/HWSim_tests.h" kshalle@26: kshalle@26: kshalle@26: kshalle@27: /*This Hello World sample code demonstrates the bare structure of an HWSim kshalle@27: * based simulator. kshalle@27: *The application code creates a netlist, which is populated with element kshalle@27: * structures and activity structures. kshalle@27: *The elements register activities, which represent triggered behaviors. kshalle@27: * During a run, the arrival of a communication on the inport of an kshalle@27: * element triggers the registered activity, which in turn calls the kshalle@27: * activity's behavior function and its time-width calculation function. kshalle@27: *The behavior function can access and modify the state of the element, kshalle@27: * and it can send out communications on the elements outports. kshalle@27: *When a communication is sent, a separate function is called to calculate kshalle@27: * the time of flight of that communication. kshalle@26: * kshalle@27: *Commands of the HWSim langlet are invoked by calling a function. Such kshalle@27: * functions have a name that begins with "HWSim__" for example, kshalle@27: * "HWSim__run_simulation" is a command to tell HWSim to perform a kshalle@27: * simulation run. kshalle@27: * kshalle@27: *Data structures that are defined by the HWSim langlet have names that kshalle@27: * begin with "HWSim", for example "HWSimNetlist" is a data structure kshalle@27: * defined by the HWSim langlet. kshalle@26: */ kshalle@26: kshalle@26: int main(int argc, char **argv) kshalle@26: { kshalle@26: ParamBag *simParams; kshalle@26: HWSimNetlist *netlist; kshalle@26: HWSimResults *simResults; kshalle@26: int result; kshalle@26: kshalle@26: //Use a helper called ParamBag to read in paramters from file kshalle@26: simParams = makeParamBag(); kshalle@26: readParamFileIntoBag( argv[1], simParams ); kshalle@26: kshalle@26: //Create the simulated objects and connect them to each other kshalle@26: netlist = createPingPongNetlist(); //defined in CircuitNetlistCreator.c kshalle@26: kshalle@26: simResults = HWSim__run_simulation( simParams, netlist ); kshalle@26: kshalle@26: exit(0); //cleans up kshalle@26: } kshalle@26: