source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Two_Level_Branch_Predictor/Two_Level_Branch_Predictor_Glue/src/Two_Level_Branch_Predictor_Glue_vhdl_body.cpp @ 2

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

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