summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/misc/user_guide/chpt3.2
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/misc/user_guide/chpt3.2')
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f4
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp52
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h62
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp83
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h75
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log32
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp63
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp58
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h64
-rw-r--r--src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase9
10 files changed, 502 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f
new file mode 100644
index 000000000..88feda635
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/chpt3.2.f
@@ -0,0 +1,4 @@
+chpt3.2/counter.cpp
+chpt3.2/fsmr.cpp
+chpt3.2/main.cpp
+chpt3.2/sg.cpp
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.cpp
new file mode 100644
index 000000000..7dbab48d1
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ counter.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:
+
+ *****************************************************************************/
+
+/* File containing functionality of counter */
+
+#include "counter.h"
+
+void counter::entry()
+{
+ int count;
+
+ count = 0;
+ while (true) { // infinite loop
+ do { wait(); } while (found != true);
+ count = count + 1;
+ cout << "\nFound Count is " << count << "\n";
+ }
+}
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h
new file mode 100644
index 000000000..400246f5f
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/counter.h
@@ -0,0 +1,62 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ counter.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:
+
+ *****************************************************************************/
+
+/* Header file for the counter that counts number of strings found */
+
+#include "systemc.h"
+
+SC_MODULE( counter )
+{
+ SC_HAS_PROCESS( counter );
+
+ sc_in_clk clk;
+
+ // The inputs
+ const sc_signal<bool>& found;
+
+ // The constructor
+ counter(sc_module_name NAME,
+ sc_clock& POS_CLK,
+ const sc_signal<bool>& FOUND)
+ : found(FOUND) {
+ clk(POS_CLK);
+ SC_CTHREAD( entry, clk.pos() );
+ }
+
+ // The main functionality of the process
+ void entry();
+};
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp
new file mode 100644
index 000000000..adb1a9c81
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.cpp
@@ -0,0 +1,83 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ fsmr.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:
+
+ *****************************************************************************/
+
+/* File containing functionality of the FSM recognizer */
+
+#include "fsmr.h"
+
+void fsm_recognizer::entry()
+{
+ char c;
+ int state = 0;
+ bool out;
+
+ while (true) {
+ do { wait(); } while (data_ready != true);
+ c = input_char.read();
+ cout << c;
+
+ switch(state) {
+ case 0:
+ if (c == pattern[0]) state = 1;
+ else state = 0;
+ out = false;
+ break;
+ case 1:
+ if (c == pattern[1]) state = 2;
+ else state = 0;
+ out = false;
+ break;
+ case 2:
+ if (c == pattern[2]) state = 3;
+ else state = 0;
+ out = false;
+ break;
+ case 3:
+ if (c == pattern[3]) out = true;
+ else out = false;
+ state = 0;
+ break;
+ default:
+ cout << "Error: FSM in bad state." << endl;
+ break;
+ }
+
+ found.write(out);
+ wait(); // for writing the found signal
+ found.write(false); // reset the found signal
+ }
+}
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h
new file mode 100644
index 000000000..13b192655
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/fsmr.h
@@ -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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ fsmr.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:
+
+ *****************************************************************************/
+
+/* Header file for FSM recognizer */
+
+#include "systemc.h"
+
+SC_MODULE( fsm_recognizer )
+{
+ SC_HAS_PROCESS( fsm_recognizer );
+
+ sc_in_clk clk;
+
+ // The input signals
+ const sc_signal<char>& input_char; // The input character
+ const sc_signal<bool>& data_ready; // The data ready signal
+ // The output signals
+ sc_signal<bool>& found; // The indicator that sequence found
+
+ // The internal variables
+ char pattern[4]; // This string will hold the pattern to match against
+
+ // The constructor
+ fsm_recognizer(sc_module_name NAME,
+ sc_clock& TICK,
+ const sc_signal<char>& INPUT_CHAR,
+ const sc_signal<bool>& DATA_READY,
+ sc_signal<bool>& FOUND)
+ : input_char(INPUT_CHAR), data_ready(DATA_READY),
+ found(FOUND) {
+ clk(TICK);
+ SC_CTHREAD( entry, clk.pos() );
+ pattern[0] = 'S';
+ pattern[1] = 'c';
+ pattern[2] = 'e';
+ pattern[3] = 'n';
+ }
+
+ // The functionality of the process
+ void entry();
+};
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log
new file mode 100644
index 000000000..959b3c600
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/golden/chpt3.2.log
@@ -0,0 +1,32 @@
+SystemC Simulation
+Synopsys is delivering great value through Scen
+Found Count is 1
+ic. I cannot wait to use Scen
+Found Count is 2
+ic
+Compiler and Scen
+Found Count is 3
+ic Simulator. I am learning a lot about modeling using
+Scen
+Found Count is 4
+ic.
+
+This is a testcase for my first Scen
+Found Count is 5
+ic program. I have learnt modeling using
+Scen
+Found Count is 6
+ic and would now like to check if I can really program in Scen
+Found Count is 7
+ic. There is
+no doubt in my mind that Scen
+Found Count is 8
+ic is the best way to model hardware. The Scen
+Found Count is 9
+ic
+Compiler will make a lot of things easy by implementing by refined Scen
+Found Count is 10
+ic
+models.
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp
new file mode 100644
index 000000000..eeed80090
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/main.cpp
@@ -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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ 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 - top level */
+
+#include "counter.h"
+#include "sg.h"
+#include "fsmr.h"
+
+int sc_main(int ac, char **av)
+{
+ sc_signal<bool> handshake ("HS");
+ sc_signal<bool> found;
+ sc_signal<char> stream ("ST");
+
+ sc_clock clk("Clock", 20, SC_NS, 0.5, 0.0, SC_NS);
+
+ counter cnt("COUNTER", clk, found);
+ fsm_recognizer fsm("Recog", clk, stream, handshake, found);
+ stimgen chargen("TESTB", clk, stream, handshake);
+
+ // initialize signals - ali
+ handshake = false;
+ found = false;
+
+ sc_start();
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.cpp
new file mode 100644
index 000000000..995d4a2c5
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sg.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:
+
+ *****************************************************************************/
+
+/* File containing functionality for the Stimulus Generator */
+
+#include "sg.h"
+
+void stimgen::entry()
+{
+ char c;
+ FILE *file;
+
+ file = fopen("./chpt3.2/testcase", "r");
+
+ while (true) {
+ if (fscanf(file, "%c", &c) == EOF)
+ sc_stop();
+ data_ready.write(true);
+ stream.write(c);
+ wait();
+ data_ready.write(false);
+ wait();
+ }
+}
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h
new file mode 100644
index 000000000..937c3169e
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/sg.h
@@ -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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ sg.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:
+
+ *****************************************************************************/
+
+/* Header file for the stimulus generator */
+
+#include "systemc.h"
+
+SC_MODULE( stimgen )
+{
+ SC_HAS_PROCESS( stimgen );
+
+ sc_in_clk clk;
+
+ // The output
+ sc_signal<char>& stream;
+ sc_signal<bool>& data_ready;
+
+ // The constructor
+ stimgen(sc_module_name NAME,
+ sc_clock& CLK,
+ sc_signal<char>& STREAM,
+ sc_signal<bool>& DATA_READY)
+ : stream(STREAM), data_ready(DATA_READY) {
+ clk(CLK);
+ SC_CTHREAD( entry, clk.pos() );
+ }
+
+ // The functionality of the process
+ void entry();
+};
diff --git a/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase
new file mode 100644
index 000000000..3b56603ff
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/user_guide/chpt3.2/testcase
@@ -0,0 +1,9 @@
+Synopsys is delivering great value through Scenic. I cannot wait to use Scenic
+Compiler and Scenic Simulator. I am learning a lot about modeling using
+Scenic.
+
+This is a testcase for my first Scenic program. I have learnt modeling using
+Scenic and would now like to check if I can really program in Scenic. There is
+no doubt in my mind that Scenic is the best way to model hardware. The Scenic
+Compiler will make a lot of things easy by implementing by refined Scenic
+models.