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/cae_test/general/arith/addition/increment | |
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/cae_test/general/arith/addition/increment')
10 files changed, 626 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/common.h b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/common.h new file mode 100644 index 000000000..b0b56195b --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/common.h @@ -0,0 +1,45 @@ +/***************************************************************************** + + 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<sc_bv<5> > sc_signal_bool_vector; + +#endif diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.cpp b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.cpp new file mode 100644 index 000000000..64c5ee2b4 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.cpp @@ -0,0 +1,58 @@ +/***************************************************************************** + + 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: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "display.h" + +void display::entry(){ + int i = 0; + + wait(2); + while(1) { + // Reading Data, and Counter i,j is counted up.
+ while (in_valid.read()==false) wait(); + cout << "Display : " << in_data1.read() << " " + << in_data2.read() << " " + << " at " << sc_time_stamp() << endl; + + i++; + if(i == 24) sc_stop(); + wait(); + } +} + + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.h b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.h new file mode 100644 index 000000000..21e3c27fd --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/display.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. + + *****************************************************************************/ + +/***************************************************************************** + + display.h -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "common.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + sc_in_clk clk; + + const sc_signal<int>& in_data1; // Input port + const sc_signal_bool_vector& in_data2; // Input port + const sc_signal<bool>& in_valid; + + display( sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& IN_DATA1, + const sc_signal_bool_vector& IN_DATA2, + const sc_signal<bool>& IN_VALID + ) + : + in_data1(IN_DATA1), + in_data2(IN_DATA2), + in_valid(IN_VALID) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/golden/increment.log b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/golden/increment.log new file mode 100644 index 000000000..e8205e774 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/golden/increment.log @@ -0,0 +1,51 @@ +SystemC Simulation +Stimuli : 0 0 at 23 ns +Display : 3 00011 at 27 ns +Stimuli : 4 4 at 44 ns +Display : 7 00111 at 48 ns +Stimuli : 8 8 at 65 ns +Display : 11 01011 at 69 ns +Stimuli : 12 12 at 86 ns +Display : 15 01111 at 90 ns +Stimuli : 16 -16 at 107 ns +Display : 19 10011 at 111 ns +Stimuli : 20 -12 at 128 ns +Display : 23 10111 at 132 ns +Stimuli : 24 -8 at 149 ns +Display : 27 11011 at 153 ns +Stimuli : 28 -4 at 170 ns +Display : 31 11111 at 174 ns +Stimuli : 32 0 at 191 ns +Display : 35 00011 at 195 ns +Stimuli : 36 4 at 212 ns +Display : 39 00111 at 216 ns +Stimuli : 40 8 at 233 ns +Display : 43 01011 at 237 ns +Stimuli : 44 12 at 254 ns +Display : 47 01111 at 258 ns +Stimuli : 48 -16 at 275 ns +Display : 51 10011 at 279 ns +Stimuli : 52 -12 at 296 ns +Display : 55 10111 at 300 ns +Stimuli : 56 -8 at 317 ns +Display : 59 11011 at 321 ns +Stimuli : 60 -4 at 338 ns +Display : 63 11111 at 342 ns +Stimuli : 64 0 at 359 ns +Display : 67 00011 at 363 ns +Stimuli : 68 4 at 380 ns +Display : 71 00111 at 384 ns +Stimuli : 72 8 at 401 ns +Display : 75 01011 at 405 ns +Stimuli : 76 12 at 422 ns +Display : 79 01111 at 426 ns +Stimuli : 80 -16 at 443 ns +Display : 83 10011 at 447 ns +Stimuli : 84 -12 at 464 ns +Display : 87 10111 at 468 ns +Stimuli : 88 -8 at 485 ns +Display : 91 11011 at 489 ns +Stimuli : 92 -4 at 506 ns +Display : 95 11111 at 510 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.cpp b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.cpp new file mode 100644 index 000000000..3b32d2317 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.cpp @@ -0,0 +1,85 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + increment.cpp -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "increment.h" + +void increment::entry(){ + + #define ONE 1 + const int eins = 1; + int tmp1; + sc_bigint<5> tmp2; + + // reset_loop + if (reset.read() == true) { + out_valid.write(false); + wait(); + } else wait(); + + // + // main loop + // + // + while(1) { + while(in_valid.read()==false) wait(); + wait(); + + //reading the inputs + tmp1 = in_value1.read(); + tmp2 = in_value2.read(); + + //execute simple operations + tmp1 = tmp1 + 1; + tmp1 = tmp1 + ONE; + tmp1 = tmp1 + eins; + tmp2 = tmp2 + 1; + tmp2 = tmp2 + ONE; + tmp2 = tmp2 + eins; + wait(); + + // write outputs + out_value1.write(tmp1); + out_value2.write(tmp2); + out_valid.write(true); + wait(); + out_valid.write(false); + wait(); + } +} + +// EOF + diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.f b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.f new file mode 100644 index 000000000..3e7b5f3b7 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.f @@ -0,0 +1,4 @@ +increment/stimulus.cpp +increment/display.cpp +increment/increment.cpp +increment/main.cpp diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.h b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.h new file mode 100644 index 000000000..30093ede8 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/increment.h @@ -0,0 +1,96 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + increment.h -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "common.h" + +SC_MODULE( increment ) +{ + SC_HAS_PROCESS( increment ); + + sc_in_clk clk; + + //==================================================================== + // [C] Always Needed Member Function + // -- constructor + // -- entry + //==================================================================== + + const sc_signal<bool>& reset ; + const sc_signal<int>& in_value1; // Input port + const sc_signal_bool_vector& in_value2; // Input port + const sc_signal<bool>& in_valid; // Input port + sc_signal<int>& out_value1; // Output port + sc_signal_bool_vector& out_value2; // Output port + sc_signal<bool>& out_valid; // Output port + + // + // Constructor + // + + increment ( + sc_module_name NAME, // referense name + sc_clock& CLK, // clock + const sc_signal<bool>& RESET, + const sc_signal<int>& IN_VALUE1, + const sc_signal_bool_vector& IN_VALUE2, + const sc_signal<bool>& IN_VALID, // Input port + sc_signal<int>& OUT_VALUE1, + sc_signal_bool_vector& OUT_VALUE2, + sc_signal<bool>& OUT_VALID // Output port + ) + : + reset (RESET), + in_value1 (IN_VALUE1), + in_value2 (IN_VALUE2), + in_valid (IN_VALID), + out_value1 (OUT_VALUE1), + out_value2 (OUT_VALUE2), + out_valid (OUT_VALID) + + { + clk (CLK); + SC_CTHREAD( entry, clk.pos() ); + reset_signal_is(reset,true); + }; + + // + + void entry (); + +}; + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/main.cpp b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/main.cpp new file mode 100644 index 000000000..6189f9dc5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/main.cpp @@ -0,0 +1,79 @@ +/***************************************************************************** + + 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: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "stimulus.h" +#include "display.h" +#include "increment.h" + +int sc_main (int argc , char *argv[]) { + sc_clock clock; + sc_signal<bool> reset; + sc_signal<int> stimulus_line1; + sc_signal_bool_vector stimulus_line2; + sc_signal<bool> input_valid; + sc_signal<bool> output_valid; + sc_signal<int> result_line1; + sc_signal_bool_vector result_line2; + + stimulus stimulus1("stimulus_block", + clock, + reset, + stimulus_line1, + stimulus_line2, + input_valid); + + increment increment1 ( "process_body", + clock, + reset, + stimulus_line1, + stimulus_line2, + input_valid, + result_line1, + result_line2, + output_valid); + + display display1 ( "display", + clock, + result_line1, + result_line2, + output_valid); + + sc_start(); + return 0; +} + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.cpp b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.cpp new file mode 100644 index 000000000..9f22a9c34 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.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. + + *****************************************************************************/ + +/***************************************************************************** + + stimulus.cpp -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "stimulus.h" + +void stimulus::entry() +{ + int send_value1 = 0; + sc_signed send_value2(5); + + // sending some reset values + reset.write(true); + out_valid.write(false); + send_value2 = 0; + out_stimulus1.write(0); + out_stimulus2.write(0); + wait(3); + reset.write(false); + // sending normal mode values + while(true){ + wait(20); + out_stimulus1.write( send_value1 ); + out_stimulus2.write( send_value2 ); + out_valid.write( true ); + cout << "Stimuli : " << send_value1 << " " + << send_value2 << " at " + << sc_time_stamp() << endl; + send_value1 = send_value1+4; + send_value2 = send_value2+4; + wait(); + out_valid.write( false ); + } +} + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.h b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.h new file mode 100644 index 000000000..0bda545fa --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/arith/addition/increment/stimulus.h @@ -0,0 +1,71 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + stimulus.h -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-09 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + +#include "common.h" + +SC_MODULE( stimulus ) +{ + SC_HAS_PROCESS( stimulus ); + + sc_in_clk clk; + + sc_signal<bool>& reset; + sc_signal<int>& out_stimulus1; + sc_signal_bool_vector& out_stimulus2; + sc_signal<bool>& out_valid; + + stimulus(sc_module_name NAME, + sc_clock& CLK, + sc_signal<bool>& RESET, + sc_signal<int>& OUT_STIMULUS1, + sc_signal_bool_vector& OUT_STIMULUS2, + sc_signal<bool>& OUT_VALID + ) + : + reset(RESET), + out_stimulus1(OUT_STIMULUS1), + out_stimulus2(OUT_STIMULUS2), + out_valid(OUT_VALID) + { + clk (CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; + +// EOF |