main.cpp revision 12855
17404SAli.Saidi@ARM.com/*****************************************************************************
211574SCurtis.Dunham@arm.com
37404SAli.Saidi@ARM.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
47404SAli.Saidi@ARM.com  more contributor license agreements.  See the NOTICE file distributed
57404SAli.Saidi@ARM.com  with this work for additional information regarding copyright ownership.
67404SAli.Saidi@ARM.com  Accellera licenses this file to you under the Apache License, Version 2.0
77404SAli.Saidi@ARM.com  (the "License"); you may not use this file except in compliance with the
87404SAli.Saidi@ARM.com  License.  You may obtain a copy of the License at
97404SAli.Saidi@ARM.com
107404SAli.Saidi@ARM.com    http://www.apache.org/licenses/LICENSE-2.0
117404SAli.Saidi@ARM.com
127404SAli.Saidi@ARM.com  Unless required by applicable law or agreed to in writing, software
137404SAli.Saidi@ARM.com  distributed under the License is distributed on an "AS IS" BASIS,
147404SAli.Saidi@ARM.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
157404SAli.Saidi@ARM.com  implied.  See the License for the specific language governing
167404SAli.Saidi@ARM.com  permissions and limitations under the License.
177404SAli.Saidi@ARM.com
187404SAli.Saidi@ARM.com *****************************************************************************/
197404SAli.Saidi@ARM.com
207404SAli.Saidi@ARM.com/*****************************************************************************
217404SAli.Saidi@ARM.com
227404SAli.Saidi@ARM.com  main.cpp -- Main function for the dashboard controller for a
237404SAli.Saidi@ARM.com           car. This controller contains a speedometer, two odometers (total
247404SAli.Saidi@ARM.com           and partial distance), the driver of the car, clocks, and the
257404SAli.Saidi@ARM.com           pulse generator. The pulses are generated by the sensors placed
267404SAli.Saidi@ARM.com           around one of the wheel shafts. The rate of pulse generation is
277404SAli.Saidi@ARM.com           determined by the speed of the car. The driver can start the car,
287404SAli.Saidi@ARM.com           set its speed, reset the partial distance odometer, and stop the
297404SAli.Saidi@ARM.com           car (which means he will stop the simulation). One of the clocks
307404SAli.Saidi@ARM.com           is slow and the other is fast. The fast clock represents the real
317404SAli.Saidi@ARM.com           time. The slow clock is used to control the actions of the
327404SAli.Saidi@ARM.com           driver. The signals in this program are traced.
337404SAli.Saidi@ARM.com
347404SAli.Saidi@ARM.com           purpose (in terms of changes to dash4's purpose) -- synchronous
357404SAli.Saidi@ARM.com           processes.
367404SAli.Saidi@ARM.com
377404SAli.Saidi@ARM.com  Original Author: Ali Dasdan, Synopsys, Inc.
3810037SARM gem5 Developers
397404SAli.Saidi@ARM.com *****************************************************************************/
4010873Sandreas.sandberg@arm.com
417404SAli.Saidi@ARM.com/*****************************************************************************
4210474Sandreas.hansson@arm.com
4310474Sandreas.hansson@arm.com  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
447404SAli.Saidi@ARM.com  changes you are making here.
4510037SARM gem5 Developers
4610037SARM gem5 Developers      Name, Affiliation, Date:
477404SAli.Saidi@ARM.com  Description of Modification:
487728SAli.Saidi@ARM.com
497404SAli.Saidi@ARM.com *****************************************************************************/
508245Snate@binkert.org
519152Satgutier@umich.edu// $Log: main.cpp,v $
528245Snate@binkert.org// Revision 1.2  2011/01/07 01:20:20  acg
538245Snate@binkert.org//  Andy Goodrich: update for new IEEE 1666.
5410873Sandreas.sandberg@arm.com//
557748SAli.Saidi@ARM.com// Revision 1.1.1.1  2006/12/15 20:26:24  acg
567404SAli.Saidi@ARM.com// systemc_tests-2.3
577404SAli.Saidi@ARM.com//
587404SAli.Saidi@ARM.com// Revision 1.5  2006/01/24 21:05:56  acg
597404SAli.Saidi@ARM.com//  Andy Goodrich: replacement of deprecated features with their non-deprecated
6010913Sandreas.sandberg@arm.com//  counterparts.
6110717Sandreas.hansson@arm.com//
6210717Sandreas.hansson@arm.com// Revision 1.4  2006/01/20 00:43:24  acg
6310717Sandreas.hansson@arm.com// Andy Goodrich: Changed over to use putenv() instead of setenv() to accommodate old versions of Solaris.
649258SAli.Saidi@ARM.com//
6510621SCurtis.Dunham@arm.com// Revision 1.3  2006/01/19 00:48:20  acg
6610621SCurtis.Dunham@arm.com// Andy Goodrich: Changes for the fact signal write checking is enabled.
6710037SARM gem5 Developers//
6811588SCurtis.Dunham@arm.com// Revision 1.2  2006/01/18 00:23:51  acg
6911588SCurtis.Dunham@arm.com// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call.
7011588SCurtis.Dunham@arm.com//
7111588SCurtis.Dunham@arm.com
7210037SARM gem5 Developers#define SC_NO_WRITE_CHECK
737439Sdam.sunwoo@arm.com#include "systemc.h"
747576SAli.Saidi@ARM.com#include "const.h"
7510037SARM gem5 Developers#include "driver.h"
7610037SARM gem5 Developers#include "pulse.h"
7710037SARM gem5 Developers#include "speed.h"
7810717Sandreas.hansson@arm.com#include "dist.h"
7910037SARM gem5 Developers
8010037SARM gem5 Developersint
8110037SARM gem5 Developerssc_main(int argc, char *argv[])
8210037SARM gem5 Developers{
8310037SARM gem5 Developers  // Pulses for the speedometer and odometers, generated by the pulse
8410037SARM gem5 Developers  // generator.
8510037SARM gem5 Developers  sc_signal<bool> speed_pulses("speed_pulses");
8610037SARM gem5 Developers  sc_signal<bool> dist_pulses("dist_pulses");
8710037SARM gem5 Developers  // Signals for the driver's actions.
8810037SARM gem5 Developers  sc_signal<bool> reset("reset");
8910037SARM gem5 Developers  sc_signal<int>  speed("speed");
9010037SARM gem5 Developers  sc_signal<bool> start("start");
917439Sdam.sunwoo@arm.com
927404SAli.Saidi@ARM.com  // Signals observed by the driver.
937404SAli.Saidi@ARM.com  sc_signal<double> disp_speed("disp_speed");
947404SAli.Saidi@ARM.com  sc_signal<double> disp_angle("disp_angle");
957404SAli.Saidi@ARM.com  sc_signal<double> disp_total_dist("disp_total_dist");
967404SAli.Saidi@ARM.com  sc_signal<double> disp_partial_dist("disp_partial_dist");
977404SAli.Saidi@ARM.com
9810717Sandreas.hansson@arm.com  // Clocks.
9910717Sandreas.hansson@arm.com  sc_clock clk0("slow_clk", SLOW_CLOCK_PERIOD0, SC_NS, 0.5, 0.0, SC_NS, true);
10010717Sandreas.hansson@arm.com  sc_clock clk1("fast_clk", FAST_CLOCK_PERIOD1, SC_NS, 0.5, 0.0, SC_NS, false);
10110717Sandreas.hansson@arm.com
10210717Sandreas.hansson@arm.com  driver_mod driver("driver");
10310717Sandreas.hansson@arm.com  driver(clk0, disp_speed, disp_angle, disp_total_dist, disp_partial_dist,
10410717Sandreas.hansson@arm.com      reset, speed, start);
10510717Sandreas.hansson@arm.com
10610717Sandreas.hansson@arm.com  gen_pulse_mod gen_pulse("gen_pulse");
10710717Sandreas.hansson@arm.com  gen_pulse(clk1, start, speed, speed_pulses, dist_pulses);
10810717Sandreas.hansson@arm.com
10910717Sandreas.hansson@arm.com  speed_mod speedometer("speedometer");
11010717Sandreas.hansson@arm.com  speedometer(clk1, start, speed_pulses, disp_speed, disp_angle);
11110717Sandreas.hansson@arm.com
11210717Sandreas.hansson@arm.com  dist_mod odometers("odometers");
11310717Sandreas.hansson@arm.com  odometers(dist_pulses, reset, start, disp_total_dist, disp_partial_dist);
11410717Sandreas.hansson@arm.com
11510717Sandreas.hansson@arm.com  // Initialize signals:
11610717Sandreas.hansson@arm.com  start = false;
11710717Sandreas.hansson@arm.com
11810717Sandreas.hansson@arm.com  // Tracing:
11910717Sandreas.hansson@arm.com  // Trace file creation.
12010717Sandreas.hansson@arm.com  sc_trace_file *tf = sc_create_vcd_trace_file("dash");
12110717Sandreas.hansson@arm.com  // External signals.
12210717Sandreas.hansson@arm.com  sc_trace(tf, clk0, "slow_clk");
12310717Sandreas.hansson@arm.com  sc_trace(tf, clk1, "fast_clk");
12410717Sandreas.hansson@arm.com  sc_trace(tf, speed_pulses, "speed_pulses");
12510717Sandreas.hansson@arm.com  sc_trace(tf, dist_pulses, "dist_pulses");
12610717Sandreas.hansson@arm.com  sc_trace(tf, reset, "reset");
12710537Sandreas.hansson@arm.com  sc_trace(tf, start, "start");
12810537Sandreas.hansson@arm.com  sc_trace(tf, speed, "speed");
12910537Sandreas.hansson@arm.com  sc_trace(tf, disp_speed, "disp_speed");
13010537Sandreas.hansson@arm.com  sc_trace(tf, disp_angle, "disp_angle");
13110537Sandreas.hansson@arm.com  sc_trace(tf, disp_total_dist, "disp_total_dist");
13210537Sandreas.hansson@arm.com  sc_trace(tf, disp_partial_dist, "disp_partial_dist");
13310537Sandreas.hansson@arm.com  // Internal signals.
13410537Sandreas.hansson@arm.com  sc_trace(tf, speedometer.elapsed_time, "elapsed_time");
13510537Sandreas.hansson@arm.com  sc_trace(tf, speedometer.read_mod->raw_speed, "raw_speed");
13610037SARM gem5 Developers  sc_trace(tf, speedometer.filtered_speed, "filtered_speed");
13710037SARM gem5 Developers  sc_trace(tf, odometers.ok_for_incr, "ok_for_incr");
13810037SARM gem5 Developers  sc_trace(tf, odometers.total_dist, "total_dist");
1399152Satgutier@umich.edu  sc_trace(tf, odometers.partial_dist, "partial_dist");
1409152Satgutier@umich.edu
1419152Satgutier@umich.edu  disp_speed = 0.0;
14210913Sandreas.sandberg@arm.com  disp_angle = 0.0;
14311588SCurtis.Dunham@arm.com  disp_total_dist = 0.0;
14411588SCurtis.Dunham@arm.com  disp_partial_dist = 0.0;
1459152Satgutier@umich.edu
14610913Sandreas.sandberg@arm.com  sc_start();
1479152Satgutier@umich.edu
14810913Sandreas.sandberg@arm.com  return 0;
1499152Satgutier@umich.edu}
1509152Satgutier@umich.edu
1519152Satgutier@umich.edu// End of file
15210913Sandreas.sandberg@arm.com