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), a clock, and the pulse generator. The 25 pulses are generated by the sensors placed around one of the wheel 26 shafts. The rate of pulse generation is determined by the speed of 27 the car, which is constant at 120 km/h. The clock represents the 28 real time. The signals in this program are traced. The simulation 29 is stopped by the odometers module. 30 31 purpose -- no environment module; multiple modules at one level; 32 single processes within each module; input, output and clock 33 ports; internal and external signals; asynchronous function and 34 thread processes; one clock; tracing. 35 36 Original Author: Ali Dasdan, Synopsys, Inc. 37 38 *****************************************************************************/ 39 40/***************************************************************************** 41 42 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 43 changes you are making here. 44 45 Name, Affiliation, Date: 46 Description of Modification: 47 48 *****************************************************************************/ 49 50// $Log: main.cpp,v $ 51// Revision 1.2 2011/01/07 01:20:19 acg 52// Andy Goodrich: update for new IEEE 1666. 53// 54// Revision 1.1.1.1 2006/12/15 20:26:24 acg 55// systemc_tests-2.3 56// 57// Revision 1.5 2006/01/24 21:05:51 acg 58// Andy Goodrich: replacement of deprecated features with their non-deprecated 59// counterparts. 60// 61// Revision 1.4 2006/01/20 00:43:24 acg 62// Andy Goodrich: Changed over to use putenv() instead of setenv() to accommodate old versions of Solaris. 63// 64// Revision 1.3 2006/01/19 00:48:10 acg 65// Andy Goodrich: Changes for the fact signal write checking is enabled. 66// 67// Revision 1.2 2006/01/18 00:23:44 acg 68// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call. 69// 70 71#define SC_NO_WRITE_CHECK 72#include "systemc.h" 73#include "const.h" 74#include "pulse.h" 75#include "speed.h" 76#include "dist.h" 77 78int 79sc_main(int argc, char *argv[]) 80{ 81 // Pulses for the speedometer and odometers, generated by the pulse 82 // generator. 83 sc_signal<bool> speed_pulses("speed_pulses"); 84 sc_signal<bool> dist_pulses("dist_pulses"); 85 // Clocks. 86 sc_clock clk1("fast_clk", FAST_CLOCK_PERIOD1, SC_NS, 0.5, 0.0, SC_NS, false); 87 88 gen_pulse_mod gen_pulse("gen_pulse"); 89 gen_pulse(clk1, speed_pulses, dist_pulses); 90 91 speed_mod speedometer("speedometer"); 92 speedometer(clk1, speed_pulses); 93 94 dist_mod odometers("odometers"); 95 odometers(dist_pulses); 96 97 // Tracing: 98 // Trace file creation. 99 sc_trace_file *tf = sc_create_vcd_trace_file("dash"); 100 // External signals. 101 sc_trace(tf, clk1, "fast_clk"); 102 sc_trace(tf, speed_pulses, "speed_pulses"); 103 sc_trace(tf, dist_pulses, "dist_pulses"); 104 // Internal signals. 105 sc_trace(tf, speedometer.elapsed_time, "elapsed_time"); 106 107 sc_start(); 108 109 return 0; 110} 111 112// End of file 113