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/chpt12.1/accessor.cpp | 84 ++++++++++++++++++++++ .../systemc/misc/user_guide/chpt12.1/accessor.h | 74 +++++++++++++++++++ .../systemc/misc/user_guide/chpt12.1/chpt12.1.f | 3 + .../systemc/misc/user_guide/chpt12.1/common.h | 46 ++++++++++++ .../misc/user_guide/chpt12.1/golden/chpt12.1.log | 15 ++++ .../systemc/misc/user_guide/chpt12.1/main.cpp | 60 ++++++++++++++++ .../tests/systemc/misc/user_guide/chpt12.1/ram.cpp | 60 ++++++++++++++++ .../tests/systemc/misc/user_guide/chpt12.1/ram.h | 74 +++++++++++++++++++ 8 files changed, 416 insertions(+) create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/accessor.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/chpt12.1.f create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/common.h create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/golden/chpt12.1.log create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/main.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.cpp create mode 100644 src/systemc/tests/systemc/misc/user_guide/chpt12.1/ram.h (limited to 'src/systemc/tests/systemc/misc/user_guide/chpt12.1') 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& chip_select; //output + sc_signal& 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& CHIP_SELECT, + sc_signal& 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 > signal_bool_vector10; +typedef sc_signal > 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 cs("CS"); + sc_signal 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& cs; //input + const sc_signal& 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& CS, + const sc_signal& 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(); +}; + + -- cgit v1.2.3