dist.cpp revision 12855:588919e0e4aa
12139SN/A/***************************************************************************** 22139SN/A 32139SN/A Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 42139SN/A more contributor license agreements. See the NOTICE file distributed 52139SN/A with this work for additional information regarding copyright ownership. 62139SN/A Accellera licenses this file to you under the Apache License, Version 2.0 72139SN/A (the "License"); you may not use this file except in compliance with the 82139SN/A License. You may obtain a copy of the License at 92139SN/A 102139SN/A http://www.apache.org/licenses/LICENSE-2.0 112139SN/A 122139SN/A Unless required by applicable law or agreed to in writing, software 132139SN/A distributed under the License is distributed on an "AS IS" BASIS, 142139SN/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 152139SN/A implied. See the License for the specific language governing 162139SN/A permissions and limitations under the License. 172139SN/A 182139SN/A *****************************************************************************/ 192139SN/A 202139SN/A/***************************************************************************** 212139SN/A 222139SN/A dist.cpp -- Implementation of the odometers. 232139SN/A 242139SN/A Original Author: Ali Dasdan, Synopsys, Inc. 252139SN/A 262139SN/A *****************************************************************************/ 272139SN/A 282665Ssaidi@eecs.umich.edu/***************************************************************************** 292665Ssaidi@eecs.umich.edu 302139SN/A MODIFICATION LOG - modifiers, enter your name, affiliation, date and 314202Sbinkertn@umich.edu changes you are making here. 322139SN/A 334202Sbinkertn@umich.edu Name, Affiliation, Date: 342152SN/A Description of Modification: 352152SN/A 362139SN/A *****************************************************************************/ 372139SN/A 382139SN/A// $Log: dist.cpp,v $ 392139SN/A// Revision 1.1.1.1 2006/12/15 20:26:24 acg 402139SN/A// systemc_tests-2.3 412152SN/A// 422152SN/A// Revision 1.3 2006/01/19 00:48:20 acg 432139SN/A// Andy Goodrich: Changes for the fact signal write checking is enabled. 442139SN/A// 452139SN/A// Revision 1.2 2006/01/18 00:23:51 acg 464781Snate@binkert.org// Change over from SC_NO_WRITE_CHECK to sc_write_check_enable() call. 474781Snate@binkert.org// 484781Snate@binkert.org 494781Snate@binkert.org#define SC_NO_WRITE_CHECK 504781Snate@binkert.org#include "systemc.h" 513170Sstever@eecs.umich.edu#include "const.h" 525664Sgblack@eecs.umich.edu#include "dist.h" 533806Ssaidi@eecs.umich.edu 544781Snate@binkert.orgbool dist_compute_mod::prev_reset; 554781Snate@binkert.orgdouble dist_compute_mod::total_compute_dist; 564781Snate@binkert.orgdouble dist_compute_mod::partial_compute_dist; 574781Snate@binkert.org 584781Snate@binkert.org// Get the pulses for one distance increment. 594781Snate@binkert.orgvoid 604781Snate@binkert.orgdist_read_mod::get_dist_proc() 614781Snate@binkert.org{ 624781Snate@binkert.org wait(); 634781Snate@binkert.org 642139SN/A bool ok = false; 652139SN/A 663546Sgblack@eecs.umich.edu while (true) { 674202Sbinkertn@umich.edu 682152SN/A // More than one pulse is needed for a distance increment. This 692152SN/A // function collects NUM_PULSES_FOR_DIST_INCR pulses for that 702152SN/A // purpose. 712152SN/A AWAIT(NUM_PULSES_FOR_DIST_INCR); 722152SN/A 732152SN/A if (start) 742152SN/A ok = !ok; 752152SN/A else 762152SN/A ok = false; 772152SN/A 782152SN/A ok_for_incr = ok; 792152SN/A } 802504SN/A} 812504SN/A 822504SN/A// Compute total distance. 832504SN/Avoid 842152SN/Adist_compute_mod::compute_total_proc() 852504SN/A{ 862152SN/A if (start) 872152SN/A total_compute_dist += 1.0; 882152SN/A else 892152SN/A total_compute_dist = 0.0; 902152SN/A 912152SN/A total_dist = total_compute_dist; 922152SN/A} 932152SN/A 942632Sstever@eecs.umich.edu// Compute partial distance. 952155SN/Avoid 962155SN/Adist_compute_mod::compute_partial_proc() 972155SN/A{ 982155SN/A if (start) { 992155SN/A 1002155SN/A // Implement reset.event(): 1015228Sgblack@eecs.umich.edu if (prev_reset != (bool) reset) 1022155SN/A partial_compute_dist = 0.0; 1032155SN/A else 1042155SN/A partial_compute_dist += 1.0; 1052152SN/A 1062766Sktlim@umich.edu prev_reset = reset; 1072766Sktlim@umich.edu 1082766Sktlim@umich.edu } 1092766Sktlim@umich.edu else 1102766Sktlim@umich.edu partial_compute_dist = 0.0; 1112152SN/A 1122152SN/A partial_dist = partial_compute_dist; 1132152SN/A} 1142155SN/A 1152152SN/A// LCD display driver. 1162152SN/Avoid 1172718Sstever@eecs.umich.edudist_lcd_mod::lcd_driver_proc() 1182921Sktlim@umich.edu{ 1192921Sktlim@umich.edu if (start) { 1202921Sktlim@umich.edu 1212921Sktlim@umich.edu if (total_dist.event()) 1222921Sktlim@umich.edu total = total_dist * DIST_INCR; 1232921Sktlim@umich.edu 1242921Sktlim@umich.edu if (partial_dist.event()) 1252921Sktlim@umich.edu partial = partial_dist * DIST_INCR; 1262921Sktlim@umich.edu 1272152SN/A } 1282152SN/A else { 129 total = 0.0; 130 partial = 0.0; 131 } 132} 133 134// End of file 135