gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
41SC_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
60SC_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
94SC_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
115SC_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 read_mod->pulse(pulse);
147 read_mod->start(start);
148 read_mod->ok_for_incr(ok_for_incr);
149
150 // (*read_mod)(pulse, start, ok_for_incr);
151
152 // compute_mod->reset.bind(reset);
153 // compute_mod->start.bind(start);
154 // compute_mod->ok_for_incr.bind(ok_for_incr);
155 // compute_mod->total_dist.bind(total_dist);
156 // compute_mod->partial_dist.bind(partial_dist);
157 compute_mod->reset(reset);
158 compute_mod->start(start);
159 compute_mod->ok_for_incr.bind(ok_for_incr);
160 compute_mod->total_dist.bind(total_dist);
161 compute_mod->partial_dist(partial_dist);
162
163 // lcd_mod->start.bind(start);
164 // lcd_mod->total_dist.bind(total_dist);
165 // lcd_mod->partial_dist.bind(partial_dist);
166 // lcd_mod->total.bind(total);
167 // lcd_mod->partial.bind(partial);
168
169 lcd_mod->start(start);
170 lcd_mod->total_dist(total_dist);
171 lcd_mod->partial_dist(partial_dist);
172 lcd_mod->total(total);
173 lcd_mod->partial(partial);
174
175 // *lcd_mod << start, total_dist, partial_dist, total, partial;
176
177 ok_for_incr = false;
178 total_dist = 0.0;
179 partial_dist = 0.0;
180 }
181};
182
183#endif
#define SC_METHOD(name)
Definition sc_module.hh:303
#define SC_THREAD(name)
Definition sc_module.hh:313
#define SC_MODULE(name)
Definition sc_module.hh:295
#define SC_CTOR(name)
Definition sc_module.hh:297

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0