| Last change
                  on this file since 54 was
                  41,
                  checked in by buchmann, 16 years ago | 
        
          | 
Add:
 openmp support:
add flags to test_regression makefile
configure.ac now checks for openmp
Makefile.am add openmp flags
a new testbench to check benefits due to openmp
 | 
        | File size:
            1.2 KB | 
      
      
        
  | Line |  | 
|---|
| 1 | #include <systemc.h> | 
|---|
| 2 | #include <signal.h> | 
|---|
| 3 |  | 
|---|
| 4 | using namespace std; | 
|---|
| 5 |  | 
|---|
| 6 | struct A : sc_module { | 
|---|
| 7 | sc_in_clk                       clk; | 
|---|
| 8 | sc_in     <int>                 i1; | 
|---|
| 9 | sc_signal <int>                 r1; | 
|---|
| 10 | sc_out    <int>                 o1; | 
|---|
| 11 |  | 
|---|
| 12 | void transition () { | 
|---|
| 13 | int i; | 
|---|
| 14 | for (i = 0; i < 1000; ++i) | 
|---|
| 15 | ; | 
|---|
| 16 | r1 = i1; | 
|---|
| 17 | } | 
|---|
| 18 | void gen_moore () { | 
|---|
| 19 | int i; | 
|---|
| 20 | for (i = 0; i < 1000; ++i) | 
|---|
| 21 | ; | 
|---|
| 22 | o1 = r1; | 
|---|
| 23 | } | 
|---|
| 24 |  | 
|---|
| 25 | SC_CTOR (A) : clk ("clk"), o1("o1") { | 
|---|
| 26 | SC_METHOD(transition); | 
|---|
| 27 | sensitive << clk.pos(); | 
|---|
| 28 | SC_METHOD(gen_moore); | 
|---|
| 29 | sensitive << clk.neg(); | 
|---|
| 30 | }; | 
|---|
| 31 | }; | 
|---|
| 32 |  | 
|---|
| 33 | int sc_main (int argc, char *argv[]) | 
|---|
| 34 | { | 
|---|
| 35 | sc_clock                     signal_clk("my_clock",1, 0.5); | 
|---|
| 36 | sc_signal<int>               s1("s1"),s2("s2"),s3("s3"),s4("s4"); | 
|---|
| 37 |  | 
|---|
| 38 | A      a("a"); | 
|---|
| 39 | A      b("b"); | 
|---|
| 40 |  | 
|---|
| 41 | a.clk         (signal_clk); | 
|---|
| 42 | b.clk         (signal_clk); | 
|---|
| 43 |  | 
|---|
| 44 | a.i1          (s1); | 
|---|
| 45 | a.o1          (s2); | 
|---|
| 46 |  | 
|---|
| 47 | b.i1          (s3); | 
|---|
| 48 | b.o1          (s4); | 
|---|
| 49 |  | 
|---|
| 50 | // Init & run | 
|---|
| 51 | sc_initialize (); | 
|---|
| 52 |  | 
|---|
| 53 | if (argc == 1) | 
|---|
| 54 | { | 
|---|
| 55 | cout << "Usage :\n" << argv[0] << " [#cycles]\n"; | 
|---|
| 56 | return EXIT_SUCCESS; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | s1.write (1); | 
|---|
| 60 |  | 
|---|
| 61 | sc_start (atoi(argv[1])); | 
|---|
| 62 |  | 
|---|
| 63 | cout << s1.read() << endl; | 
|---|
| 64 | cout << s2.read() << endl; | 
|---|
| 65 |  | 
|---|
| 66 | return EXIT_SUCCESS; | 
|---|
| 67 | } | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.