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/chpt5.1 | |
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/chpt5.1')
7 files changed, 364 insertions, 0 deletions
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(); +}; + + |