From 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 May 2018 01:37:55 -0700 Subject: systemc: Import tests from the Accellera systemc distribution. Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- .../systemc/misc/user_guide/chpt14.1/chpt14.1.f | 3 + .../misc/user_guide/chpt14.1/golden/chpt14.1.log | 33 +++++++++++ .../systemc/misc/user_guide/chpt14.1/main.cpp | 57 ++++++++++++++++++ .../systemc/misc/user_guide/chpt14.1/proc1.cpp | 69 ++++++++++++++++++++++ .../tests/systemc/misc/user_guide/chpt14.1/proc1.h | 69 ++++++++++++++++++++++ .../systemc/misc/user_guide/chpt14.1/proc2.cpp | 64 ++++++++++++++++++++ .../tests/systemc/misc/user_guide/chpt14.1/proc2.h | 69 ++++++++++++++++++++++ 7 files changed, 364 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/chpt14.1.f create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/golden/chpt14.1.log create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/main.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc1.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt14.1/proc2.h (limited to 'src/systemc/tests/systemc/misc/user_guide/chpt14.1') 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 data_ready; + sc_signal data_ack; + sc_signal 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& data_ack; //input + sc_signal& data; //output + sc_signal& data_ready; //output + + //Constructor + proc1(sc_module_name NAME, + sc_clock& CLK, + const sc_signal& DATA_ACK, + sc_signal& DATA, + sc_signal& 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& data_ready; //input + const sc_signal& data; //input + sc_signal& data_ack; //output + + //Constructor + proc2(sc_module_name NAME, + sc_clock& CLK, + const sc_signal& DATA_READY, + const sc_signal& DATA, + sc_signal& 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(); +}; + + -- cgit v1.2.3