diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/misc/user_guide | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz |
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6
Reviewed-on: https://gem5-review.googlesource.com/10845
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/misc/user_guide')
222 files changed, 14053 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/golden/test1.log b/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/golden/test1.log new file mode 100644 index 000000000..0dd89eb5e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/golden/test1.log @@ -0,0 +1,19 @@ +SystemC Simulation +Value sent = 10 Value read = 129 +Value sent = 129 Value read = 10 +Value sent = 11 Value read = 130 +Value sent = 130 Value read = 11 +Value sent = 12 Value read = 131 +Value sent = 131 Value read = 12 +Value sent = 13 Value read = 132 +Value sent = 132 Value read = 13 +Value sent = 14 Value read = 133 +Value sent = 133 Value read = 14 +Value sent = 15 Value read = 134 +Value sent = 134 Value read = 15 +Value sent = 16 Value read = 135 +Value sent = 135 Value read = 16 +Value sent = 17 Value read = 136 +Value sent = 136 Value read = 17 +Value sent = 18 Value read = 137 +Value sent = 137 Value read = 18 diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/test1.cpp b/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/test1.cpp new file mode 100644 index 000000000..5667d470c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test1/test1.cpp @@ -0,0 +1,111 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "systemc.h" + +SC_MODULE( p1 ) +{ + SC_HAS_PROCESS( p1 ); + + sc_fifo<int>& a; + sc_fifo<int>& b; + sc_signal<bool>& clock; + + int init; + + p1(sc_module_name name, + sc_fifo<int>& A, + sc_fifo<int>& B, + sc_signal<bool>& CLOCK, + int INIT) + : a(A), b(B), clock(CLOCK) + { + init = INIT; + SC_THREAD( entry ); + sensitive << clock; + // sensitive << b; + } + + void entry() { + wait(); + int i = init; + wait(); + while (true) { + a.write(i); + int j = b.read(); + cout << "Value sent = " << i << " Value read = " << j << endl; + wait(); i++; + } + } +}; + +int sc_main(int ac, char *av[]) +{ + sc_fifo<int> a(2), b(2); + sc_signal<bool> clock; + + p1 Proc1("Proc1", a, b, clock, 10); + p1 Proc2("Proc2", b, a, clock, 129); + + sc_start(0, SC_NS); + clock = 1; + sc_start(1, SC_NS); + clock = 0; + sc_start(1, SC_NS); + + clock = 1; + sc_start(1, SC_NS); + clock = 0; + sc_start(1, SC_NS); + + clock = 1; + sc_start(1, SC_NS); + clock = 0; + sc_start(1, SC_NS); + + clock = 1; + sc_start(1, SC_NS); + clock = 0; + sc_start(1, SC_NS); + + clock = 1; + sc_start(1, SC_NS); + clock = 0; + sc_start(1, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/golden/test2.log b/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/golden/test2.log new file mode 100644 index 000000000..17f483f04 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/golden/test2.log @@ -0,0 +1,25 @@ +SystemC Simulation +Value sent = 129 Value read = 10 +Value sent = 10 Value read = 129 +Value sent = 130 Value read = 11 +Value sent = 11 Value read = 130 +Value sent = 131 Value read = 12 +Value sent = 12 Value read = 131 +Value sent = 132 Value read = 13 +Value sent = 13 Value read = 132 +Value sent = 133 Value read = 14 +Value sent = 14 Value read = 133 +Value sent = 134 Value read = 15 +Value sent = 15 Value read = 134 +Value sent = 135 Value read = 16 +Value sent = 16 Value read = 135 +Value sent = 136 Value read = 17 +Value sent = 17 Value read = 136 +Value sent = 137 Value read = 18 +Value sent = 18 Value read = 137 +Value sent = 138 Value read = 19 +Value sent = 19 Value read = 138 +Value sent = 139 Value read = 20 +Value sent = 20 Value read = 139 +Value sent = 140 Value read = 21 +Value sent = 21 Value read = 140 diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/test2.cpp b/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/test2.cpp new file mode 100644 index 000000000..ef1b237bc --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test2/test2.cpp @@ -0,0 +1,124 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "systemc.h" + +SC_MODULE( p1 ) +{ + SC_HAS_PROCESS( p1 ); + + sc_fifo<int>& a; + sc_fifo<int>& b; + sc_in<bool> clk; + + int init; + + p1(sc_module_name name, + sc_fifo<int>& A, + sc_fifo<int>& B, + sc_signal_in_if<bool>& CLK, + int INIT) + : a(A), b(B) + { + clk(CLK); + init = INIT; + SC_THREAD( entry ); + sensitive << clk; + // sensitive << b; + } + + void entry() { + wait(); + int i = init; + wait(); + while (true) { + a.write(i); + int j = b.read(); + cout << "Value sent = " << i << " Value read = " << j << endl; + wait(); i++; + } + } +}; + +SC_MODULE( p2 ) +{ + SC_HAS_PROCESS( p2 ); + + sc_in_clk clk; + + sc_fifo<int>& a; + sc_fifo<int>& b; + + int init; + + p2 (sc_module_name name, + sc_clock& CLK, + sc_fifo<int>& A, + sc_fifo<int>& B, + int INIT) + : a(A), b(B) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + init = INIT; + } + + void entry() { + int i = init; + wait(); + while (true) { + a.write(i); + int j = b.read(); + cout << "Value sent = " << i << " Value read = " << j << endl; + wait(); i++; + } + } +}; + +int sc_main(int ac, char *av[]) +{ + sc_fifo<int> a(2), b(2); + sc_clock clock("Clock", 20, SC_NS); + + p1 Proc1("Proc1", a, b, clock, 10); + p2 Proc2("Proc2", clock, b, a, 129); + + // sc_start(500, SC_NS); + sc_start(250, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/golden/test3.log b/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/golden/test3.log new file mode 100644 index 000000000..b42cb2d1a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/golden/test3.log @@ -0,0 +1,25 @@ +SystemC Simulation +Value sent = 129 + Value read = 129 +Value sent = 130 + Value read = 130 +Value sent = 131 + Value read = 131 +Value sent = 132 + Value read = 132 +Value sent = 133 + Value read = 133 +Value sent = 134 + Value read = 134 +Value sent = 135 + Value read = 135 +Value sent = 136 + Value read = 136 +Value sent = 137 + Value read = 137 +Value sent = 138 + Value read = 138 +Value sent = 139 + Value read = 139 +Value sent = 140 + Value read = 140 diff --git a/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/test3.cpp b/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/test3.cpp new file mode 100644 index 000000000..f60a2d9cd --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/async_chn/test3/test3.cpp @@ -0,0 +1,114 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test3.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "systemc.h" + +SC_MODULE( p1 ) +{ + SC_HAS_PROCESS( p1 ); + + sc_fifo<int>& b; + + int init; + + p1(sc_module_name name, + sc_fifo<int>& B, + int INIT) + : b(B) + { + init = INIT; + SC_THREAD( entry ); + // sensitive << b; + } + + void entry() { + // wait(); + int i = init; + // wait(); + while (true) { + int j = b.read(); + cout << " Value read = " << j << endl; + // wait(); + } + } +}; + +SC_MODULE( p2 ) +{ + SC_HAS_PROCESS( p2 ); + + sc_in<bool> clk; + + sc_fifo<int>& a; + + int init; + + p2 (sc_module_name name, + sc_signal_in_if<bool>& CLK, + sc_fifo<int>& A, + int INIT) + : a(A) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + init = INIT; + } + + void entry() { + int i = init; + wait(); + while (true) { + a.write(i); + cout << "Value sent = " << i << endl; + wait(); i++; + } + } +}; + +int sc_main(int ac, char *av[]) +{ + sc_fifo<int> a(2), b(2); + sc_clock clock("Clock", 20, SC_NS); + + p1 Proc1("Proc1", a, 10); + p2 Proc2("Proc2", clock, a, 129); + + // sc_start(500, SC_NS); + sc_start(250, SC_NS); + + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/chpt10.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/chpt10.1.f new file mode 100644 index 000000000..9e0d8be37 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/chpt10.1.f @@ -0,0 +1,3 @@ +chpt10.1/main.cpp +chpt10.1/paramadd.cpp +chpt10.1/stim.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/common.h b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/common.h new file mode 100644 index 000000000..20e0a6f30 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/common.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_signal<sc_bv<4> > signal_bool_vector; + +#endif diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/golden/chpt10.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/golden/chpt10.1.log new file mode 100644 index 000000000..2edaad097 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/golden/chpt10.1.log @@ -0,0 +1,260 @@ +SystemC Simulation +35 ns : RESET off ...by stim +60 ns : 0 + 0 + 1 = 1 => carry = 0 sum = 0001 +100 ns : 1 + 0 + 0 = 1 => carry = 0 sum = 0001 +140 ns : 2 + 0 + 1 = 3 => carry = 0 sum = 0011 +180 ns : 3 + 0 + 0 = 3 => carry = 0 sum = 0011 +220 ns : 4 + 0 + 1 = 5 => carry = 0 sum = 0101 +260 ns : 5 + 0 + 0 = 5 => carry = 0 sum = 0101 +300 ns : 6 + 0 + 1 = 7 => carry = 0 sum = 0111 +340 ns : 7 + 0 + 0 = 7 => carry = 0 sum = 0111 +380 ns : 8 + 0 + 1 = 9 => carry = 0 sum = 1001 +420 ns : 9 + 0 + 0 = 9 => carry = 0 sum = 1001 +460 ns : 10 + 0 + 1 = 11 => carry = 0 sum = 1011 +500 ns : 11 + 0 + 0 = 11 => carry = 0 sum = 1011 +540 ns : 12 + 0 + 1 = 13 => carry = 0 sum = 1101 +580 ns : 13 + 0 + 0 = 13 => carry = 0 sum = 1101 +620 ns : 14 + 0 + 1 = 15 => carry = 0 sum = 1111 +660 ns : 15 + 0 + 0 = 15 => carry = 0 sum = 1111 +700 ns : 0 + 1 + 1 = 2 => carry = 0 sum = 0010 +740 ns : 1 + 1 + 0 = 2 => carry = 0 sum = 0010 +780 ns : 2 + 1 + 1 = 4 => carry = 0 sum = 0100 +820 ns : 3 + 1 + 0 = 4 => carry = 0 sum = 0100 +860 ns : 4 + 1 + 1 = 6 => carry = 0 sum = 0110 +900 ns : 5 + 1 + 0 = 6 => carry = 0 sum = 0110 +940 ns : 6 + 1 + 1 = 8 => carry = 0 sum = 1000 +980 ns : 7 + 1 + 0 = 8 => carry = 0 sum = 1000 +1020 ns : 8 + 1 + 1 = 10 => carry = 0 sum = 1010 +1060 ns : 9 + 1 + 0 = 10 => carry = 0 sum = 1010 +1100 ns : 10 + 1 + 1 = 12 => carry = 0 sum = 1100 +1140 ns : 11 + 1 + 0 = 12 => carry = 0 sum = 1100 +1180 ns : 12 + 1 + 1 = 14 => carry = 0 sum = 1110 +1220 ns : 13 + 1 + 0 = 14 => carry = 0 sum = 1110 +1260 ns : 14 + 1 + 1 = 16 => carry = 1 sum = 0000 +1300 ns : 15 + 1 + 0 = 16 => carry = 1 sum = 0000 +1340 ns : 0 + 2 + 1 = 3 => carry = 0 sum = 0011 +1380 ns : 1 + 2 + 0 = 3 => carry = 0 sum = 0011 +1420 ns : 2 + 2 + 1 = 5 => carry = 0 sum = 0101 +1460 ns : 3 + 2 + 0 = 5 => carry = 0 sum = 0101 +1500 ns : 4 + 2 + 1 = 7 => carry = 0 sum = 0111 +1540 ns : 5 + 2 + 0 = 7 => carry = 0 sum = 0111 +1580 ns : 6 + 2 + 1 = 9 => carry = 0 sum = 1001 +1620 ns : 7 + 2 + 0 = 9 => carry = 0 sum = 1001 +1660 ns : 8 + 2 + 1 = 11 => carry = 0 sum = 1011 +1700 ns : 9 + 2 + 0 = 11 => carry = 0 sum = 1011 +1740 ns : 10 + 2 + 1 = 13 => carry = 0 sum = 1101 +1780 ns : 11 + 2 + 0 = 13 => carry = 0 sum = 1101 +1820 ns : 12 + 2 + 1 = 15 => carry = 0 sum = 1111 +1860 ns : 13 + 2 + 0 = 15 => carry = 0 sum = 1111 +1900 ns : 14 + 2 + 1 = 17 => carry = 1 sum = 0001 +1940 ns : 15 + 2 + 0 = 17 => carry = 1 sum = 0001 +1980 ns : 0 + 3 + 1 = 4 => carry = 0 sum = 0100 +2020 ns : 1 + 3 + 0 = 4 => carry = 0 sum = 0100 +2060 ns : 2 + 3 + 1 = 6 => carry = 0 sum = 0110 +2100 ns : 3 + 3 + 0 = 6 => carry = 0 sum = 0110 +2140 ns : 4 + 3 + 1 = 8 => carry = 0 sum = 1000 +2180 ns : 5 + 3 + 0 = 8 => carry = 0 sum = 1000 +2220 ns : 6 + 3 + 1 = 10 => carry = 0 sum = 1010 +2260 ns : 7 + 3 + 0 = 10 => carry = 0 sum = 1010 +2300 ns : 8 + 3 + 1 = 12 => carry = 0 sum = 1100 +2340 ns : 9 + 3 + 0 = 12 => carry = 0 sum = 1100 +2380 ns : 10 + 3 + 1 = 14 => carry = 0 sum = 1110 +2420 ns : 11 + 3 + 0 = 14 => carry = 0 sum = 1110 +2460 ns : 12 + 3 + 1 = 16 => carry = 1 sum = 0000 +2500 ns : 13 + 3 + 0 = 16 => carry = 1 sum = 0000 +2540 ns : 14 + 3 + 1 = 18 => carry = 1 sum = 0010 +2580 ns : 15 + 3 + 0 = 18 => carry = 1 sum = 0010 +2620 ns : 0 + 4 + 1 = 5 => carry = 0 sum = 0101 +2660 ns : 1 + 4 + 0 = 5 => carry = 0 sum = 0101 +2700 ns : 2 + 4 + 1 = 7 => carry = 0 sum = 0111 +2740 ns : 3 + 4 + 0 = 7 => carry = 0 sum = 0111 +2780 ns : 4 + 4 + 1 = 9 => carry = 0 sum = 1001 +2820 ns : 5 + 4 + 0 = 9 => carry = 0 sum = 1001 +2860 ns : 6 + 4 + 1 = 11 => carry = 0 sum = 1011 +2900 ns : 7 + 4 + 0 = 11 => carry = 0 sum = 1011 +2940 ns : 8 + 4 + 1 = 13 => carry = 0 sum = 1101 +2980 ns : 9 + 4 + 0 = 13 => carry = 0 sum = 1101 +3020 ns : 10 + 4 + 1 = 15 => carry = 0 sum = 1111 +3060 ns : 11 + 4 + 0 = 15 => carry = 0 sum = 1111 +3100 ns : 12 + 4 + 1 = 17 => carry = 1 sum = 0001 +3140 ns : 13 + 4 + 0 = 17 => carry = 1 sum = 0001 +3180 ns : 14 + 4 + 1 = 19 => carry = 1 sum = 0011 +3220 ns : 15 + 4 + 0 = 19 => carry = 1 sum = 0011 +3260 ns : 0 + 5 + 1 = 6 => carry = 0 sum = 0110 +3300 ns : 1 + 5 + 0 = 6 => carry = 0 sum = 0110 +3340 ns : 2 + 5 + 1 = 8 => carry = 0 sum = 1000 +3380 ns : 3 + 5 + 0 = 8 => carry = 0 sum = 1000 +3420 ns : 4 + 5 + 1 = 10 => carry = 0 sum = 1010 +3460 ns : 5 + 5 + 0 = 10 => carry = 0 sum = 1010 +3500 ns : 6 + 5 + 1 = 12 => carry = 0 sum = 1100 +3540 ns : 7 + 5 + 0 = 12 => carry = 0 sum = 1100 +3580 ns : 8 + 5 + 1 = 14 => carry = 0 sum = 1110 +3620 ns : 9 + 5 + 0 = 14 => carry = 0 sum = 1110 +3660 ns : 10 + 5 + 1 = 16 => carry = 1 sum = 0000 +3700 ns : 11 + 5 + 0 = 16 => carry = 1 sum = 0000 +3740 ns : 12 + 5 + 1 = 18 => carry = 1 sum = 0010 +3780 ns : 13 + 5 + 0 = 18 => carry = 1 sum = 0010 +3820 ns : 14 + 5 + 1 = 20 => carry = 1 sum = 0100 +3860 ns : 15 + 5 + 0 = 20 => carry = 1 sum = 0100 +3900 ns : 0 + 6 + 1 = 7 => carry = 0 sum = 0111 +3940 ns : 1 + 6 + 0 = 7 => carry = 0 sum = 0111 +3980 ns : 2 + 6 + 1 = 9 => carry = 0 sum = 1001 +4020 ns : 3 + 6 + 0 = 9 => carry = 0 sum = 1001 +4060 ns : 4 + 6 + 1 = 11 => carry = 0 sum = 1011 +4100 ns : 5 + 6 + 0 = 11 => carry = 0 sum = 1011 +4140 ns : 6 + 6 + 1 = 13 => carry = 0 sum = 1101 +4180 ns : 7 + 6 + 0 = 13 => carry = 0 sum = 1101 +4220 ns : 8 + 6 + 1 = 15 => carry = 0 sum = 1111 +4260 ns : 9 + 6 + 0 = 15 => carry = 0 sum = 1111 +4300 ns : 10 + 6 + 1 = 17 => carry = 1 sum = 0001 +4340 ns : 11 + 6 + 0 = 17 => carry = 1 sum = 0001 +4380 ns : 12 + 6 + 1 = 19 => carry = 1 sum = 0011 +4420 ns : 13 + 6 + 0 = 19 => carry = 1 sum = 0011 +4460 ns : 14 + 6 + 1 = 21 => carry = 1 sum = 0101 +4500 ns : 15 + 6 + 0 = 21 => carry = 1 sum = 0101 +4540 ns : 0 + 7 + 1 = 8 => carry = 0 sum = 1000 +4580 ns : 1 + 7 + 0 = 8 => carry = 0 sum = 1000 +4620 ns : 2 + 7 + 1 = 10 => carry = 0 sum = 1010 +4660 ns : 3 + 7 + 0 = 10 => carry = 0 sum = 1010 +4700 ns : 4 + 7 + 1 = 12 => carry = 0 sum = 1100 +4740 ns : 5 + 7 + 0 = 12 => carry = 0 sum = 1100 +4780 ns : 6 + 7 + 1 = 14 => carry = 0 sum = 1110 +4820 ns : 7 + 7 + 0 = 14 => carry = 0 sum = 1110 +4860 ns : 8 + 7 + 1 = 16 => carry = 1 sum = 0000 +4900 ns : 9 + 7 + 0 = 16 => carry = 1 sum = 0000 +4940 ns : 10 + 7 + 1 = 18 => carry = 1 sum = 0010 +4980 ns : 11 + 7 + 0 = 18 => carry = 1 sum = 0010 +5020 ns : 12 + 7 + 1 = 20 => carry = 1 sum = 0100 +5060 ns : 13 + 7 + 0 = 20 => carry = 1 sum = 0100 +5100 ns : 14 + 7 + 1 = 22 => carry = 1 sum = 0110 +5140 ns : 15 + 7 + 0 = 22 => carry = 1 sum = 0110 +5180 ns : 0 + 8 + 1 = 9 => carry = 0 sum = 1001 +5220 ns : 1 + 8 + 0 = 9 => carry = 0 sum = 1001 +5260 ns : 2 + 8 + 1 = 11 => carry = 0 sum = 1011 +5300 ns : 3 + 8 + 0 = 11 => carry = 0 sum = 1011 +5340 ns : 4 + 8 + 1 = 13 => carry = 0 sum = 1101 +5380 ns : 5 + 8 + 0 = 13 => carry = 0 sum = 1101 +5420 ns : 6 + 8 + 1 = 15 => carry = 0 sum = 1111 +5460 ns : 7 + 8 + 0 = 15 => carry = 0 sum = 1111 +5500 ns : 8 + 8 + 1 = 17 => carry = 1 sum = 0001 +5540 ns : 9 + 8 + 0 = 17 => carry = 1 sum = 0001 +5580 ns : 10 + 8 + 1 = 19 => carry = 1 sum = 0011 +5620 ns : 11 + 8 + 0 = 19 => carry = 1 sum = 0011 +5660 ns : 12 + 8 + 1 = 21 => carry = 1 sum = 0101 +5700 ns : 13 + 8 + 0 = 21 => carry = 1 sum = 0101 +5740 ns : 14 + 8 + 1 = 23 => carry = 1 sum = 0111 +5780 ns : 15 + 8 + 0 = 23 => carry = 1 sum = 0111 +5820 ns : 0 + 9 + 1 = 10 => carry = 0 sum = 1010 +5860 ns : 1 + 9 + 0 = 10 => carry = 0 sum = 1010 +5900 ns : 2 + 9 + 1 = 12 => carry = 0 sum = 1100 +5940 ns : 3 + 9 + 0 = 12 => carry = 0 sum = 1100 +5980 ns : 4 + 9 + 1 = 14 => carry = 0 sum = 1110 +6020 ns : 5 + 9 + 0 = 14 => carry = 0 sum = 1110 +6060 ns : 6 + 9 + 1 = 16 => carry = 1 sum = 0000 +6100 ns : 7 + 9 + 0 = 16 => carry = 1 sum = 0000 +6140 ns : 8 + 9 + 1 = 18 => carry = 1 sum = 0010 +6180 ns : 9 + 9 + 0 = 18 => carry = 1 sum = 0010 +6220 ns : 10 + 9 + 1 = 20 => carry = 1 sum = 0100 +6260 ns : 11 + 9 + 0 = 20 => carry = 1 sum = 0100 +6300 ns : 12 + 9 + 1 = 22 => carry = 1 sum = 0110 +6340 ns : 13 + 9 + 0 = 22 => carry = 1 sum = 0110 +6380 ns : 14 + 9 + 1 = 24 => carry = 1 sum = 1000 +6420 ns : 15 + 9 + 0 = 24 => carry = 1 sum = 1000 +6460 ns : 0 + 10 + 1 = 11 => carry = 0 sum = 1011 +6500 ns : 1 + 10 + 0 = 11 => carry = 0 sum = 1011 +6540 ns : 2 + 10 + 1 = 13 => carry = 0 sum = 1101 +6580 ns : 3 + 10 + 0 = 13 => carry = 0 sum = 1101 +6620 ns : 4 + 10 + 1 = 15 => carry = 0 sum = 1111 +6660 ns : 5 + 10 + 0 = 15 => carry = 0 sum = 1111 +6700 ns : 6 + 10 + 1 = 17 => carry = 1 sum = 0001 +6740 ns : 7 + 10 + 0 = 17 => carry = 1 sum = 0001 +6780 ns : 8 + 10 + 1 = 19 => carry = 1 sum = 0011 +6820 ns : 9 + 10 + 0 = 19 => carry = 1 sum = 0011 +6860 ns : 10 + 10 + 1 = 21 => carry = 1 sum = 0101 +6900 ns : 11 + 10 + 0 = 21 => carry = 1 sum = 0101 +6940 ns : 12 + 10 + 1 = 23 => carry = 1 sum = 0111 +6980 ns : 13 + 10 + 0 = 23 => carry = 1 sum = 0111 +7020 ns : 14 + 10 + 1 = 25 => carry = 1 sum = 1001 +7060 ns : 15 + 10 + 0 = 25 => carry = 1 sum = 1001 +7100 ns : 0 + 11 + 1 = 12 => carry = 0 sum = 1100 +7140 ns : 1 + 11 + 0 = 12 => carry = 0 sum = 1100 +7180 ns : 2 + 11 + 1 = 14 => carry = 0 sum = 1110 +7220 ns : 3 + 11 + 0 = 14 => carry = 0 sum = 1110 +7260 ns : 4 + 11 + 1 = 16 => carry = 1 sum = 0000 +7300 ns : 5 + 11 + 0 = 16 => carry = 1 sum = 0000 +7340 ns : 6 + 11 + 1 = 18 => carry = 1 sum = 0010 +7380 ns : 7 + 11 + 0 = 18 => carry = 1 sum = 0010 +7420 ns : 8 + 11 + 1 = 20 => carry = 1 sum = 0100 +7460 ns : 9 + 11 + 0 = 20 => carry = 1 sum = 0100 +7500 ns : 10 + 11 + 1 = 22 => carry = 1 sum = 0110 +7540 ns : 11 + 11 + 0 = 22 => carry = 1 sum = 0110 +7580 ns : 12 + 11 + 1 = 24 => carry = 1 sum = 1000 +7620 ns : 13 + 11 + 0 = 24 => carry = 1 sum = 1000 +7660 ns : 14 + 11 + 1 = 26 => carry = 1 sum = 1010 +7700 ns : 15 + 11 + 0 = 26 => carry = 1 sum = 1010 +7740 ns : 0 + 12 + 1 = 13 => carry = 0 sum = 1101 +7780 ns : 1 + 12 + 0 = 13 => carry = 0 sum = 1101 +7820 ns : 2 + 12 + 1 = 15 => carry = 0 sum = 1111 +7860 ns : 3 + 12 + 0 = 15 => carry = 0 sum = 1111 +7900 ns : 4 + 12 + 1 = 17 => carry = 1 sum = 0001 +7940 ns : 5 + 12 + 0 = 17 => carry = 1 sum = 0001 +7980 ns : 6 + 12 + 1 = 19 => carry = 1 sum = 0011 +8020 ns : 7 + 12 + 0 = 19 => carry = 1 sum = 0011 +8060 ns : 8 + 12 + 1 = 21 => carry = 1 sum = 0101 +8100 ns : 9 + 12 + 0 = 21 => carry = 1 sum = 0101 +8140 ns : 10 + 12 + 1 = 23 => carry = 1 sum = 0111 +8180 ns : 11 + 12 + 0 = 23 => carry = 1 sum = 0111 +8220 ns : 12 + 12 + 1 = 25 => carry = 1 sum = 1001 +8260 ns : 13 + 12 + 0 = 25 => carry = 1 sum = 1001 +8300 ns : 14 + 12 + 1 = 27 => carry = 1 sum = 1011 +8340 ns : 15 + 12 + 0 = 27 => carry = 1 sum = 1011 +8380 ns : 0 + 13 + 1 = 14 => carry = 0 sum = 1110 +8420 ns : 1 + 13 + 0 = 14 => carry = 0 sum = 1110 +8460 ns : 2 + 13 + 1 = 16 => carry = 1 sum = 0000 +8500 ns : 3 + 13 + 0 = 16 => carry = 1 sum = 0000 +8540 ns : 4 + 13 + 1 = 18 => carry = 1 sum = 0010 +8580 ns : 5 + 13 + 0 = 18 => carry = 1 sum = 0010 +8620 ns : 6 + 13 + 1 = 20 => carry = 1 sum = 0100 +8660 ns : 7 + 13 + 0 = 20 => carry = 1 sum = 0100 +8700 ns : 8 + 13 + 1 = 22 => carry = 1 sum = 0110 +8740 ns : 9 + 13 + 0 = 22 => carry = 1 sum = 0110 +8780 ns : 10 + 13 + 1 = 24 => carry = 1 sum = 1000 +8820 ns : 11 + 13 + 0 = 24 => carry = 1 sum = 1000 +8860 ns : 12 + 13 + 1 = 26 => carry = 1 sum = 1010 +8900 ns : 13 + 13 + 0 = 26 => carry = 1 sum = 1010 +8940 ns : 14 + 13 + 1 = 28 => carry = 1 sum = 1100 +8980 ns : 15 + 13 + 0 = 28 => carry = 1 sum = 1100 +9020 ns : 0 + 14 + 1 = 15 => carry = 0 sum = 1111 +9060 ns : 1 + 14 + 0 = 15 => carry = 0 sum = 1111 +9100 ns : 2 + 14 + 1 = 17 => carry = 1 sum = 0001 +9140 ns : 3 + 14 + 0 = 17 => carry = 1 sum = 0001 +9180 ns : 4 + 14 + 1 = 19 => carry = 1 sum = 0011 +9220 ns : 5 + 14 + 0 = 19 => carry = 1 sum = 0011 +9260 ns : 6 + 14 + 1 = 21 => carry = 1 sum = 0101 +9300 ns : 7 + 14 + 0 = 21 => carry = 1 sum = 0101 +9340 ns : 8 + 14 + 1 = 23 => carry = 1 sum = 0111 +9380 ns : 9 + 14 + 0 = 23 => carry = 1 sum = 0111 +9420 ns : 10 + 14 + 1 = 25 => carry = 1 sum = 1001 +9460 ns : 11 + 14 + 0 = 25 => carry = 1 sum = 1001 +9500 ns : 12 + 14 + 1 = 27 => carry = 1 sum = 1011 +9540 ns : 13 + 14 + 0 = 27 => carry = 1 sum = 1011 +9580 ns : 14 + 14 + 1 = 29 => carry = 1 sum = 1101 +9620 ns : 15 + 14 + 0 = 29 => carry = 1 sum = 1101 +9660 ns : 0 + 15 + 1 = 16 => carry = 1 sum = 0000 +9700 ns : 1 + 15 + 0 = 16 => carry = 1 sum = 0000 +9740 ns : 2 + 15 + 1 = 18 => carry = 1 sum = 0010 +9780 ns : 3 + 15 + 0 = 18 => carry = 1 sum = 0010 +9820 ns : 4 + 15 + 1 = 20 => carry = 1 sum = 0100 +9860 ns : 5 + 15 + 0 = 20 => carry = 1 sum = 0100 +9900 ns : 6 + 15 + 1 = 22 => carry = 1 sum = 0110 +9940 ns : 7 + 15 + 0 = 22 => carry = 1 sum = 0110 +9980 ns : 8 + 15 + 1 = 24 => carry = 1 sum = 1000 +10020 ns : 9 + 15 + 0 = 24 => carry = 1 sum = 1000 +10060 ns : 10 + 15 + 1 = 26 => carry = 1 sum = 1010 +10100 ns : 11 + 15 + 0 = 26 => carry = 1 sum = 1010 +10140 ns : 12 + 15 + 1 = 28 => carry = 1 sum = 1100 +10180 ns : 13 + 15 + 0 = 28 => carry = 1 sum = 1100 +10220 ns : 14 + 15 + 1 = 30 => carry = 1 sum = 1110 +10260 ns : 15 + 15 + 0 = 30 => carry = 1 sum = 1110 + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/main.cpp new file mode 100644 index 000000000..58f54baf2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/main.cpp @@ -0,0 +1,70 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for parametric adder simulation */ + +#include "paramadd.h" +#include "stim.h" + +int sc_main(int ac, char *av[]) +{ + // Parameter Settings + int width = 4; + + // Signal Instantiation + sc_signal<bool> reset; + signal_bool_vector a ("Operand1"); + signal_bool_vector b ("Operand2"); + sc_signal<bool> cin; + sc_signal<bool> ready; + signal_bool_vector sum ("Sum"); + sc_signal<bool> co; + sc_signal<bool> done; + + // Clock Instantiation + sc_clock clk ("Clock", 10, SC_NS, 0.5, 0, SC_NS); + + // Process Instantiation + paramadd D1("D1", clk, reset, a, b, cin, ready, sum, + co, done, width); + stim T1("T1", clk, done, reset, a, b, cin, + ready, width); + + // Simulation Run Control + sc_start(); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.cpp new file mode 100644 index 000000000..7be025c2c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.cpp @@ -0,0 +1,89 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + paramadd.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename paramadd.cc */ +/* This is the implementation file for synchronous process `paramadd' */ + +#include "paramadd.h" + +void paramadd::entry() +{ + sc_biguint<5> sum1; + sc_unsigned a1(data_width); + sc_unsigned b1(data_width); + bool c1; + + // Reset handler + sum.write(0); + co.write(0); + wait(); + + while(true) { // Main Loop + + // HANDSHAKE + done.write(0); + do { wait(); } while (ready != 1); + + // COMPUTATION + a1 = a.read(); + b1 = b.read(); + c1 = cin.read(); + + sum1 = a1 + b1 + c1; + + // sum.write( sum1.range(data_width-1,0) ); + sc_unsigned tmp( data_width ); + tmp = sum1.range( data_width - 1, 0 ); + sum.write( tmp ); + co.write( sum1[data_width] ); + wait( 2 ); + + cout << sc_time_stamp() << "\t : " + << a1 << " + " + << b1 << " + " + << cin << " = " << sum1 + << "\t => carry = " << co + << " sum = " << sum + << endl; + + + // HANDSHAKE + done.write(1); + wait(); + } +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.h b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.h new file mode 100644 index 000000000..b9c681f1a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/paramadd.h @@ -0,0 +1,86 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + paramadd.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename paramadd.h */ +/* Interface file for synchronous process `paramadd' */ + +#include "common.h" + +SC_MODULE( paramadd ) +{ + SC_HAS_PROCESS( paramadd ); + + sc_in_clk clk; + + // Inputs + const sc_signal<bool>& reset; + const signal_bool_vector& a; + const signal_bool_vector& b; + const sc_signal<bool>& cin; + const sc_signal<bool>& ready; + // Outputs + signal_bool_vector& sum; + sc_signal<bool>& co; + sc_signal<bool>& done; + // Parameters + const int data_width; + + // Constructor + paramadd(sc_module_name NAME, + sc_clock& TICK, + const sc_signal<bool>& RESET, + const signal_bool_vector& A, + const signal_bool_vector& B, + const sc_signal<bool>& CIN, + const sc_signal<bool>& READY, + signal_bool_vector& SUM, + sc_signal<bool>& CO, + sc_signal<bool>& DONE, + const int DATA_WIDTH = 8) + : reset(RESET), a(A), + b(B), cin(CIN), ready(READY), + sum(SUM), co(CO), done(DONE), + data_width(DATA_WIDTH) + { + clk(TICK); + SC_CTHREAD( entry, clk.pos() ); + reset_signal_is(reset,false); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.cpp new file mode 100644 index 000000000..a7a285d66 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.cpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stim.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stim.cc */ +/* This is the interface file for synchronous process `stim' */ + +#include "stim.h" + +void stim::entry() +{ + // Variable definition + sc_unsigned a_tmp(data_width); + sc_unsigned b_tmp(data_width); + bool c_tmp; + int i, j; + + // Reset handler + reset.write(0); + wait(2); + + reset.write(1); + wait(); + cout << sc_time_stamp() << "\t : " + << "RESET off \t...by stim" << endl; + + // Stimulus Generation + c_tmp = 0; + for (i=0; i<16; i++) { + for (j=0; j<16; j++) { + a_tmp = j; + b_tmp = i; + c_tmp = !c_tmp; + + a.write(a_tmp); + b.write(b_tmp); + cin.write(c_tmp); + + ready.write(1); + // wait(); + do { wait(); } while (done != 1); + + ready.write(0); + // do { wait(); } while (done == 1); + wait(); + } + } + + sc_stop(); +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.h b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.h new file mode 100644 index 000000000..a34ab8578 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt10.1/stim.h @@ -0,0 +1,81 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stim.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stim.h */ +/* This is the interface file for synchronous process `stim' */ + +#include "common.h" + +SC_MODULE( stim ) +{ + SC_HAS_PROCESS( stim ); + + sc_in_clk clk; + + // Inputs + const sc_signal<bool>& done; + // Outputs + sc_signal<bool>& reset; + signal_bool_vector& a; + signal_bool_vector& b; + sc_signal<bool>& cin; + sc_signal<bool>& ready; + // Parameters + const int data_width; + + // Constructor + stim (sc_module_name NAME, + sc_clock& TICK, + const sc_signal<bool>& DONE, + sc_signal<bool>& RESET, + signal_bool_vector& A, + signal_bool_vector& B, + sc_signal<bool>& CIN, + sc_signal<bool>& READY, + const int DATA_WIDTH = 8) + : done(DONE), reset(RESET), + a(A),b(B), cin(CIN), + ready(READY), + data_width(DATA_WIDTH) + { + clk(TICK); + SC_CTHREAD( entry, clk.neg() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.1/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.cpp new file mode 100644 index 000000000..f20862063 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.cpp @@ -0,0 +1,90 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + i = a.read().to_int(); + j = b.read().to_int(); + k = c.read().to_int(); + l = d.read().to_int(); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + am.write(arith); + gm.write(geom); + hm.write(harmonic); + + wait(); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.h new file mode 100644 index 000000000..b1987436b --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.1/mean.h @@ -0,0 +1,79 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const signal_bool_vector& a; //input + const signal_bool_vector& b; //input + const signal_bool_vector& c; //input + const signal_bool_vector& d; //input + signal_bool_vector& am; //output + signal_bool_vector& gm; //output + signal_bool_vector& hm; //output + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector& A, + const signal_bool_vector& B, + const signal_bool_vector& C, + const signal_bool_vector& D, + signal_bool_vector& AM, + signal_bool_vector& GM, + signal_bool_vector& HM) + : a(A), b(B), c(C), d(D), am(AM), gm(GM), hm(HM) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.2/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.cpp new file mode 100644 index 000000000..5cf35627a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.cpp @@ -0,0 +1,96 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + i = in.read().to_int(); + wait(); + j = in.read().to_int(); + wait(); + k = in.read().to_int(); + wait(); + l = in.read().to_int(); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + out.write(arith); + wait(); + out.write(geom); + wait(); + out.write(harmonic); + wait(); + + wait(); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.h new file mode 100644 index 000000000..54b4e33e6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.2/mean.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const signal_bool_vector& in; //input + signal_bool_vector& out; //output + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector& IN_, + signal_bool_vector& OUT_) + : in(IN_), out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.3/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.cpp new file mode 100644 index 000000000..1449a84ab --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.cpp @@ -0,0 +1,98 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + do { wait(); } while (data_available != true); + i = in.read().to_int(); + wait(); + j = in.read().to_int(); + wait(); + k = in.read().to_int(); + wait(); + l = in.read().to_int(); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + data_ready.write(true); + wait(); + out.write(arith); + wait(); + out.write(geom); + wait(); + out.write(harmonic); + wait(); + data_ready.write(false); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.h new file mode 100644 index 000000000..eb0db1a2e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.3/mean.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const signal_bool_vector& in; //input + signal_bool_vector& out; //output + const sc_signal<bool>& data_available; //input + sc_signal<bool>& data_ready; //output + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector& IN_, + signal_bool_vector& OUT_, + const sc_signal<bool>& DATA_AVAILABLE, + sc_signal<bool>& DATA_READY) + : in(IN_), out(OUT_), data_available(DATA_AVAILABLE), data_ready(DATA_READY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.4/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.cpp new file mode 100644 index 000000000..bc82a7739 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.cpp @@ -0,0 +1,99 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + send_input.write(true); + wait(2); + i = in.read().to_int(); + wait(); + j = in.read().to_int(); + wait(); + k = in.read().to_int(); + wait(); + l = in.read().to_int(); + send_input.write(false); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + do { wait(); } while (receiver_ready != true); + wait(); + out.write(arith); + wait(); + out.write(geom); + wait(); + out.write(harmonic); + wait(); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.h new file mode 100644 index 000000000..a0495a3d0 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.4/mean.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > sc_signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const sc_signal_bool_vector& in; //input + sc_signal_bool_vector& out; //output + const sc_signal<bool>& receiver_ready; //input + sc_signal<bool>& send_input; //output + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const sc_signal_bool_vector& IN_, + sc_signal_bool_vector& OUT_, + const sc_signal<bool>& RECEIVER_READY, + sc_signal<bool>& SEND_INPUT) + : in(IN_), out(OUT_), receiver_ready(RECEIVER_READY), send_input(SEND_INPUT) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.5/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.cpp new file mode 100644 index 000000000..2689c305a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.cpp @@ -0,0 +1,102 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + do { wait(); } while (input_available != true); + send_data.write(true); + wait(); + i = in.read().to_int(); + wait(); + j = in.read().to_int(); + wait(); + k = in.read().to_int(); + wait(); + l = in.read().to_int(); + send_data.write(false); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + output_ready.write(true); + do { wait(); } while (receiver_ready != true); + wait(); + out.write(arith); + wait(); + out.write(geom); + wait(); + out.write(harmonic); + wait(); + output_ready.write(false); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.h new file mode 100644 index 000000000..1495e5285 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.h @@ -0,0 +1,75 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > sc_signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const sc_signal_bool_vector& in; //input + sc_signal_bool_vector& out; //output + const sc_signal<bool>& input_available; //input + sc_signal<bool>& send_data; //output + sc_signal<bool>& output_ready; //output + const sc_signal<bool>& receiver_ready; //input + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const sc_signal_bool_vector& IN_, + sc_signal_bool_vector& OUT_, + const sc_signal<bool>& INPUT_AVAILABLE, + sc_signal<bool>& SEND_DATA, + sc_signal<bool>& OUTPUT_READY, + const sc_signal<bool>& RECEIVER_READY) + : in(IN_), out(OUT_), receiver_ready(RECEIVER_READY), send_data(SEND_DATA), input_available(INPUT_AVAILABLE), output_ready(OUTPUT_READY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.6/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.cpp new file mode 100644 index 000000000..ffef8d07f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.cpp @@ -0,0 +1,101 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + send_input.write(true); + do { wait(); } while (data_available != true); + i = in.read().to_int(); + wait(); + j = in.read().to_int(); + wait(); + k = in.read().to_int(); + wait(); + l = in.read().to_int(); + send_input.write(false); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + do { wait(); } while (receiver_ready != true); + data_ready.write(true); + wait(); + out.write(arith); + wait(); + out.write(geom); + wait(); + out.write(harmonic); + wait(); + data_ready.write(false); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.h new file mode 100644 index 000000000..4f7fb17a3 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.6/mean.h @@ -0,0 +1,74 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const signal_bool_vector& in; //input + signal_bool_vector& out; //output + const sc_signal<bool>& data_available; //input + sc_signal<bool>& send_input; //output + sc_signal<bool>& data_ready; //output + const sc_signal<bool>& receiver_ready; //input + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector& IN_, + signal_bool_vector& OUT_, + const sc_signal<bool>& DATA_AVAILABLE, + sc_signal<bool>& SEND_INPUT, + sc_signal<bool>& DATA_READY, + const sc_signal<bool>& RECEIVER_READY) + : in(IN_), out(OUT_), receiver_ready(RECEIVER_READY), send_input(SEND_INPUT), data_available(DATA_AVAILABLE), data_ready(DATA_READY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.7/golden/mean.log b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/golden/mean.log new file mode 100644 index 000000000..6d243dcc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/golden/mean.log @@ -0,0 +1 @@ +SystemC Simulation diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.cpp new file mode 100644 index 000000000..64b210b10 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.cpp @@ -0,0 +1,123 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.cc */ +/* This is the implementation file for synchronous process `mean' */ + +#include "mean.h" + +void calculate_geometric_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void calculate_harmonic_mean(const sc_signed& a, const sc_signed& b, + const sc_signed& c, const sc_signed& d, + sc_signed& mean){} + +void mean::entry() +{ + sc_signed i(24); // Will hold input a + sc_signed j(24); // Will hold input b + sc_signed k(24); // Will hold input c + sc_signed l(24); // Will hold input d + + sc_signed arith(24); // Arithmetic mean + sc_signed geom(24); // Geometric mean + sc_signed harmonic(24); // Harmonic mean + + while (true) { + // read all inputs + do { wait(); } while (input_available != true); + send_data.write(true); + do { wait(); } while (input_available != false); + i = in.read().to_int(); + send_data.write(false); + + do { wait(); } while (input_available != true); + send_data.write(true); + do { wait(); } while (input_available != false); + j = in.read().to_int(); + send_data.write(false); + + do { wait(); } while (input_available != true); + send_data.write(true); + do { wait(); } while (input_available != false); + k = in.read().to_int(); + send_data.write(false); + + do { wait(); } while (input_available != true); + send_data.write(true); + do { wait(); } while (input_available != false); + l = in.read().to_int(); + send_data.write(false); + wait(); + + // Calculate arithmetic mean + arith = (i + j + k + l) / 4; + // Calculate geometric mean + calculate_geometric_mean(i, j, k, l, geom); + // Calculate harmonic mean + calculate_harmonic_mean(i, j, k, l, harmonic); + + // write all outputs + output_ready.write(true); + do { wait(); } while (receiver_ready != true); + output_ready.write(false); + out.write(arith); + do { wait(); } while (receiver_ready != false); + + output_ready.write(true); + do { wait(); } while (receiver_ready != true); + output_ready.write(false); + out.write(geom); + do { wait(); } while (receiver_ready != false); + + + output_ready.write(true); + do { wait(); } while (receiver_ready != true); + output_ready.write(false); + out.write(harmonic); + do { wait(); } while (receiver_ready != false); + } +} // end of entry function + +// Just to make the compiler shut up + +int sc_main(int ac, char *av[]) +{ + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.h b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.h new file mode 100644 index 000000000..1495e5285 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt11.7/mean.h @@ -0,0 +1,75 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + mean.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename mean.h */ +/* This is the interface file for synchronous process `mean' */ + +#include "systemc.h" + +typedef sc_signal<sc_bv<24> > sc_signal_bool_vector; + +SC_MODULE( mean ) +{ + SC_HAS_PROCESS( mean ); + + sc_in_clk clk; + + const sc_signal_bool_vector& in; //input + sc_signal_bool_vector& out; //output + const sc_signal<bool>& input_available; //input + sc_signal<bool>& send_data; //output + sc_signal<bool>& output_ready; //output + const sc_signal<bool>& receiver_ready; //input + + //Constructor + mean(sc_module_name NAME, + sc_clock& CLK, + const sc_signal_bool_vector& IN_, + sc_signal_bool_vector& OUT_, + const sc_signal<bool>& INPUT_AVAILABLE, + sc_signal<bool>& SEND_DATA, + sc_signal<bool>& OUTPUT_READY, + const sc_signal<bool>& RECEIVER_READY) + : in(IN_), out(OUT_), receiver_ready(RECEIVER_READY), send_data(SEND_DATA), input_available(INPUT_AVAILABLE), output_ready(OUTPUT_READY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.cpp new file mode 100644 index 000000000..30f2888cf --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.cpp @@ -0,0 +1,84 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accessor.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accessor.cc */ +/* This is the implementation file for synchronous process 'accessor' */ + +#include "accessor.h" + +void accessor::entry() +{ + int addr; + int datao; + int datai; + + addr = 10; + datao = 0xdeadbeef; + + while (true) { + // Write memory location first + chip_select.write(true); + write_enable.write(true); + address.write(addr); + dataout.write(datao); + cout << "Accessor: Data Written = " << hex << datao << " at address " + << hex << addr << endl; + wait(); // To make all the outputs appear at the interface + + // some process functionality not shown here during which chip + // chip select is deasserted + chip_select.write(false); + dataout.write(0); + wait(); + + // Now read memory location + chip_select.write(true); + write_enable.write(false); + address.write(addr); + wait(); // To make all the outputs appear at the interface + + datai = datain.read().to_int(); + cout << "Accessor: Data Read = " << hex << datai << " from address " + << hex << addr << endl; + chip_select.write(false); + wait(); + + addr++; + datao++; + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.h new file mode 100644 index 000000000..d31c64eb6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.h @@ -0,0 +1,74 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accessor.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accessor.h */ +/* This is the interface file for synchronous process 'accessor' */ + +#include "common.h" + +SC_MODULE( accessor ) +{ + SC_HAS_PROCESS( accessor ); + + sc_in_clk clk; + + const signal_bool_vector32& datain; //input + sc_signal<bool>& chip_select; //output + sc_signal<bool>& write_enable; //output + signal_bool_vector10& address; //output + signal_bool_vector32& dataout; //output + + //Constructor + accessor(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector32& DATAIN, + sc_signal<bool>& CHIP_SELECT, + sc_signal<bool>& WRITE_ENABLE, + signal_bool_vector10& ADDRESS, + signal_bool_vector32& DATAOUT) + : datain(DATAIN), chip_select(CHIP_SELECT), + write_enable(WRITE_ENABLE), address(ADDRESS), dataout(DATAOUT) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/chpt12.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/chpt12.1.f new file mode 100644 index 000000000..f8f6c63a8 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/chpt12.1.f @@ -0,0 +1,3 @@ +chpt12.1/accessor.cpp +chpt12.1/main.cpp +chpt12.1/ram.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/common.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/common.h new file mode 100644 index 000000000..5bdfda659 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/common.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_signal<sc_bv<10> > signal_bool_vector10; +typedef sc_signal<sc_bv<32> > signal_bool_vector32; + +#endif diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/golden/chpt12.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/golden/chpt12.1.log new file mode 100644 index 000000000..e2074c96b --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/golden/chpt12.1.log @@ -0,0 +1,15 @@ +SystemC Simulation +Accessor: Data Written = deadbeef at address a +Accessor: Data Read = deadbeef from address a +Accessor: Data Written = deadbef0 at address b +Accessor: Data Read = deadbef0 from address b +Accessor: Data Written = deadbef1 at address c +Accessor: Data Read = deadbef1 from address c +Accessor: Data Written = deadbef2 at address d +Accessor: Data Read = deadbef2 from address d +Accessor: Data Written = deadbef3 at address e +Accessor: Data Read = deadbef3 from address e +Accessor: Data Written = deadbef4 at address f +Accessor: Data Read = deadbef4 from address f +Accessor: Data Written = deadbef5 at address 10 +Accessor: Data Read = deadbef5 from address 10 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/main.cpp new file mode 100644 index 000000000..bc889e7af --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/main.cpp @@ -0,0 +1,60 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for memory simulation */ + +#include "accessor.h" +#include "ram.h" + +int global_mem[4000]; + +int sc_main(int ac, char *av[]) +{ + sc_signal<bool> cs("CS"); + sc_signal<bool> we("WE"); + signal_bool_vector10 addr("Address"); + signal_bool_vector32 data1("Data1"); + signal_bool_vector32 data2("Data2"); + + sc_clock clk("Clock", 20, SC_NS, 0.5, 0.0, SC_NS); + + accessor A("Accessor", clk, data1, cs, we, addr, data2); + ram R("Ram", data2, cs, we, addr, data1); + + sc_start(560, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.cpp new file mode 100644 index 000000000..2296a9770 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.cpp @@ -0,0 +1,60 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ram.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ram.cc */ +/* This is the implementation file for asynchronous process `ram' */ + +#include "ram.h" + +extern int global_mem[]; + +void ram::entry() +{ + int address; + + if (cs.read() == true) { // Block selected + address = addr.read().to_int(); + if (we.read() == true) { // Write operation + global_mem[address] = datain.read().to_int(); + } + else { // Read operation + dataout.write(global_mem[address]); + } + } + // else block not selected +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.h new file mode 100644 index 000000000..cbbcd56f5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.h @@ -0,0 +1,74 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ram.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ram.h */ +/* This is the interface file for asynchronous process 'ram' */ + +#include "common.h" + +SC_MODULE( ram ) +{ + SC_HAS_PROCESS( ram ); + + const signal_bool_vector32& datain; //input + const sc_signal<bool>& cs; //input + const sc_signal<bool>& we; //input + const signal_bool_vector10& addr; //input + signal_bool_vector32& dataout; //output + + //Constructor + ram(sc_module_name NAME, + const signal_bool_vector32& DATAIN, + const sc_signal<bool>& CS, + const sc_signal<bool>& WE, + const signal_bool_vector10& ADDR, + signal_bool_vector32& DATAOUT) + : datain(DATAIN), cs(CS), we(WE), + addr(ADDR), dataout(DATAOUT) + { + SC_METHOD( entry ); + sensitive << datain; + sensitive << cs; + sensitive << we; + sensitive << addr; + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.cpp new file mode 100644 index 000000000..dbab69698 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.cpp @@ -0,0 +1,84 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accessor.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accessor.cc */ +/* This is the implementation file for synchronous process 'accessor' */ + +#include "accessor.h" + +void accessor::entry() +{ + int addr; + int datao; + int datai; + + addr = 10; + datao = 0xdeadbeef; + + while (true) { + // Write memory location first + chip_select.write(true); + write_enable.write(true); + address.write(addr); + dataout.write(datao); + cout << "Accessor: Data Written = " << hex << datao << " at address " + << hex << addr << endl; + wait(memory_latency); // To make all the outputs appear at the interface + + // some process functionality not shown here during which chip + // chip select is deasserted and bus is tristated + chip_select.write(false); + dataout.write(0); + wait(); + + // Now read memory location + chip_select.write(true); + write_enable.write(false); + address.write(addr); + wait(memory_latency); // For data to appear + + datai = datain.read().to_int(); + cout << "Accessor: Data Read = " << hex << datai << " from address " + << hex << addr << endl; + chip_select.write(false); + wait(); + + addr++; + datao++; + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.h new file mode 100644 index 000000000..74e1ad141 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/accessor.h @@ -0,0 +1,79 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accessor.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accessor.h */ +/* This is the interface file for synchronous process 'accessor' */ + +#include "common.h" + +SC_MODULE( accessor ) +{ + SC_HAS_PROCESS( accessor ); + + sc_in_clk clk; + + const signal_bool_vector32& datain; //input + sc_signal<bool>& chip_select; //output + sc_signal<bool>& write_enable; //output + signal_bool_vector10& address; //output + signal_bool_vector32& dataout; //output + + // Parameter + const int memory_latency; + + //Constructor + accessor(sc_module_name NAME, + sc_clock& CLK, + const signal_bool_vector32& DATAIN, + sc_signal<bool>& CHIP_SELECT, + sc_signal<bool>& WRITE_ENABLE, + signal_bool_vector10& ADDRESS, + signal_bool_vector32& DATAOUT, + const int MEMORY_LATENCY = 1) + : datain(DATAIN), chip_select(CHIP_SELECT), + write_enable(WRITE_ENABLE), address(ADDRESS), dataout(DATAOUT), + memory_latency(MEMORY_LATENCY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/chpt12.2.f b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/chpt12.2.f new file mode 100644 index 000000000..b0f5c4a21 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/chpt12.2.f @@ -0,0 +1,3 @@ +chpt12.2/accessor.cpp +chpt12.2/main.cpp +chpt12.2/ram.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/common.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/common.h new file mode 100644 index 000000000..5bdfda659 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/common.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_signal<sc_bv<10> > signal_bool_vector10; +typedef sc_signal<sc_bv<32> > signal_bool_vector32; + +#endif diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/golden/chpt12.2.log b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/golden/chpt12.2.log new file mode 100644 index 000000000..6ac89b345 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/golden/chpt12.2.log @@ -0,0 +1,18 @@ +SystemC Simulation +Accessor: Data Written = deadbeef at address a +Accessor: Data Read = deadbeef from address a +Accessor: Data Written = deadbef0 at address b +Accessor: Data Read = deadbef0 from address b +Accessor: Data Written = deadbef1 at address c +Accessor: Data Read = deadbef1 from address c +Accessor: Data Written = deadbef2 at address d +Accessor: Data Read = deadbef2 from address d +Accessor: Data Written = deadbef3 at address e +Accessor: Data Read = deadbef3 from address e +Accessor: Data Written = deadbef4 at address f +Accessor: Data Read = deadbef4 from address f +Accessor: Data Written = deadbef5 at address 10 +Accessor: Data Read = deadbef5 from address 10 +Accessor: Data Written = deadbef6 at address 11 +Accessor: Data Read = deadbef6 from address 11 +Accessor: Data Written = deadbef7 at address 12 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/main.cpp new file mode 100644 index 000000000..148ed84db --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/main.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for memory simulation */ + +#include "accessor.h" +#include "ram.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<bool> cs("CS"); + sc_signal<bool> we("WE"); + signal_bool_vector10 addr("Address"); + signal_bool_vector32 data1("Data1"); + signal_bool_vector32 data2("Data2"); + const int delay_cycles = 2; + + sc_clock clk("Clock", 20, SC_NS, 0.5, 0.0, SC_NS); + + accessor A("Accessor", clk, data1, cs, we, addr, data2, delay_cycles); + ram R("Ram", clk, data2, cs, we, addr, data1, delay_cycles); + + sc_start(1060, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.cpp new file mode 100644 index 000000000..2aa9a5c47 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.cpp @@ -0,0 +1,62 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ram.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ram.cc */ +/* This is the implementation file for asynchronous process `ram' */ + +#include "ram.h" + +void ram::entry() +{ + int address; + + while (true) { + do { wait(); } while (cs != true); + address = addr.read().to_int(); + if (we.read() == true) { // Write operation + wait(wait_cycles-1); + memory[address] = datain.read().to_int(); + } + else { // Read operation + if (wait_cycles > 2) + wait(wait_cycles-2); // Introduce delay needed + dataout.write(memory[address]); + wait(); + } + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.h b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.h new file mode 100644 index 000000000..f1b3b824b --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt12.2/ram.h @@ -0,0 +1,81 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ram.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ram.h */ +/* This is the interface file for synchronous process 'ram' */ + +#include "common.h" + +SC_MODULE( ram ) +{ + SC_HAS_PROCESS( ram ); + + sc_in_clk clk; + + const signal_bool_vector32& datain; //input + const sc_signal<bool>& cs; //input + const sc_signal<bool>& we; //input + const signal_bool_vector10& addr; //input + signal_bool_vector32& dataout; //output + + // Internal variable + int memory[4000]; + + // Parameter + const int wait_cycles; // Number of cycles it takes to access memory + + //Constructor + ram(sc_module_name NAME, + sc_clock& TICK, + const signal_bool_vector32& DATAIN, + const sc_signal<bool>& CS, + const sc_signal<bool>& WE, + const signal_bool_vector10& ADDR, + signal_bool_vector32& DATAOUT, + const int WAIT_CYCLES = 1) + : datain(DATAIN), cs(CS), we(WE), + addr(ADDR), dataout(DATAOUT), wait_cycles(WAIT_CYCLES) + { + clk(TICK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/chpt14.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/chpt14.1.f new file mode 100644 index 000000000..6ce18bf40 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/chpt14.1.f @@ -0,0 +1,3 @@ +chpt14.1/main.cpp +chpt14.1/proc1.cpp +chpt14.1/proc2.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/golden/chpt14.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/golden/chpt14.1.log new file mode 100644 index 000000000..81d08281a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/golden/chpt14.1.log @@ -0,0 +1,33 @@ +SystemC Simulation + +Proc1: Initiating Transfer +Proc1: Data Ready has value = 1 at time 20 ns +Proc1: Data Ack has value = 0 at same time +Proc2: Received data = 10 at time 20 ns +Proc1: Data Ack Received at time 30 ns +Proc1: Data Ready has value = 0 at time 40 ns +Proc1: Transfer complete + +Proc1: Initiating Transfer +Proc1: Data Ready has value = 1 at time 50 ns +Proc1: Data Ack has value = 0 at same time +Proc2: Received data = 11 at time 50 ns +Proc1: Data Ack Received at time 60 ns +Proc1: Data Ready has value = 0 at time 70 ns +Proc1: Transfer complete + +Proc1: Initiating Transfer +Proc1: Data Ready has value = 1 at time 80 ns +Proc1: Data Ack has value = 0 at same time +Proc2: Received data = 12 at time 80 ns +Proc1: Data Ack Received at time 90 ns +Proc1: Data Ready has value = 0 at time 100 ns +Proc1: Transfer complete + +Proc1: Initiating Transfer +Proc1: Data Ready has value = 1 at time 110 ns +Proc1: Data Ack has value = 0 at same time +Proc2: Received data = 13 at time 110 ns + +Info: /OSCI/SystemC: Simulation stopped by user. +SIMULATION COMPLETED AT TIME 110 ns diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/main.cpp new file mode 100644 index 000000000..0d21a9bb9 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/main.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for handshaking simulation */ + +#include "proc1.h" +#include "proc2.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<bool> data_ready; + sc_signal<bool> data_ack; + sc_signal<int> data; + + sc_clock clock("CLOCK", 10, SC_NS, 0.5, 0.0, SC_NS); + + proc1 Master("MasterProcess", clock, data_ack, data, data_ready); + proc2 Slave("SlaveProcess", clock, data_ready, data, data_ack); + + sc_start(); + cout << "SIMULATION COMPLETED AT TIME " << sc_time_stamp() << endl; + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.cpp new file mode 100644 index 000000000..2c7463e42 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + proc1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename proc1.cc */ +/* This is the implementation file for synchronous process `proc1' */ + +#include "proc1.h" + +void proc1::entry() +{ + int i = 10; + + data_ready.write(false); + wait(); + + while(true) { + cout << endl << "Proc1: Initiating Transfer" << endl; + data_ready.write(true); + data.write(i++); + wait(); + cout << "Proc1: Data Ready has value = " << data_ready.read() + << " at time " << sc_time_stamp() << endl; + cout << "Proc1: Data Ack has value = " << data_ack.read() + << " at same time" << endl; + do { wait(); } while (data_ack != true); + cout << "Proc1: Data Ack Received at time " << sc_time_stamp() << + endl; + data_ready.write(false); + wait(); + cout << "Proc1: Data Ready has value = " << data_ready.read() + << " at time " << sc_time_stamp() << endl; + cout << "Proc1: Transfer complete" << endl; + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.h b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.h new file mode 100644 index 000000000..85e801580 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + proc1.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename proc1.h */ +/* This is the interface file for synchronous process `proc1' */ + +#include "systemc.h" + +SC_MODULE( proc1 ) +{ + SC_HAS_PROCESS( proc1 ); + + sc_in_clk clk; + + const sc_signal<bool>& data_ack; //input + sc_signal<int>& data; //output + sc_signal<bool>& data_ready; //output + + //Constructor + proc1(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<bool>& DATA_ACK, + sc_signal<int>& DATA, + sc_signal<bool>& DATA_READY) + : data_ack(DATA_ACK), data(DATA), data_ready(DATA_READY) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.cpp new file mode 100644 index 000000000..6047baea9 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + proc2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename proc2.cc */ +/* This is the implementation file for synchronous process `proc2' */ + +#include "proc2.h" + +void proc2::entry() +{ + int i; + + data_ack.write(false); + wait(); + + while (true) { + do { wait(); } while (data_ready != true); + i = data.read(); + cout << "Proc2: Received data = " << i << " at time " << + sc_time_stamp() << endl; + if (i > 12) { + sc_stop(); + } + data_ack.write(true); + wait(); + do { wait(); } while (data_ready != false); + data_ack.write(false); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.h b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.h new file mode 100644 index 000000000..d056542c2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + proc2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename proc2.h */ +/* This is the interface file for synchronous process `proc2' */ + +#include "systemc.h" + +SC_MODULE( proc2 ) +{ + SC_HAS_PROCESS( proc2 ); + + sc_in_clk clk; + + const sc_signal<bool>& data_ready; //input + const sc_signal<int>& data; //input + sc_signal<bool>& data_ack; //output + + //Constructor + proc2(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<bool>& DATA_READY, + const sc_signal<int>& DATA, + sc_signal<bool>& DATA_ACK) + : data_ready(DATA_READY), data(DATA), data_ack(DATA_ACK) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/chpt3.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/chpt3.1.f new file mode 100644 index 000000000..e036afa06 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/chpt3.1.f @@ -0,0 +1,4 @@ +chpt3.1/counter.cpp +chpt3.1/fsmr.cpp +chpt3.1/main.cpp +chpt3.1/sg.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.cpp new file mode 100644 index 000000000..a5cf06e8f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + counter.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality of counter */ + +#include "counter.h" + +void counter::entry() +{ + int count; + + count = 0; + while (true) { // infinite loop + do { wait(); } while (found != true); + count = count + 1; + cout << "\nFound Count is " << count << endl; + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.h new file mode 100644 index 000000000..400246f5f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/counter.h @@ -0,0 +1,62 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + counter.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for the counter that counts number of strings found */ + +#include "systemc.h" + +SC_MODULE( counter ) +{ + SC_HAS_PROCESS( counter ); + + sc_in_clk clk; + + // The inputs + const sc_signal<bool>& found; + + // The constructor + counter(sc_module_name NAME, + sc_clock& POS_CLK, + const sc_signal<bool>& FOUND) + : found(FOUND) { + clk(POS_CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // The main functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.cpp new file mode 100644 index 000000000..d2fef570d --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.cpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + fsmr.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality of the FSM recognizer */ + +#include "fsmr.h" + +void fsm_recognizer::entry() +{ + char c; + int state = 0; + bool out; + + while (true) { + do { wait(); } while (data_ready != true); + c = input_char.read(); + cout << c << flush; + + switch(state) { + case 0: + if (c == pattern[0]) state = 1; + else state = 0; + out = false; + break; + case 1: + if (c == pattern[1]) state = 2; + else state = 0; + out = false; + break; + case 2: + if (c == pattern[2]) state = 3; + else state = 0; + out = false; + break; + case 3: + if (c == pattern[3]) out = true; + else out = false; + state = 0; + break; + default: + cout << "Error: FSM in bad state." << endl; + break; + } + + found.write(out); + wait(); // for writing the found signal + found.write(false); // reset the found signal + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.h new file mode 100644 index 000000000..237afcfae --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/fsmr.h @@ -0,0 +1,76 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + fsmr.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for FSM recognizer */ + +#include "systemc.h" + +SC_MODULE( fsm_recognizer ) +{ + SC_HAS_PROCESS( fsm_recognizer ); + + sc_in_clk clk; + + // The input signals + const sc_signal<char>& input_char; // The input character + const sc_signal<bool>& data_ready; // The data ready signal + // The output signals + sc_signal<bool>& found; // The indicator that sequence found + + // The internal variables + char pattern[4]; // This string will hold the pattern to match against + + // The constructor + fsm_recognizer(sc_module_name NAME, + sc_clock& TICK, + const sc_signal<char>& INPUT_CHAR, + const sc_signal<bool>& DATA_READY, + sc_signal<bool>& FOUND) + : input_char(INPUT_CHAR), data_ready(DATA_READY), + found(FOUND) { + clk(TICK); + SC_CTHREAD( entry, clk.pos() ); + found = 0; + pattern[0] = 'S'; + pattern[1] = 'c'; + pattern[2] = 'e'; + pattern[3] = 'n'; + } + + // The functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/golden/chpt3.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/golden/chpt3.1.log new file mode 100644 index 000000000..52e7c3766 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/golden/chpt3.1.log @@ -0,0 +1,12 @@ +SystemC Simulation +Synopsys is delivering great value through Scen +Found Count is 1 +ic. I cannot wait to use Scen +Found Count is 2 +ic +Compiler and Scen +Found Count is 3 +ic Simulator. I am learning a lot about modeling using +Scen +Found Count is 4 +ic. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/main.cpp new file mode 100644 index 000000000..d432b7f42 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/main.cpp @@ -0,0 +1,63 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main routine - top level */ + +#include "counter.h" +#include "sg.h" +#include "fsmr.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<bool> handshake ("HS"); + sc_signal<bool> found; + sc_signal<char> stream ("ST"); + + sc_clock clk("Clock", 20, SC_NS, 0.5, 0.0, SC_NS); + + counter cnt("COUNTER", clk, found); + fsm_recognizer fsm("Recog", clk, stream, handshake, found); + stimgen chargen("TESTB", clk, stream, handshake); + + int n; + if (ac == 2) n = atoi(av[1]); + else n = 6340; + sc_start(n, SC_NS); + cout << endl; + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.cpp new file mode 100644 index 000000000..65edd73e6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + sg.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality for the Stimulus Generator */ + +#include "sg.h" + +void stimgen::entry() +{ + char c; + FILE *file; + + file = fopen("./chpt3.1/testcase", "r"); + + while (true) { + fscanf(file, "%c", &c); + data_ready.write(true); + stream.write(c); + wait(); + data_ready.write(false); + wait(); + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.h new file mode 100644 index 000000000..937c3169e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/sg.h @@ -0,0 +1,64 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + sg.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for the stimulus generator */ + +#include "systemc.h" + +SC_MODULE( stimgen ) +{ + SC_HAS_PROCESS( stimgen ); + + sc_in_clk clk; + + // The output + sc_signal<char>& stream; + sc_signal<bool>& data_ready; + + // The constructor + stimgen(sc_module_name NAME, + sc_clock& CLK, + sc_signal<char>& STREAM, + sc_signal<bool>& DATA_READY) + : stream(STREAM), data_ready(DATA_READY) { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // The functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.1/testcase b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/testcase new file mode 100644 index 000000000..3b56603ff --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.1/testcase @@ -0,0 +1,9 @@ +Synopsys is delivering great value through Scenic. I cannot wait to use Scenic +Compiler and Scenic Simulator. I am learning a lot about modeling using +Scenic. + +This is a testcase for my first Scenic program. I have learnt modeling using +Scenic and would now like to check if I can really program in Scenic. There is +no doubt in my mind that Scenic is the best way to model hardware. The Scenic +Compiler will make a lot of things easy by implementing by refined Scenic +models. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f new file mode 100644 index 000000000..88feda635 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f @@ -0,0 +1,4 @@ +chpt3.2/counter.cpp +chpt3.2/fsmr.cpp +chpt3.2/main.cpp +chpt3.2/sg.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp new file mode 100644 index 000000000..7dbab48d1 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + counter.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality of counter */ + +#include "counter.h" + +void counter::entry() +{ + int count; + + count = 0; + while (true) { // infinite loop + do { wait(); } while (found != true); + count = count + 1; + cout << "\nFound Count is " << count << "\n"; + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h new file mode 100644 index 000000000..400246f5f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h @@ -0,0 +1,62 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + counter.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for the counter that counts number of strings found */ + +#include "systemc.h" + +SC_MODULE( counter ) +{ + SC_HAS_PROCESS( counter ); + + sc_in_clk clk; + + // The inputs + const sc_signal<bool>& found; + + // The constructor + counter(sc_module_name NAME, + sc_clock& POS_CLK, + const sc_signal<bool>& FOUND) + : found(FOUND) { + clk(POS_CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // The main functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp new file mode 100644 index 000000000..adb1a9c81 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp @@ -0,0 +1,83 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + fsmr.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality of the FSM recognizer */ + +#include "fsmr.h" + +void fsm_recognizer::entry() +{ + char c; + int state = 0; + bool out; + + while (true) { + do { wait(); } while (data_ready != true); + c = input_char.read(); + cout << c; + + switch(state) { + case 0: + if (c == pattern[0]) state = 1; + else state = 0; + out = false; + break; + case 1: + if (c == pattern[1]) state = 2; + else state = 0; + out = false; + break; + case 2: + if (c == pattern[2]) state = 3; + else state = 0; + out = false; + break; + case 3: + if (c == pattern[3]) out = true; + else out = false; + state = 0; + break; + default: + cout << "Error: FSM in bad state." << endl; + break; + } + + found.write(out); + wait(); // for writing the found signal + found.write(false); // reset the found signal + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h new file mode 100644 index 000000000..13b192655 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h @@ -0,0 +1,75 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + fsmr.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for FSM recognizer */ + +#include "systemc.h" + +SC_MODULE( fsm_recognizer ) +{ + SC_HAS_PROCESS( fsm_recognizer ); + + sc_in_clk clk; + + // The input signals + const sc_signal<char>& input_char; // The input character + const sc_signal<bool>& data_ready; // The data ready signal + // The output signals + sc_signal<bool>& found; // The indicator that sequence found + + // The internal variables + char pattern[4]; // This string will hold the pattern to match against + + // The constructor + fsm_recognizer(sc_module_name NAME, + sc_clock& TICK, + const sc_signal<char>& INPUT_CHAR, + const sc_signal<bool>& DATA_READY, + sc_signal<bool>& FOUND) + : input_char(INPUT_CHAR), data_ready(DATA_READY), + found(FOUND) { + clk(TICK); + SC_CTHREAD( entry, clk.pos() ); + pattern[0] = 'S'; + pattern[1] = 'c'; + pattern[2] = 'e'; + pattern[3] = 'n'; + } + + // The functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log new file mode 100644 index 000000000..959b3c600 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log @@ -0,0 +1,32 @@ +SystemC Simulation +Synopsys is delivering great value through Scen +Found Count is 1 +ic. I cannot wait to use Scen +Found Count is 2 +ic +Compiler and Scen +Found Count is 3 +ic Simulator. I am learning a lot about modeling using +Scen +Found Count is 4 +ic. + +This is a testcase for my first Scen +Found Count is 5 +ic program. I have learnt modeling using +Scen +Found Count is 6 +ic and would now like to check if I can really program in Scen +Found Count is 7 +ic. There is +no doubt in my mind that Scen +Found Count is 8 +ic is the best way to model hardware. The Scen +Found Count is 9 +ic +Compiler will make a lot of things easy by implementing by refined Scen +Found Count is 10 +ic +models. + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp new file mode 100644 index 000000000..eeed80090 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp @@ -0,0 +1,63 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main routine - top level */ + +#include "counter.h" +#include "sg.h" +#include "fsmr.h" + +int sc_main(int ac, char **av) +{ + sc_signal<bool> handshake ("HS"); + sc_signal<bool> found; + sc_signal<char> stream ("ST"); + + sc_clock clk("Clock", 20, SC_NS, 0.5, 0.0, SC_NS); + + counter cnt("COUNTER", clk, found); + fsm_recognizer fsm("Recog", clk, stream, handshake, found); + stimgen chargen("TESTB", clk, stream, handshake); + + // initialize signals - ali + handshake = false; + found = false; + + sc_start(); + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp new file mode 100644 index 000000000..995d4a2c5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp @@ -0,0 +1,58 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + sg.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* File containing functionality for the Stimulus Generator */ + +#include "sg.h" + +void stimgen::entry() +{ + char c; + FILE *file; + + file = fopen("./chpt3.2/testcase", "r"); + + while (true) { + if (fscanf(file, "%c", &c) == EOF) + sc_stop(); + data_ready.write(true); + stream.write(c); + wait(); + data_ready.write(false); + wait(); + } +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h new file mode 100644 index 000000000..937c3169e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h @@ -0,0 +1,64 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + sg.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Header file for the stimulus generator */ + +#include "systemc.h" + +SC_MODULE( stimgen ) +{ + SC_HAS_PROCESS( stimgen ); + + sc_in_clk clk; + + // The output + sc_signal<char>& stream; + sc_signal<bool>& data_ready; + + // The constructor + stimgen(sc_module_name NAME, + sc_clock& CLK, + sc_signal<char>& STREAM, + sc_signal<bool>& DATA_READY) + : stream(STREAM), data_ready(DATA_READY) { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // The functionality of the process + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase new file mode 100644 index 000000000..3b56603ff --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase @@ -0,0 +1,9 @@ +Synopsys is delivering great value through Scenic. I cannot wait to use Scenic +Compiler and Scenic Simulator. I am learning a lot about modeling using +Scenic. + +This is a testcase for my first Scenic program. I have learnt modeling using +Scenic and would now like to check if I can really program in Scenic. There is +no doubt in my mind that Scenic is the best way to model hardware. The Scenic +Compiler will make a lot of things easy by implementing by refined Scenic +models. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/chpt4.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/chpt4.1.f new file mode 100644 index 000000000..e0ed6002a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/chpt4.1.f @@ -0,0 +1,6 @@ +chpt4.1/display.cpp +chpt4.1/main.cpp +chpt4.1/numgen.cpp +chpt4.1/stage1.cpp +chpt4.1/stage2.cpp +chpt4.1/stage3.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.cpp new file mode 100644 index 000000000..ae725e8b2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.cc */ +/* This is the implementation file for synchronous process `display' */ + +#include "display.h" + +void display::entry() +{ + while (true) { + char buf[BUFSIZ]; + sprintf( buf, "Result = %.16g", in.read() ); + cout << buf << endl; + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.h new file mode 100644 index 000000000..176856285 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/display.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.h */ +/* This is the interface file for synchronous process `display' */ + +#include "systemc.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + sc_in_clk clk; + + const sc_signal<double>& in; //input + + //Constructor + display(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN_) + : in(IN_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log new file mode 100644 index 000000000..2632f0378 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.bsd64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.cygwin64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.cygwin64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.cygwin64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw64 new file mode 100644 index 000000000..cbad61984 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.mingw64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111162 +Result = 7.880663294494538e+023 +Result = 5.025308156461848e+022 +Result = 3.785504588212779e+021 +Result = 3.318767046037847e+020 +Result = 3.342044498889828e+019 +Result = 3.820952118187873e+018 +Result = 4.908588040698598e+017 +Result = 7.020262707849121e+016 +Result = 1.108584445158e+016 +Result = 1918564708588396 +Result = 361468937900785.8 +Result = 73693454684249.83 +Result = 16168706434671.58 +Result = 3798873238107.02 +Result = 951496336681.9108 +Result = 253014396064.4429 +Result = 71160144395.97923 +Result = 21095409040.56878 +Result = 6570959918.81201 +Result = 2144377535.813799 +Result = 731219410.5057683 +Result = 259897217.2803262 +Result = 96068017.3665321 +Result = 36852754.87464552 +Result = 14643125.53882816 +Result = 6015770.001652751 +Result = 2551056.2523366 +Result = 1114936.454099942 +Result = 501486.5582467155 +Result = 231829.9907002871 +Result = 110013.0011393046 +Result = 53528.29122037047 +Result = 26676.20253819451 +Result = 13603.0193391548 +Result = 7091.170580193591 +Result = 3775.739764121695 +Result = 2051.852446275869 +Result = 1137.197386657551 +Result = 642.367482946381 +Result = 369.5965461434236 +Result = 216.4882041213385 +Result = 129.0313860266489 +Result = 78.22278438714326 +Result = 48.21719670307594 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc10-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc11-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/golden/chpt4.1.log.msvc12-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/main.cpp new file mode 100644 index 000000000..d9b80752d --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/main.cpp @@ -0,0 +1,68 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for pipeline simulation */ + +#include "stage1.h" +#include "stage2.h" +#include "stage3.h" +#include "display.h" +#include "numgen.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<double> in1; + sc_signal<double> in2; + sc_signal<double> sum; + sc_signal<double> diff; + sc_signal<double> prod; + sc_signal<double> quot; + sc_signal<double> powr; + powr = 0.0; + + sc_clock clk("CLOCK", 20.0, SC_NS, 0.5, 0.0, SC_NS); + + numgen N("STIMULUS", clk, in1, in2); + stage1 S1("Stage1", clk, in1, in2, sum, diff); + stage2 S2("Stage2", clk, sum, diff, prod, quot); + stage3 S3("Stage3", clk, prod, quot, powr); + display D("Display", clk, powr); + + sc_start(1000, SC_NS); + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.cpp new file mode 100644 index 000000000..77887df1a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.cc */ +/* This is the implementation file for synchronous process `numgen' */ + +#include "numgen.h" + +void numgen::entry() +{ + double a = 134.56; + double b = 98.24; + + while (true) { + a -= 1.5; + b -= 2.8; + out1.write(a); + out2.write(b); + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.h new file mode 100644 index 000000000..c56670c86 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/numgen.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.h */ +/* This is the interface file for synchronous process `numgen' */ + +#include "systemc.h" + +SC_MODULE( numgen ) +{ + SC_HAS_PROCESS( numgen ); + + sc_in_clk clk; + + sc_signal<double>& out1; //output + sc_signal<double>& out2; //output + + //Constructor + numgen(sc_module_name NAME, + sc_clock& CLK, + sc_signal<double>& OUT1, + sc_signal<double>& OUT2) + : out1(OUT1), out2(OUT2) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.cpp new file mode 100644 index 000000000..58a59f7ab --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.cc */ +/* This is the implementation file for synchronous process `stage1' */ + +#include "stage1.h" + +void stage1::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + sum.write(a+b); + diff.write(a-b); + wait(); + a = in1.read(); + b = in2.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.h new file mode 100644 index 000000000..5f5cc8044 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage1.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.h */ +/* This is the interface file for synchronous process `stage1' */ + +#include "systemc.h" + +SC_MODULE( stage1 ) +{ + SC_HAS_PROCESS( stage1 ); + + sc_in_clk clk; + + const sc_signal<double>& in1; //input + const sc_signal<double>& in2; //input + sc_signal<double>& sum; //output + sc_signal<double>& diff; //output + + //Constructor + stage1(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& SUM, + sc_signal<double>& DIFF) + : in1(IN1), in2(IN2), sum(SUM), diff(DIFF) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.cpp new file mode 100644 index 000000000..7a80f1f50 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.cc */ +/* This is the implementation file for synchronous process `stage2' */ + +#include "stage2.h" + +void stage2::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + prod.write(a*b); + quot.write(a/b); + wait(); + a = sum.read(); + b = diff.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.h new file mode 100644 index 000000000..5e8e788d1 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage2.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.h */ +/* This is the interface file for synchronous process `stage2' */ + +#include "systemc.h" + +SC_MODULE( stage2 ) +{ + SC_HAS_PROCESS( stage2 ); + + sc_in_clk clk; + + const sc_signal<double>& sum; //input + const sc_signal<double>& diff; //input + sc_signal<double>& prod; //output + sc_signal<double>& quot; //output + + //Constructor + stage2(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& SUM, + const sc_signal<double>& DIFF, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) + : sum(SUM), diff(DIFF), prod(PROD), quot(QUOT) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.cpp new file mode 100644 index 000000000..2cdb4f519 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.cc */ +/* This is the implementation file for synchronous process `stage3' */ + +#include <math.h> +#include "stage3.h" + +void stage3::entry() +{ + double a, b; + double c; + + a = 20.0; + b = 5.0; + while (true) { + c = pow(a, b); + powr.write(c); + wait(); + a = prod.read(); + b = quot.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.h new file mode 100644 index 000000000..60bb8caad --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.h */ +/* This is the interface file for synchronous process `stage3' */ + +#include "systemc.h" + +SC_MODULE( stage3 ) +{ + SC_HAS_PROCESS( stage3 ); + + sc_in_clk clk; + + const sc_signal<double>& prod; //input + const sc_signal<double>& quot; //input + sc_signal<double>& powr; //output + + //Constructor + stage3(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& PROD, + const sc_signal<double>& QUOT, + sc_signal<double>& POWR) + : prod(PROD), quot(QUOT), powr(POWR) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/chpt4.2.f b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/chpt4.2.f new file mode 100644 index 000000000..17905fc7b --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/chpt4.2.f @@ -0,0 +1,6 @@ +chpt4.2/display.cpp +chpt4.2/main.cpp +chpt4.2/numgen.cpp +chpt4.2/stage1.cpp +chpt4.2/stage2.cpp +chpt4.2/stage3.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.cpp new file mode 100644 index 000000000..ae725e8b2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.cc */ +/* This is the implementation file for synchronous process `display' */ + +#include "display.h" + +void display::entry() +{ + while (true) { + char buf[BUFSIZ]; + sprintf( buf, "Result = %.16g", in.read() ); + cout << buf << endl; + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.h new file mode 100644 index 000000000..176856285 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/display.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.h */ +/* This is the interface file for synchronous process `display' */ + +#include "systemc.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + sc_in_clk clk; + + const sc_signal<double>& in; //input + + //Constructor + display(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN_) + : in(IN_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log new file mode 100644 index 000000000..2632f0378 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.bsd64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.cygwin64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.cygwin64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.cygwin64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw64 new file mode 100644 index 000000000..cbad61984 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.mingw64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111162 +Result = 7.880663294494538e+023 +Result = 5.025308156461848e+022 +Result = 3.785504588212779e+021 +Result = 3.318767046037847e+020 +Result = 3.342044498889828e+019 +Result = 3.820952118187873e+018 +Result = 4.908588040698598e+017 +Result = 7.020262707849121e+016 +Result = 1.108584445158e+016 +Result = 1918564708588396 +Result = 361468937900785.8 +Result = 73693454684249.83 +Result = 16168706434671.58 +Result = 3798873238107.02 +Result = 951496336681.9108 +Result = 253014396064.4429 +Result = 71160144395.97923 +Result = 21095409040.56878 +Result = 6570959918.81201 +Result = 2144377535.813799 +Result = 731219410.5057683 +Result = 259897217.2803262 +Result = 96068017.3665321 +Result = 36852754.87464552 +Result = 14643125.53882816 +Result = 6015770.001652751 +Result = 2551056.2523366 +Result = 1114936.454099942 +Result = 501486.5582467155 +Result = 231829.9907002871 +Result = 110013.0011393046 +Result = 53528.29122037047 +Result = 26676.20253819451 +Result = 13603.0193391548 +Result = 7091.170580193591 +Result = 3775.739764121695 +Result = 2051.852446275869 +Result = 1137.197386657551 +Result = 642.367482946381 +Result = 369.5965461434236 +Result = 216.4882041213385 +Result = 129.0313860266489 +Result = 78.22278438714326 +Result = 48.21719670307594 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc10-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc11-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/golden/chpt4.2.log.msvc12-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/main.cpp new file mode 100644 index 000000000..6ceda6f1c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/main.cpp @@ -0,0 +1,66 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for pipeline simulation */ + +#include "stage1.h" +#include "stage2.h" +#include "stage3.h" +#include "display.h" +#include "numgen.h" +#include "stage1_2.h" +#include "pipeline.h" +#include "testbench.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<double> in1; + sc_signal<double> in2; + sc_signal<double> powr; + + in1 = 0.0; + in2 = 0.0; + powr = 0.0; + sc_clock clk("CLOCK", 20.0, SC_NS, 0.5, 0.0, SC_NS); + + testbench T("Testbench", clk, powr, in1, in2); + pipeline P("PIPE", clk, in1, in2, powr); + + sc_start(1000, SC_NS); + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.cpp new file mode 100644 index 000000000..77887df1a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.cc */ +/* This is the implementation file for synchronous process `numgen' */ + +#include "numgen.h" + +void numgen::entry() +{ + double a = 134.56; + double b = 98.24; + + while (true) { + a -= 1.5; + b -= 2.8; + out1.write(a); + out2.write(b); + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.h new file mode 100644 index 000000000..c56670c86 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/numgen.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.h */ +/* This is the interface file for synchronous process `numgen' */ + +#include "systemc.h" + +SC_MODULE( numgen ) +{ + SC_HAS_PROCESS( numgen ); + + sc_in_clk clk; + + sc_signal<double>& out1; //output + sc_signal<double>& out2; //output + + //Constructor + numgen(sc_module_name NAME, + sc_clock& CLK, + sc_signal<double>& OUT1, + sc_signal<double>& OUT2) + : out1(OUT1), out2(OUT2) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/pipeline.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/pipeline.h new file mode 100644 index 000000000..febd18488 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/pipeline.h @@ -0,0 +1,63 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + pipeline.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename pipeline.h */ +/* This is the interface file for module `pipeline' */ + +#include "systemc.h" + +struct pipeline : public sc_module { + sc_signal<double> prod; + sc_signal<double> quot; + + stage1_2 S1_2; // component + stage3 S3; //component + + //Constructor + pipeline(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& OUT_) + : sc_module(NAME), + S1_2("Stage1_2", CLK, IN1, IN2, prod, quot), + S3("Stage3", CLK, prod, quot, OUT_) + { + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.cpp new file mode 100644 index 000000000..58a59f7ab --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.cc */ +/* This is the implementation file for synchronous process `stage1' */ + +#include "stage1.h" + +void stage1::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + sum.write(a+b); + diff.write(a-b); + wait(); + a = in1.read(); + b = in2.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.h new file mode 100644 index 000000000..5f5cc8044 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.h */ +/* This is the interface file for synchronous process `stage1' */ + +#include "systemc.h" + +SC_MODULE( stage1 ) +{ + SC_HAS_PROCESS( stage1 ); + + sc_in_clk clk; + + const sc_signal<double>& in1; //input + const sc_signal<double>& in2; //input + sc_signal<double>& sum; //output + sc_signal<double>& diff; //output + + //Constructor + stage1(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& SUM, + sc_signal<double>& DIFF) + : in1(IN1), in2(IN2), sum(SUM), diff(DIFF) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1_2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1_2.h new file mode 100644 index 000000000..e6ec5fac8 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage1_2.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1_2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1_2.h */ +/* This is the interface file for module `stage1_2' */ + +#include "systemc.h" + +struct stage1_2 : public sc_module { + sc_signal<double> sum; // internal signal + sc_signal<double> diff; // internal signal + + stage1 S1; // component + stage2 S2; // component + + //Constructor + stage1_2(sc_module_name NAME, + sc_clock& TICK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) + : sc_module(NAME), + S1("Stage1", TICK, IN1, IN2, sum, diff), + S2("Stage2", TICK, sum, diff, PROD, QUOT), + sum("SigSum") + { + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.cpp new file mode 100644 index 000000000..7a80f1f50 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.cc */ +/* This is the implementation file for synchronous process `stage2' */ + +#include "stage2.h" + +void stage2::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + prod.write(a*b); + quot.write(a/b); + wait(); + a = sum.read(); + b = diff.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.h new file mode 100644 index 000000000..5e8e788d1 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage2.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.h */ +/* This is the interface file for synchronous process `stage2' */ + +#include "systemc.h" + +SC_MODULE( stage2 ) +{ + SC_HAS_PROCESS( stage2 ); + + sc_in_clk clk; + + const sc_signal<double>& sum; //input + const sc_signal<double>& diff; //input + sc_signal<double>& prod; //output + sc_signal<double>& quot; //output + + //Constructor + stage2(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& SUM, + const sc_signal<double>& DIFF, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) + : sum(SUM), diff(DIFF), prod(PROD), quot(QUOT) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.cpp new file mode 100644 index 000000000..2cdb4f519 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.cc */ +/* This is the implementation file for synchronous process `stage3' */ + +#include <math.h> +#include "stage3.h" + +void stage3::entry() +{ + double a, b; + double c; + + a = 20.0; + b = 5.0; + while (true) { + c = pow(a, b); + powr.write(c); + wait(); + a = prod.read(); + b = quot.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.h new file mode 100644 index 000000000..60bb8caad --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/stage3.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.h */ +/* This is the interface file for synchronous process `stage3' */ + +#include "systemc.h" + +SC_MODULE( stage3 ) +{ + SC_HAS_PROCESS( stage3 ); + + sc_in_clk clk; + + const sc_signal<double>& prod; //input + const sc_signal<double>& quot; //input + sc_signal<double>& powr; //output + + //Constructor + stage3(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& PROD, + const sc_signal<double>& QUOT, + sc_signal<double>& POWR) + : prod(PROD), quot(QUOT), powr(POWR) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.2/testbench.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/testbench.h new file mode 100644 index 000000000..128433c2a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.2/testbench.h @@ -0,0 +1,60 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.h */ +/* This is the interface file for module `testbench' */ + +#include "systemc.h" + +struct testbench : public sc_module { + numgen N; // component + display D; // component + + //Constructor + testbench(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN_, + sc_signal<double>& OUT1, + sc_signal<double>& OUT2) + : sc_module(NAME), + N("Numgen", CLK, OUT1, OUT2), + D("Display", CLK, IN_) + { + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.3/clocks.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/clocks.h new file mode 100644 index 000000000..cf5db589a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/clocks.h @@ -0,0 +1,166 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + clocks.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename clocks.h */ +/* This is an integrated interface & implementation file for */ +/* all clock processes that react to the clock edges */ + +#include "systemc.h" + +// First process +SC_MODULE( clk_pos ) +{ + SC_HAS_PROCESS( clk_pos ); + + sc_in_clk clk; + + sc_signal<bool>& out_clk_pos; + + clk_pos(sc_module_name NAME, + sc_clock& TICK_P, + sc_signal<bool>& OUT_CLK_POS) + : + out_clk_pos(OUT_CLK_POS) + { + clk(TICK_P); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; + +void +clk_pos::entry() +{ + out_clk_pos.write(1); cout << "Clk Pos 1\n"; + wait(); + out_clk_pos.write(0); cout << "Clk Pos 0\n"; + wait(); +} + +// Second process +SC_MODULE( clk_neg ) +{ + SC_HAS_PROCESS( clk_neg ); + + sc_in_clk clk; + + sc_signal<bool>& out_clk_neg; + + clk_neg(sc_module_name NAME, + sc_clock& TICK_N, + sc_signal<bool>& OUT_CLK_NEG) + : + out_clk_neg(OUT_CLK_NEG) + { + clk(TICK_N); + SC_CTHREAD( entry, clk.neg() ); + } + + void entry(); +}; + +void +clk_neg::entry() +{ + out_clk_neg.write(1); cout << "Clk Neg 1\n"; + wait(); + out_clk_neg.write(0); cout << "Clk Neg 0\n"; + wait(); +} + +// Third process +SC_MODULE( clk2_pos ) +{ + SC_HAS_PROCESS( clk2_pos ); + + sc_in_clk clk; + + sc_signal<bool>& out_clk2_pos; + + clk2_pos(sc_module_name NAME, + sc_clock& TICK2_P, + sc_signal<bool>& OUT_CLK2_POS) + : + out_clk2_pos(OUT_CLK2_POS) + { + clk(TICK2_P); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; + +void +clk2_pos::entry() +{ + out_clk2_pos.write(1); cout << "Clk2 Pos 1\n"; + wait(); + out_clk2_pos.write(0); cout << "Clk2 Pos 0\n"; + wait(); +} + +// Fourth process +SC_MODULE( clk2_neg ) +{ + SC_HAS_PROCESS( clk2_neg ); + + sc_in_clk clk; + + sc_signal<bool>& out_clk2_neg; + + clk2_neg(sc_module_name NAME, + sc_clock& TICK2_N, + sc_signal<bool>& OUT_CLK2_NEG) + : + out_clk2_neg (OUT_CLK2_NEG) + { + clk(TICK2_N); + SC_CTHREAD( entry, clk.neg() ); + } + + void entry(); +}; + +void +clk2_neg::entry() +{ + out_clk2_neg.write(1); cout << "Clk2 Neg 1\n"; + wait(); + out_clk2_neg.write(0); cout << "Clk2 Neg 0\n"; + wait(); +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.3/golden/main.log b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/golden/main.log new file mode 100644 index 000000000..969474425 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/golden/main.log @@ -0,0 +1,10 @@ +SystemC Simulation +Clk Pos 1 +Clk2 Pos 1 +Clk2 Neg 1 +Clk Neg 1 +Clk Pos 0 +Clk2 Pos 0 +Clk2 Neg 0 +Clk Neg 0 +Example run successfully diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.3/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/main.cpp new file mode 100644 index 000000000..5bec21ff5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/main.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for clock simulation */ + +#include "clocks.h" +#include "tb.h" + +int sc_main(int ac, char *av[]) +{ + sc_clock clk( "CLK", 20, SC_NS, 0.5, 0, SC_NS); + sc_clock clk2( "CLK2", 20, SC_NS, 0.2, 5, SC_NS); + testbench tb1("TB1", clk, clk2); + + sc_start(80, SC_NS); + cout << "Example run successfully" << endl; + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.3/tb.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/tb.h new file mode 100644 index 000000000..1d9e77c7b --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.3/tb.h @@ -0,0 +1,68 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + tb.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename tb.h */ +/* This is the interface file for the testbench module */ + +#include "systemc.h" + +struct testbench : public sc_module { + sc_signal<bool> out_clk_pos; + sc_signal<bool> out_clk_neg; + sc_signal<bool> out_clk2_pos; + sc_signal<bool> out_clk2_neg; + clk_pos clkp; + clk_neg clkn; + clk2_pos clkp2; + clk2_neg clkn2; + + // Constructor + testbench(sc_module_name NAME, + sc_clock& TICK, + sc_clock& TICK2) + : sc_module (NAME), + out_clk_pos ("out_clk_pos"), + out_clk_neg ("out_clk_neg"), + out_clk2_pos ("out_clk2_pos"), + out_clk2_neg ("out_clk2_neg"), + clkp ("CLKP", TICK, out_clk_pos), + clkn ("CLKN", TICK, out_clk_neg), + clkp2 ("CLKP2", TICK2, out_clk2_pos), + clkn2 ("CLKN2", TICK2, out_clk2_neg) + { + } +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/chpt4.4.f b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/chpt4.4.f new file mode 100644 index 000000000..319f4cc1d --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/chpt4.4.f @@ -0,0 +1,7 @@ +chpt4.4/display.cpp +chpt4.4/main.cpp +chpt4.4/numgen.cpp +chpt4.4/pipeline.cpp +chpt4.4/stage1.cpp +chpt4.4/stage2.cpp +chpt4.4/stage3.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.cpp new file mode 100644 index 000000000..ae725e8b2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.cc */ +/* This is the implementation file for synchronous process `display' */ + +#include "display.h" + +void display::entry() +{ + while (true) { + char buf[BUFSIZ]; + sprintf( buf, "Result = %.16g", in.read() ); + cout << buf << endl; + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.h new file mode 100644 index 000000000..176856285 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/display.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.h */ +/* This is the interface file for synchronous process `display' */ + +#include "systemc.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + sc_in_clk clk; + + const sc_signal<double>& in; //input + + //Constructor + display(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN_) + : in(IN_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_pipeline.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_pipeline.h new file mode 100644 index 000000000..38b7534f4 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_pipeline.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + f_pipeline.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename f_pipeline.h */ +/* This is the functional interface file for module `pipeline' */ + +void f_pipeline(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& OUT); + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage1.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage1.h new file mode 100644 index 000000000..0120bdbd0 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage1.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + f_stage1.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename f_stage1.h */ +/* This is the functional interface file for synchronous process `stage1' */ + +void f_stage1(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& SUM, + sc_signal<double>& DIFF); diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage2.h new file mode 100644 index 000000000..08eaa6529 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage2.h @@ -0,0 +1,46 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + f_stage2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename f_stage2.h */ +/* This is the functional interface file for synchronous process `stage2' */ + +void f_stage2(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& SUM, + const sc_signal<double>& DIFF, + sc_signal<double>& PROD, + sc_signal<double>& QUOT); diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage3.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage3.h new file mode 100644 index 000000000..6532f99ff --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/f_stage3.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + f_stage3.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename f_stage3.h */ +/* This is the functional interface file for synchronous process `stage3' */ + +void f_stage3(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& PROD, + const sc_signal<double>& QUOT, + sc_signal<double>& POWR); diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log new file mode 100644 index 000000000..2632f0378 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.bsd64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.cygwin64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.cygwin64 new file mode 100644 index 000000000..be6a13764 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.cygwin64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+23 +Result = 5.025308156461862e+22 +Result = 3.785504588212786e+21 +Result = 3.318767046037861e+20 +Result = 3.342044498889812e+19 +Result = 3.820952118187878e+18 +Result = 4.9085880406986e+17 +Result = 7.02026270784911e+16 +Result = 1.108584445158003e+16 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812002 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803264 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037049 +Result = 26676.20253819449 +Result = 13603.01933915479 +Result = 7091.170580193586 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463808 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw64 new file mode 100644 index 000000000..cbad61984 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.mingw64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111162 +Result = 7.880663294494538e+023 +Result = 5.025308156461848e+022 +Result = 3.785504588212779e+021 +Result = 3.318767046037847e+020 +Result = 3.342044498889828e+019 +Result = 3.820952118187873e+018 +Result = 4.908588040698598e+017 +Result = 7.020262707849121e+016 +Result = 1.108584445158e+016 +Result = 1918564708588396 +Result = 361468937900785.8 +Result = 73693454684249.83 +Result = 16168706434671.58 +Result = 3798873238107.02 +Result = 951496336681.9108 +Result = 253014396064.4429 +Result = 71160144395.97923 +Result = 21095409040.56878 +Result = 6570959918.81201 +Result = 2144377535.813799 +Result = 731219410.5057683 +Result = 259897217.2803262 +Result = 96068017.3665321 +Result = 36852754.87464552 +Result = 14643125.53882816 +Result = 6015770.001652751 +Result = 2551056.2523366 +Result = 1114936.454099942 +Result = 501486.5582467155 +Result = 231829.9907002871 +Result = 110013.0011393046 +Result = 53528.29122037047 +Result = 26676.20253819451 +Result = 13603.0193391548 +Result = 7091.170580193591 +Result = 3775.739764121695 +Result = 2051.852446275869 +Result = 1137.197386657551 +Result = 642.367482946381 +Result = 369.5965461434236 +Result = 216.4882041213385 +Result = 129.0313860266489 +Result = 78.22278438714326 +Result = 48.21719670307594 +Result = 30.2128638146017 +Result = 19.24141599285792 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc10-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc11-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12-x64 b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12-x64 new file mode 100644 index 000000000..59ff54c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/golden/chpt4.4.log.msvc12-x64 @@ -0,0 +1,51 @@ +SystemC Simulation +Result = 0 +Result = 3200000 +Result = 100000000 +Result = 19500.78584111161 +Result = 7.880663294494549e+023 +Result = 5.025308156461862e+022 +Result = 3.785504588212786e+021 +Result = 3.318767046037861e+020 +Result = 3.342044498889812e+019 +Result = 3.820952118187878e+018 +Result = 4.9085880406986e+017 +Result = 7.02026270784911e+016 +Result = 1.108584445158003e+016 +Result = 1918564708588393 +Result = 361468937900785.4 +Result = 73693454684249.92 +Result = 16168706434671.58 +Result = 3798873238107.018 +Result = 951496336681.913 +Result = 253014396064.4423 +Result = 71160144395.97931 +Result = 21095409040.5688 +Result = 6570959918.812003 +Result = 2144377535.8138 +Result = 731219410.5057685 +Result = 259897217.2803263 +Result = 96068017.36653221 +Result = 36852754.87464556 +Result = 14643125.53882816 +Result = 6015770.001652755 +Result = 2551056.252336602 +Result = 1114936.454099941 +Result = 501486.5582467156 +Result = 231829.9907002873 +Result = 110013.0011393045 +Result = 53528.29122037048 +Result = 26676.2025381945 +Result = 13603.01933915479 +Result = 7091.170580193587 +Result = 3775.739764121693 +Result = 2051.852446275868 +Result = 1137.19738665755 +Result = 642.3674829463809 +Result = 369.5965461434234 +Result = 216.4882041213384 +Result = 129.0313860266488 +Result = 78.22278438714326 +Result = 48.21719670307593 +Result = 30.2128638146017 +Result = 19.24141599285791 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/main.cpp new file mode 100644 index 000000000..9af44ba3e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/main.cpp @@ -0,0 +1,63 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main file for pipeline simulation */ + +#include "display.h" +#include "numgen.h" +#include "testbench.h" +#include "f_pipeline.h" + +int sc_main(int ac, char* av[]) +{ + sc_signal<double> in1; + sc_signal<double> in2; + sc_signal<double> powr; + + in1 = 0.0; + in2 = 0.0; + powr = 0.0; + + sc_clock clk("CLOCK", 20.0, SC_NS, 0.5, 0.0, SC_NS); + + testbench T("Testbench", clk, powr, in1, in2); + f_pipeline("PIPE", clk, in1, in2, powr); + + sc_start(1000, SC_NS); + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.cpp new file mode 100644 index 000000000..77887df1a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.cc */ +/* This is the implementation file for synchronous process `numgen' */ + +#include "numgen.h" + +void numgen::entry() +{ + double a = 134.56; + double b = 98.24; + + while (true) { + a -= 1.5; + b -= 2.8; + out1.write(a); + out2.write(b); + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.h new file mode 100644 index 000000000..c56670c86 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/numgen.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + numgen.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename numgen.h */ +/* This is the interface file for synchronous process `numgen' */ + +#include "systemc.h" + +SC_MODULE( numgen ) +{ + SC_HAS_PROCESS( numgen ); + + sc_in_clk clk; + + sc_signal<double>& out1; //output + sc_signal<double>& out2; //output + + //Constructor + numgen(sc_module_name NAME, + sc_clock& CLK, + sc_signal<double>& OUT1, + sc_signal<double>& OUT2) + : out1(OUT1), out2(OUT2) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.cpp new file mode 100644 index 000000000..a1a9a903c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.cpp @@ -0,0 +1,56 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + pipeline.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename pipeline.cc */ +/* This is the implementation file for module `pipeline' */ + +#include "systemc.h" +#include "f_stage1.h" +#include "f_stage2.h" +#include "stage1_2.h" +#include "f_stage3.h" +#include "pipeline.h" +#include "f_pipeline.h" + +void f_pipeline(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& OUT_) +{ + SC_NEW(pipeline(NAME, CLK, IN1, IN2, OUT_)); +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.h new file mode 100644 index 000000000..e328f5ac5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/pipeline.h @@ -0,0 +1,62 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + pipeline.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename pipeline.h */ +/* This is the interface file for module `pipeline' */ + +#include "systemc.h" + +struct pipeline : public sc_module { + sc_signal<double> prod; + sc_signal<double> quot; + + stage1_2 S1_2; // component + + //Constructor + pipeline(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& OUT_) + : sc_module(NAME), + S1_2("Stage1_2", CLK, IN1, IN2, prod, quot) + { + f_stage3("Stage3", CLK, prod, quot, OUT_); + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.cpp new file mode 100644 index 000000000..f09af1ef3 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.cpp @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.cc */ +/* This is the implementation file for synchronous process `stage1' */ + +#include "stage1.h" +#include "f_stage1.h" + +void stage1::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + sum.write(a+b); + diff.write(a-b); + wait(); + a = in1.read(); + b = in2.read(); + } +} // end of entry function + +void f_stage1(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& SUM, + sc_signal<double>& DIFF) +{ + SC_NEW(stage1(NAME, CLK, IN1, IN2, SUM, DIFF)); +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.h new file mode 100644 index 000000000..5f5cc8044 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1.h */ +/* This is the interface file for synchronous process `stage1' */ + +#include "systemc.h" + +SC_MODULE( stage1 ) +{ + SC_HAS_PROCESS( stage1 ); + + sc_in_clk clk; + + const sc_signal<double>& in1; //input + const sc_signal<double>& in2; //input + sc_signal<double>& sum; //output + sc_signal<double>& diff; //output + + //Constructor + stage1(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& SUM, + sc_signal<double>& DIFF) + : in1(IN1), in2(IN2), sum(SUM), diff(DIFF) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1_2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1_2.h new file mode 100644 index 000000000..166cc0be6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage1_2.h @@ -0,0 +1,61 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage1_2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage1_2.h */ +/* This is the interface file for module `stage1_2' */ + +#include "systemc.h" + +struct stage1_2 : public sc_module { + sc_signal<double> sum; // internal signal + sc_signal<double> diff; // internal signal + + //Constructor + stage1_2(sc_module_name NAME, + sc_clock& TICK, + const sc_signal<double>& IN1, + const sc_signal<double>& IN2, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) + : sc_module(NAME) + { + f_stage1("Stage1", TICK, IN1, IN2, sum, diff); + f_stage2("Stage2", TICK, sum, diff, PROD, QUOT); + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.cpp new file mode 100644 index 000000000..9d3128b15 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.cpp @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.cc */ +/* This is the implementation file for synchronous process `stage2' */ + +#include "stage2.h" +#include "f_stage2.h" + +void stage2::entry() +{ + double a, b; + + a = 20.0; + b = 5.0; + while (true) { + prod.write(a*b); + quot.write(a/b); + wait(); + a = sum.read(); + b = diff.read(); + } +} // end of entry function + +void f_stage2(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& SUM, + const sc_signal<double>& DIFF, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) +{ + SC_NEW(stage2(NAME, CLK, SUM, DIFF, PROD, QUOT)); +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.h new file mode 100644 index 000000000..5e8e788d1 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage2.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage2.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage2.h */ +/* This is the interface file for synchronous process `stage2' */ + +#include "systemc.h" + +SC_MODULE( stage2 ) +{ + SC_HAS_PROCESS( stage2 ); + + sc_in_clk clk; + + const sc_signal<double>& sum; //input + const sc_signal<double>& diff; //input + sc_signal<double>& prod; //output + sc_signal<double>& quot; //output + + //Constructor + stage2(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& SUM, + const sc_signal<double>& DIFF, + sc_signal<double>& PROD, + sc_signal<double>& QUOT) + : sum(SUM), diff(DIFF), prod(PROD), quot(QUOT) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.cpp new file mode 100644 index 000000000..1a7c47489 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.cpp @@ -0,0 +1,70 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.cc */ +/* This is the implementation file for synchronous process `stage3' */ + +#include <math.h> +#include "stage3.h" +#include "f_stage3.h" + +void stage3::entry() +{ + double a, b; + double c; + + a = 20.0; + b = 5.0; + while (true) { + c = pow(a, b); + powr.write(c); + wait(); + a = prod.read(); + b = quot.read(); + } +} // end of entry function + + +void f_stage3(const char *NAME, + sc_clock& CLK, + const sc_signal<double>& PROD, + const sc_signal<double>& QUOT, + sc_signal<double>& POWR) +{ + SC_NEW(stage3(NAME, CLK, PROD, QUOT, POWR)); +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.h new file mode 100644 index 000000000..60bb8caad --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/stage3.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stage3.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename stage3.h */ +/* This is the interface file for synchronous process `stage3' */ + +#include "systemc.h" + +SC_MODULE( stage3 ) +{ + SC_HAS_PROCESS( stage3 ); + + sc_in_clk clk; + + const sc_signal<double>& prod; //input + const sc_signal<double>& quot; //input + sc_signal<double>& powr; //output + + //Constructor + stage3(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& PROD, + const sc_signal<double>& QUOT, + sc_signal<double>& POWR) + : prod(PROD), quot(QUOT), powr(POWR) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt4.4/testbench.h b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/testbench.h new file mode 100644 index 000000000..128433c2a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt4.4/testbench.h @@ -0,0 +1,60 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.h */ +/* This is the interface file for module `testbench' */ + +#include "systemc.h" + +struct testbench : public sc_module { + numgen N; // component + display D; // component + + //Constructor + testbench(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<double>& IN_, + sc_signal<double>& OUT1, + sc_signal<double>& OUT2) + : sc_module(NAME), + N("Numgen", CLK, OUT1, OUT2), + D("Display", CLK, IN_) + { + } +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.cpp new file mode 100644 index 000000000..fa55fb2fd --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accumulator.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accumulator.cc */ +/* This is the implementation file for synchronous process `accumulator' */ + +#include "accumulator.h" + +void accumulator::entry() +{ + int a = 1; + + sum_acc = 1234; // some random number + mult_acc = 3; // some random number + + while (true) { + sum_acc += a; + mult_acc *= a; + sum.write(sum_acc); + prod.write(mult_acc); + wait(); + a = number.read(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.h b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.h new file mode 100644 index 000000000..6005d3fac --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/accumulator.h @@ -0,0 +1,72 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + accumulator.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename accumulator.h */ +/* This is the interface file for synchronous process `accumulator' */ + +#include "systemc.h" + +SC_MODULE( accumulator ) +{ + SC_HAS_PROCESS( accumulator ); + + sc_in_clk clk; + + const sc_signal<int>& number; //input + sc_signal<int>& sum; //output + sc_signal<int>& prod; //output + + int sum_acc; //internal variable + int mult_acc; //internal variable + + //Constructor + accumulator(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& NUMBER, + sc_signal<int>& SUM, + sc_signal<int>& PROD) + : number(NUMBER), sum(SUM), prod(PROD) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/chpt5.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/chpt5.1.f new file mode 100644 index 000000000..58b8e125d --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/chpt5.1.f @@ -0,0 +1,3 @@ +chpt5.1/accumulator.cpp +chpt5.1/main.cpp +chpt5.1/testbench.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/golden/chpt5.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/golden/chpt5.1.log new file mode 100644 index 000000000..e9253c827 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/golden/chpt5.1.log @@ -0,0 +1,50 @@ +SystemC Simulation +Result = 1235 and 3 +Result = 1237 and 6 +Result = 1240 and 18 +Result = 1244 and 72 +Result = 1249 and 360 +Result = 1255 and 2160 +Result = 1262 and 15120 +Result = 1270 and 120960 +Result = 1279 and 1088640 +Result = 1289 and 10886400 +Result = 1300 and 119750400 +Result = 1312 and 1437004800 +Result = 1325 and 1501193216 +Result = 1339 and -458131456 +Result = 1354 and 1717962752 +Result = 1370 and 1717600256 +Result = 1387 and -865566720 +Result = 1405 and 1599668224 +Result = 1424 and 328925184 +Result = 1444 and -2011430912 +Result = 1465 and 709623808 +Result = 1487 and -1568145408 +Result = 1510 and -1707606016 +Result = 1534 and 1967128576 +Result = 1559 and 1933574144 +Result = 1585 and -1266679808 +Result = 1612 and 159383552 +Result = 1640 and 167772160 +Result = 1669 and 570425344 +Result = 1699 and -67108864 +Result = 1730 and -2080374784 +Result = 1762 and -2147483648 +Result = 1795 and -2147483648 +Result = 1829 and 0 +Result = 1864 and 0 +Result = 1900 and 0 +Result = 1937 and 0 +Result = 1975 and 0 +Result = 2014 and 0 +Result = 2054 and 0 +Result = 2095 and 0 +Result = 2137 and 0 +Result = 2180 and 0 +Result = 2224 and 0 +Result = 2269 and 0 +Result = 2315 and 0 +Result = 2362 and 0 +Result = 2410 and 0 +Result = 2459 and 0 diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/main.cpp new file mode 100644 index 000000000..8762229c7 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/main.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +/* Main file for accumulator simulation */ + +#include "testbench.h" +#include "accumulator.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<int> number; + sc_signal<int> resulta; + sc_signal<int> resultm; + + sc_clock clk("Clock", 20.0, SC_NS, 0.5, 0.0, SC_NS); + + testbench TBH("TB", clk, resulta,resultm, number); + accumulator ACC("ACC", clk, number, resulta, resultm); + + sc_start(1000, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.cpp new file mode 100644 index 000000000..9d1df8a8a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.cpp @@ -0,0 +1,54 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.cc */ +/* This is the implementation file for synchronous process `testbench' */ + +#include "testbench.h" + +void testbench::entry() +{ + int num = 2; + + while (true) { + number.write(num++); + wait(); + cout << "Result = " << resulta.read() << " and " << resultm.read() + << endl; + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.h b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.h new file mode 100644 index 000000000..0ab21e4b3 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt5.1/testbench.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.h */ +/* This is the interface file for synchronous process `testbench' */ + +#include "systemc.h" + +SC_MODULE( testbench ) +{ + SC_HAS_PROCESS( testbench ); + + sc_in_clk clk; + + const sc_signal<int>& resulta; //input + const sc_signal<int>& resultm; //input + sc_signal<int>& number; //output + + //Constructor + testbench(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& RESULTA, + const sc_signal<int>& RESULTM, + sc_signal<int>& NUMBER) + : resulta(RESULTA), resultm(RESULTM), number(NUMBER) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/chpt6.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/chpt6.1.f new file mode 100644 index 000000000..656c43793 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/chpt6.1.f @@ -0,0 +1,5 @@ +chpt6.1/display.cpp +chpt6.1/driver.cpp +chpt6.1/main.cpp +chpt6.1/pullup.cpp +chpt6.1/ts_buf.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/common.h b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/common.h new file mode 100644 index 000000000..4d5a25eb6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/common.h @@ -0,0 +1,47 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_logic std_ulogic; + +typedef sc_signal<sc_logic> signal_std_logic; + +#endif diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.cpp new file mode 100644 index 000000000..a60ae744f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.cpp @@ -0,0 +1,47 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.cc */ +/* This is the implementation file for asynchronous process `display' */ + +#include "display.h" + +void display::entry() +{ + cout << "Value on Bus = " << bus.read() << endl; +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.h b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.h new file mode 100644 index 000000000..5d2185daf --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.h @@ -0,0 +1,63 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + display.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename display.h */ +/* This is the interface file for asynchronous process `display' */ + +#include "common.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + const signal_std_logic& bus; //input + + //Constructor + display(sc_module_name NAME, + const signal_std_logic& BUS) + : bus(BUS) + { + SC_METHOD( entry ); + dont_initialize(); + sensitive << bus; + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.cpp new file mode 100644 index 000000000..797de03cd --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + driver.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename driver.cc */ +/* This is the implementation file for synchronous process `driver' */ + +#include "driver.h" + +void driver::entry() +{ + control.write(true); + out.write(false); + wait(); + cout << "Input is = " << in.read() << endl; + + control.write(false); + wait(); + cout << "Input is = " << in.read() << endl; + + control.write(true); + out.write(true); + wait(); + cout << "Input is = " << in.read() << endl; + + control.write(false); + wait(); + cout << "Input is = " << in.read() << endl; + sc_stop(); +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.h b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.h new file mode 100644 index 000000000..68df6d26f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.h @@ -0,0 +1,69 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + driver.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename driver.h */ +/* This is the interface file for synchronous process `driver' */ + +#include "common.h" + +SC_MODULE( driver ) +{ + SC_HAS_PROCESS( driver ); + + sc_in_clk clk; + + const signal_std_logic& in; //input + sc_signal<bool>& control; //output + sc_signal<bool>& out; //output + + //Constructor + driver(sc_module_name NAME, + sc_clock& CLK, + const signal_std_logic& IN_, + sc_signal<bool>& CONTROL, + sc_signal<bool>& OUT_) + : in(IN_), control(CONTROL), out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/golden/chpt6.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/golden/chpt6.1.log new file mode 100644 index 000000000..58ed81894 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/golden/chpt6.1.log @@ -0,0 +1,12 @@ +SystemC Simulation +Value on Bus = Z +Value on Bus = 0 +Input is = 0 +Value on Bus = Z +Input is = Z +Value on Bus = 1 +Input is = 1 +Value on Bus = Z +Input is = Z + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/main.cpp new file mode 100644 index 000000000..afb1d333c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/main.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Main routine for tri-state simulation */ + +#include "driver.h" +#include "ts_buf.h" +#include "display.h" + +int sc_main(int ac, char *av[]) +{ + signal_std_logic bus; + sc_signal<bool> control; + sc_signal<bool> out; + + sc_clock clock("CLK", 10.0, SC_NS, 0.5, 0.0, SC_NS); + + driver D("Driver", clock, bus, control, out); + ts_buf B("Buffer", out, control, bus); + display DISP("BusDisplay", bus); + + sc_start(200, SC_NS); + return 0; +} + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.cpp new file mode 100644 index 000000000..e4729a6ec --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.cpp @@ -0,0 +1,50 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + pullup.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename pullup.cc */ +/* This is the implementation file for synchronous process `pullup' */ + +#include "pullup.h" + +void pullup::entry() +{ + while (true) { + pup.write(sc_logic('H')); + wait(); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.h b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.h new file mode 100644 index 000000000..a5608f51e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.h @@ -0,0 +1,65 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + pullup.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename pullup.h */ +/* This is the interface file for synchronous process `pullup' */ + +#include "common.h" + +SC_MODULE( pullup ) +{ + SC_HAS_PROCESS( pullup ); + + sc_in_clk clk; + + signal_std_logic& pup; //output + + //Constructor + pullup(sc_module_name NAME, + sc_clock& CLK, + signal_std_logic& PUP) + : pup(PUP) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.cpp new file mode 100644 index 000000000..28e0e257a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.cpp @@ -0,0 +1,60 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ts_buf.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ts_buf.cc */ +/* This is the implementation file for asynchronous process `ts_buf' */ + +#include "ts_buf.h" + +void ts_buf::entry() +{ + bool c; + bool bus_val; + std_ulogic val; + + c = control.read(); + + if (c == false) { + ts_out.write(sc_logic('Z')); + } + else { + bus_val = in.read(); + val = bus_val; // automatic type conversion + ts_out.write(val); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.h b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.h new file mode 100644 index 000000000..4a0a9bc90 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.h @@ -0,0 +1,67 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + ts_buf.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename ts_buf.h */ +/* This is the interface file for asynchronous process `ts_buf' */ + +#include "common.h" + +SC_MODULE( ts_buf ) +{ + SC_HAS_PROCESS( ts_buf ); + + const sc_signal<bool>& in; //input + const sc_signal<bool>& control; //input + signal_std_logic& ts_out; //output + + //Constructor + ts_buf(sc_module_name NAME, + const sc_signal<bool>& IN_, + const sc_signal<bool>& CONTROL, + signal_std_logic& TS_OUT) + : in(IN_), control(CONTROL), ts_out(TS_OUT) + { + SC_METHOD( entry ); + sensitive << in; + sensitive << control; + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/chpt7.1.f b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/chpt7.1.f new file mode 100644 index 000000000..4bc3b23d4 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/chpt7.1.f @@ -0,0 +1,2 @@ +chpt7.1/main.cpp +chpt7.1/testbench.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/golden/chpt7.1.log b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/golden/chpt7.1.log new file mode 100644 index 000000000..25ff64775 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/golden/chpt7.1.log @@ -0,0 +1,13 @@ +SystemC Simulation +A = 136708339, B = 739981, C = 1795618, D = 135968358, SUM = 139243938 +A = 9096481, B = 158324345, C = 156370665, D = -149227864, SUM = 323791491 +A = 67086517, B = 264870948, C = 252125103, D = -197784431, SUM = 584082568 +A = 35986927, B = 156189122, C = 206347003, D = -120202195, SUM = 398523052 +A = 113459060, B = 75282205, C = 152014781, D = 38176855, SUM = 340756046 +A = 106493306, B = 96640536, C = 38402601, D = 9852770, SUM = 241536443 +A = 182546426, B = 97022397, C = 80174628, D = 85524029, SUM = 359743451 +A = 179563193, B = 205851535, C = 103403428, D = -26288342, SUM = 488818156 +A = 1501295, B = 41700621, C = 124029719, D = -40199326, SUM = 167231635 +A = 96489422, B = 81002361, C = 111989263, D = 15487061, SUM = 289481046 + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/isaac.h b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/isaac.h new file mode 100644 index 000000000..9625be2ac --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/isaac.h @@ -0,0 +1,272 @@ +#ifndef __ISAAC_HPP +#define __ISAAC_HPP + + +/* + + C++ TEMPLATE VERSION OF Robert J. Jenkins Jr.'s + ISAAC Random Number Generator. + + Ported from vanilla C to to template C++ class + by Quinn Tyler Jackson on 16-23 July 1998. + + quinn@qtj.net + + The function for the expected period of this + random number generator, according to Jenkins is: + + f(a,b) = 2**((a+b*(3+2^^a)-1) + + (where a is ALPHA and b is bitwidth) + + So, for a bitwidth of 32 and an ALPHA of 8, + the expected period of ISAAC is: + + 2^^(8+32*(3+2^^8)-1) = 2^^8295 + + Jackson has been able to run implementations + with an ALPHA as high as 16, or + + 2^^2097263 + +*/ + + +typedef unsigned int UINT32; +const UINT32 GOLDEN_RATIO = UINT32(0x9e3779b9); + + +template <UINT32 ALPHA = (8)> +class QTIsaac +{ + public: + + typedef unsigned char byte; + + struct randctx + { + randctx(void) + { + randrsl = new UINT32[N]; + randmem = new UINT32[N]; + } + + ~randctx(void) + { + delete [] randrsl; + delete [] randmem; + } + + UINT32 randcnt; + UINT32* randrsl; + UINT32* randmem; + UINT32 randa; + UINT32 randb; + UINT32 randc; + }; + + QTIsaac(UINT32 a = 0, UINT32 b = 0, UINT32 c = 0); + virtual ~QTIsaac(void); + + UINT32 rand(void); + virtual void randinit(randctx* ctx, bool bUseSeed); + virtual void srand( + UINT32 a = 0, UINT32 b = 0, UINT32 c = 0, UINT32* s = NULL); + + enum {N = (1<<ALPHA)}; + + protected: + + virtual void isaac(randctx* ctx); + + UINT32 ind(UINT32* mm, UINT32 x); + void rngstep( + UINT32 mix, UINT32& a, UINT32& b, UINT32*& mm, UINT32*& m, + UINT32*& m2, UINT32*& r, UINT32& x, UINT32& y); + virtual void shuffle( + UINT32& a, UINT32& b, UINT32& c, UINT32& d, UINT32& e, UINT32& f, + UINT32& g, UINT32& h); + + private: + randctx m_rc; +}; + + +template<UINT32 ALPHA> +QTIsaac<ALPHA>::QTIsaac(UINT32 a, UINT32 b, UINT32 c) : m_rc() +{ + srand(a, b, c); +} + + +template<UINT32 ALPHA> +QTIsaac<ALPHA>::~QTIsaac(void) +{ + // DO NOTHING +} + + +template<UINT32 ALPHA> +void QTIsaac<ALPHA>::srand(UINT32 a, UINT32 b, UINT32 c, UINT32* s) +{ + for(int i = 0; i < N; i++) + { + m_rc.randrsl[i] = s != NULL ? s[i] : 0; + } + + m_rc.randa = a; + m_rc.randb = b; + m_rc.randc = c; + + randinit(&m_rc, true); +} + + +template<UINT32 ALPHA> +inline UINT32 QTIsaac<ALPHA>::rand(void) +{ + return 0x7fffffff & (!m_rc.randcnt-- ? + (isaac(&m_rc), m_rc.randcnt=(N-1), m_rc.randrsl[m_rc.randcnt]) : + m_rc.randrsl[m_rc.randcnt]); +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::randinit(randctx* ctx, bool bUseSeed) +{ + UINT32 a,b,c,d,e,f,g,h; + int i; + + a = b = c = d = e = f = g = h = GOLDEN_RATIO; + + UINT32* m = (ctx->randmem); + UINT32* r = (ctx->randrsl); + + if(!bUseSeed) + { + ctx->randa = 0; + ctx->randb = 0; + ctx->randc = 0; + } + + // scramble it + for(i=0; i < 4; ++i) + { + shuffle(a,b,c,d,e,f,g,h); + } + + if(bUseSeed) + { + // initialize using the contents of r[] as the seed + + for(i=0; i < N; i+=8) + { + a+=r[i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3]; + e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7]; + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + } + + //do a second pass to make all of the seed affect all of m + + for(i=0; i < N; i += 8) + { + a+=m[i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3]; + e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7]; + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + } + } + else + { + // fill in mm[] with messy stuff + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + + } + + isaac(ctx); // fill in the first set of results + ctx->randcnt = N; // prepare to use the first set of results +} + + +template<UINT32 ALPHA> +inline UINT32 QTIsaac<ALPHA>::ind(UINT32* mm, UINT32 x) +{ + return (*(UINT32*)((byte*)(mm) + ((x) & ((N-1)<<2)))); +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::rngstep(UINT32 mix, UINT32& a, UINT32& b, UINT32*& mm, UINT32*& m, UINT32*& m2, UINT32*& r, UINT32& x, UINT32& y) +{ + x = *m; + a = (a^(mix)) + *(m2++); + *(m++) = y = ind(mm,x) + a + b; + *(r++) = b = ind(mm,y>>ALPHA) + x; +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::shuffle(UINT32& a, UINT32& b, UINT32& c, UINT32& d, UINT32& e, UINT32& f, UINT32& g, UINT32& h) +{ + a^=b<<11; d+=a; b+=c; + b^=c>>2; e+=b; c+=d; + c^=d<<8; f+=c; d+=e; + d^=e>>16; g+=d; e+=f; + e^=f<<10; h+=e; f+=g; + f^=g>>4; a+=f; g+=h; + g^=h<<8; b+=g; h+=a; + h^=a>>9; c+=h; a+=b; +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::isaac(randctx* ctx) +{ + UINT32 x,y; + + UINT32* mm = ctx->randmem; + UINT32* r = ctx->randrsl; + + UINT32 a = (ctx->randa); + UINT32 b = (ctx->randb + (++ctx->randc)); + + UINT32* m = mm; + UINT32* m2 = (m+(N/2)); + UINT32* mend = m2; + + for(; m<mend; ) + { + rngstep((a<<13), a, b, mm, m, m2, r, x, y); + rngstep((a>>6) , a, b, mm, m, m2, r, x, y); + rngstep((a<<2) , a, b, mm, m, m2, r, x, y); + rngstep((a>>16), a, b, mm, m, m2, r, x, y); + } + + m2 = mm; + + for(; m2<mend; ) + { + rngstep((a<<13), a, b, mm, m, m2, r, x, y); + rngstep((a>>6) , a, b, mm, m, m2, r, x, y); + rngstep((a<<2) , a, b, mm, m, m2, r, x, y); + rngstep((a>>16), a, b, mm, m, m2, r, x, y); + } + + ctx->randb = b; + ctx->randa = a; +} + + +#endif // __ISAAC_HPP + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/main.cpp new file mode 100644 index 000000000..7e442ee4c --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/main.cpp @@ -0,0 +1,50 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// Main routine + +#include "testbench.h" + +int sc_main(int ac, char *av[]) +{ + sc_clock clock("Clock", 10, SC_NS, 0.5, 0, SC_NS); + + testbench T("TB", clock); + + sc_start(); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.cpp new file mode 100644 index 000000000..aa6e20ad6 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.cpp @@ -0,0 +1,81 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.cc */ +/* This is the implementation file for synchronous process `testbench' */ + +#include <math.h> +#include "testbench.h" +#include "isaac.h" + +QTIsaac<8> rng; + +int add(int a, int b) +{ + return (a + b); +} + +int adder_sub(int a, int b, int c, int *d) +{ + int sum; + + sum = add(a, b); + sum = add(sum, c); + *d = a - b; + return (sum); +} + +void testbench::entry() +{ + int a, b, c, d; + int sum; + int i; + + for (i=0; i < 10; i++) { + a = rng.rand() & 0x0fffffff; + b = rng.rand() & 0x0fffffff; + c = rng.rand() & 0x0fffffff; + + sum = adder_sub(a, b, c, &d); + // printf("A = %d, B = %d, C = %d, D = %d, SUM = %d\n", a, b, c, d, sum); + char buf[BUFSIZ]; + sprintf(buf, "A = %d, B = %d, C = %d, D = %d, SUM = %d\n", a, b, c, d, sum); + cout << buf; + } + sc_stop(); +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.h b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.h new file mode 100644 index 000000000..275bf0ea5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.1/testbench.h @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.h */ +/* This is the interface file for synchronous process `testbench' */ + +#include "systemc.h" + +SC_MODULE( testbench ) +{ + SC_HAS_PROCESS( testbench ); + + sc_in_clk clk; + + //Constructor + testbench(sc_module_name NAME, + sc_clock& CLK) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.cpp new file mode 100644 index 000000000..caf7e5c1f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.cpp @@ -0,0 +1,76 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + adder_sub.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename adder_sub.cc */ +/* This is the implementation file for synchronous process `adder_sub' */ + +#include "adder_sub.h" + +int add(int a, int b) +{ + return (a + b); +} + +void adder_sub::entry() +{ + int sum; + int a, b, c, d; + + while (true) { + // Wait until you get signal to go + do { wait(); } while (adder_sub_ready != true); + // Read inputs + a = Sa.read(); + b = Sb.read(); + c = Sc.read(); + + // Perform the computation. + sum = add(a, b); + sum = add(sum, c); + d = a - b; + + // Write outputs + adder_sub_done.write(true); + Ssum.write(sum); + Sd.write(d); + wait(); + adder_sub_done.write(false); + // Loop back to do { wait(); } while . + } + +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.h b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.h new file mode 100644 index 000000000..913f1f5f2 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/adder_sub.h @@ -0,0 +1,79 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + adder_sub.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename adder_sub.h */ +/* This is the interface file for synchronous process `adder_sub' */ + +#include "systemc.h" + +SC_MODULE( adder_sub ) +{ + SC_HAS_PROCESS( adder_sub ); + + sc_in_clk clk; + + const sc_signal<int>& Sa; //input + const sc_signal<int>& Sb; //input + const sc_signal<int>& Sc; //input + const sc_signal<bool>& adder_sub_ready; //input + sc_signal<int>& Sd; //output + sc_signal<int>& Ssum; //output + sc_signal<bool>& adder_sub_done; //output + + //Constructor + adder_sub(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& SA, + const sc_signal<int>& SB, + const sc_signal<int>& SC, + const sc_signal<bool>& ADDER_SUB_READY, + sc_signal<int>& SD, + sc_signal<int>& SSUM, + sc_signal<bool>& ADDER_SUB_DONE) + : Sa(SA), Sb(SB), Sc(SC), + adder_sub_ready(ADDER_SUB_READY), + Sd(SD), Ssum(SSUM), adder_sub_done(ADDER_SUB_DONE) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/chpt7.2.f b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/chpt7.2.f new file mode 100644 index 000000000..e19c1162a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/chpt7.2.f @@ -0,0 +1,3 @@ +chpt7.2/adder_sub.cpp +chpt7.2/main.cpp +chpt7.2/testbench.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/golden/chpt7.2.log b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/golden/chpt7.2.log new file mode 100644 index 000000000..25ff64775 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/golden/chpt7.2.log @@ -0,0 +1,13 @@ +SystemC Simulation +A = 136708339, B = 739981, C = 1795618, D = 135968358, SUM = 139243938 +A = 9096481, B = 158324345, C = 156370665, D = -149227864, SUM = 323791491 +A = 67086517, B = 264870948, C = 252125103, D = -197784431, SUM = 584082568 +A = 35986927, B = 156189122, C = 206347003, D = -120202195, SUM = 398523052 +A = 113459060, B = 75282205, C = 152014781, D = 38176855, SUM = 340756046 +A = 106493306, B = 96640536, C = 38402601, D = 9852770, SUM = 241536443 +A = 182546426, B = 97022397, C = 80174628, D = 85524029, SUM = 359743451 +A = 179563193, B = 205851535, C = 103403428, D = -26288342, SUM = 488818156 +A = 1501295, B = 41700621, C = 124029719, D = -40199326, SUM = 167231635 +A = 96489422, B = 81002361, C = 111989263, D = 15487061, SUM = 289481046 + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/isaac.h b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/isaac.h new file mode 100644 index 000000000..9625be2ac --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/isaac.h @@ -0,0 +1,272 @@ +#ifndef __ISAAC_HPP +#define __ISAAC_HPP + + +/* + + C++ TEMPLATE VERSION OF Robert J. Jenkins Jr.'s + ISAAC Random Number Generator. + + Ported from vanilla C to to template C++ class + by Quinn Tyler Jackson on 16-23 July 1998. + + quinn@qtj.net + + The function for the expected period of this + random number generator, according to Jenkins is: + + f(a,b) = 2**((a+b*(3+2^^a)-1) + + (where a is ALPHA and b is bitwidth) + + So, for a bitwidth of 32 and an ALPHA of 8, + the expected period of ISAAC is: + + 2^^(8+32*(3+2^^8)-1) = 2^^8295 + + Jackson has been able to run implementations + with an ALPHA as high as 16, or + + 2^^2097263 + +*/ + + +typedef unsigned int UINT32; +const UINT32 GOLDEN_RATIO = UINT32(0x9e3779b9); + + +template <UINT32 ALPHA = (8)> +class QTIsaac +{ + public: + + typedef unsigned char byte; + + struct randctx + { + randctx(void) + { + randrsl = new UINT32[N]; + randmem = new UINT32[N]; + } + + ~randctx(void) + { + delete [] randrsl; + delete [] randmem; + } + + UINT32 randcnt; + UINT32* randrsl; + UINT32* randmem; + UINT32 randa; + UINT32 randb; + UINT32 randc; + }; + + QTIsaac(UINT32 a = 0, UINT32 b = 0, UINT32 c = 0); + virtual ~QTIsaac(void); + + UINT32 rand(void); + virtual void randinit(randctx* ctx, bool bUseSeed); + virtual void srand( + UINT32 a = 0, UINT32 b = 0, UINT32 c = 0, UINT32* s = NULL); + + enum {N = (1<<ALPHA)}; + + protected: + + virtual void isaac(randctx* ctx); + + UINT32 ind(UINT32* mm, UINT32 x); + void rngstep( + UINT32 mix, UINT32& a, UINT32& b, UINT32*& mm, UINT32*& m, + UINT32*& m2, UINT32*& r, UINT32& x, UINT32& y); + virtual void shuffle( + UINT32& a, UINT32& b, UINT32& c, UINT32& d, UINT32& e, UINT32& f, + UINT32& g, UINT32& h); + + private: + randctx m_rc; +}; + + +template<UINT32 ALPHA> +QTIsaac<ALPHA>::QTIsaac(UINT32 a, UINT32 b, UINT32 c) : m_rc() +{ + srand(a, b, c); +} + + +template<UINT32 ALPHA> +QTIsaac<ALPHA>::~QTIsaac(void) +{ + // DO NOTHING +} + + +template<UINT32 ALPHA> +void QTIsaac<ALPHA>::srand(UINT32 a, UINT32 b, UINT32 c, UINT32* s) +{ + for(int i = 0; i < N; i++) + { + m_rc.randrsl[i] = s != NULL ? s[i] : 0; + } + + m_rc.randa = a; + m_rc.randb = b; + m_rc.randc = c; + + randinit(&m_rc, true); +} + + +template<UINT32 ALPHA> +inline UINT32 QTIsaac<ALPHA>::rand(void) +{ + return 0x7fffffff & (!m_rc.randcnt-- ? + (isaac(&m_rc), m_rc.randcnt=(N-1), m_rc.randrsl[m_rc.randcnt]) : + m_rc.randrsl[m_rc.randcnt]); +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::randinit(randctx* ctx, bool bUseSeed) +{ + UINT32 a,b,c,d,e,f,g,h; + int i; + + a = b = c = d = e = f = g = h = GOLDEN_RATIO; + + UINT32* m = (ctx->randmem); + UINT32* r = (ctx->randrsl); + + if(!bUseSeed) + { + ctx->randa = 0; + ctx->randb = 0; + ctx->randc = 0; + } + + // scramble it + for(i=0; i < 4; ++i) + { + shuffle(a,b,c,d,e,f,g,h); + } + + if(bUseSeed) + { + // initialize using the contents of r[] as the seed + + for(i=0; i < N; i+=8) + { + a+=r[i ]; b+=r[i+1]; c+=r[i+2]; d+=r[i+3]; + e+=r[i+4]; f+=r[i+5]; g+=r[i+6]; h+=r[i+7]; + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + } + + //do a second pass to make all of the seed affect all of m + + for(i=0; i < N; i += 8) + { + a+=m[i ]; b+=m[i+1]; c+=m[i+2]; d+=m[i+3]; + e+=m[i+4]; f+=m[i+5]; g+=m[i+6]; h+=m[i+7]; + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + } + } + else + { + // fill in mm[] with messy stuff + + shuffle(a,b,c,d,e,f,g,h); + + m[i ]=a; m[i+1]=b; m[i+2]=c; m[i+3]=d; + m[i+4]=e; m[i+5]=f; m[i+6]=g; m[i+7]=h; + + } + + isaac(ctx); // fill in the first set of results + ctx->randcnt = N; // prepare to use the first set of results +} + + +template<UINT32 ALPHA> +inline UINT32 QTIsaac<ALPHA>::ind(UINT32* mm, UINT32 x) +{ + return (*(UINT32*)((byte*)(mm) + ((x) & ((N-1)<<2)))); +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::rngstep(UINT32 mix, UINT32& a, UINT32& b, UINT32*& mm, UINT32*& m, UINT32*& m2, UINT32*& r, UINT32& x, UINT32& y) +{ + x = *m; + a = (a^(mix)) + *(m2++); + *(m++) = y = ind(mm,x) + a + b; + *(r++) = b = ind(mm,y>>ALPHA) + x; +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::shuffle(UINT32& a, UINT32& b, UINT32& c, UINT32& d, UINT32& e, UINT32& f, UINT32& g, UINT32& h) +{ + a^=b<<11; d+=a; b+=c; + b^=c>>2; e+=b; c+=d; + c^=d<<8; f+=c; d+=e; + d^=e>>16; g+=d; e+=f; + e^=f<<10; h+=e; f+=g; + f^=g>>4; a+=f; g+=h; + g^=h<<8; b+=g; h+=a; + h^=a>>9; c+=h; a+=b; +} + + +template<UINT32 ALPHA> +inline void QTIsaac<ALPHA>::isaac(randctx* ctx) +{ + UINT32 x,y; + + UINT32* mm = ctx->randmem; + UINT32* r = ctx->randrsl; + + UINT32 a = (ctx->randa); + UINT32 b = (ctx->randb + (++ctx->randc)); + + UINT32* m = mm; + UINT32* m2 = (m+(N/2)); + UINT32* mend = m2; + + for(; m<mend; ) + { + rngstep((a<<13), a, b, mm, m, m2, r, x, y); + rngstep((a>>6) , a, b, mm, m, m2, r, x, y); + rngstep((a<<2) , a, b, mm, m, m2, r, x, y); + rngstep((a>>16), a, b, mm, m, m2, r, x, y); + } + + m2 = mm; + + for(; m2<mend; ) + { + rngstep((a<<13), a, b, mm, m, m2, r, x, y); + rngstep((a>>6) , a, b, mm, m, m2, r, x, y); + rngstep((a<<2) , a, b, mm, m, m2, r, x, y); + rngstep((a>>16), a, b, mm, m, m2, r, x, y); + } + + ctx->randb = b; + ctx->randa = a; +} + + +#endif // __ISAAC_HPP + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/main.cpp new file mode 100644 index 000000000..745338a04 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/main.cpp @@ -0,0 +1,59 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// Main routine + +#include "testbench.h" +#include "adder_sub.h" + +int sc_main(int ac, char *av[]) +{ + sc_signal<int> a; + sc_signal<int> b; + sc_signal<int> c; + sc_signal<int> d; + sc_signal<int> sum; + sc_signal<bool> ready; + sc_signal<bool> done; + sc_clock clock("Clock", 10, SC_NS, 0.5, 0, SC_NS); + + testbench T("TB", clock, sum, d, done, a, b, c, ready); + adder_sub AS("AS", clock, a, b, c, ready, d, sum, done); + + sc_start(); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.cpp new file mode 100644 index 000000000..bc91bb257 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.cpp @@ -0,0 +1,75 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.cc */ +/* This is the implementation file for synchronous process `testbench' */ + +#include <math.h> +#include "testbench.h" +#include "isaac.h" + +QTIsaac<8> rng; + +void testbench::entry() +{ + int a, b, c, d; + int sum; + int i; + + for (i=0; i < 10; i++) { + a = rng.rand() & 0x0fffffff; + b = rng.rand() & 0x0fffffff; + c = rng.rand() & 0x0fffffff; + + Sa.write(a); + Sb.write(b); + Sc.write(c); + adder_sub_ready.write(true); + wait(); + adder_sub_ready.write(false); + do { wait(); } while (adder_sub_done != true); + sum = Ssum.read(); + d = Sdiff.read(); + // printf("A = %d, B = %d, C = %d, D = %d, SUM = %d\n", a, b, c, d, sum); + char buf[BUFSIZ]; + sprintf(buf, "A = %d, B = %d, C = %d, D = %d, SUM = %d\n", a, b, c, d, sum); + cout << buf; + } + sc_stop(); + +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.h b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.h new file mode 100644 index 000000000..9e5e2383f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/chpt7.2/testbench.h @@ -0,0 +1,80 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + testbench.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* Filename testbench.h */ +/* This is the interface file for synchronous process `testbench' */ + +#include "systemc.h" + +SC_MODULE( testbench ) +{ + SC_HAS_PROCESS( testbench ); + + sc_in_clk clk; + + const sc_signal<int>& Ssum; //input + const sc_signal<int>& Sdiff; //input + const sc_signal<bool>& adder_sub_done; //input + sc_signal<int>& Sa; //output + sc_signal<int>& Sb; //output + sc_signal<int>& Sc; //output + sc_signal<bool>& adder_sub_ready; //output + + //Constructor + testbench(sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& SSUM, + const sc_signal<int>& SDIFF, + const sc_signal<bool>& ADDER_SUB_DONE, + sc_signal<int>& SA, + sc_signal<int>& SB, + sc_signal<int>& SC, + sc_signal<bool>& ADDER_SUB_READY) + : Ssum(SSUM), Sdiff(SDIFF), + adder_sub_done(ADDER_SUB_DONE), + Sa(SA), Sb(SB), Sc(SC), adder_sub_ready(ADDER_SUB_READY) + + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + + diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test1/golden/test1.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test1/golden/test1.log new file mode 100644 index 000000000..102bd3432 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test1/golden/test1.log @@ -0,0 +1,38 @@ +SystemC Simulation + +Info: (I703) tracing timescale unit set: 1 ns (systemc.vcd) +Seen other edge +AsyncBlock: Value read = 0 +AsyncProc: Value read = 0 +Seen other edge +AsyncBlock: Value read = 100 +Sync: Value written = 100 value1 read = 0 value2 read = 0 +AsyncProc: Value read = 100 +Seen other edge +AsyncBlock: Value read = 100 +Waited one cycle + +AsyncProc: Value read = 100 +Seen other edge +AsyncBlock: Value read = 101 +Sync: Value written = 101 value1 read = 100 value2 read = 100 +AsyncProc: Value read = 101 +Seen other edge +AsyncBlock: Value read = 101 +Waited one cycle + +AsyncProc: Value read = 101 +Seen other edge +AsyncBlock: Value read = 102 +Sync: Value written = 102 value1 read = 101 value2 read = 101 +AsyncProc: Value read = 102 +Seen other edge +AsyncBlock: Value read = 102 +Waited one cycle + +AsyncProc: Value read = 102 +Seen other edge +AsyncBlock: Value read = 103 +Sync: Value written = 103 value1 read = 102 value2 read = 102 +AsyncProc: Value read = 103 +Seen other edge diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test1/test1.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test1/test1.cpp new file mode 100644 index 000000000..101387b96 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test1/test1.cpp @@ -0,0 +1,176 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test1.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 1. Checking triggering of a sc_async/sc_aproc + vis-a-vis a synchronous process. + This test checks to ensure that a synch. and async. sensitive + to a clock are triggered correctly. + */ + +#include "systemc.h" + +SC_MODULE( syncproc ) +{ + SC_HAS_PROCESS( syncproc ); + + sc_in<bool> clk; + + const sc_signal<int>& in1; + const sc_signal<int>& in2; + sc_signal<int>& out; + + syncproc(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + const sc_signal<int>& IN1, + const sc_signal<int>& IN2, + sc_signal<int>& OUT_) + : in1(IN1), in2(IN2), out(OUT_) + { + SC_CTHREAD( entry, clk.pos() ); + clk(CLK); + out = 0; + } + + void entry() + { + int i = 100; + while (true) { + out = i; + wait(); + while (in1.read() != i) { + cout << "Sync: Value written = " << i << " value1 read = " << in1.read() << " value2 read = " << in2.read() << endl; + wait(); + cout << "Waited one cycle\n" << endl; + } + i++; + } + } +}; + +SC_MODULE( asyncproc ) +{ + SC_HAS_PROCESS( asyncproc ); + + const sc_signal<int>& in; + sc_signal<int>& out; + sc_in<bool> clock; + + asyncproc(sc_module_name NAME, + const sc_signal<int>& IN_, + sc_signal<int>& OUT_, + sc_signal_in_if<bool>& CLOCK) + : in(IN_), out(OUT_) + { + out = 0; + clock(CLOCK); + SC_THREAD( entry ); + sensitive << clock.pos(); + } + + void entry() + { + wait(); + while (true) { + if (clock.posedge()) { + out = in; + cout << "AsyncProc: Value read = " << in.read() << endl; + } + else { + cout << "Error" << endl; + } + wait(); + } + } +}; + +SC_MODULE( asyncblock ) +{ + SC_HAS_PROCESS( asyncblock ); + + const sc_signal<int>& in; + sc_signal<int>& out; + sc_in<bool> clock; + + asyncblock(sc_module_name NAME, + const sc_signal<int>& IN_, + sc_signal<int>& OUT_, + sc_signal_in_if<bool>& CLOCK) + : in(IN_), out(OUT_) + { + clock(CLOCK); + out = 0; + SC_METHOD( entry ); + sensitive << clock; + } + + void entry() + { + if (clock.posedge()) { + out = in; + cout << "AsyncBlock: Value read = " << in.read() << endl; + } + else { + cout << "Seen other edge" << endl; + } + } +}; + + +int +sc_main(int ac, char *av[]) +{ + sc_signal<int> a, b, c; + + sc_clock clock("Clock", 20, SC_NS, 0.5); + + syncproc P1("P1", clock, a, b, c); + asyncproc P2("P2", c, a, clock); + asyncblock P3("P3", c, b, clock); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + tf->set_time_unit(1, SC_NS); + sc_trace(tf, a, "SYNC-IN1"); + sc_trace(tf, b, "SYNC-IN2"); + sc_trace(tf, c, "SYNC2-OUT"); + sc_trace(tf, clock, "Clock"); + + sc_start(160, SC_NS); + return 0; + +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test2/golden/test2.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test2/golden/test2.log new file mode 100644 index 000000000..33f68dce4 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test2/golden/test2.log @@ -0,0 +1,34 @@ +SystemC Simulation + +Info: (I703) tracing timescale unit set: 1 ns (systemc.vcd) +Seen other edge +AsyncBlock: Value read = 0 +AsyncProc: Value read = 100 +Seen other edge +AsyncBlock: Value read = 100 +Sync: Value written = 100 value1 read = 110 value2 read = 0 +Seen other edge +AsyncBlock: Value read = 100 +Waited one cycle + +AsyncProc: Value read = 101 +Seen other edge +AsyncBlock: Value read = 101 +Sync: Value written = 101 value1 read = 111 value2 read = 100 +Seen other edge +AsyncBlock: Value read = 101 +Waited one cycle + +AsyncProc: Value read = 102 +Seen other edge +AsyncBlock: Value read = 102 +Sync: Value written = 102 value1 read = 112 value2 read = 101 +Seen other edge +AsyncBlock: Value read = 102 +Waited one cycle + +AsyncProc: Value read = 103 +Seen other edge +AsyncBlock: Value read = 103 +Sync: Value written = 103 value1 read = 113 value2 read = 102 +Seen other edge diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test2/test2.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test2/test2.cpp new file mode 100644 index 000000000..8b6201c96 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test2/test2.cpp @@ -0,0 +1,170 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test2.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 2: Checking single cycle interaction between + sc_sync and async, in conjunction with triggering of + sc_sync and async that are sensitive to a clock + */ + +#include "systemc.h" + +SC_MODULE( syncproc ) +{ + SC_HAS_PROCESS( syncproc ); + + sc_in<bool> clk; + + const sc_signal<int>& in1; + const sc_signal<int>& in2; + sc_signal<int>& out; + + syncproc(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + const sc_signal<int>& IN1, + const sc_signal<int>& IN2, + sc_signal<int>& OUT_) + : in1(IN1), in2(IN2), out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 100; + while (true) { + out = i; + wait(); + while (in2.read() != i) { + cout << "Sync: Value written = " << i << " value1 read = " << in1.read() << " value2 read = " << in2.read() << endl; + wait(); + cout << "Waited one cycle\n" << endl; + } + i++; + } + } +}; + +SC_MODULE( asyncproc ) +{ + SC_HAS_PROCESS( asyncproc ); + + const sc_signal<int>& in; + sc_signal<int>& out; + sc_in<bool> clock; + + asyncproc(sc_module_name NAME, + const sc_signal<int>& IN_, + sc_signal<int>& OUT_, + sc_signal_in_if<bool>& CLOCK) + : in(IN_), out(OUT_) + { + clock(CLOCK); + out = 0; + SC_THREAD( entry ); + sensitive << in; + } + + void entry() + { + wait(); + while (true) { + out = in + 10; + cout << "AsyncProc: Value read = " << in.read() << endl; + wait(); + } + } +}; + +SC_MODULE( asyncblock ) +{ + SC_HAS_PROCESS( asyncblock ); + + const sc_signal<int>& in; + sc_signal<int>& out; + sc_in<bool> clock; + + asyncblock(sc_module_name NAME, + const sc_signal<int>& IN_, + sc_signal<int>& OUT_, + sc_signal_in_if<bool>& CLOCK) + : in(IN_), out(OUT_) + { + clock(CLOCK); + out = 0; + SC_METHOD( entry ); + sensitive << clock; + } + + void entry() + { + if (clock.posedge()) { + out = in; + cout << "AsyncBlock: Value read = " << in.read() << endl; + } + else { + cout << "Seen other edge" << endl; + } + } +}; + + +int +sc_main(int ac, char *av[]) +{ + sc_signal<int> a, b, c; + + sc_clock clock("Clock", 20, SC_NS, 0.5); + + syncproc P1("P1", clock, a, b, c); + asyncproc P2("P2", c, a, clock); + asyncblock P3("P3", c, b, clock); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + tf->set_time_unit(1, SC_NS); + sc_trace(tf, a, "SYNC-IN1"); + sc_trace(tf, b, "SYNC-IN2"); + sc_trace(tf, c, "SYNC2-OUT"); + sc_trace(tf, clock, "Clock"); + + sc_start(160, SC_NS); + return 0; + +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test3/golden/test3.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test3/golden/test3.log new file mode 100644 index 000000000..694dcb348 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test3/golden/test3.log @@ -0,0 +1,18 @@ +SystemC Simulation +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge +AsyncProc: Posedge +AsyncBlock: Negedge diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test3/test3.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test3/test3.cpp new file mode 100644 index 000000000..eda07c614 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test3/test3.cpp @@ -0,0 +1,111 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test3.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 3: Checking sensitive_pos() and sensitive_neg() methods +*/ + +#include "systemc.h" + +SC_MODULE( asyncproc ) +{ + SC_HAS_PROCESS( asyncproc ); + + sc_in<bool> clock; + + asyncproc(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK) + { + clock(CLOCK); + SC_THREAD( entry ); + sensitive << clock.pos(); + } + + void entry() + { + wait(); + while (true) { + if (clock.posedge()) { + cout << "AsyncProc: Posedge\n"; + } + else { + cout << "AsyncProc: ERROR" << endl; + } + wait(); + } + } +}; + +SC_MODULE( asyncblock ) +{ + SC_HAS_PROCESS( asyncblock ); + + sc_in<bool> clock; + + asyncblock(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK) + { + clock(CLOCK); + SC_METHOD( entry ); + sensitive << clock.neg(); + } + + void entry() + { + if (clock.posedge()) { + cout << "AsyncBlock: ERROR\n"; + } + else { + cout << "AsyncBlock: Negedge" << endl; + } + } +}; + + +int +sc_main(int ac, char *av[]) +{ + sc_clock clock("Clock", 20, SC_NS, 0.5); + + asyncproc P2("P2", clock); + asyncblock P3("P3", clock); + + sc_start(160, SC_NS); + return 0; + +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test4/golden/test4.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test4/golden/test4.log new file mode 100644 index 000000000..c4c8ca893 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test4/golden/test4.log @@ -0,0 +1,121 @@ +SystemC Simulation +[ Gate = 1 - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 11 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 12 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 13 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 14 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 15 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 16 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 17 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 18 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 19 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 20 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 21 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 22 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 23 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 24 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 25 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 26 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 27 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 28 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 29 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 30 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test4/test4.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test4/test4.cpp new file mode 100644 index 000000000..f9d97063f --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test4/test4.cpp @@ -0,0 +1,199 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test4.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 4: Checking gated clocks and triggering of processes + */ + +#include "systemc.h" + +SC_MODULE( cgater ) +{ + SC_HAS_PROCESS( cgater ); + + const sc_signal<bool>& gate; + sc_in<bool> clock_in; + sc_out<bool> clock_out; + + cgater(sc_module_name NAME, + const sc_signal<bool>& GATE, + sc_signal_in_if<bool>& CLOCK_IN, + sc_signal_out_if<bool>& CLOCK_OUT) + : gate(GATE) + { + clock_in(CLOCK_IN); + clock_out(CLOCK_OUT); + SC_METHOD( entry ); + sensitive << gate; + sensitive << clock_in; + } + + void entry() + { + clock_out = clock_in & gate; + } +}; + +SC_MODULE( watcher ) +{ + SC_HAS_PROCESS( watcher ); + + const sc_signal<bool>& gate; + sc_in<bool> clock; + sc_in<bool> dclock; + const sc_signal<int>& a; + + watcher(sc_module_name NAME, + const sc_signal<bool>& GATE, + sc_signal_in_if<bool>& CLOCK, + sc_signal_in_if<bool>& DCLOCK, + const sc_signal<int>& A) + : gate(GATE), a(A) + { + clock(CLOCK); + dclock(DCLOCK); + SC_METHOD( entry ); + sensitive << clock; + sensitive << a; + sensitive << gate; + sensitive << dclock; + } + + void entry() + { + cout << "[ "; + if (clock.posedge()) cout << "Posedge - "; + if (clock.negedge()) cout << "Negedge - "; + if (dclock.posedge()) cout << "Posedge(D) - "; + if (dclock.negedge()) cout << "Negedge(D) - "; + if (a.event()) cout << "A = " << a.read() << " - "; + if (gate.event()) cout << "Gate = " << gate.read() << " - "; + cout << "]" << endl; + } +}; + + +SC_MODULE( gategen ) +{ + SC_HAS_PROCESS( gategen ); + + sc_in<bool> clk; + + sc_signal<bool>& gate; + + gategen(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<bool>& GATE) + : gate(GATE) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + gate = 1; + } + + void entry() + { + while (true) { + gate = 1; wait(3); + gate = 0; wait (3); + } + } +}; + +SC_MODULE( trigp ) +{ + SC_HAS_PROCESS( trigp ); + + sc_in<bool> clk; + + sc_signal<int>& out; + + trigp(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 11; + while (true) { + out = i++; + wait(); + } + } +}; + +int +sc_main(int ac, char *av[]) +{ + // sc_clock clock1("Clock1", 20, SC_NS, 0.5); + // sc_clock dclock("Derived"); + sc_signal<bool> clock1( "Clock1" ); + sc_signal<bool> dclock( "Derived" ); + + sc_signal<bool> Gate; + sc_signal<int> Output; + + cgater CG("CG", Gate, clock1, dclock); + watcher W("W", Gate, clock1, dclock, Output); + gategen G("G", clock1, Gate); + trigp T("T", dclock, Output); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + sc_trace(tf, clock1, "Clock"); + sc_trace(tf, dclock, "Dclock"); + sc_trace(tf, Gate, "Gate"); + sc_trace(tf, Output, "Out"); + + sc_start(0, SC_NS); + clock1.write(0); + sc_start(5, SC_NS); + for (int i=0; i < 30; i++) { + clock1.write(1); + sc_start(5, SC_NS); + clock1.write(0); + sc_start(5, SC_NS); + } + + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test5/golden/test5.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test5/golden/test5.log new file mode 100644 index 000000000..c4c8ca893 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test5/golden/test5.log @@ -0,0 +1,121 @@ +SystemC Simulation +[ Gate = 1 - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 11 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 12 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 13 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 14 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 15 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 16 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 17 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 18 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 19 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 20 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 21 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 22 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 23 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 24 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 25 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 26 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Gate = 1 - ] +[ Posedge(D) - ] +[ A = 27 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 28 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - ] +[ A = 29 - ] +[ Negedge - ] +[ Negedge(D) - ] +[ Posedge - ] +[ Posedge(D) - Gate = 0 - ] +[ Negedge(D) - A = 30 - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] +[ Posedge - ] +[ Negedge - ] diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test5/test5.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test5/test5.cpp new file mode 100644 index 000000000..2338cde83 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test5/test5.cpp @@ -0,0 +1,189 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test5.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 4: Checking gated clocks and triggering of processes + */ + +#include "systemc.h" + +SC_MODULE( cgater ) +{ + SC_HAS_PROCESS( cgater ); + + const sc_signal<bool>& gate; + sc_in<bool> clock_in; + sc_out<bool> clock_out; + + cgater(sc_module_name NAME, + const sc_signal<bool>& GATE, + sc_signal_in_if<bool>& CLOCK_IN, + sc_signal_out_if<bool>& CLOCK_OUT) + : gate(GATE) + { + clock_in(CLOCK_IN); + clock_out(CLOCK_OUT); + SC_METHOD( entry ); + sensitive << gate; + sensitive << clock_in; + } + + void entry() + { + clock_out = clock_in & gate; + } +}; + +SC_MODULE( watcher ) +{ + SC_HAS_PROCESS( watcher ); + + const sc_signal<bool>& gate; + sc_in<bool> clock; + sc_in<bool> dclock; + const sc_signal<int>& a; + + watcher(sc_module_name NAME, + const sc_signal<bool>& GATE, + sc_signal_in_if<bool>& CLOCK, + sc_signal_in_if<bool>& DCLOCK, + const sc_signal<int>& A) + : gate(GATE), a(A) + { + clock(CLOCK); + dclock(DCLOCK); + SC_METHOD( entry ); + sensitive << clock; + sensitive << a; + sensitive << gate; + sensitive << dclock; + } + + void entry() + { + cout << "[ "; + if (clock.posedge()) cout << "Posedge - "; + if (clock.negedge()) cout << "Negedge - "; + if (dclock.posedge()) cout << "Posedge(D) - "; + if (dclock.negedge()) cout << "Negedge(D) - "; + if (a.event()) cout << "A = " << a.read() << " - "; + if (gate.event()) cout << "Gate = " << gate.read() << " - "; + cout << "]" << endl; + } +}; + + +SC_MODULE( gategen ) +{ + SC_HAS_PROCESS( gategen ); + + sc_in<bool> clk; + + sc_signal<bool>& gate; + + gategen(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<bool>& GATE) + : gate(GATE) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + gate = 1; + } + + void entry() + { + while (true) { + gate = 1; wait(3); + gate = 0; wait (3); + } + } +}; + +SC_MODULE( trigp ) +{ + SC_HAS_PROCESS( trigp ); + + sc_in<bool> clk; + + sc_signal<int>& out; + + trigp(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 11; + while (true) { + out = i++; + wait(); + } + } +}; + +int +sc_main(int ac, char *av[]) +{ + sc_clock clock1("Clock1", 20, SC_NS, 0.5); + // sc_clock dclock("Derived", -1); + sc_signal<bool> dclock( "Derived" ); + + sc_signal<bool> Gate; + sc_signal<int> Output; + + cgater CG("CG", Gate, clock1, dclock); + watcher W("W", Gate, clock1, dclock, Output); + gategen G("G", clock1, Gate); + trigp T("T", dclock, Output); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + sc_trace(tf, clock1, "Clock"); + sc_trace(tf, dclock, "Dclock"); + sc_trace(tf, Gate, "Gate"); + sc_trace(tf, Output, "Out"); + + sc_start(600, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test6/golden/test6.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test6/golden/test6.log new file mode 100644 index 000000000..8b5d0ffef --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test6/golden/test6.log @@ -0,0 +1,22 @@ +SystemC Simulation +[ ] +[ Posedge(1) - Posedge(2) - ASync1 Out = 1 - ASync2 Out = 1 - ] +[ Sync1 Out = 11 - ASync1 Out = 2 - Sync2 Out = 11 - ASync2 Out = 2 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 3 - ASync2 Out = 3 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 12 - ASync1 Out = 4 - Sync2 Out = 12 - ASync2 Out = 4 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 5 - ASync2 Out = 5 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 13 - ASync1 Out = 6 - Sync2 Out = 13 - ASync2 Out = 6 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 7 - ASync2 Out = 7 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 14 - ASync1 Out = 8 - Sync2 Out = 14 - ASync2 Out = 8 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 9 - ASync2 Out = 9 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 15 - ASync1 Out = 10 - Sync2 Out = 15 - ASync2 Out = 10 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 11 - ASync2 Out = 11 - ] diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test6/test6.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test6/test6.cpp new file mode 100644 index 000000000..a1446e8aa --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test6/test6.cpp @@ -0,0 +1,165 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test6.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 5: Checking multiple clock transitions at the same time + */ + +#include "systemc.h" + +SC_MODULE( triga ) +{ + SC_HAS_PROCESS( triga ); + + sc_in<bool> clock; + sc_signal<int>& out; + + int i; + + triga(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clock(CLOCK); + SC_METHOD( entry ); + sensitive << clock; + i = 0; + out = i++; + } + + void entry() + { + out = i++; + } +}; + +SC_MODULE( watcher ) +{ + SC_HAS_PROCESS( watcher ); + + sc_in<bool> clock1; + sc_in<bool> clock2; + const sc_signal<int>& in1; + const sc_signal<int>& in2; + const sc_signal<int>& in3; + const sc_signal<int>& in4; + + watcher(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK1, + sc_signal_in_if<bool>& CLOCK2, + const sc_signal<int>& IN1, + const sc_signal<int>& IN2, + const sc_signal<int>& IN3, + const sc_signal<int>& IN4) + : in1(IN1), in2(IN2), in3(IN3), in4(IN4) + { + clock1(CLOCK1); clock2(CLOCK2); + SC_METHOD( entry ); + sensitive << clock1 << clock2 << in1 << in2 << in3 << in4; + } + + void entry() + { + cout << "[ "; + if (clock1.posedge()) cout << "Posedge(1) - "; + if (clock1.negedge()) cout << "Negedge(1) - "; + if (clock2.posedge()) cout << "Posedge(2) - "; + if (clock2.negedge()) cout << "Negedge(2) - "; + if (in1.event()) cout << "Sync1 Out = " << in1.read() << " - "; + if (in2.event()) cout << "ASync1 Out = " << in2.read() << " - "; + if (in3.event()) cout << "Sync2 Out = " << in3.read() << " - "; + if (in4.event()) cout << "ASync2 Out = " << in4.read() << " - "; + cout << "]" << endl; + } +}; + + +SC_MODULE( trigp ) +{ + SC_HAS_PROCESS( trigp ); + + sc_in<bool> clk; + + sc_signal<int>& out; + + trigp(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 11; + while (true) { + out = i++; + wait(); + } + } +}; + +int +sc_main(int ac, char *av[]) +{ + sc_clock clock1("Clock1", 20, SC_NS, 0.5); + sc_clock clock2("Clock2", 20, SC_NS, 0.5); + + sc_signal<int> sig1, sig2, sig3, sig4; + + triga T1("T1", clock1, sig2); + triga T2("T2", clock2, sig4); + trigp T3("T3", clock1, sig1); + trigp T4("T4", clock2, sig3); + watcher W("W", clock1, clock2, sig1, sig2, sig3, sig4); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + sc_trace(tf, clock1, "Clock1"); + sc_trace(tf, clock2, "Clock2"); + sc_trace(tf, sig1, "Sync1"); + sc_trace(tf, sig2, "Async1"); + sc_trace(tf, sig3, "Sync2"); + sc_trace(tf, sig4, "Async2"); + + sc_start(100, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test7/golden/test7.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test7/golden/test7.log new file mode 100644 index 000000000..be038115a --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test7/golden/test7.log @@ -0,0 +1,22 @@ +SystemC Simulation +[ ] +[ Posedge(1) - Posedge(2) - ASync1 Out = 1 - ASync2 Out = 1 - ] +[ Sync1 Out = 11 - ASync1 Out = 2 - Sync2 Out = 11 - ASync2 Out = 2 - ] +[ Negedge(1) - ] +[ ASync1 Out = 3 - ] +[ Posedge(1) - Negedge(2) - ] +[ Sync1 Out = 12 - ASync1 Out = 4 - ASync2 Out = 3 - ] +[ Negedge(1) - ] +[ ASync1 Out = 5 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 13 - ASync1 Out = 6 - Sync2 Out = 12 - ASync2 Out = 4 - ] +[ Negedge(1) - ] +[ ASync1 Out = 7 - ] +[ Posedge(1) - Negedge(2) - ] +[ Sync1 Out = 14 - ASync1 Out = 8 - ASync2 Out = 5 - ] +[ Negedge(1) - ] +[ ASync1 Out = 9 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 15 - ASync1 Out = 10 - Sync2 Out = 13 - ASync2 Out = 6 - ] +[ Negedge(1) - ] +[ ASync1 Out = 11 - ] diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test7/test7.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test7/test7.cpp new file mode 100644 index 000000000..a9bc31693 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test7/test7.cpp @@ -0,0 +1,167 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test7.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +/* + Corner case testing for new scheduler. + Case 5: Checking multiple clock transitions at the same time + */ + +#include "systemc.h" + +SC_MODULE( triga ) +{ + SC_HAS_PROCESS( triga ); + + sc_in<bool> clock; + sc_signal<int>& out; + + int i; + + triga(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clock(CLOCK); + SC_METHOD( entry ); + sensitive << clock; + i = 0; + out = i++; + } + + void entry() + { + out = i++; + } +}; + +SC_MODULE( watcher ) +{ + SC_HAS_PROCESS( watcher ); + + sc_in<bool> clock1; + sc_in<bool> clock2; + const sc_signal<int>& in1; + const sc_signal<int>& in2; + const sc_signal<int>& in3; + const sc_signal<int>& in4; + + watcher(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK1, + sc_signal_in_if<bool>& CLOCK2, + const sc_signal<int>& IN1, + const sc_signal<int>& IN2, + const sc_signal<int>& IN3, + const sc_signal<int>& IN4) + : in1(IN1), in2(IN2), in3(IN3), in4(IN4) + { + clock1(CLOCK1); + clock2(CLOCK2); + SC_METHOD( entry ); + sensitive << clock1 << clock2; + sensitive << in1 << in2 << in3 << in4; + } + + void entry() + { + cout << "[ "; + if (clock1.posedge()) cout << "Posedge(1) - "; + if (clock1.negedge()) cout << "Negedge(1) - "; + if (clock2.posedge()) cout << "Posedge(2) - "; + if (clock2.negedge()) cout << "Negedge(2) - "; + if (in1.event()) cout << "Sync1 Out = " << in1.read() << " - "; + if (in2.event()) cout << "ASync1 Out = " << in2.read() << " - "; + if (in3.event()) cout << "Sync2 Out = " << in3.read() << " - "; + if (in4.event()) cout << "ASync2 Out = " << in4.read() << " - "; + cout << "]" << endl; + } +}; + + +SC_MODULE( trigp ) +{ + SC_HAS_PROCESS( trigp ); + + sc_in<bool> clk; + + sc_signal<int>& out; + + trigp(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 11; + while (true) { + out = i++; + wait(); + } + } +}; + +int +sc_main(int ac, char *av[]) +{ + sc_clock clock1("Clock1", 20, SC_NS, 0.5); + sc_clock clock2("Clock2", 40, SC_NS, 0.5); + + sc_signal<int> sig1, sig2, sig3, sig4; + + triga T1("T1", clock1, sig2); + triga T2("T2", clock2, sig4); + trigp T3("T3", clock1, sig1); + trigp T4("T4", clock2, sig3); + watcher W("W", clock1, clock2, sig1, sig2, sig3, sig4); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + sc_trace(tf, clock1, "Clock1"); + sc_trace(tf, clock2, "Clock2"); + sc_trace(tf, sig1, "Sync1"); + sc_trace(tf, sig2, "Async1"); + sc_trace(tf, sig3, "Sync2"); + sc_trace(tf, sig4, "Async2"); + + sc_start(100, SC_NS); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test8/golden/test8.log b/src/systemc/tests/systemc/misc/user_guide/newsched/test8/golden/test8.log new file mode 100644 index 000000000..33a2eacbf --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test8/golden/test8.log @@ -0,0 +1,43 @@ +SystemC Simulation +[ ] +[ ASync1 Out = 1 - ASync2 Out = 1 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 11 - ASync1 Out = 2 - Sync2 Out = 11 - ASync2 Out = 2 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 3 - ASync2 Out = 3 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 12 - ASync1 Out = 4 - Sync2 Out = 12 - ASync2 Out = 4 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 5 - ASync2 Out = 5 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 13 - ASync1 Out = 6 - Sync2 Out = 13 - ASync2 Out = 6 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 7 - ASync2 Out = 7 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 14 - ASync1 Out = 8 - Sync2 Out = 14 - ASync2 Out = 8 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 9 - ASync2 Out = 9 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 15 - ASync1 Out = 10 - Sync2 Out = 15 - ASync2 Out = 10 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 11 - ASync2 Out = 11 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 16 - ASync1 Out = 12 - Sync2 Out = 16 - ASync2 Out = 12 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 13 - ASync2 Out = 13 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 17 - ASync1 Out = 14 - Sync2 Out = 17 - ASync2 Out = 14 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 15 - ASync2 Out = 15 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 18 - ASync1 Out = 16 - Sync2 Out = 18 - ASync2 Out = 16 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 17 - ASync2 Out = 17 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 19 - ASync1 Out = 18 - Sync2 Out = 19 - ASync2 Out = 18 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 19 - ASync2 Out = 19 - ] +[ Posedge(1) - Posedge(2) - ] +[ Sync1 Out = 20 - ASync1 Out = 20 - Sync2 Out = 20 - ASync2 Out = 20 - ] +[ Negedge(1) - Negedge(2) - ] +[ ASync1 Out = 21 - ASync2 Out = 21 - ] diff --git a/src/systemc/tests/systemc/misc/user_guide/newsched/test8/test8.cpp b/src/systemc/tests/systemc/misc/user_guide/newsched/test8/test8.cpp new file mode 100644 index 000000000..9d4fe3d00 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/newsched/test8/test8.cpp @@ -0,0 +1,187 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + test8.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +// $Log: test8.cpp,v $ +// Revision 1.1.1.1 2006/12/15 20:26:23 acg +// systemc_tests-2.3 +// +// Revision 1.2 2006/01/24 21:05:50 acg +// Andy Goodrich: replacement of deprecated features with their non-deprecated +// counterparts. +// + +/* + Corner case testing for new scheduler. + Case 5: Checking multiple clock transitions at the same time + */ + +#include "systemc.h" + +SC_MODULE( triga ) +{ + SC_HAS_PROCESS( triga ); + + sc_in<bool> clock; + sc_signal<int>& out; + + int i; + + triga(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clock(CLOCK); + SC_METHOD( entry ); + sensitive << clock; + i = 0; + out = i++; + } + + void entry() + { + out = i++; + } +}; + +SC_MODULE( watcher ) +{ + SC_HAS_PROCESS( watcher ); + + sc_in<bool> clock1; + sc_in<bool> clock2; + const sc_signal<int>& in1; + const sc_signal<int>& in2; + const sc_signal<int>& in3; + const sc_signal<int>& in4; + + watcher(sc_module_name NAME, + sc_signal_in_if<bool>& CLOCK1, + sc_signal_in_if<bool>& CLOCK2, + const sc_signal<int>& IN1, + const sc_signal<int>& IN2, + const sc_signal<int>& IN3, + const sc_signal<int>& IN4) + : in1(IN1), in2(IN2), in3(IN3), in4(IN4) + { + clock1(CLOCK1); + clock2(CLOCK2); + SC_METHOD( entry ); + sensitive << clock1; sensitive << clock2; + sensitive << in1; sensitive << in2; sensitive << in3; sensitive << in4; + } + + void entry() + { + cout << "[ "; + if (clock1.posedge()) cout << "Posedge(1) - "; + if (clock1.negedge()) cout << "Negedge(1) - "; + if (clock2.posedge()) cout << "Posedge(2) - "; + if (clock2.negedge()) cout << "Negedge(2) - "; + if (in1.event()) cout << "Sync1 Out = " << in1.read() << " - "; + if (in2.event()) cout << "ASync1 Out = " << in2.read() << " - "; + if (in3.event()) cout << "Sync2 Out = " << in3.read() << " - "; + if (in4.event()) cout << "ASync2 Out = " << in4.read() << " - "; + cout << "]" << endl; + } +}; + + +SC_MODULE( trigp ) +{ + SC_HAS_PROCESS( trigp ); + + sc_in<bool> clk; + + sc_signal<int>& out; + + trigp(sc_module_name NAME, + sc_signal_in_if<bool>& CLK, + sc_signal<int>& OUT_) + : out(OUT_) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + out = 0; + } + + void entry() + { + int i = 11; + while (true) { + out = i++; + wait(); + } + } +}; + +int +sc_main(int ac, char *av[]) +{ + // sc_clock clock1("Clock1", 20, SC_NS, 0.5); + // sc_clock clock2("Clock2", 20, SC_NS, 0.5); + sc_signal<bool> clock1( "Clock1" ); + sc_signal<bool> clock2( "Clock2" ); + + sc_signal<int> sig1, sig2, sig3, sig4; + + triga T1("T1", clock1, sig2); + triga T2("T2", clock2, sig4); + trigp T3("T3", clock1, sig1); + trigp T4("T4", clock2, sig3); + watcher W("W", clock1, clock2, sig1, sig2, sig3, sig4); + + sc_trace_file *tf = sc_create_vcd_trace_file("systemc"); + sc_trace(tf, clock1, "Clock1"); + sc_trace(tf, clock2, "Clock2"); + sc_trace(tf, sig1, "Sync1"); + sc_trace(tf, sig2, "Async1"); + sc_trace(tf, sig3, "Sync2"); + sc_trace(tf, sig4, "Async2"); + + sc_start(0, SC_NS); + clock1 = 0; + clock2 = 0; + sc_start(5, SC_NS); + for (int i = 0; i< 10; i++) { + clock1 = 1; clock2 = 1; + sc_start(5, SC_NS); + clock1 = 0; clock2 = 0; + sc_start(5, SC_NS); + } + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/common.h b/src/systemc/tests/systemc/misc/user_guide/param_model/common.h new file mode 100644 index 000000000..43c767bcc --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/common.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + common.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#ifndef COMMON_H +#define COMMON_H + +#include "systemc.h" + +typedef sc_signal<sc_bv<5> > signal_bool_vector; + +#endif diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/golden/param_model.log b/src/systemc/tests/systemc/misc/user_guide/param_model/golden/param_model.log new file mode 100644 index 000000000..8b3af8297 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/golden/param_model.log @@ -0,0 +1,260 @@ +SystemC Simulation +35 ns : RESET off ...by stim +60 ns : 0 + 0 + 1 = 1 => carry = 0 sum = 00001 +100 ns : 1 + 0 + 0 = 1 => carry = 0 sum = 00001 +140 ns : 2 + 0 + 1 = 3 => carry = 0 sum = 00011 +180 ns : 3 + 0 + 0 = 3 => carry = 0 sum = 00011 +220 ns : 4 + 0 + 1 = 5 => carry = 0 sum = 00101 +260 ns : 5 + 0 + 0 = 5 => carry = 0 sum = 00101 +300 ns : 6 + 0 + 1 = 7 => carry = 0 sum = 00111 +340 ns : 7 + 0 + 0 = 7 => carry = 0 sum = 00111 +380 ns : 8 + 0 + 1 = 9 => carry = 0 sum = 01001 +420 ns : 9 + 0 + 0 = 9 => carry = 0 sum = 01001 +460 ns : 10 + 0 + 1 = 11 => carry = 0 sum = 01011 +500 ns : 11 + 0 + 0 = 11 => carry = 0 sum = 01011 +540 ns : 12 + 0 + 1 = 13 => carry = 0 sum = 01101 +580 ns : 13 + 0 + 0 = 13 => carry = 0 sum = 01101 +620 ns : 14 + 0 + 1 = 15 => carry = 0 sum = 01111 +660 ns : 15 + 0 + 0 = 15 => carry = 0 sum = 01111 +700 ns : 0 + 1 + 1 = 2 => carry = 0 sum = 00010 +740 ns : 1 + 1 + 0 = 2 => carry = 0 sum = 00010 +780 ns : 2 + 1 + 1 = 4 => carry = 0 sum = 00100 +820 ns : 3 + 1 + 0 = 4 => carry = 0 sum = 00100 +860 ns : 4 + 1 + 1 = 6 => carry = 0 sum = 00110 +900 ns : 5 + 1 + 0 = 6 => carry = 0 sum = 00110 +940 ns : 6 + 1 + 1 = 8 => carry = 0 sum = 01000 +980 ns : 7 + 1 + 0 = 8 => carry = 0 sum = 01000 +1020 ns : 8 + 1 + 1 = 10 => carry = 0 sum = 01010 +1060 ns : 9 + 1 + 0 = 10 => carry = 0 sum = 01010 +1100 ns : 10 + 1 + 1 = 12 => carry = 0 sum = 01100 +1140 ns : 11 + 1 + 0 = 12 => carry = 0 sum = 01100 +1180 ns : 12 + 1 + 1 = 14 => carry = 0 sum = 01110 +1220 ns : 13 + 1 + 0 = 14 => carry = 0 sum = 01110 +1260 ns : 14 + 1 + 1 = 16 => carry = 0 sum = 10000 +1300 ns : 15 + 1 + 0 = 16 => carry = 0 sum = 10000 +1340 ns : 0 + 2 + 1 = 3 => carry = 0 sum = 00011 +1380 ns : 1 + 2 + 0 = 3 => carry = 0 sum = 00011 +1420 ns : 2 + 2 + 1 = 5 => carry = 0 sum = 00101 +1460 ns : 3 + 2 + 0 = 5 => carry = 0 sum = 00101 +1500 ns : 4 + 2 + 1 = 7 => carry = 0 sum = 00111 +1540 ns : 5 + 2 + 0 = 7 => carry = 0 sum = 00111 +1580 ns : 6 + 2 + 1 = 9 => carry = 0 sum = 01001 +1620 ns : 7 + 2 + 0 = 9 => carry = 0 sum = 01001 +1660 ns : 8 + 2 + 1 = 11 => carry = 0 sum = 01011 +1700 ns : 9 + 2 + 0 = 11 => carry = 0 sum = 01011 +1740 ns : 10 + 2 + 1 = 13 => carry = 0 sum = 01101 +1780 ns : 11 + 2 + 0 = 13 => carry = 0 sum = 01101 +1820 ns : 12 + 2 + 1 = 15 => carry = 0 sum = 01111 +1860 ns : 13 + 2 + 0 = 15 => carry = 0 sum = 01111 +1900 ns : 14 + 2 + 1 = 17 => carry = 0 sum = 10001 +1940 ns : 15 + 2 + 0 = 17 => carry = 0 sum = 10001 +1980 ns : 0 + 3 + 1 = 4 => carry = 0 sum = 00100 +2020 ns : 1 + 3 + 0 = 4 => carry = 0 sum = 00100 +2060 ns : 2 + 3 + 1 = 6 => carry = 0 sum = 00110 +2100 ns : 3 + 3 + 0 = 6 => carry = 0 sum = 00110 +2140 ns : 4 + 3 + 1 = 8 => carry = 0 sum = 01000 +2180 ns : 5 + 3 + 0 = 8 => carry = 0 sum = 01000 +2220 ns : 6 + 3 + 1 = 10 => carry = 0 sum = 01010 +2260 ns : 7 + 3 + 0 = 10 => carry = 0 sum = 01010 +2300 ns : 8 + 3 + 1 = 12 => carry = 0 sum = 01100 +2340 ns : 9 + 3 + 0 = 12 => carry = 0 sum = 01100 +2380 ns : 10 + 3 + 1 = 14 => carry = 0 sum = 01110 +2420 ns : 11 + 3 + 0 = 14 => carry = 0 sum = 01110 +2460 ns : 12 + 3 + 1 = 16 => carry = 0 sum = 10000 +2500 ns : 13 + 3 + 0 = 16 => carry = 0 sum = 10000 +2540 ns : 14 + 3 + 1 = 18 => carry = 0 sum = 10010 +2580 ns : 15 + 3 + 0 = 18 => carry = 0 sum = 10010 +2620 ns : 0 + 4 + 1 = 5 => carry = 0 sum = 00101 +2660 ns : 1 + 4 + 0 = 5 => carry = 0 sum = 00101 +2700 ns : 2 + 4 + 1 = 7 => carry = 0 sum = 00111 +2740 ns : 3 + 4 + 0 = 7 => carry = 0 sum = 00111 +2780 ns : 4 + 4 + 1 = 9 => carry = 0 sum = 01001 +2820 ns : 5 + 4 + 0 = 9 => carry = 0 sum = 01001 +2860 ns : 6 + 4 + 1 = 11 => carry = 0 sum = 01011 +2900 ns : 7 + 4 + 0 = 11 => carry = 0 sum = 01011 +2940 ns : 8 + 4 + 1 = 13 => carry = 0 sum = 01101 +2980 ns : 9 + 4 + 0 = 13 => carry = 0 sum = 01101 +3020 ns : 10 + 4 + 1 = 15 => carry = 0 sum = 01111 +3060 ns : 11 + 4 + 0 = 15 => carry = 0 sum = 01111 +3100 ns : 12 + 4 + 1 = 17 => carry = 0 sum = 10001 +3140 ns : 13 + 4 + 0 = 17 => carry = 0 sum = 10001 +3180 ns : 14 + 4 + 1 = 19 => carry = 0 sum = 10011 +3220 ns : 15 + 4 + 0 = 19 => carry = 0 sum = 10011 +3260 ns : 0 + 5 + 1 = 6 => carry = 0 sum = 00110 +3300 ns : 1 + 5 + 0 = 6 => carry = 0 sum = 00110 +3340 ns : 2 + 5 + 1 = 8 => carry = 0 sum = 01000 +3380 ns : 3 + 5 + 0 = 8 => carry = 0 sum = 01000 +3420 ns : 4 + 5 + 1 = 10 => carry = 0 sum = 01010 +3460 ns : 5 + 5 + 0 = 10 => carry = 0 sum = 01010 +3500 ns : 6 + 5 + 1 = 12 => carry = 0 sum = 01100 +3540 ns : 7 + 5 + 0 = 12 => carry = 0 sum = 01100 +3580 ns : 8 + 5 + 1 = 14 => carry = 0 sum = 01110 +3620 ns : 9 + 5 + 0 = 14 => carry = 0 sum = 01110 +3660 ns : 10 + 5 + 1 = 16 => carry = 0 sum = 10000 +3700 ns : 11 + 5 + 0 = 16 => carry = 0 sum = 10000 +3740 ns : 12 + 5 + 1 = 18 => carry = 0 sum = 10010 +3780 ns : 13 + 5 + 0 = 18 => carry = 0 sum = 10010 +3820 ns : 14 + 5 + 1 = 20 => carry = 0 sum = 10100 +3860 ns : 15 + 5 + 0 = 20 => carry = 0 sum = 10100 +3900 ns : 0 + 6 + 1 = 7 => carry = 0 sum = 00111 +3940 ns : 1 + 6 + 0 = 7 => carry = 0 sum = 00111 +3980 ns : 2 + 6 + 1 = 9 => carry = 0 sum = 01001 +4020 ns : 3 + 6 + 0 = 9 => carry = 0 sum = 01001 +4060 ns : 4 + 6 + 1 = 11 => carry = 0 sum = 01011 +4100 ns : 5 + 6 + 0 = 11 => carry = 0 sum = 01011 +4140 ns : 6 + 6 + 1 = 13 => carry = 0 sum = 01101 +4180 ns : 7 + 6 + 0 = 13 => carry = 0 sum = 01101 +4220 ns : 8 + 6 + 1 = 15 => carry = 0 sum = 01111 +4260 ns : 9 + 6 + 0 = 15 => carry = 0 sum = 01111 +4300 ns : 10 + 6 + 1 = 17 => carry = 0 sum = 10001 +4340 ns : 11 + 6 + 0 = 17 => carry = 0 sum = 10001 +4380 ns : 12 + 6 + 1 = 19 => carry = 0 sum = 10011 +4420 ns : 13 + 6 + 0 = 19 => carry = 0 sum = 10011 +4460 ns : 14 + 6 + 1 = 21 => carry = 0 sum = 10101 +4500 ns : 15 + 6 + 0 = 21 => carry = 0 sum = 10101 +4540 ns : 0 + 7 + 1 = 8 => carry = 0 sum = 01000 +4580 ns : 1 + 7 + 0 = 8 => carry = 0 sum = 01000 +4620 ns : 2 + 7 + 1 = 10 => carry = 0 sum = 01010 +4660 ns : 3 + 7 + 0 = 10 => carry = 0 sum = 01010 +4700 ns : 4 + 7 + 1 = 12 => carry = 0 sum = 01100 +4740 ns : 5 + 7 + 0 = 12 => carry = 0 sum = 01100 +4780 ns : 6 + 7 + 1 = 14 => carry = 0 sum = 01110 +4820 ns : 7 + 7 + 0 = 14 => carry = 0 sum = 01110 +4860 ns : 8 + 7 + 1 = 16 => carry = 0 sum = 10000 +4900 ns : 9 + 7 + 0 = 16 => carry = 0 sum = 10000 +4940 ns : 10 + 7 + 1 = 18 => carry = 0 sum = 10010 +4980 ns : 11 + 7 + 0 = 18 => carry = 0 sum = 10010 +5020 ns : 12 + 7 + 1 = 20 => carry = 0 sum = 10100 +5060 ns : 13 + 7 + 0 = 20 => carry = 0 sum = 10100 +5100 ns : 14 + 7 + 1 = 22 => carry = 0 sum = 10110 +5140 ns : 15 + 7 + 0 = 22 => carry = 0 sum = 10110 +5180 ns : 0 + 8 + 1 = 9 => carry = 0 sum = 01001 +5220 ns : 1 + 8 + 0 = 9 => carry = 0 sum = 01001 +5260 ns : 2 + 8 + 1 = 11 => carry = 0 sum = 01011 +5300 ns : 3 + 8 + 0 = 11 => carry = 0 sum = 01011 +5340 ns : 4 + 8 + 1 = 13 => carry = 0 sum = 01101 +5380 ns : 5 + 8 + 0 = 13 => carry = 0 sum = 01101 +5420 ns : 6 + 8 + 1 = 15 => carry = 0 sum = 01111 +5460 ns : 7 + 8 + 0 = 15 => carry = 0 sum = 01111 +5500 ns : 8 + 8 + 1 = 17 => carry = 0 sum = 10001 +5540 ns : 9 + 8 + 0 = 17 => carry = 0 sum = 10001 +5580 ns : 10 + 8 + 1 = 19 => carry = 0 sum = 10011 +5620 ns : 11 + 8 + 0 = 19 => carry = 0 sum = 10011 +5660 ns : 12 + 8 + 1 = 21 => carry = 0 sum = 10101 +5700 ns : 13 + 8 + 0 = 21 => carry = 0 sum = 10101 +5740 ns : 14 + 8 + 1 = 23 => carry = 0 sum = 10111 +5780 ns : 15 + 8 + 0 = 23 => carry = 0 sum = 10111 +5820 ns : 0 + 9 + 1 = 10 => carry = 0 sum = 01010 +5860 ns : 1 + 9 + 0 = 10 => carry = 0 sum = 01010 +5900 ns : 2 + 9 + 1 = 12 => carry = 0 sum = 01100 +5940 ns : 3 + 9 + 0 = 12 => carry = 0 sum = 01100 +5980 ns : 4 + 9 + 1 = 14 => carry = 0 sum = 01110 +6020 ns : 5 + 9 + 0 = 14 => carry = 0 sum = 01110 +6060 ns : 6 + 9 + 1 = 16 => carry = 0 sum = 10000 +6100 ns : 7 + 9 + 0 = 16 => carry = 0 sum = 10000 +6140 ns : 8 + 9 + 1 = 18 => carry = 0 sum = 10010 +6180 ns : 9 + 9 + 0 = 18 => carry = 0 sum = 10010 +6220 ns : 10 + 9 + 1 = 20 => carry = 0 sum = 10100 +6260 ns : 11 + 9 + 0 = 20 => carry = 0 sum = 10100 +6300 ns : 12 + 9 + 1 = 22 => carry = 0 sum = 10110 +6340 ns : 13 + 9 + 0 = 22 => carry = 0 sum = 10110 +6380 ns : 14 + 9 + 1 = 24 => carry = 0 sum = 11000 +6420 ns : 15 + 9 + 0 = 24 => carry = 0 sum = 11000 +6460 ns : 0 + 10 + 1 = 11 => carry = 0 sum = 01011 +6500 ns : 1 + 10 + 0 = 11 => carry = 0 sum = 01011 +6540 ns : 2 + 10 + 1 = 13 => carry = 0 sum = 01101 +6580 ns : 3 + 10 + 0 = 13 => carry = 0 sum = 01101 +6620 ns : 4 + 10 + 1 = 15 => carry = 0 sum = 01111 +6660 ns : 5 + 10 + 0 = 15 => carry = 0 sum = 01111 +6700 ns : 6 + 10 + 1 = 17 => carry = 0 sum = 10001 +6740 ns : 7 + 10 + 0 = 17 => carry = 0 sum = 10001 +6780 ns : 8 + 10 + 1 = 19 => carry = 0 sum = 10011 +6820 ns : 9 + 10 + 0 = 19 => carry = 0 sum = 10011 +6860 ns : 10 + 10 + 1 = 21 => carry = 0 sum = 10101 +6900 ns : 11 + 10 + 0 = 21 => carry = 0 sum = 10101 +6940 ns : 12 + 10 + 1 = 23 => carry = 0 sum = 10111 +6980 ns : 13 + 10 + 0 = 23 => carry = 0 sum = 10111 +7020 ns : 14 + 10 + 1 = 25 => carry = 0 sum = 11001 +7060 ns : 15 + 10 + 0 = 25 => carry = 0 sum = 11001 +7100 ns : 0 + 11 + 1 = 12 => carry = 0 sum = 01100 +7140 ns : 1 + 11 + 0 = 12 => carry = 0 sum = 01100 +7180 ns : 2 + 11 + 1 = 14 => carry = 0 sum = 01110 +7220 ns : 3 + 11 + 0 = 14 => carry = 0 sum = 01110 +7260 ns : 4 + 11 + 1 = 16 => carry = 0 sum = 10000 +7300 ns : 5 + 11 + 0 = 16 => carry = 0 sum = 10000 +7340 ns : 6 + 11 + 1 = 18 => carry = 0 sum = 10010 +7380 ns : 7 + 11 + 0 = 18 => carry = 0 sum = 10010 +7420 ns : 8 + 11 + 1 = 20 => carry = 0 sum = 10100 +7460 ns : 9 + 11 + 0 = 20 => carry = 0 sum = 10100 +7500 ns : 10 + 11 + 1 = 22 => carry = 0 sum = 10110 +7540 ns : 11 + 11 + 0 = 22 => carry = 0 sum = 10110 +7580 ns : 12 + 11 + 1 = 24 => carry = 0 sum = 11000 +7620 ns : 13 + 11 + 0 = 24 => carry = 0 sum = 11000 +7660 ns : 14 + 11 + 1 = 26 => carry = 0 sum = 11010 +7700 ns : 15 + 11 + 0 = 26 => carry = 0 sum = 11010 +7740 ns : 0 + 12 + 1 = 13 => carry = 0 sum = 01101 +7780 ns : 1 + 12 + 0 = 13 => carry = 0 sum = 01101 +7820 ns : 2 + 12 + 1 = 15 => carry = 0 sum = 01111 +7860 ns : 3 + 12 + 0 = 15 => carry = 0 sum = 01111 +7900 ns : 4 + 12 + 1 = 17 => carry = 0 sum = 10001 +7940 ns : 5 + 12 + 0 = 17 => carry = 0 sum = 10001 +7980 ns : 6 + 12 + 1 = 19 => carry = 0 sum = 10011 +8020 ns : 7 + 12 + 0 = 19 => carry = 0 sum = 10011 +8060 ns : 8 + 12 + 1 = 21 => carry = 0 sum = 10101 +8100 ns : 9 + 12 + 0 = 21 => carry = 0 sum = 10101 +8140 ns : 10 + 12 + 1 = 23 => carry = 0 sum = 10111 +8180 ns : 11 + 12 + 0 = 23 => carry = 0 sum = 10111 +8220 ns : 12 + 12 + 1 = 25 => carry = 0 sum = 11001 +8260 ns : 13 + 12 + 0 = 25 => carry = 0 sum = 11001 +8300 ns : 14 + 12 + 1 = 27 => carry = 0 sum = 11011 +8340 ns : 15 + 12 + 0 = 27 => carry = 0 sum = 11011 +8380 ns : 0 + 13 + 1 = 14 => carry = 0 sum = 01110 +8420 ns : 1 + 13 + 0 = 14 => carry = 0 sum = 01110 +8460 ns : 2 + 13 + 1 = 16 => carry = 0 sum = 10000 +8500 ns : 3 + 13 + 0 = 16 => carry = 0 sum = 10000 +8540 ns : 4 + 13 + 1 = 18 => carry = 0 sum = 10010 +8580 ns : 5 + 13 + 0 = 18 => carry = 0 sum = 10010 +8620 ns : 6 + 13 + 1 = 20 => carry = 0 sum = 10100 +8660 ns : 7 + 13 + 0 = 20 => carry = 0 sum = 10100 +8700 ns : 8 + 13 + 1 = 22 => carry = 0 sum = 10110 +8740 ns : 9 + 13 + 0 = 22 => carry = 0 sum = 10110 +8780 ns : 10 + 13 + 1 = 24 => carry = 0 sum = 11000 +8820 ns : 11 + 13 + 0 = 24 => carry = 0 sum = 11000 +8860 ns : 12 + 13 + 1 = 26 => carry = 0 sum = 11010 +8900 ns : 13 + 13 + 0 = 26 => carry = 0 sum = 11010 +8940 ns : 14 + 13 + 1 = 28 => carry = 0 sum = 11100 +8980 ns : 15 + 13 + 0 = 28 => carry = 0 sum = 11100 +9020 ns : 0 + 14 + 1 = 15 => carry = 0 sum = 01111 +9060 ns : 1 + 14 + 0 = 15 => carry = 0 sum = 01111 +9100 ns : 2 + 14 + 1 = 17 => carry = 0 sum = 10001 +9140 ns : 3 + 14 + 0 = 17 => carry = 0 sum = 10001 +9180 ns : 4 + 14 + 1 = 19 => carry = 0 sum = 10011 +9220 ns : 5 + 14 + 0 = 19 => carry = 0 sum = 10011 +9260 ns : 6 + 14 + 1 = 21 => carry = 0 sum = 10101 +9300 ns : 7 + 14 + 0 = 21 => carry = 0 sum = 10101 +9340 ns : 8 + 14 + 1 = 23 => carry = 0 sum = 10111 +9380 ns : 9 + 14 + 0 = 23 => carry = 0 sum = 10111 +9420 ns : 10 + 14 + 1 = 25 => carry = 0 sum = 11001 +9460 ns : 11 + 14 + 0 = 25 => carry = 0 sum = 11001 +9500 ns : 12 + 14 + 1 = 27 => carry = 0 sum = 11011 +9540 ns : 13 + 14 + 0 = 27 => carry = 0 sum = 11011 +9580 ns : 14 + 14 + 1 = 29 => carry = 0 sum = 11101 +9620 ns : 15 + 14 + 0 = 29 => carry = 0 sum = 11101 +9660 ns : 0 + 15 + 1 = 16 => carry = 0 sum = 10000 +9700 ns : 1 + 15 + 0 = 16 => carry = 0 sum = 10000 +9740 ns : 2 + 15 + 1 = 18 => carry = 0 sum = 10010 +9780 ns : 3 + 15 + 0 = 18 => carry = 0 sum = 10010 +9820 ns : 4 + 15 + 1 = 20 => carry = 0 sum = 10100 +9860 ns : 5 + 15 + 0 = 20 => carry = 0 sum = 10100 +9900 ns : 6 + 15 + 1 = 22 => carry = 0 sum = 10110 +9940 ns : 7 + 15 + 0 = 22 => carry = 0 sum = 10110 +9980 ns : 8 + 15 + 1 = 24 => carry = 0 sum = 11000 +10020 ns : 9 + 15 + 0 = 24 => carry = 0 sum = 11000 +10060 ns : 10 + 15 + 1 = 26 => carry = 0 sum = 11010 +10100 ns : 11 + 15 + 0 = 26 => carry = 0 sum = 11010 +10140 ns : 12 + 15 + 1 = 28 => carry = 0 sum = 11100 +10180 ns : 13 + 15 + 0 = 28 => carry = 0 sum = 11100 +10220 ns : 14 + 15 + 1 = 30 => carry = 0 sum = 11110 +10260 ns : 15 + 15 + 0 = 30 => carry = 0 sum = 11110 + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/main.cpp b/src/systemc/tests/systemc/misc/user_guide/param_model/main.cpp new file mode 100644 index 000000000..6e74edc79 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/main.cpp @@ -0,0 +1,79 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + main.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + /***************************************/ + /* Main Filename: main.cc */ + /***************************************/ + +#include "param.h" +#include "stim.h" + +int sc_main(int ac, char *av[]) +{ + +// Parameter Settings + + int data_width = 5; + +// Signal Instantiation + + sc_signal<bool> reset; + signal_bool_vector a; + signal_bool_vector b; + sc_signal<bool> cin; + sc_signal<bool> ready; + signal_bool_vector sum; + sc_signal<bool> co; + sc_signal<bool> done; + +// Clock Instantiation + + sc_clock clk ("Clock", 10, SC_NS, 0.5, 0, SC_NS); + +// Process Instantiation + + param D1 ("D1", clk, reset, a, b, cin, ready, sum, + co, done, data_width); + + stim T1 ("T1", clk, done, reset, a, b, cin, + ready, data_width); + +// Simulation Run Control + + sc_start(); + return 0; +} diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/param.cpp b/src/systemc/tests/systemc/misc/user_guide/param_model/param.cpp new file mode 100644 index 000000000..14bfc64cb --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/param.cpp @@ -0,0 +1,91 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + param.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + /***************************************/ + /* Implementation Filename: param.cc */ + /***************************************/ + +#include "param.h" + +void param::entry() +{ + sc_unsigned sum1 (data_width + 1); + sc_unsigned a1 (data_width); + sc_unsigned b1 (data_width); + bool c1; + +// RESET INIT + sum.write(0); + co.write(0); + wait(); + + while(true) { // MAIN LOOP + + // HANDSHAKE + done.write(0); + do { wait(); } while (ready != 1); + + // COMPUTATION + a1 = a.read(); + b1 = b.read(); + c1 = cin.read(); + + sum1 = a1 + b1 + c1; + + // sum.write( sum1.range(data_width-1,0) ); + sc_unsigned tmp( data_width ); + tmp = sum1.range( data_width - 1, 0 ); + sum.write( tmp ); + co.write( sum1[data_width] ); + // wait(); + wait( 2 ); + + cout << sc_time_stamp() << "\t : " + << a1 << " + " + << b1 << " + " + << cin << " = " << sum1 + << "\t => carry = " << co + << " sum = " << sum + << endl; + + // HANDSHAKE + done.write(1); + wait(); + + } + +} diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/param.h b/src/systemc/tests/systemc/misc/user_guide/param_model/param.h new file mode 100644 index 000000000..979da821e --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/param.h @@ -0,0 +1,93 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + param.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + /***************************************/ + /* Interface Filename: param.h */ + /***************************************/ + +#include "common.h" + +SC_MODULE( param ) +{ + SC_HAS_PROCESS( param ); + + sc_in_clk clk; + + // Inputs + const sc_signal<bool>& reset; + const signal_bool_vector& a; + const signal_bool_vector& b; + const sc_signal<bool>& cin; + const sc_signal<bool>& ready; + // Outputs + signal_bool_vector& sum; + sc_signal<bool>& co; + sc_signal<bool>& done; + // Parameters + const int data_width; + + // Constructor + param (sc_module_name NAME, + sc_clock& TICK, + const sc_signal<bool>& RESET, + const signal_bool_vector& A, + const signal_bool_vector& B, + const sc_signal<bool>& CIN, + const sc_signal<bool>& READY, + signal_bool_vector& SUM, + sc_signal<bool>& CO, + sc_signal<bool>& DONE, + const int DATA_WIDTH = 4) + + : reset (RESET), + a (A), + b (B), + cin (CIN), + ready (READY), + sum (SUM), + co (CO), + done (DONE), + data_width (DATA_WIDTH) + + { + clk(TICK); + SC_CTHREAD( entry, clk.pos() ); + reset_signal_is(reset,false); + } + + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/param_model.f b/src/systemc/tests/systemc/misc/user_guide/param_model/param_model.f new file mode 100644 index 000000000..01e637776 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/param_model.f @@ -0,0 +1,3 @@ +param_model/param.cpp +param_model/stim.cpp +param_model/main.cpp diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/stim.cpp b/src/systemc/tests/systemc/misc/user_guide/param_model/stim.cpp new file mode 100644 index 000000000..5e1df5558 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/stim.cpp @@ -0,0 +1,87 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stim.cpp -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + /*************************************/ + /* Implementation Filename: stim.cc */ + /*************************************/ + +#include "stim.h" + +void stim::entry() +{ + +// VARIABLE INITIALIZATION + sc_unsigned a_tmp(data_width); + sc_unsigned b_tmp(data_width); + bool c_tmp; + int i, j; + +// RESET CYCLE + reset.write(0); + wait(2); + + reset.write(1); + wait(); + cout << sc_time_stamp() << "\t : " + << "RESET off \t...by stim" << endl; + +// STIMULUS GENERATION + c_tmp = 0; + + for (i=0; i<16; i++) { + for (j=0; j<16; j++) { + a_tmp = j; + b_tmp = i; + c_tmp = !c_tmp; + + a.write(a_tmp); + b.write(b_tmp); + cin.write(c_tmp); + + ready.write(1); + // wait(); + do { wait(); } while ( done != 1 ); + + ready.write(0); + // do { wait(); } while (done == 1); + wait(); + } + } + + sc_stop(); + +} diff --git a/src/systemc/tests/systemc/misc/user_guide/param_model/stim.h b/src/systemc/tests/systemc/misc/user_guide/param_model/stim.h new file mode 100644 index 000000000..829a83434 --- /dev/null +++ b/src/systemc/tests/systemc/misc/user_guide/param_model/stim.h @@ -0,0 +1,86 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with the + License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + *****************************************************************************/ + +/***************************************************************************** + + stim.h -- + + Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + /***************************************/ + /* Interface Filename: stim.h */ + /***************************************/ + +#include "common.h" + +SC_MODULE( stim ) +{ + SC_HAS_PROCESS( stim ); + + sc_in_clk clk; + + // Inputs + const sc_signal<bool>& done; + // Outputs + sc_signal<bool>& reset; + signal_bool_vector& a; + signal_bool_vector& b; + sc_signal<bool>& cin; + sc_signal<bool>& ready; + // Parameters + const int data_width; + + // Constructor + stim (sc_module_name NAME, + sc_clock& TICK, + const sc_signal<bool>& DONE, + sc_signal<bool>& RESET, + signal_bool_vector& A, + signal_bool_vector& B, + sc_signal<bool>& CIN, + sc_signal<bool>& READY, + const int DATA_WIDTH = 4) + + : done (DONE), + reset (RESET), + a (A), + b (B), + cin (CIN), + ready (READY), + data_width (DATA_WIDTH) + + { + clk(TICK); + SC_CTHREAD( entry, clk.neg() ); + } + + void entry(); +}; |