#ifdef SYSTEMC
/*
 * $Id: RegisterFile_Monolithic_genMealy_read.cpp 81 2008-04-15 18:40:01Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h"

namespace morpheo                    {
namespace behavioural                {
namespace generic                    {
namespace registerfile               {
namespace registerfile_monolithic    {

  void RegisterFile_Monolithic::genMealy_read (void)
  {
    log_printf(FUNC,RegisterFile,"genMealy_read","Begin");

    for (uint32_t i=0; i<_param->_nb_port_read; i++)
      {
	// Have a write?
 	if ( PORT_READ(in_READ_VAL [i]) == 1)
 	  {
	    Taddress_t address;
	    if (_param->_have_port_address)
	      address = PORT_READ(in_READ_ADDRESS[i]);
	    else
	      address = 0;
	    Tdata_t    data    = reg_DATA[address];

	    log_printf(TRACE,RegisterFile,"genMealy_read","[%d] -> %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));

	    // Write in registerFile
	    PORT_WRITE(out_READ_DATA[i],data);
 	  }
	else
	  {
	    //log_printf(TRACE,RegisterFile,"genMealy_read","Read  [%d] : No   transaction",i);
	    PORT_WRITE(out_READ_DATA[i],0);
	  }
      }

    for (uint32_t i=0; i<_param->_nb_port_read_write; i++)
      {
	Tdata_t data;

	// Have a write?
 	if ( (PORT_READ(in_READ_WRITE_VAL [i]) == 1) and
	     (PORT_READ(in_READ_WRITE_RW  [i]) == RW_READ)
	     )
 	  {
	    Taddress_t address;
	    if (_param->_have_port_address)
	      address = PORT_READ(in_READ_WRITE_ADDRESS[i]);
	    else
	      address = 0;
	    
	    data = reg_DATA[address];

	    log_printf(TRACE,RegisterFile,"genMealy_read","[%d] -> %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
 	  }
	else
	  {
	    //log_printf(TRACE,RegisterFile,"genMealy_read","Read  [%d] : No   transaction",i);
	    data = 0;
	  }

	PORT_WRITE(out_READ_WRITE_RDATA[i],data);
      }

    log_printf(FUNC,RegisterFile,"genMealy_read","End");
	
  };

}; // end namespace registerfile_monolithic
}; // end namespace registerfile 
}; // end namespace generic
}; // end namespace behavioural          
}; // end namespace morpheo              
#endif
