gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sc_signal_resolved.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * Authors: Gabe Black
28  */
29 
30 #include "systemc/core/process.hh"
33 #include "systemc/ext/core/sc_module.hh" // for sc_gen_unique_name
34 
35 namespace sc_core
36 {
37 
39  sc_signal<sc_dt::sc_logic, SC_MANY_WRITERS>(
40  sc_gen_unique_name("signal_resolved"))
41 {}
42 
44  sc_interface(), sc_signal<sc_dt::sc_logic, SC_MANY_WRITERS>(name)
45 {}
46 
49 
50 void
52 {
54 
55  auto it = inputs.find(p);
56  if (it == inputs.end()) {
57  inputs.emplace(p, l);
59  } else if (it->second != l) {
60  it->second = l;
62  }
63 }
64 
67 {
68  write(l);
69  return *this;
70 }
71 
74 {
75  write(r.read());
76  return *this;
77 }
78 
79 void
81 {
82  using sc_dt::Log_0;
83  using sc_dt::Log_1;
84  using sc_dt::Log_Z;
85  using sc_dt::Log_X;
86  static sc_dt::sc_logic_value_t merge_table[4][4] = {
87  { Log_0, Log_X, Log_0, Log_X },
88  { Log_X, Log_1, Log_1, Log_X },
89  { Log_0, Log_1, Log_Z, Log_X },
90  { Log_X, Log_X, Log_X, Log_X }
91  };
92 
93  // Resolve the inputs, and give the result to the underlying signal class.
94  m_new_val = Log_Z;
95  for (auto &input: inputs)
96  m_new_val = merge_table[m_new_val.value()][input.second.value()];
97 
98  // Ask the signal to update it's value.
100 }
101 
102 } // namespace sc_core
virtual void update()
Definition: sc_signal.hh:303
const char * sc_gen_unique_name(const char *seed)
Definition: sc_module.cc:822
Definition: sc_bit.cc:67
const char * name() const
Definition: sc_object.cc:46
std::map<::sc_gem5::Process *, sc_dt::sc_logic > inputs
virtual const T & read() const
Definition: sc_signal.hh:187
virtual void register_port(sc_port_base &, const char *)
sc_logic_value_t value() const
Definition: sc_logic.hh:236
Process * current()
Definition: scheduler.hh:172
sc_logic_value_t
Definition: sc_logic.hh:84
Scheduler scheduler
Definition: scheduler.cc:491
virtual void write(const sc_dt::sc_logic &)
Bitfield< 0 > p
Bitfield< 5 > l
sc_signal_resolved & operator=(const sc_dt::sc_logic &)

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13