Skip to content

Commit 8eda22e

Browse files
authored
Add files via upload
1 parent 205221b commit 8eda22e

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

hello_world.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "systemc.h"
2+
#include <iostream>
3+
SC_MODULE(simple_process_ex) {
4+
sc_time t;
5+
void my_thread_process(void);
6+
SC_CTOR(simple_process_ex) {
7+
t = sc_time(10, SC_NS);
8+
//SC_THREAD(my_thread_process);
9+
}
10+
};
11+
void simple_process_ex::my_thread_process(void) {
12+
std::cout << "MY THREAD EXECUTED\n"<<name()<<std::endl;
13+
}
14+
int sc_main(int i, char* c[]) {
15+
std::cout << sc_time_stamp()<<std::endl;
16+
sc_simulation_time(10,SC_SEC);
17+
std::cout << sc_time_stamp() << std::endl;
18+
simple_process_ex obj("igh");
19+
sc_start(10,SC_SEC);
20+
return 0;
21+
}

turn_of_events.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <iostream>
2+
#include "systemc.h"
3+
SC_MODULE(turn_of_events) {
4+
// Constructor
5+
SC_CTOR(turn_of_events) {
6+
SC_THREAD(turn_knob_thread);
7+
SC_THREAD(stop_signal_thread);
8+
}
9+
sc_event signal_stop, signals_off;
10+
sc_event stop_indicator_on, stop_indicator_off;
11+
void turn_knob_thread(); // stimulus process
12+
void stop_signal_thread(); // indicator process
13+
};//endclass turn_of_events
14+
void turn_of_events::turn_knob_thread() {
15+
// This process provides stimulus using stdin
16+
enum directions {STOP='S', OFF='F'};
17+
char direction; // Selects appropriate indicator
18+
bool did_stop = false;
19+
// allow other threads to get into waiting state
20+
wait(SC_ZERO_TIME);
21+
for(;;) {
22+
// Sit in an infinite loop awaiting keyboard
23+
// or STDIN input to drive the stimulus…
24+
std::cout << "Signal command: ";
25+
std::cin >> direction;
26+
switch (direction) {
27+
case STOP:
28+
// Make sure the other signals are off
29+
signals_off.notify();
30+
signal_stop.notify(); // Turn stop light on
31+
// Wait for acknowledgement of indicator
32+
wait(stop_indicator_on);
33+
did_stop = true;
34+
break;
35+
case OFF:
36+
// Make the other signals are off
37+
signals_off.notify() ;
38+
if (did_stop) wait(stop_indicator_off) ;
39+
did_stop = false;
40+
break;
41+
}//endswitch
42+
}//endforever
43+
}//end turn_knob_thread()
44+
int sc_main(int i,char* c[]){
45+
turn_of_events obj("2");
46+
sc_start();
47+
return 0;
48+
}

0 commit comments

Comments
 (0)