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/control/loop/for_exit | |
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/control/loop/for_exit')
9 files changed, 645 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.cpp b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.cpp new file mode 100644 index 000000000..05c349065 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** + + 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-27 + + *****************************************************************************/ + +/***************************************************************************** + + 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(){ + + wait(2); + while(1) { + // Reading Data, and Counter i,j is counted up. + while (out_valid.read()==false) wait(); + cout << "Display : " << result.read() << " " + << " at " << sc_time_stamp() << endl; + wait(); + } +} + diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.h b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.h new file mode 100644 index 000000000..e858eb226 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/display.h @@ -0,0 +1,66 @@ +/***************************************************************************** + + 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-22 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +#include "systemc.h" + +SC_MODULE( display ) +{ + SC_HAS_PROCESS( display ); + + sc_in_clk clk; + + const sc_signal<int>& result; // Input port + const sc_signal<bool>& out_valid; + + display( sc_module_name NAME, + sc_clock& CLK, + const sc_signal<int>& RESULT, + const sc_signal<bool>& OUT_VALID + ) + : + result(RESULT), + out_valid(OUT_VALID) + { + clk(CLK); + SC_CTHREAD( entry, clk.pos() ); + } + + void entry(); +}; + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.cpp b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.cpp new file mode 100644 index 000000000..db3ac2bb9 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.cpp @@ -0,0 +1,102 @@ +/***************************************************************************** + + 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. + + *****************************************************************************/ + +/***************************************************************************** + + for_exit.cpp -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-29 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +#include "for_exit.h" + +#define max 10 + +void for_exit::entry() +{ + + int i, inp_tmp; + + // reset_loop + if (reset.read()==true) { + result.write(0); + out_valid.write(false); + wait(); + } else wait(); + + //---------- + // main loop + //---------- + while(1) { + + // read inputs + while (in_valid.read()==false) wait(); + + // execution of for loop with continues + out_valid.write(true); + wait(); + for (i=1; i<=max; i++) { + inp_tmp = in_value.read(); + if (i==8) { + wait(); + continue; + } else if (inp_tmp<5 && i!=1) { + wait(); + continue; + } else { + result.write(inp_tmp); + wait(); + }; + }; + out_valid.write(false); + wait(5); + + // for loop with break + out_valid.write(true); + wait(); + for (i=1; i<=max; i++) { + inp_tmp = in_value.read(); + if (inp_tmp==7) { + wait(); + break; + } else { + result.write(inp_tmp); + wait(); + } + }; + out_valid.write(false); + wait(); + + } +} + +// EOF + diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.f b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.f new file mode 100644 index 000000000..b1509dea5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.f @@ -0,0 +1,4 @@ +for_exit/main.cpp +for_exit/stimulus.cpp +for_exit/display.cpp +for_exit/for_exit.cpp diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.h b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.h new file mode 100644 index 000000000..8d2de9783 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/for_exit.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. + + *****************************************************************************/ + +/***************************************************************************** + + for_exit.h -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-27 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +#include "systemc.h" + +SC_MODULE( for_exit ) +{ + SC_HAS_PROCESS( for_exit ); + + sc_in_clk clk; + + const sc_signal<bool>& reset; + const sc_signal<bool>& in_valid; + const sc_signal<int>& in_value; + sc_signal<bool>& out_valid; + sc_signal<int>& result; + + for_exit( + sc_module_name NAME, // referense name + sc_clock& CLK, // clock + const sc_signal<bool>& RESET, + const sc_signal<bool>& IN_VALID, + const sc_signal<int>& IN_VALUE, + sc_signal<bool>& OUT_VALID, + sc_signal<int>& RESULT + ) + : + reset (RESET), + in_valid (IN_VALID), + in_value (IN_VALUE), + out_valid (OUT_VALID), + result (RESULT) + { + clk (CLK); + SC_CTHREAD( entry, clk.pos() ); + reset_signal_is(reset,true); + }; + void entry (); +}; diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/golden/for_exit.log b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/golden/for_exit.log new file mode 100644 index 000000000..a7037c4e5 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/golden/for_exit.log @@ -0,0 +1,123 @@ +SystemC Simulation +Stimuli1 : in_valid = true in_value 0 at 6 ns +Stimuli1 : in_valid = true in_value 1 at 7 ns +Stimuli1 : in_valid = true in_value 2 at 8 ns +Display : 0 at 8 ns +Stimuli1 : in_valid = true in_value 3 at 9 ns +Display : 1 at 9 ns +Stimuli1 : in_valid = true in_value 4 at 10 ns +Display : 1 at 10 ns +Stimuli1 : in_valid = true in_value 5 at 11 ns +Display : 1 at 11 ns +Stimuli1 : in_valid = true in_value 6 at 12 ns +Display : 1 at 12 ns +Stimuli1 : in_valid = true in_value 7 at 13 ns +Display : 5 at 13 ns +Stimuli1 : in_valid = true in_value 8 at 14 ns +Display : 6 at 14 ns +Stimuli1 : in_valid = true in_value 9 at 15 ns +Display : 7 at 15 ns +Stimuli1 : in_valid = true in_value 10 at 16 ns +Display : 7 at 16 ns +Display : 9 at 17 ns +Display : 10 at 18 ns +Stimuli2 : in_valid = true in_value 0 at 21 ns +Stimuli2 : in_valid = true in_value 1 at 22 ns +Stimuli2 : in_valid = true in_value 2 at 23 ns +Stimuli2 : in_valid = true in_value 3 at 24 ns +Display : 10 at 24 ns +Stimuli2 : in_valid = true in_value 4 at 25 ns +Display : 2 at 25 ns +Stimuli2 : in_valid = true in_value 5 at 26 ns +Display : 3 at 26 ns +Stimuli2 : in_valid = true in_value 6 at 27 ns +Display : 4 at 27 ns +Stimuli2 : in_valid = true in_value 7 at 28 ns +Display : 5 at 28 ns +Stimuli2 : in_valid = true in_value 8 at 29 ns +Display : 6 at 29 ns +Stimuli2 : in_valid = true in_value 9 at 30 ns +Display : 6 at 30 ns +Stimuli2 : in_valid = true in_value 10 at 31 ns +Stimuli1 : in_valid = true in_value 0 at 42 ns +Stimuli1 : in_valid = true in_value 1 at 43 ns +Stimuli1 : in_valid = true in_value 2 at 44 ns +Display : 6 at 44 ns +Stimuli1 : in_valid = true in_value 3 at 45 ns +Display : 1 at 45 ns +Stimuli1 : in_valid = true in_value 4 at 46 ns +Display : 1 at 46 ns +Stimuli1 : in_valid = true in_value 5 at 47 ns +Display : 1 at 47 ns +Stimuli1 : in_valid = true in_value 6 at 48 ns +Display : 1 at 48 ns +Stimuli1 : in_valid = true in_value 7 at 49 ns +Display : 5 at 49 ns +Stimuli1 : in_valid = true in_value 8 at 50 ns +Display : 6 at 50 ns +Stimuli1 : in_valid = true in_value 9 at 51 ns +Display : 7 at 51 ns +Stimuli1 : in_valid = true in_value 10 at 52 ns +Display : 7 at 52 ns +Display : 9 at 53 ns +Display : 10 at 54 ns +Stimuli2 : in_valid = true in_value 0 at 57 ns +Stimuli2 : in_valid = true in_value 1 at 58 ns +Stimuli2 : in_valid = true in_value 2 at 59 ns +Stimuli2 : in_valid = true in_value 3 at 60 ns +Display : 10 at 60 ns +Stimuli2 : in_valid = true in_value 4 at 61 ns +Display : 2 at 61 ns +Stimuli2 : in_valid = true in_value 5 at 62 ns +Display : 3 at 62 ns +Stimuli2 : in_valid = true in_value 6 at 63 ns +Display : 4 at 63 ns +Stimuli2 : in_valid = true in_value 7 at 64 ns +Display : 5 at 64 ns +Stimuli2 : in_valid = true in_value 8 at 65 ns +Display : 6 at 65 ns +Stimuli2 : in_valid = true in_value 9 at 66 ns +Display : 6 at 66 ns +Stimuli2 : in_valid = true in_value 10 at 67 ns +Stimuli1 : in_valid = true in_value 0 at 78 ns +Stimuli1 : in_valid = true in_value 1 at 79 ns +Stimuli1 : in_valid = true in_value 2 at 80 ns +Display : 6 at 80 ns +Stimuli1 : in_valid = true in_value 3 at 81 ns +Display : 1 at 81 ns +Stimuli1 : in_valid = true in_value 4 at 82 ns +Display : 1 at 82 ns +Stimuli1 : in_valid = true in_value 5 at 83 ns +Display : 1 at 83 ns +Stimuli1 : in_valid = true in_value 6 at 84 ns +Display : 1 at 84 ns +Stimuli1 : in_valid = true in_value 7 at 85 ns +Display : 5 at 85 ns +Stimuli1 : in_valid = true in_value 8 at 86 ns +Display : 6 at 86 ns +Stimuli1 : in_valid = true in_value 9 at 87 ns +Display : 7 at 87 ns +Stimuli1 : in_valid = true in_value 10 at 88 ns +Display : 7 at 88 ns +Display : 9 at 89 ns +Display : 10 at 90 ns +Stimuli2 : in_valid = true in_value 0 at 93 ns +Stimuli2 : in_valid = true in_value 1 at 94 ns +Stimuli2 : in_valid = true in_value 2 at 95 ns +Stimuli2 : in_valid = true in_value 3 at 96 ns +Display : 10 at 96 ns +Stimuli2 : in_valid = true in_value 4 at 97 ns +Display : 2 at 97 ns +Stimuli2 : in_valid = true in_value 5 at 98 ns +Display : 3 at 98 ns +Stimuli2 : in_valid = true in_value 6 at 99 ns +Display : 4 at 99 ns +Stimuli2 : in_valid = true in_value 7 at 100 ns +Display : 5 at 100 ns +Stimuli2 : in_valid = true in_value 8 at 101 ns +Display : 6 at 101 ns +Stimuli2 : in_valid = true in_value 9 at 102 ns +Display : 6 at 102 ns +Stimuli2 : in_valid = true in_value 10 at 103 ns + +Info: /OSCI/SystemC: Simulation stopped by user. diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/main.cpp b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/main.cpp new file mode 100644 index 000000000..b560aab5e --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/main.cpp @@ -0,0 +1,81 @@ +/***************************************************************************** + + 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-27 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +#include "for_exit.h" +#include "stimulus.h" +#include "display.h" + +int sc_main (int argc , char *argv[]) { + sc_clock clock; + sc_signal<bool> reset; + sc_signal<bool> out_valid; + sc_signal<int> in_value; + sc_signal<bool> in_valid; + sc_signal<int> result; + + + for_exit for_exit1 ( + "process_body", + clock, + reset, + in_valid, + in_value, + out_valid, + result + ); + + stimulus stimulus1 ( + "stimulus", + clock, + reset, + in_value, + in_valid + ); + + display display1 ( + "display", + clock, + result, + out_valid + ); + + sc_start(); + return 0; +} + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.cpp b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.cpp new file mode 100644 index 000000000..d45342c41 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.cpp @@ -0,0 +1,75 @@ +/***************************************************************************** + + 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-27 + + *****************************************************************************/ + +/***************************************************************************** + + 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 i, j; + + // sending some reset values + reset.write(true); + in_valid.write(false); + in_value.write(0); + wait(); + reset.write(false); + wait(5); + for(i=0; i<3; i++){ + in_valid.write(true); + for(j=0; j<=10; j++) { + in_value.write(j); + cout << "Stimuli1 : in_valid = true in_value " << j << " at " + << sc_time_stamp() << endl; + wait(); + }; + in_valid.write(false); + wait(4); + for(j=0; j<=10; j++) { + in_value.write(j); + cout << "Stimuli2 : in_valid = true in_value " << j << " at " + << sc_time_stamp() << endl; + wait(); + }; + wait(10); + }; + + wait(15); + sc_stop(); +} + +// EOF diff --git a/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.h b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.h new file mode 100644 index 000000000..d8bccb0f1 --- /dev/null +++ b/src/systemc/tests/systemc/misc/cae_test/general/control/loop/for_exit/stimulus.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. + + *****************************************************************************/ + +/***************************************************************************** + + stimulus.h -- + + Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-27 + + *****************************************************************************/ + +/***************************************************************************** + + MODIFICATION LOG - modifiers, enter your name, affiliation, date and + changes you are making here. + + Name, Affiliation, Date: + Description of Modification: + + *****************************************************************************/ + + +#include "systemc.h" + +SC_MODULE( stimulus ) +{ + SC_HAS_PROCESS( stimulus ); + + sc_in_clk clk; + + sc_signal<bool>& reset; + sc_signal<int>& in_value; + sc_signal<bool>& in_valid; + + stimulus(sc_module_name NAME, + sc_clock& CLK, + sc_signal<bool>& RESET, + sc_signal<int>& IN_VALUE, + sc_signal<bool>& IN_VALID + ) + : + reset (RESET), + in_value (IN_VALUE), + in_valid (IN_VALID) + { + clk (CLK); + SC_CTHREAD( entry, clk.pos() ); + } + void entry(); +}; + +// EOF |