FaultModel.hh revision 8612:df3b7a1e883f
1/*
2 * Copyright (c) 2011 Massachusetts Institute of Technology
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Konstantinos Aisopos
29 */
30
31/*
32 * Official Tool Website: www.mit.edu/~kaisopos/FaultModel
33 *
34 * If you use our tool for academic research, we request that you cite:
35 * Konstantinos Aisopos, Chia-Hsin Owen Chen, and Li-Shiuan Peh. Enabling
36 * System-Level Modeling of Variation-Induced Faults in Networks-on-Chip.
37 * Proceedings of the 48th Design Automation Conference (DAC'11)
38 */
39
40#ifndef __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
41#define __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
42
43// tool limitations and fixed inputs
44#define MAX_VCs 40
45#define MAX_BUFFERS_per_VC 5
46#define BASELINE_TEMPERATURE_CELCIUS 71
47
48// C++ includes
49#include <string>
50using namespace std;
51
52// GEM5 includes
53#include "params/FaultModel.hh"
54#include "sim/sim_object.hh"
55
56class FaultModel : public SimObject
57{
58  public:
59    typedef FaultModelParams Params;
60    FaultModel(const Params *p);
61    const Params *params() const { return (const Params *)_params; }
62
63    /************************************************************************/
64    /**********  THE FAULT TYPES SUPPORTED BY THE FAULT MODEL ***************/
65    /************************************************************************/
66
67    enum fault_type
68    {
69        data_corruption__few_bits,
70        data_corruption__all_bits,
71        flit_conservation__flit_duplication,
72        flit_conservation__flit_loss_or_split,
73        misrouting,
74        credit_conservation__credit_generation,
75        credit_conservation__credit_loss,
76        erroneous_allocation__VC,
77        erroneous_allocation__switch,
78        unfair_arbitration,
79        number_of_fault_types
80    };
81
82    /************************************************************************/
83    /********************  INTERFACE OF THE FAULT MODEL *********************/
84    /************************************************************************/
85
86    enum conf_record_format
87    {
88        conf_record_buff_per_vc,
89        conf_record_vcs,
90        conf_record_first_fault_type,
91        conf_record_last_fault_type = conf_record_first_fault_type + number_of_fault_types - 1,
92        fields_per_conf_record
93    };
94
95    enum temperature_record_format
96    {
97        temperature_record_temp,
98        temperature_record_weight,
99        fields_per_temperature_record
100    };
101
102    struct system_conf
103    {
104        int vcs;
105        int buff_per_vc;
106        float fault_type[number_of_fault_types];
107    };
108
109    int declare_router(int number_of_inputs,
110                       int number_of_outputs,
111                       int number_of_vcs_per_vnet,
112                       int number_of_buff_per_data_vc,
113                       int number_of_buff_per_ctrl_vc);
114
115    string fault_type_to_string(int fault_type_index);
116
117    // the following 2 functions are called at runtime, to get the probability
118    // of each fault type (fault_vector) or the aggregate fault probability
119    // (fault_prob). Note: the probability values are provided by reference
120    // (in the variables fault_vector[] & aggregate_fault_prob respectively).
121    // Both functions also return a success flag (which is always true if
122    // temperature ranges from 0C to 125C)
123
124    bool fault_vector(int routerID,
125                      int temperature,
126                      float fault_vector[]);
127
128    bool fault_prob(int routerID,
129                    int temperature,
130                    float *aggregate_fault_prob);
131
132    // for debugging purposes
133
134    void print(void);
135
136  private:
137    vector <system_conf> configurations;
138    vector <system_conf> routers;
139    vector <int> temperature_weights;
140};
141
142#endif //  __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
143