source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Two_Level_Branch_Predictor_Glue/src/Two_Level_Branch_Predictor_Glue_vhdl_body.cpp @ 48

Last change on this file since 48 was 48, checked in by rosiere, 17 years ago

Modification des Makefile : pas de creation inutile de shell

File size: 5.6 KB
Line 
1#ifdef VHDL
2/*
3 * $Id$
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Two_Level_Branch_Predictor_Glue/include/Two_Level_Branch_Predictor_Glue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18
19namespace meta_predictor {
20namespace two_level_branch_predictor {
21namespace two_level_branch_predictor_glue {
22
23
24  void Two_Level_Branch_Predictor_Glue::vhdl_body (Vhdl * & vhdl)
25  {
26    log_printf(FUNC,Two_Level_Branch_Predictor_Glue,"vhdl_body","Begin");
27
28    vhdl->set_body ("-- ack output");
29    for (uint32_t i=0; i<_param._nb_prediction; i++)
30      {
31        string bht_ack, pht_ack;
32
33        if (_param._have_bht)
34          bht_ack = "in_PREDICT_"+toString(i)+"_BHT_ACK";
35        else
36          bht_ack = "'1'";
37
38        if (_param._have_pht)
39          pht_ack = "in_PREDICT_"+toString(i)+"_PHT_ACK";
40        else
41          pht_ack = "'1'";
42
43        vhdl->set_body ("out_PREDICT_"+toString(i)+"_ACK         <= "+bht_ack+" and "+pht_ack+";");
44      }
45
46    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
47      {
48        string bht_ack, pht_ack;
49
50        if (_param._have_bht)
51          bht_ack = "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK";
52        else
53          bht_ack = "'1'";
54
55        if (_param._have_pht)
56          pht_ack = "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK";
57        else
58          pht_ack = "'1'";
59
60        vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_ACK <= "+bht_ack+" and "+pht_ack+";");
61      }
62   
63    vhdl->set_body ("");
64    vhdl->set_body ("-- address output");
65
66    for (uint32_t i=0; i<_param._nb_prediction; i++)
67      {
68        // The address is higher than the address size of bht
69        if (_param._have_bht)
70          vhdl->set_body ("out_PREDICT_"+toString(i)+"_BHT_ADDRESS <= in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._bht_size_address)+";");
71
72        if (_param._have_pht)
73          {
74            // For pht : 2 cases
75            if (_param._have_bht)
76              {
77                uint32_t min = 0;
78                uint32_t max = _param._pht_size_address;
79
80                // A lot of case :
81                //
82                //      pht_size_addr
83                // addr             bht_history
84                //
85                // ---------] |
86                //            |[---------
87                //
88                // -----------|----]               share
89                //            |  [-------
90                //
91                // -----------|----]            no share
92                //            |     [-----
93                //
94               
95                // Test if address is share
96                if (_param._pht_size_address_shift > 0)
97                  {
98                    min = _param._pht_size_address_shift;
99                    vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(min) + " <=  in_PREDICT_"+toString(i)+"_BHT_HISTORY"+std_logic_range(min)+";");
100                  }
101
102                if (_param._bht_size_history < _param._pht_size_address)
103                  {
104                    max = _param._bht_size_history;
105                    vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(_param._pht_size_address-1,max) + " <=  in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address-1-_param._pht_size_address_shift, _param._pht_size_address_share)+";");
106                  }
107               
108                // intersection
109                if (_param._pht_size_address_share > 0)
110                  vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(max-1,min) + " <=  in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address_share-1,0)+" xor in_PREDICT_"+toString(i)+"_BHT_HISTORY"+std_logic_range(max-1,min)+";");
111              }
112            else
113              vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS <=  in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address)+";");
114          }
115      }
116
117    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
118      {
119        // The address is higher than the address size of bht
120        if (_param._have_bht)
121          vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS <= in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._bht_size_address)+";");
122
123        if (_param._have_pht)
124          {
125            // For pht : 2 cases
126            if (_param._have_bht)
127              {
128                uint32_t min = 0;
129                uint32_t max = _param._pht_size_address;
130
131                // Test if address is share
132                if (_param._pht_size_address_shift > 0)
133                  {
134                    min = _param._pht_size_address_shift;
135                    vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(min) + " <=  in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"+std_logic_range(min)+";");
136                  }
137
138                if (_param._bht_size_history < _param._pht_size_address)
139                  {
140                    max = _param._bht_size_history;
141                    vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(_param._pht_size_address-1,max) + " <=  in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address-1-_param._pht_size_address_shift, _param._pht_size_address_share)+";");
142                  }
143               
144                // intersection
145                if (_param._pht_size_address_share > 0)
146                  vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(max-1,min) + " <=  in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address_share-1,0)+" xor in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"+std_logic_range(max-1,min)+";");
147              }
148            else
149              vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS <=  in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address)+";");
150          }
151      }
152
153    log_printf(FUNC,Two_Level_Branch_Predictor_Glue,"vhdl_body","End");
154  };
155
156}; // end namespace two_level_branch_predictor_glue
157}; // end namespace two_level_branch_predictor
158}; // end namespace meta_predictor
159
160}; // end namespace core
161}; // end namespace multi_front_end
162}; // end namespace front_end
163}; // end namespace prediction_unit
164}; // end namespace direction
165
166
167}; // end namespace behavioural
168}; // end namespace morpheo             
169#endif
Note: See TracBrowser for help on using the repository browser.