summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/misc/v1.0/dash9
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/misc/v1.0/dash9')
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/const.h62
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/dash9.f5
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/dist.cpp134
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/dist.h183
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/driver.cpp124
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/driver.h69
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/golden/dash9.log35
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/main.cpp169
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/pulse.cpp101
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/pulse.h63
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/speed.cpp111
-rw-r--r--src/systemc/tests/systemc/misc/v1.0/dash9/speed.h154
12 files changed, 1210 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/const.h b/src/systemc/tests/systemc/misc/v1.0/dash9/const.h
new file mode 100644
index 000000000..9bc1ed3bf
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/const.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ const.h -- Constants for the dashboard controller.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#ifndef CONST_H
+#define CONST_H
+
+const int MAX_SPEED = 130; // Car speed in km/h.
+const int MAX_ANGLE = 270; // Needle angle in the speedometer in degrees.
+
+const double DIST_BETWEEN_TWO_PULSES = 0.00066 / 2; // 1/2 of a tire in km.
+const double DIST_INCR = 0.01; // One distance increment in km.
+
+// Two pulses are needed to compute speed.
+const int NUM_PULSES_FOR_SPEED = 2;
+
+// DIST_INCR / DIST_BETWEEN_TWO_PULSES
+const int NUM_PULSES_FOR_DIST_INCR = 61;
+
+const int SLOW_CLOCK_PERIOD0 = 10000; // in 10 x milliseconds.
+const int FAST_CLOCK_PERIOD1 = 50; // in 10 x milliseconds.
+const int ONE_HOUR = 36000000; // in 10 x milliseconds.
+const int PERIODS_PER_HOUR = ONE_HOUR / FAST_CLOCK_PERIOD1;
+
+#define AWAIT(N) \
+ for (register int i = 0; i < N; ++i) \
+ wait();
+
+#endif
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/dash9.f b/src/systemc/tests/systemc/misc/v1.0/dash9/dash9.f
new file mode 100644
index 000000000..bfe0d5fe0
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/dash9.f
@@ -0,0 +1,5 @@
+dash9/driver.cpp
+dash9/dist.cpp
+dash9/main.cpp
+dash9/pulse.cpp
+dash9/speed.cpp
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/dist.cpp b/src/systemc/tests/systemc/misc/v1.0/dash9/dist.cpp
new file mode 100644
index 000000000..7080a461f
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/dist.cpp
@@ -0,0 +1,134 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ dist.cpp -- Implementation of the odometers.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: dist.cpp,v $
+// Revision 1.1.1.1 2006/12/15 20:26:24 acg
+// systemc_tests-2.3
+//
+// Revision 1.3 2006/01/19 00:48:20 acg
+// Andy Goodrich: Changes for the fact signal write checking is enabled.
+//
+// Revision 1.2 2006/01/18 00:23:51 acg
+// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
+//
+
+#define SC_NO_WRITE_CHECK
+#include "systemc.h"
+#include "const.h"
+#include "dist.h"
+
+bool dist_compute_mod::prev_reset;
+double dist_compute_mod::total_compute_dist;
+double dist_compute_mod::partial_compute_dist;
+
+// Get the pulses for one distance increment.
+void
+dist_read_mod::get_dist_proc()
+{
+ wait();
+
+ bool ok = false;
+
+ while (true) {
+
+ // More than one pulse is needed for a distance increment. This
+ // function collects NUM_PULSES_FOR_DIST_INCR pulses for that
+ // purpose.
+ AWAIT(NUM_PULSES_FOR_DIST_INCR);
+
+ if (start)
+ ok = !ok;
+ else
+ ok = false;
+
+ ok_for_incr = ok;
+ }
+}
+
+// Compute total distance.
+void
+dist_compute_mod::compute_total_proc()
+{
+ if (start)
+ total_compute_dist += 1.0;
+ else
+ total_compute_dist = 0.0;
+
+ total_dist = total_compute_dist;
+}
+
+// Compute partial distance.
+void
+dist_compute_mod::compute_partial_proc()
+{
+ if (start) {
+
+ // Implement reset.event():
+ if (prev_reset != (bool) reset)
+ partial_compute_dist = 0.0;
+ else
+ partial_compute_dist += 1.0;
+
+ prev_reset = reset;
+
+ }
+ else
+ partial_compute_dist = 0.0;
+
+ partial_dist = partial_compute_dist;
+}
+
+// LCD display driver.
+void
+dist_lcd_mod::lcd_driver_proc()
+{
+ if (start) {
+
+ if (total_dist.event())
+ total = total_dist * DIST_INCR;
+
+ if (partial_dist.event())
+ partial = partial_dist * DIST_INCR;
+
+ }
+ else {
+ total = 0.0;
+ partial = 0.0;
+ }
+}
+
+// End of file
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/dist.h b/src/systemc/tests/systemc/misc/v1.0/dash9/dist.h
new file mode 100644
index 000000000..6cf8446f0
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/dist.h
@@ -0,0 +1,183 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ dist.h -- Definition of the odometers.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#ifndef DIST_H
+#define DIST_H
+
+SC_MODULE( dist_read_mod )
+{
+ // Input ports:
+ sc_in<bool> pulse; // Pulse coming from the pulse generator.
+ sc_in<bool> start; // Becomes true if the car's started.
+
+ // Output ports:
+ sc_out<bool> ok_for_incr;
+
+ // Get the pulses for one distance increment.
+ void get_dist_proc();
+
+ SC_CTOR( dist_read_mod )
+ {
+ SC_THREAD( get_dist_proc );
+ sensitive << pulse.pos();
+ }
+};
+
+SC_MODULE( dist_compute_mod )
+{
+ // Input ports:
+ sc_in<bool> reset; // Reset the partial distance odometer if true.
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<bool> ok_for_incr;
+
+ // Output ports:
+ sc_out<double> total_dist;
+ sc_out<double> partial_dist;
+
+ // Internal variables:
+ static bool prev_reset;
+ static double total_compute_dist;
+ static double partial_compute_dist;
+
+ // Compute total and partial distances.
+ void compute_total_proc();
+ void compute_partial_proc();
+
+ SC_CTOR( dist_compute_mod )
+ {
+ SC_METHOD( compute_total_proc );
+ sensitive << ok_for_incr;
+
+ SC_METHOD( compute_partial_proc );
+ sensitive << ok_for_incr;
+
+ prev_reset = false;
+ total_compute_dist = 0.0;
+ partial_compute_dist = 0.0;
+ }
+};
+
+SC_MODULE( dist_lcd_mod )
+{
+ // Input ports:
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<double> total_dist;
+ sc_in<double> partial_dist;
+
+ // Output ports:
+ sc_out<double> total; // Total distance.
+ sc_out<double> partial; // Partial distance.
+
+ // LCD display driver.
+ void lcd_driver_proc();
+
+ SC_CTOR( dist_lcd_mod )
+ {
+ SC_METHOD( lcd_driver_proc );
+ sensitive << total_dist << partial_dist;
+ }
+};
+
+SC_MODULE( dist_mod )
+{
+ // Ports:
+ sc_in<bool> pulse; // Pulse coming ftom the pulse generator.
+ sc_in<bool> reset; // Reset the partial distance odometer if true.
+ sc_in<bool> start; // Becomes true if the car's started.
+
+ // Output ports:
+ sc_out<double> total; // Total distance.
+ sc_out<double> partial; // Partial distance.
+
+ // Internal signals:
+ sc_signal<bool> ok_for_incr;
+ sc_signal<double> total_dist;
+ sc_signal<double> partial_dist;
+
+ // Internal models:
+ dist_read_mod *read_mod;
+ dist_compute_mod *compute_mod;
+ dist_lcd_mod *lcd_mod;
+
+ SC_CTOR( dist_mod )
+ {
+ read_mod = new dist_read_mod("read_mod");
+ compute_mod = new dist_compute_mod("compute_mod");
+ lcd_mod = new dist_lcd_mod("lcd_mod");
+
+ // read_mod->pulse.bind(pulse);
+ // read_mod->start.bind(start);
+ // read_mod->ok_for_incr.bind(ok_for_incr);
+
+ read_mod->pulse(pulse);
+ read_mod->start(start);
+ read_mod->ok_for_incr(ok_for_incr);
+
+ // (*read_mod)(pulse, start, ok_for_incr);
+
+ // compute_mod->reset.bind(reset);
+ // compute_mod->start.bind(start);
+ // compute_mod->ok_for_incr.bind(ok_for_incr);
+ // compute_mod->total_dist.bind(total_dist);
+ // compute_mod->partial_dist.bind(partial_dist);
+ compute_mod->reset(reset);
+ compute_mod->start(start);
+ compute_mod->ok_for_incr.bind(ok_for_incr);
+ compute_mod->total_dist.bind(total_dist);
+ compute_mod->partial_dist(partial_dist);
+
+ // lcd_mod->start.bind(start);
+ // lcd_mod->total_dist.bind(total_dist);
+ // lcd_mod->partial_dist.bind(partial_dist);
+ // lcd_mod->total.bind(total);
+ // lcd_mod->partial.bind(partial);
+
+ lcd_mod->start(start);
+ lcd_mod->total_dist(total_dist);
+ lcd_mod->partial_dist(partial_dist);
+ lcd_mod->total(total);
+ lcd_mod->partial(partial);
+
+ // *lcd_mod << start, total_dist, partial_dist, total, partial;
+
+ ok_for_incr = false;
+ total_dist = 0.0;
+ partial_dist = 0.0;
+ }
+};
+
+#endif
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/driver.cpp b/src/systemc/tests/systemc/misc/v1.0/dash9/driver.cpp
new file mode 100644
index 000000000..8f36a3e4f
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/driver.cpp
@@ -0,0 +1,124 @@
+/*****************************************************************************
+
+ 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 -- Implementation of the driver.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: driver.cpp,v $
+// Revision 1.1.1.1 2006/12/15 20:26:24 acg
+// systemc_tests-2.3
+//
+// Revision 1.4 2006/01/24 21:05:59 acg
+// Andy Goodrich: replacement of deprecated features with their non-deprecated
+// counterparts.
+//
+// Revision 1.3 2006/01/19 00:48:20 acg
+// Andy Goodrich: Changes for the fact signal write checking is enabled.
+//
+// Revision 1.2 2006/01/18 00:23:51 acg
+// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
+//
+
+#define SC_NO_WRITE_CHECK
+#include "systemc.h"
+#include "const.h"
+#include "driver.h"
+
+// Driver's output actions.
+void
+driver_mod::driver_out_proc()
+{
+ // while (true) {
+ cout << "Driver is up @ " << sc_time_stamp() << endl;
+
+ // Car is at rest.
+ speed_set = 0;
+ reset = false;
+ start = false;
+ wait();
+
+ cout << "Driver started the car @ " << sc_time_stamp() << endl;
+ cout << "Driver set the speed to 40 km/h @ " << sc_time_stamp() << endl;
+ start = true;
+ speed_set = 40;
+ wait();
+
+ cout << "Driver set the speed to 120 km/h @ " << sc_time_stamp() << endl;
+ speed_set = 120;
+ wait();
+
+ cout << "Driver reset the partial distance odometer @ "
+ << sc_time_stamp() << endl;
+ cout << "Driver set the speed to 60 km/h @ " << sc_time_stamp() << endl;
+ reset = true;
+ speed_set = 60;
+ wait();
+
+ cout << "Driver set the speed to 40 km/h @ " << sc_time_stamp() << endl;
+ speed_set = 40;
+ wait();
+
+ cout << "Driver stopped the car @ " << sc_time_stamp() << endl;
+ wait();
+
+ sc_stop();
+ // }
+}
+
+// Driver's input actions.
+void
+driver_mod::driver_in_proc()
+{
+ if (speed.event()) {
+ cout << "Current speed displayed = "
+ << speed << " km/h @ " << sc_time_stamp() << endl;
+ }
+
+ if (angle.event()) {
+ cout << "Current speedometer angle = " << angle
+ << " degrees @ " << sc_time_stamp() << endl;
+ }
+
+ if (total.event()) {
+ cout << "Current total distance displayed = "
+ << total << " km @ " << sc_time_stamp() << endl;
+ }
+
+ if (partial.event()) {
+ cout << "Current partial distance displayed = "
+ << partial << " km @ " << sc_time_stamp() << endl;
+ }
+}
+
+// End of file
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/driver.h b/src/systemc/tests/systemc/misc/v1.0/dash9/driver.h
new file mode 100644
index 000000000..795fa63b5
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/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 -- Definition of the driver.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#ifndef DRIVER_H
+#define DRIVER_H
+
+SC_MODULE( driver_mod )
+{
+ // Input ports:
+ sc_in_clk clk; // Clock for the actions of the driver.
+ sc_in<double> speed;
+ sc_in<double> angle;
+ sc_in<double> total;
+ sc_in<double> partial;
+
+ // Output ports:
+ sc_out<bool> reset; // Set if the driver wants to reset the partial
+ // distance odometer.
+ sc_out<int> speed_set; // Speed of the car as set by the driver.
+ sc_out<bool> start; // Set if the driver starts the car.
+
+ // Driver's actions.
+ void driver_out_proc();
+ void driver_in_proc();
+
+ SC_CTOR( driver_mod )
+ {
+ SC_CTHREAD( driver_out_proc, clk.pos() );
+
+ SC_METHOD( driver_in_proc );
+ sensitive << speed << angle << total << partial;
+ }
+};
+
+#endif
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/golden/dash9.log b/src/systemc/tests/systemc/misc/v1.0/dash9/golden/dash9.log
new file mode 100644
index 000000000..8668a2d8a
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/golden/dash9.log
@@ -0,0 +1,35 @@
+SystemC Simulation
+Driver is up @ 0 s
+Driver started the car @ 10 us
+Driver set the speed to 40 km/h @ 10 us
+Current speed displayed = 18.2769 km/h @ 10625 ns
+Current speedometer angle = 37.9598 degrees @ 10625 ns
+Current speed displayed = 19.8 km/h @ 11225 ns
+Current speedometer angle = 41.1231 degrees @ 11225 ns
+Driver set the speed to 120 km/h @ 20 us
+Current speed displayed = 26.4 km/h @ 20075 ns
+Current speedometer angle = 54.8308 degrees @ 20075 ns
+Current speed displayed = 59.4 km/h @ 20275 ns
+Current speedometer angle = 123.369 degrees @ 20275 ns
+Current total distance displayed = 0.01 km @ 22775 ns
+Current partial distance displayed = 0.01 km @ 22775 ns
+Current total distance displayed = 0.02 km @ 28875 ns
+Current partial distance displayed = 0.02 km @ 28875 ns
+Driver reset the partial distance odometer @ 30 us
+Driver set the speed to 60 km/h @ 30 us
+Current speed displayed = 39.6 km/h @ 30175 ns
+Current speedometer angle = 82.2462 degrees @ 30175 ns
+Current speed displayed = 29.7 km/h @ 30575 ns
+Current speedometer angle = 61.6846 degrees @ 30575 ns
+Current total distance displayed = 0.03 km @ 39975 ns
+Current partial distance displayed = 0 km @ 39975 ns
+Driver set the speed to 40 km/h @ 40 us
+Current speed displayed = 23.76 km/h @ 40275 ns
+Current speedometer angle = 49.3477 degrees @ 40275 ns
+Current speed displayed = 19.8 km/h @ 40875 ns
+Current speedometer angle = 41.1231 degrees @ 40875 ns
+Driver stopped the car @ 50 us
+Current total distance displayed = 0.04 km @ 58275 ns
+Current partial distance displayed = 0.01 km @ 58275 ns
+
+Info: /OSCI/SystemC: Simulation stopped by user.
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/main.cpp b/src/systemc/tests/systemc/misc/v1.0/dash9/main.cpp
new file mode 100644
index 000000000..22c03af23
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/main.cpp
@@ -0,0 +1,169 @@
+/*****************************************************************************
+
+ 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 -- Main function for the dashboard controller for a
+ car. This controller contains a speedometer, two odometers (total
+ and partial distance), the driver of the car, clocks, and the
+ pulse generator. The pulses are generated by the sensors placed
+ around one of the wheel shafts. The rate of pulse generation is
+ determined by the speed of the car. The driver can start the car,
+ set its speed, reset the partial distance odometer, and stop the
+ car (which means he will stop the simulation). One of the clocks
+ is slow and the other is fast. The fast clock represents the real
+ time. The slow clock is used to control the actions of the
+ driver. The signals in this program are traced.
+
+ dash8's purpose (in terms of changes to dash7's purpose) --
+ Positional connection method for binding the ports of modules.
+ Example: Let m be a module with ports p1 and p2. Let m_ptr be a
+ pointer to m, and let p1_arg and p2_arg be the ports that we want
+ to bind to p1 and p2 of m. Then, we can do the binding in one of
+ the following:
+
+ m(p1_arg, p2_arg); or (*m_ptr)(p1_arg, p2_arg);
+
+ m.p1(p1_arg); m.p2.bind(p2_arg); or
+ m_ptr->p1(p1_arg); m->p2.bind(p2_arg);
+
+ The output of this program is identical to that of dash[6-8].
+
+ purpose (in terms of changes to dash8's purpose) -- the use of
+ module and process declaration macros, defined in systemc.h.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: main.cpp,v $
+// Revision 1.2 2011/01/07 01:20:20 acg
+// Andy Goodrich: update for new IEEE 1666.
+//
+// Revision 1.1.1.1 2006/12/15 20:26:24 acg
+// systemc_tests-2.3
+//
+// Revision 1.5 2006/01/24 21:05:59 acg
+// Andy Goodrich: replacement of deprecated features with their non-deprecated
+// counterparts.
+//
+// Revision 1.4 2006/01/20 00:43:24 acg
+// Andy Goodrich: Changed over to use putenv() instead of setenv() to accommodate old versions of Solaris.
+//
+// Revision 1.3 2006/01/19 00:48:20 acg
+// Andy Goodrich: Changes for the fact signal write checking is enabled.
+//
+// Revision 1.2 2006/01/18 00:23:51 acg
+// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
+//
+
+#define SC_NO_WRITE_CHECK
+#include "systemc.h"
+#include "const.h"
+#include "driver.h"
+#include "pulse.h"
+#include "speed.h"
+#include "dist.h"
+
+int
+sc_main(int argc, char *argv[])
+{
+ // Pulses for the speedometer and odometers, generated by the pulse
+ // generator.
+ sc_signal<bool> speed_pulses("speed_pulses");
+ sc_signal<bool> dist_pulses("dist_pulses");
+ // Signals for the driver's actions.
+ sc_signal<bool> reset("reset");
+ sc_signal<int> speed("speed");
+ sc_signal<bool> start("start");
+
+ // Signals observed by the driver.
+ sc_signal<double> disp_speed("disp_speed");
+ sc_signal<double> disp_angle("disp_angle");
+ sc_signal<double> disp_total_dist("disp_total_dist");
+ sc_signal<double> disp_partial_dist("disp_partial_dist");
+
+ // Clocks.
+ sc_clock clk0("slow_clk", SLOW_CLOCK_PERIOD0, SC_NS, 0.5, 0.0, SC_NS, true);
+ sc_clock clk1("fast_clk", FAST_CLOCK_PERIOD1, SC_NS, 0.5, 0.0, SC_NS, false);
+
+ driver_mod driver("driver");
+ driver(clk0, disp_speed, disp_angle, disp_total_dist,
+ disp_partial_dist, reset, speed, start);
+
+ gen_pulse_mod gen_pulse("gen_pulse");
+ gen_pulse(clk1, start, speed, speed_pulses, dist_pulses);
+
+ speed_mod speedometer("speedometer");
+ speedometer(clk1, start, speed_pulses, disp_speed, disp_angle);
+
+ dist_mod odometers("odometers");
+ odometers.pulse(dist_pulses);
+ odometers.reset(reset);
+ odometers.start.bind(start);
+ odometers.total(disp_total_dist);
+ odometers.partial.bind(disp_partial_dist);
+
+ // Initialize signals:
+ start = false;
+
+ // Tracing:
+ // Trace file creation.
+ sc_trace_file *tf = sc_create_vcd_trace_file("dash");
+ // External signals.
+ sc_trace(tf, clk0, "slow_clk");
+ sc_trace(tf, clk1, "fast_clk");
+ sc_trace(tf, speed_pulses, "speed_pulses");
+ sc_trace(tf, dist_pulses, "dist_pulses");
+ sc_trace(tf, reset, "reset");
+ sc_trace(tf, start, "start");
+ sc_trace(tf, speed, "speed");
+ sc_trace(tf, disp_speed, "disp_speed");
+ sc_trace(tf, disp_angle, "disp_angle");
+ sc_trace(tf, disp_total_dist, "disp_total_dist");
+ sc_trace(tf, disp_partial_dist, "disp_partial_dist");
+ // Internal signals.
+ sc_trace(tf, speedometer.elapsed_time, "elapsed_time");
+ sc_trace(tf, speedometer.read_mod->raw_speed, "raw_speed");
+ sc_trace(tf, speedometer.filtered_speed, "filtered_speed");
+ sc_trace(tf, odometers.ok_for_incr, "ok_for_incr");
+ sc_trace(tf, odometers.total_dist, "total_dist");
+ sc_trace(tf, odometers.partial_dist, "partial_dist");
+
+ disp_speed = 0.0;
+ disp_angle = 0.0;
+ disp_total_dist = 0.0;
+ disp_partial_dist = 0.0;
+
+ sc_start();
+
+ return 0;
+}
+
+// End of file
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.cpp b/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.cpp
new file mode 100644
index 000000000..c2b5031f2
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.cpp
@@ -0,0 +1,101 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ pulse.cpp -- Implementation of the pulse generator.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: pulse.cpp,v $
+// Revision 1.1.1.1 2006/12/15 20:26:24 acg
+// systemc_tests-2.3
+//
+// Revision 1.3 2006/01/19 00:48:20 acg
+// Andy Goodrich: Changes for the fact signal write checking is enabled.
+//
+// Revision 1.2 2006/01/18 00:23:51 acg
+// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
+//
+
+#define SC_NO_WRITE_CHECK
+#include "systemc.h"
+#include "const.h"
+#include "pulse.h"
+
+// Find the pulse period to produce speed.
+// This function also rounds the period to the nearest integer.
+int
+gen_pulse_mod::find_period(int speed)
+{
+ if (speed <= 0)
+ return 1;
+
+ const double num = DIST_BETWEEN_TWO_PULSES * PERIODS_PER_HOUR / 2;
+
+ double dp = num / speed;
+ int ip = int(dp);
+
+ ip = ip + ((dp - ip) >= double(0.5) ? 1 : 0);
+
+ return ip;
+}
+
+// Generate pulses for speedometer and odometers.
+void
+gen_pulse_mod::gen_pulse_proc()
+{
+ speed_pulse = false;
+ dist_pulse = false;
+
+ // Wait until the car is started.
+
+ do { wait(); } while (start != true);
+
+ /*
+ do {
+ wait();
+ } while (start == false);
+ */
+
+ while (true) {
+
+ speed_pulse = true;
+ dist_pulse = true;
+ AWAIT(find_period(speed));
+
+ speed_pulse = false;
+ dist_pulse = false;
+ AWAIT(find_period(speed));
+ }
+}
+
+// End of file
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.h b/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.h
new file mode 100644
index 000000000..b1206d185
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/pulse.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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ pulse.h -- Definition of the pulse generator.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#ifndef PULSE_H
+#define PULSE_H
+
+SC_MODULE( gen_pulse_mod )
+{
+ // Ports:
+ sc_in_clk clk; // Clock for the pulse generator.
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<int> speed; // Speed of the car set by the driver.
+ sc_out<bool> speed_pulse; // Pulses for the speedometer.
+ sc_out<bool> dist_pulse; // Pulses for the odometers.
+
+ // Find the pulse period to produce speed.
+ int find_period(int speed);
+
+ // Generate pulses for speedometer and odometers.
+ void gen_pulse_proc();
+
+ SC_CTOR( gen_pulse_mod )
+ {
+ SC_CTHREAD( gen_pulse_proc, clk.pos() );
+ }
+};
+
+#endif
+
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/speed.cpp b/src/systemc/tests/systemc/misc/v1.0/dash9/speed.cpp
new file mode 100644
index 000000000..10e29ce12
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/speed.cpp
@@ -0,0 +1,111 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ speed.cpp -- Definition of the speedometer.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+// $Log: speed.cpp,v $
+// Revision 1.1.1.1 2006/12/15 20:26:24 acg
+// systemc_tests-2.3
+//
+// Revision 1.3 2006/01/19 00:48:20 acg
+// Andy Goodrich: Changes for the fact signal write checking is enabled.
+//
+// Revision 1.2 2006/01/18 00:23:51 acg
+// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
+//
+
+#define SC_NO_WRITE_CHECK
+#include "systemc.h"
+#include "const.h"
+#include "speed.h"
+
+// Find the elapsed_time between NUM_PULSES_FOR_SPEED pulses.
+void speed_mod::find_time_proc()
+{
+ if (start)
+ elapsed_time = elapsed_time + 1;
+ else
+ elapsed_time = 0;
+}
+
+// Compute speed.
+void
+speed_read_mod::read_speed_proc()
+{
+ wait();
+
+ while (true) {
+
+ // More than one pulse is needed to compute a distance and
+ // consequently, speed. This function collects NUM_PULSES_FOR_SPEED
+ // pulses for that purpose.
+ AWAIT(NUM_PULSES_FOR_SPEED);
+
+ if (start)
+ raw_speed = DIST_BETWEEN_TWO_PULSES * PERIODS_PER_HOUR / elapsed_time;
+ else
+ raw_speed = 0.0;
+
+ // Reset timer.
+ elapsed_time = 0;
+ }
+}
+
+// Filter speed.
+void
+speed_read_mod::filter_speed_proc()
+{
+ if (start)
+ filtered_speed = raw_speed;
+ else
+ filtered_speed = 0.0;
+}
+
+// Compute needle angle and drive the speedometer.
+void
+speed_pwm_mod::pwm_driver_proc()
+{
+ if (start) {
+ speed = filtered_speed;
+ angle = filtered_speed * MAX_ANGLE / MAX_SPEED;
+ }
+ else {
+ speed = 0.0;
+ angle = 0.0;
+ }
+}
+
+
+// End of file
diff --git a/src/systemc/tests/systemc/misc/v1.0/dash9/speed.h b/src/systemc/tests/systemc/misc/v1.0/dash9/speed.h
new file mode 100644
index 000000000..181cac253
--- /dev/null
+++ b/src/systemc/tests/systemc/misc/v1.0/dash9/speed.h
@@ -0,0 +1,154 @@
+/*****************************************************************************
+
+ 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.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ speed.h -- Definition of the speedometer.
+
+ Original Author: Ali Dasdan, Synopsys, Inc.
+
+ *****************************************************************************/
+
+/*****************************************************************************
+
+ MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+ changes you are making here.
+
+ Name, Affiliation, Date:
+ Description of Modification:
+
+ *****************************************************************************/
+
+#ifndef SPEED_H
+#define SPEED_H
+
+SC_MODULE( speed_read_mod )
+{
+ // Input ports:
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<bool> pulse; // Pulse coming from the pulse generator.
+
+ // Output ports:
+ sc_out<double> filtered_speed; // Filtered speed.
+
+ // Inout ports:
+ sc_inout<int> elapsed_time;
+
+ // Internal signals:
+ sc_signal<double> raw_speed;
+
+ // Compute speed.
+ void read_speed_proc();
+
+ // Filter speed.
+ void filter_speed_proc();
+
+ SC_CTOR( speed_read_mod )
+ {
+ SC_THREAD( read_speed_proc );
+ sensitive << pulse.pos();
+
+ SC_METHOD( filter_speed_proc );
+ sensitive << raw_speed;
+
+ raw_speed = 0.0;
+ }
+};
+
+SC_MODULE( speed_pwm_mod )
+{
+ // Input ports:
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<double> filtered_speed;
+
+ // Output ports:
+ sc_out<double> speed; // Displayed speed.
+ sc_out<double> angle; // Displayed angle.
+
+ // Compute needle angle and drive the speedometer.
+ void pwm_driver_proc();
+
+ SC_CTOR( speed_pwm_mod )
+ {
+ SC_METHOD( pwm_driver_proc );
+ sensitive << filtered_speed;
+ }
+};
+
+SC_MODULE( speed_mod )
+{
+ // Input ports:
+ sc_in_clk clk; // Clock to measure the time, needed to compute the speed.
+ sc_in<bool> start; // Becomes true if the car's started.
+ sc_in<bool> pulse; // Pulse coming from the pulse generator.
+
+ // Output ports:
+ sc_out<double> speed; // Displayed speed.
+ sc_out<double> angle; // Displayed angle.
+
+ // Internal signals:
+ sc_signal<int> elapsed_time;
+ sc_signal<double> filtered_speed;
+
+ // Internal models:
+ speed_read_mod *read_mod;
+ speed_pwm_mod *pwm_mod;
+
+ // Find the elapsed_time between NUM_PULSES_FOR_SPEED pulses.
+ void find_time_proc();
+
+ SC_CTOR( speed_mod )
+ {
+ SC_METHOD( find_time_proc );
+ sensitive << clk.pos();
+
+ read_mod = new speed_read_mod("read_mod");
+ pwm_mod = new speed_pwm_mod("pwm_mod");
+
+ // read_mod->start.bind(start);
+ // read_mod->pulse.bind(pulse);
+ // read_mod->filtered_speed.bind(filtered_speed);
+ // read_mod->elapsed_time.bind(elapsed_time);
+
+ read_mod->start(start);
+ read_mod->pulse(pulse);
+ read_mod->filtered_speed(filtered_speed);
+ read_mod->elapsed_time(elapsed_time);
+
+ // (*read_mod)(start, pulse, filtered_speed, elapsed_time);
+
+ // pwm_mod->start.bind(start);
+ // pwm_mod->filtered_speed.bind(filtered_speed);
+ // pwm_mod->speed.bind(speed);
+ // pwm_mod->angle.bind(angle);
+
+ pwm_mod->start(start);
+ pwm_mod->filtered_speed(filtered_speed);
+ pwm_mod->speed(speed);
+ pwm_mod->angle(angle);
+
+ // *pwm_mod << start << filtered_speed << speed << angle;
+
+ elapsed_time = 0;
+ filtered_speed = 0.0;
+ }
+};
+
+#endif
+