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

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

1) Correct bug in link two signal
2) Fix error detected with valgrind
3) modif distexe script

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