main.cpp revision 12855:588919e0e4aa
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 main.cpp -- Main function for the dashboard controller for a 23 car. This controller contains a speedometer, two odometers (total 24 and partial distance), the driver of the car, clocks, and the 25 pulse generator. The pulses are generated by the sensors placed 26 around one of the wheel shafts. The rate of pulse generation is 27 determined by the speed of the car. The driver can start the car, 28 set its speed, reset the partial distance odometer, and stop the 29 car (which means he will stop the simulation). One of the clocks 30 is slow and the other is fast. The fast clock represents the real 31 time. The slow clock is used to control the actions of the 32 driver. The signals in this program are traced. 33 34 purpose (in terms of changes to dash3's purpose) -- new style of 35 declaring modules and processes (i.e., via the use of 36 module_name). 37 38 Original Author: Ali Dasdan, Synopsys, Inc. 39 40 *****************************************************************************/ 41 42/***************************************************************************** 43 44 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 45 changes you are making here. 46 47 Name, Affiliation, Date: 48 Description of Modification: 49 50 *****************************************************************************/ 51 52// $Log: main.cpp,v $ 53// Revision 1.2 2011/01/07 01:20:20 acg 54// Andy Goodrich: update for new IEEE 1666. 55// 56// Revision 1.1.1.1 2006/12/15 20:26:24 acg 57// systemc_tests-2.3 58// 59// Revision 1.5 2006/01/24 21:05:55 acg 60// Andy Goodrich: replacement of deprecated features with their non-deprecated 61// counterparts. 62// 63// Revision 1.4 2006/01/20 00:43:24 acg 64// Andy Goodrich: Changed over to use putenv() instead of setenv() to accommodate old versions of Solaris. 65// 66// Revision 1.3 2006/01/19 00:48:19 acg 67// Andy Goodrich: Changes for the fact signal write checking is enabled. 68// 69// Revision 1.2 2006/01/18 00:23:50 acg 70// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call. 71// 72 73#define SC_NO_WRITE_CHECK 74#include "systemc.h" 75#include "const.h" 76#include "driver.h" 77#include "pulse.h" 78#include "speed.h" 79#include "dist.h" 80 81int 82sc_main(int argc, char *argv[]) 83{ 84 // Pulses for the speedometer and odometers, generated by the pulse 85 // generator. 86 sc_signal<bool> speed_pulses("speed_pulses"); 87 sc_signal<bool> dist_pulses("dist_pulses"); 88 // Signals for the driver's actions. 89 sc_signal<bool> reset("reset"); 90 sc_signal<int> speed("speed"); 91 sc_signal<bool> start("start"); 92 93 // Signals observed by the driver. 94 sc_signal<double> disp_speed("disp_speed"); 95 sc_signal<double> disp_angle("disp_angle"); 96 sc_signal<double> disp_total_dist("disp_total_dist"); 97 sc_signal<double> disp_partial_dist("disp_partial_dist"); 98 99 // Clocks. 100 sc_clock clk0("slow_clk", SLOW_CLOCK_PERIOD0, SC_NS, 0.5, 0.0, SC_NS, true); 101 sc_clock clk1("fast_clk", FAST_CLOCK_PERIOD1, SC_NS, 0.5, 0.0, SC_NS, false); 102 103 driver_mod driver("driver"); 104 driver(clk0, disp_speed, disp_angle, disp_total_dist, disp_partial_dist, 105 reset, speed, start); 106 107 gen_pulse_mod gen_pulse("gen_pulse"); 108 gen_pulse(clk1, start, speed, speed_pulses, dist_pulses); 109 110 speed_mod speedometer("speedometer"); 111 speedometer(clk1, start, speed_pulses, disp_speed, disp_angle); 112 113 dist_mod odometers("odometers"); 114 odometers(dist_pulses, reset, start, disp_total_dist, disp_partial_dist); 115 116 // Initialize signals: 117 start = false; 118 119 // Tracing: 120 // Trace file creation. 121 sc_trace_file *tf = sc_create_vcd_trace_file("dash"); 122 // External signals. 123 sc_trace(tf, clk0, "slow_clk"); 124 sc_trace(tf, clk1, "fast_clk"); 125 sc_trace(tf, speed_pulses, "speed_pulses"); 126 sc_trace(tf, dist_pulses, "dist_pulses"); 127 sc_trace(tf, reset, "reset"); 128 sc_trace(tf, start, "start"); 129 sc_trace(tf, speed, "speed"); 130 sc_trace(tf, disp_speed, "disp_speed"); 131 sc_trace(tf, disp_angle, "disp_angle"); 132 sc_trace(tf, disp_total_dist, "disp_total_dist"); 133 sc_trace(tf, disp_partial_dist, "disp_partial_dist"); 134 // Internal signals. 135 sc_trace(tf, speedometer.elapsed_time, "elapsed_time"); 136 sc_trace(tf, speedometer.read_mod->raw_speed, "raw_speed"); 137 sc_trace(tf, speedometer.filtered_speed, "filtered_speed"); 138 sc_trace(tf, odometers.ok_for_incr, "ok_for_incr"); 139 sc_trace(tf, odometers.total_dist, "total_dist"); 140 sc_trace(tf, odometers.partial_dist, "partial_dist"); 141 142 disp_speed = 0.0; 143 disp_angle = 0.0; 144 disp_total_dist = 0.0; 145 disp_partial_dist = 0.0; 146 147 sc_start(); 148 149 return 0; 150} 151 152// End of file 153