//================================================= file = process_csim.c ===== //= A program to demonstate CSIM processes = //============================================================================= //= Notes: 1) Program does nothing "useful" other than demonstrate how = //= processes are independent and how hold() makes time go by = //=---------------------------------------------------------------------------= //= Build: standard CSIM build = //=---------------------------------------------------------------------------= //= Execute: process_csim = //=---------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=---------------------------------------------------------------------------= //= History: KJC (06/24/13) - Genesis = //============================================================================= //----- Includes -------------------------------------------------------------- #include // Needed for printf() #include "csim.h" // Needed for CSIM stuff //----- Prototypes ------------------------------------------------------------ void process1(void); // Process #1 void process2(void); // Process #2 //============================================================================= //== Main program == //============================================================================= void sim(void) { // Create the main simulation process create("sim"); // Output begin message and time printf("Begin at time = %f \n", clock); // Kick-off two independent processes with a hold between kick-offs process1(); hold(1.0); process2(); // Hold and then end hold(100.0); printf("End at time = %f \n", clock); } //============================================================================= //== CSIM process #1 == //============================================================================= void process1() { int i; // Loop counter // Create the process create("process1"); // Loop 10 times holding between each iteration for (i=0; i<10; i++) { printf("Hello from process #1 at time = %f \n", clock); hold(1.0); } } //============================================================================= //== CSIM process #2 == //============================================================================= void process2() { int i; // Loop counter // Create the process create("process2"); // Loop 10 times holding between each iteration for (i=0; i<10; i++) { printf("Hello from process #2 at time = %f \n", clock); hold(1.5); } }