112855Sgabeblack@google.com/***************************************************************************** 212855Sgabeblack@google.com 312855Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412855Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512855Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612855Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712855Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812855Sgabeblack@google.com License. You may obtain a copy of the License at 912855Sgabeblack@google.com 1012855Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112855Sgabeblack@google.com 1212855Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312855Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412855Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512855Sgabeblack@google.com implied. See the License for the specific language governing 1612855Sgabeblack@google.com permissions and limitations under the License. 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com *****************************************************************************/ 1912855Sgabeblack@google.com 2012855Sgabeblack@google.com/***************************************************************************** 2112855Sgabeblack@google.com 2212855Sgabeblack@google.com dist.h -- Definition of the odometers. 2312855Sgabeblack@google.com 2412855Sgabeblack@google.com Original Author: Ali Dasdan, Synopsys, Inc. 2512855Sgabeblack@google.com 2612855Sgabeblack@google.com *****************************************************************************/ 2712855Sgabeblack@google.com 2812855Sgabeblack@google.com/***************************************************************************** 2912855Sgabeblack@google.com 3012855Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112855Sgabeblack@google.com changes you are making here. 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com Name, Affiliation, Date: 3412855Sgabeblack@google.com Description of Modification: 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com *****************************************************************************/ 3712855Sgabeblack@google.com 3812855Sgabeblack@google.com#ifndef DIST_H 3912855Sgabeblack@google.com#define DIST_H 4012855Sgabeblack@google.com 4112855Sgabeblack@google.comSC_MODULE( dist_read_mod ) 4212855Sgabeblack@google.com{ 4312855Sgabeblack@google.com // Input ports: 4412855Sgabeblack@google.com sc_in<bool> pulse; // Pulse coming from the pulse generator. 4512855Sgabeblack@google.com sc_in<bool> start; // Becomes true if the car's started. 4612855Sgabeblack@google.com 4712855Sgabeblack@google.com // Output ports: 4812855Sgabeblack@google.com sc_out<bool> ok_for_incr; 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com // Get the pulses for one distance increment. 5112855Sgabeblack@google.com void get_dist_proc(); 5212855Sgabeblack@google.com 5312855Sgabeblack@google.com SC_CTOR( dist_read_mod ) 5412855Sgabeblack@google.com { 5512855Sgabeblack@google.com SC_THREAD( get_dist_proc ); 5612855Sgabeblack@google.com sensitive << pulse.pos(); 5712855Sgabeblack@google.com } 5812855Sgabeblack@google.com}; 5912855Sgabeblack@google.com 6012855Sgabeblack@google.comSC_MODULE( dist_compute_mod ) 6112855Sgabeblack@google.com{ 6212855Sgabeblack@google.com // Input ports: 6312855Sgabeblack@google.com sc_in<bool> reset; // Reset the partial distance odometer if true. 6412855Sgabeblack@google.com sc_in<bool> start; // Becomes true if the car's started. 6512855Sgabeblack@google.com sc_in<bool> ok_for_incr; 6612855Sgabeblack@google.com 6712855Sgabeblack@google.com // Output ports: 6812855Sgabeblack@google.com sc_out<double> total_dist; 6912855Sgabeblack@google.com sc_out<double> partial_dist; 7012855Sgabeblack@google.com 7112855Sgabeblack@google.com // Internal variables: 7212855Sgabeblack@google.com static bool prev_reset; 7312855Sgabeblack@google.com static double total_compute_dist; 7412855Sgabeblack@google.com static double partial_compute_dist; 7512855Sgabeblack@google.com 7612855Sgabeblack@google.com // Compute total and partial distances. 7712855Sgabeblack@google.com void compute_total_proc(); 7812855Sgabeblack@google.com void compute_partial_proc(); 7912855Sgabeblack@google.com 8012855Sgabeblack@google.com SC_CTOR( dist_compute_mod ) 8112855Sgabeblack@google.com { 8212855Sgabeblack@google.com SC_METHOD( compute_total_proc ); 8312855Sgabeblack@google.com sensitive << ok_for_incr; 8412855Sgabeblack@google.com 8512855Sgabeblack@google.com SC_METHOD( compute_partial_proc ); 8612855Sgabeblack@google.com sensitive << ok_for_incr; 8712855Sgabeblack@google.com 8812855Sgabeblack@google.com prev_reset = false; 8912855Sgabeblack@google.com total_compute_dist = 0.0; 9012855Sgabeblack@google.com partial_compute_dist = 0.0; 9112855Sgabeblack@google.com } 9212855Sgabeblack@google.com}; 9312855Sgabeblack@google.com 9412855Sgabeblack@google.comSC_MODULE( dist_lcd_mod ) 9512855Sgabeblack@google.com{ 9612855Sgabeblack@google.com // Input ports: 9712855Sgabeblack@google.com sc_in<bool> start; // Becomes true if the car's started. 9812855Sgabeblack@google.com sc_in<double> total_dist; 9912855Sgabeblack@google.com sc_in<double> partial_dist; 10012855Sgabeblack@google.com 10112855Sgabeblack@google.com // Output ports: 10212855Sgabeblack@google.com sc_out<double> total; // Total distance. 10312855Sgabeblack@google.com sc_out<double> partial; // Partial distance. 10412855Sgabeblack@google.com 10512855Sgabeblack@google.com // LCD display driver. 10612855Sgabeblack@google.com void lcd_driver_proc(); 10712855Sgabeblack@google.com 10812855Sgabeblack@google.com SC_CTOR( dist_lcd_mod ) 10912855Sgabeblack@google.com { 11012855Sgabeblack@google.com SC_METHOD( lcd_driver_proc ); 11112855Sgabeblack@google.com sensitive << total_dist << partial_dist; 11212855Sgabeblack@google.com } 11312855Sgabeblack@google.com}; 11412855Sgabeblack@google.com 11512855Sgabeblack@google.comSC_MODULE( dist_mod ) 11612855Sgabeblack@google.com{ 11712855Sgabeblack@google.com // Ports: 11812855Sgabeblack@google.com sc_in<bool> pulse; // Pulse coming ftom the pulse generator. 11912855Sgabeblack@google.com sc_in<bool> reset; // Reset the partial distance odometer if true. 12012855Sgabeblack@google.com sc_in<bool> start; // Becomes true if the car's started. 12112855Sgabeblack@google.com 12212855Sgabeblack@google.com // Output ports: 12312855Sgabeblack@google.com sc_out<double> total; // Total distance. 12412855Sgabeblack@google.com sc_out<double> partial; // Partial distance. 12512855Sgabeblack@google.com 12612855Sgabeblack@google.com // Internal signals: 12712855Sgabeblack@google.com sc_signal<bool> ok_for_incr; 12812855Sgabeblack@google.com sc_signal<double> total_dist; 12912855Sgabeblack@google.com sc_signal<double> partial_dist; 13012855Sgabeblack@google.com 13112855Sgabeblack@google.com // Internal models: 13212855Sgabeblack@google.com dist_read_mod *read_mod; 13312855Sgabeblack@google.com dist_compute_mod *compute_mod; 13412855Sgabeblack@google.com dist_lcd_mod *lcd_mod; 13512855Sgabeblack@google.com 13612855Sgabeblack@google.com SC_CTOR( dist_mod ) 13712855Sgabeblack@google.com { 13812855Sgabeblack@google.com read_mod = new dist_read_mod("read_mod"); 13912855Sgabeblack@google.com compute_mod = new dist_compute_mod("compute_mod"); 14012855Sgabeblack@google.com lcd_mod = new dist_lcd_mod("lcd_mod"); 14112855Sgabeblack@google.com 14212855Sgabeblack@google.com // read_mod->pulse.bind(pulse); 14312855Sgabeblack@google.com // read_mod->start.bind(start); 14412855Sgabeblack@google.com // read_mod->ok_for_incr.bind(ok_for_incr); 14512855Sgabeblack@google.com 14612855Sgabeblack@google.com read_mod->pulse(pulse); 14712855Sgabeblack@google.com read_mod->start(start); 14812855Sgabeblack@google.com read_mod->ok_for_incr(ok_for_incr); 14912855Sgabeblack@google.com 15012855Sgabeblack@google.com // (*read_mod)(pulse, start, ok_for_incr); 15112855Sgabeblack@google.com 15212855Sgabeblack@google.com // compute_mod->reset.bind(reset); 15312855Sgabeblack@google.com // compute_mod->start.bind(start); 15412855Sgabeblack@google.com // compute_mod->ok_for_incr.bind(ok_for_incr); 15512855Sgabeblack@google.com // compute_mod->total_dist.bind(total_dist); 15612855Sgabeblack@google.com // compute_mod->partial_dist.bind(partial_dist); 15712855Sgabeblack@google.com compute_mod->reset(reset); 15812855Sgabeblack@google.com compute_mod->start(start); 15912855Sgabeblack@google.com compute_mod->ok_for_incr.bind(ok_for_incr); 16012855Sgabeblack@google.com compute_mod->total_dist.bind(total_dist); 16112855Sgabeblack@google.com compute_mod->partial_dist(partial_dist); 16212855Sgabeblack@google.com 16312855Sgabeblack@google.com // lcd_mod->start.bind(start); 16412855Sgabeblack@google.com // lcd_mod->total_dist.bind(total_dist); 16512855Sgabeblack@google.com // lcd_mod->partial_dist.bind(partial_dist); 16612855Sgabeblack@google.com // lcd_mod->total.bind(total); 16712855Sgabeblack@google.com // lcd_mod->partial.bind(partial); 16812855Sgabeblack@google.com 16912855Sgabeblack@google.com lcd_mod->start(start); 17012855Sgabeblack@google.com lcd_mod->total_dist(total_dist); 17112855Sgabeblack@google.com lcd_mod->partial_dist(partial_dist); 17212855Sgabeblack@google.com lcd_mod->total(total); 17312855Sgabeblack@google.com lcd_mod->partial(partial); 17412855Sgabeblack@google.com 17512855Sgabeblack@google.com // *lcd_mod << start, total_dist, partial_dist, total, partial; 17612855Sgabeblack@google.com 17712855Sgabeblack@google.com ok_for_incr = false; 17812855Sgabeblack@google.com total_dist = 0.0; 17912855Sgabeblack@google.com partial_dist = 0.0; 18012855Sgabeblack@google.com } 18112855Sgabeblack@google.com}; 18212855Sgabeblack@google.com 18312855Sgabeblack@google.com#endif 184