gem5  v22.0.0.2
dist.h
Go to the documentation of this file.
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  dist.h -- Definition of the odometers.
23 
24  Original Author: Ali Dasdan, Synopsys, Inc.
25 
26  *****************************************************************************/
27 
28 /*****************************************************************************
29 
30  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
31  changes you are making here.
32 
33  Name, Affiliation, Date:
34  Description of Modification:
35 
36  *****************************************************************************/
37 
38 #ifndef DIST_H
39 #define DIST_H
40 
41 SC_MODULE( dist_read_mod )
42 {
43  // Input ports:
44  sc_in<bool> pulse; // Pulse coming from the pulse generator.
45  sc_in<bool> start; // Becomes true if the car's started.
46 
47  // Output ports:
48  sc_out<bool> ok_for_incr;
49 
50  // Get the pulses for one distance increment.
51  void get_dist_proc();
52 
53  SC_CTOR( dist_read_mod )
54  {
55  SC_THREAD( get_dist_proc );
56  sensitive << pulse.pos();
57  }
58 };
59 
60 SC_MODULE( dist_compute_mod )
61 {
62  // Input ports:
63  sc_in<bool> reset; // Reset the partial distance odometer if true.
64  sc_in<bool> start; // Becomes true if the car's started.
65  sc_in<bool> ok_for_incr;
66 
67  // Output ports:
68  sc_out<double> total_dist;
69  sc_out<double> partial_dist;
70 
71  // Internal variables:
72  static bool prev_reset;
73  static double total_compute_dist;
74  static double partial_compute_dist;
75 
76  // Compute total and partial distances.
77  void compute_total_proc();
78  void compute_partial_proc();
79 
80  SC_CTOR( dist_compute_mod )
81  {
82  SC_METHOD( compute_total_proc );
83  sensitive << ok_for_incr;
84 
85  SC_METHOD( compute_partial_proc );
86  sensitive << ok_for_incr;
87 
88  prev_reset = false;
89  total_compute_dist = 0.0;
90  partial_compute_dist = 0.0;
91  }
92 };
93 
94 SC_MODULE( dist_lcd_mod )
95 {
96  // Input ports:
97  sc_in<bool> start; // Becomes true if the car's started.
98  sc_in<double> total_dist;
99  sc_in<double> partial_dist;
100 
101  // Output ports:
102  sc_out<double> total; // Total distance.
103  sc_out<double> partial; // Partial distance.
104 
105  // LCD display driver.
106  void lcd_driver_proc();
107 
108  SC_CTOR( dist_lcd_mod )
109  {
110  SC_METHOD( lcd_driver_proc );
111  sensitive << total_dist << partial_dist;
112  }
113 };
114 
115 SC_MODULE( dist_mod )
116 {
117  // Ports:
118  sc_in<bool> pulse; // Pulse coming ftom the pulse generator.
119  sc_in<bool> reset; // Reset the partial distance odometer if true.
120  sc_in<bool> start; // Becomes true if the car's started.
121 
122  // Output ports:
123  sc_out<double> total; // Total distance.
124  sc_out<double> partial; // Partial distance.
125 
126  // Internal signals:
127  sc_signal<bool> ok_for_incr;
128  sc_signal<double> total_dist;
129  sc_signal<double> partial_dist;
130 
131  // Internal models:
132  dist_read_mod *read_mod;
133  dist_compute_mod *compute_mod;
134  dist_lcd_mod *lcd_mod;
135 
136  SC_CTOR( dist_mod )
137  {
138  read_mod = new dist_read_mod("read_mod");
139  compute_mod = new dist_compute_mod("compute_mod");
140  lcd_mod = new dist_lcd_mod("lcd_mod");
141 
142  read_mod->pulse.bind(pulse);
143  read_mod->start.bind(start);
144  read_mod->ok_for_incr.bind(ok_for_incr);
145 
146  compute_mod->reset.bind(reset);
147  compute_mod->start.bind(start);
148  compute_mod->ok_for_incr.bind(ok_for_incr);
149  compute_mod->total_dist.bind(total_dist);
150  compute_mod->partial_dist.bind(partial_dist);
151 
152  lcd_mod->start.bind(start);
153  lcd_mod->total_dist.bind(total_dist);
154  lcd_mod->partial_dist.bind(partial_dist);
155  lcd_mod->total.bind(total);
156  lcd_mod->partial.bind(partial);
157 
158  ok_for_incr = false;
159  total_dist = 0.0;
160  partial_dist = 0.0;
161  }
162 };
163 
164 #endif
SC_THREAD
#define SC_THREAD(name)
Definition: sc_module.hh:313
SC_CTOR
#define SC_CTOR(name)
Definition: sc_module.hh:297
SC_METHOD
#define SC_METHOD(name)
Definition: sc_module.hh:303
gem5::statistics::reset
void reset()
Definition: statistics.cc:310
SC_MODULE
SC_MODULE(dist_mod)
Definition: dist.h:41
gem5::statistics::total
const FlagsType total
Print the total.
Definition: info.hh:60

Generated on Thu Jul 28 2022 13:32:43 for gem5 by doxygen 1.8.17