source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Dcache_Access/src/Dcache_Access_genMealy_rsp.cpp @ 123

Last change on this file since 123 was 123, checked in by rosiere, 15 years ago

1) Fix performance
2) add auto generation to SPECINT2000
3) add reset in genMoore and genMealy

  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Dcache_Access_genMealy_rsp.cpp 123 2009-06-08 20:43:30Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Dcache_Access/include/Dcache_Access.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace dcache_access {
15
16
17#undef  FUNCTION
18#define FUNCTION "Dcache_Access::genMealy_rsp"
19  void Dcache_Access::genMealy_rsp (void)
20  {
21    log_begin(Dcache_Access,FUNCTION);
22
23    if (PORT_READ(in_NRESET))
24      {
25    Tcontrol_t lsq_rsp_val [_param->_nb_execute_loop][_param->_max_nb_load_store_unit][_param->_max_nb_cache_access];
26    for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
27      for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j)
28        for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k)
29          lsq_rsp_val [i][j][k] = 0;
30
31    for (uint32_t i=0; i<_param->_nb_dcache_port; ++i)
32      {
33        Tcontrol_t val = PORT_READ(in_DCACHE_RSP_VAL [i]);
34        Tcontrol_t ack;
35       
36        if (val)
37          {
38            Tcontext_t thread_id = (_param->_have_port_dcache_thread_id)?PORT_READ(in_DCACHE_RSP_THREAD_ID [i]):0;
39            Tcontext_t packet_id = (_param->_have_port_dcache_packet_id)?PORT_READ(in_DCACHE_RSP_PACKET_ID [i]):0;
40
41            Tcontext_t execute_loop_id     = _param->_translate_thread_to_execute_loop    [thread_id];
42            Tcontext_t load_store_unit_id  = _param->_translate_thread_to_load_store_unit [thread_id];
43            Tcontext_t context_id          = _param->_translate_thread_to_context         [thread_id];
44
45            Tpacket_t  cache_access_id     = (packet_id >> _param->_shift_num_cache_access   ) & _param->_mask_num_cache_access;
46            Tpacket_t  lsq_packet_id       =  packet_id                                        & _param->_mask_num_lsq_packet;
47
48//          log_printf(TRACE,Dcache_Access,FUNCTION,"thread_id          : %d",thread_id);
49//          log_printf(TRACE,Dcache_Access,FUNCTION,"execute_loop_id    : %d",execute_loop_id);
50//          log_printf(TRACE,Dcache_Access,FUNCTION,"load_store_unit_id : %d",load_store_unit_id);
51//          log_printf(TRACE,Dcache_Access,FUNCTION,"cache_access_id    : %d",cache_access_id);
52           
53#ifdef DEBUG_TEST
54            if (execute_loop_id > _param->_nb_execute_loop)
55              throw ERRORMORPHEO(FUNCTION,_("invalid execute_loop_id.\n"));
56
57            if (load_store_unit_id > _param->_nb_load_store_unit[execute_loop_id])
58              throw ERRORMORPHEO(FUNCTION,_("invalid load_store_unit_id.\n"));
59
60            if (context_id > _param->_nb_context[execute_loop_id])
61              throw ERRORMORPHEO(FUNCTION,_("invalid context_id.\n"));
62
63            if (cache_access_id > _param->_nb_cache_access[execute_loop_id][load_store_unit_id])
64              throw ERRORMORPHEO(FUNCTION,_("invalid cache_access_id.\n"));
65
66            if (_param->_table_routing [execute_loop_id][load_store_unit_id][cache_access_id] != i)
67              throw ERRORMORPHEO(FUNCTION,_("invalid route.\n"));
68#endif
69
70            ack = PORT_READ(in_LSQ_RSP_ACK [execute_loop_id][load_store_unit_id][cache_access_id]);
71           
72            lsq_rsp_val [execute_loop_id][load_store_unit_id][cache_access_id] = 1;
73
74            if (_param->_have_port_lsq_thread_id [execute_loop_id][load_store_unit_id])
75            PORT_WRITE(out_LSQ_RSP_THREAD_ID   [execute_loop_id][load_store_unit_id][cache_access_id], context_id);
76            if (_param->_have_port_lsq_packet_id [execute_loop_id][load_store_unit_id])
77            PORT_WRITE(out_LSQ_RSP_PACKET_ID   [execute_loop_id][load_store_unit_id][cache_access_id], lsq_packet_id);
78            PORT_WRITE(out_LSQ_RSP_RDATA       [execute_loop_id][load_store_unit_id][cache_access_id], PORT_READ(in_DCACHE_RSP_RDATA       [i]));
79            PORT_WRITE(out_LSQ_RSP_ERROR       [execute_loop_id][load_store_unit_id][cache_access_id], PORT_READ(in_DCACHE_RSP_ERROR       [i]));
80          }
81        else
82          ack = 0;
83               
84        PORT_WRITE(out_DCACHE_RSP_ACK [i],ack);
85      }
86
87    for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
88      for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j)
89        for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k)
90          PORT_WRITE(out_LSQ_RSP_VAL [i][j][k], lsq_rsp_val [i][j][k]);
91      }
92    else
93      {
94        for (uint32_t i=0; i<_param->_nb_dcache_port; ++i)
95          PORT_WRITE(out_DCACHE_RSP_ACK [i],0);
96
97        for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
98          for (uint32_t j=0; j<_param->_nb_load_store_unit[i]; ++j)
99            for (uint32_t k=0; k<_param->_nb_cache_access [i][j]; ++k)
100              PORT_WRITE(out_LSQ_RSP_VAL [i][j][k], 0);
101      }
102
103    log_end(Dcache_Access,FUNCTION);
104  };
105
106}; // end namespace dcache_access
107}; // end namespace core
108
109}; // end namespace behavioural
110}; // end namespace morpheo             
111#endif
Note: See TracBrowser for help on using the repository browser.