diff options
Diffstat (limited to 'src/systemc/tests/systemc/misc/sim_tests/hshake2')
7 files changed, 361 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/sim_tests/hshake2/golden/hshake2.log b/src/systemc/tests/systemc/misc/sim_tests/hshake2/golden/hshake2.log new file mode 100644 index 000000000..97b3db6b8 --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/golden/hshake2.log @@ -0,0 +1,33 @@ +SystemC Simulation + +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 +Transfer complete + +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 +Transfer complete + +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 +Transfer complete + +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/sim_tests/hshake2/hshake2.f b/src/systemc/tests/systemc/misc/sim_tests/hshake2/hshake2.f new file mode 100644 index 000000000..a898f3890 --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/hshake2.f @@ -0,0 +1,3 @@ +hshake2/proc1.cpp +hshake2/proc2.cpp +hshake2/main.cpp diff --git a/src/systemc/tests/systemc/misc/sim_tests/hshake2/main.cpp b/src/systemc/tests/systemc/misc/sim_tests/hshake2/main.cpp new file mode 100644 index 000000000..1e0b0eefa --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/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("DataReady"); + sc_signal<bool> data_ack("DataAck"); + sc_signal<int> data("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/sim_tests/hshake2/proc1.cpp b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc1.cpp new file mode 100644 index 000000000..24807ef25 --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/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 << "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 == false); + 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 << "Transfer complete" << endl; + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc1.h b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc1.h new file mode 100644 index 000000000..540706ce3 --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc1.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. + + *****************************************************************************/ + +/***************************************************************************** + + 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; + + sc_in<bool> data_ack; + sc_inout<int> data; + sc_inout<bool> data_ready; + + // Constructor + proc1( sc_module_name NAME, + sc_clock& CLK, + sc_signal<bool>& DATA_ACK, + sc_signal<int>& DATA, + sc_signal<bool>& DATA_READY ) + { + clk(CLK); + data_ack(DATA_ACK); data(DATA); data_ready(DATA_READY); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; diff --git a/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc2.cpp b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc2.cpp new file mode 100644 index 000000000..f1bb5a519 --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/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 == false); + 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 == true); + data_ack.write(false); + } +} // end of entry function + diff --git a/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc2.h b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc2.h new file mode 100644 index 000000000..769ad5aed --- /dev/null +++ b/src/systemc/tests/systemc/misc/sim_tests/hshake2/proc2.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. + + *****************************************************************************/ + +/***************************************************************************** + + 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; + + sc_in<bool> data_ready; + sc_in<int> data; + sc_out<bool> data_ack; + + // Constructor + proc2( sc_module_name NAME, + sc_clock& CLK, + sc_signal<bool>& DATA_READY, + sc_signal<int>& DATA, + sc_signal<bool>& DATA_ACK ) + { + clk(CLK); + data_ready(DATA_READY); data(DATA); data_ack(DATA_ACK); + SC_CTHREAD( entry, clk.pos() ); + } + + // Process functionality in member function below + void entry(); +}; + |