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/chpt6.1/chpt6.1.f | 5 ++ .../tests/systemc/misc/user_guide/chpt6.1/common.h | 47 +++++++++++++++ .../systemc/misc/user_guide/chpt6.1/display.cpp | 47 +++++++++++++++ .../systemc/misc/user_guide/chpt6.1/display.h | 63 ++++++++++++++++++++ .../systemc/misc/user_guide/chpt6.1/driver.cpp | 64 ++++++++++++++++++++ .../tests/systemc/misc/user_guide/chpt6.1/driver.h | 69 ++++++++++++++++++++++ .../misc/user_guide/chpt6.1/golden/chpt6.1.log | 12 ++++ .../tests/systemc/misc/user_guide/chpt6.1/main.cpp | 59 ++++++++++++++++++ .../systemc/misc/user_guide/chpt6.1/pullup.cpp | 50 ++++++++++++++++ .../tests/systemc/misc/user_guide/chpt6.1/pullup.h | 65 ++++++++++++++++++++ .../systemc/misc/user_guide/chpt6.1/ts_buf.cpp | 60 +++++++++++++++++++ .../tests/systemc/misc/user_guide/chpt6.1/ts_buf.h | 67 +++++++++++++++++++++ 12 files changed, 608 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/chpt6.1.f create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/common.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/display.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/driver.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/golden/chpt6.1.log create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/main.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/pullup.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt6.1/ts_buf.h (limited to 'src/systemc/tests/systemc/misc/user_guide/chpt6.1') 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 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& control; //output + sc_signal& out; //output + + //Constructor + driver(sc_module_name NAME, + sc_clock& CLK, + const signal_std_logic& IN_, + sc_signal& CONTROL, + sc_signal& 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 control; + sc_signal 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& in; //input + const sc_signal& control; //input + signal_std_logic& ts_out; //output + + //Constructor + ts_buf(sc_module_name NAME, + const sc_signal& IN_, + const sc_signal& 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(); +}; + + -- cgit v1.2.3