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_FAULTMODEL_HH__
41#define __MEM_RUBY_NETWORK_FAULT_MODEL_FAULTMODEL_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>
50
51// GEM5 includes
52#include "params/FaultModel.hh"
53#include "sim/sim_object.hh"
54
55class FaultModel : public SimObject
56{
57  public:
58    typedef FaultModelParams Params;
59    FaultModel(const Params *p);
60    const Params *params() const { return (const Params *)_params; }
61
62    /************************************************************************/
63    /**********  THE FAULT TYPES SUPPORTED BY THE FAULT MODEL ***************/
64    /************************************************************************/
65
66    enum fault_type
67    {
68        data_corruption__few_bits,
69        data_corruption__all_bits,
70        flit_conservation__flit_duplication,
71        flit_conservation__flit_loss_or_split,
72        misrouting,
73        credit_conservation__credit_generation,
74        credit_conservation__credit_loss,
75        erroneous_allocation__VC,
76        erroneous_allocation__switch,
77        unfair_arbitration,
78        number_of_fault_types
79    };
80
81    /************************************************************************/
82    /********************  INTERFACE OF THE FAULT MODEL *********************/
83    /************************************************************************/
84
85    enum conf_record_format
86    {
87        conf_record_buff_per_vc,
88        conf_record_vcs,
89        conf_record_first_fault_type,
90        conf_record_last_fault_type = conf_record_first_fault_type + number_of_fault_types - 1,
91        fields_per_conf_record
92    };
93
94    enum temperature_record_format
95    {
96        temperature_record_temp,
97        temperature_record_weight,
98        fields_per_temperature_record
99    };
100
101    struct system_conf
102    {
103        int vcs;
104        int buff_per_vc;
105        float fault_type[number_of_fault_types];
106    };
107
108    int declare_router(int number_of_inputs,
109                       int number_of_outputs,
110                       int number_of_vcs_per_vnet,
111                       int number_of_buff_per_data_vc,
112                       int number_of_buff_per_ctrl_vc);
113
114    std::string fault_type_to_string(int fault_type_index);
115
116    // the following 2 functions are called at runtime, to get the probability
117    // of each fault type (fault_vector) or the aggregate fault probability
118    // (fault_prob). Note: the probability values are provided by reference
119    // (in the variables fault_vector[] & aggregate_fault_prob respectively).
120    // Both functions also return a success flag (which is always true if
121    // temperature ranges from 0C to 125C)
122
123    bool fault_vector(int routerID,
124                      int temperature,
125                      float fault_vector[]);
126
127    bool fault_prob(int routerID,
128                    int temperature,
129                    float *aggregate_fault_prob);
130
131    // for debugging purposes
132
133    void print(void);
134
135  private:
136    std::vector <system_conf> configurations;
137    std::vector <system_conf> routers;
138    std::vector <int> temperature_weights;
139};
140
141#endif //__MEM_RUBY_NETWORK_FAULT_MODEL_FAULTMODEL_HH__
142