source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Shifter/src/Shifter_genMealy_shift.cpp @ 144

Last change on this file since 144 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: 2.1 KB
RevLine 
[2]1#ifdef SYSTEMC
2/*
3 * $Id: Shifter_genMealy_shift.cpp 123 2009-06-08 20:43:30Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Generic/Shifter/include/Shifter.h"
[44]10#include "Common/include/BitManipulation.h"
[2]11#include <bitset>
12
13namespace morpheo {
14namespace behavioural {
15namespace generic {
16namespace shifter {
17
18  void Shifter::genMealy_shift (void)
19  {
[123]20    if (PORT_READ(in_NRESET))
[82]21    for (uint32_t i=0; i<_param->_nb_port; i++)
[2]22      {
23        // Read
24        Tdata_t      data_in     = PORT_READ(in_SHIFTER_DATA [i]);
25        Tdata_t      data_out    = data_in;
[82]26        Tshift_t     shift_value = _param->_shift_value;
[2]27        if (shift_value == 0)
28          shift_value = PORT_READ(in_SHIFTER_SHIFT [i]);
29
30        Tdirection_t direction; 
[82]31        if (_param->_direction == external_direction)
[2]32          direction = PORT_READ(in_SHIFTER_DIRECTION [i]);
33        else
[82]34          direction = _param->_internal_direction;
[2]35
36        Ttype_t      type;
[82]37        if (_param->_rotate    == external_rotate)
[2]38          type      = PORT_READ(in_SHIFTER_TYPE      [i]);
39        else
[82]40          type      = _param->_internal_type; 
[2]41
42        Tcarry_t     carry;     
[82]43        if (_param->_carry     == external_carry)
[2]44          carry     = PORT_READ(in_SHIFTER_CARRY     [i]);
45        else
[82]46          carry     = _param->_internal_carry; 
[2]47       
48        if (type == _shift)
49          {
[82]50            data_out = shift  <Tdata_t> (_param->_size_data, data_in, shift_value, direction == _left, carry == _arithmetic);
[2]51
[82]52            if (_param->_size_data_completion > 0)
[2]53              {
54                Tdata_t completion;
55
[82]56                if (_param->_type_completion_bool == true)
[2]57                  completion = (PORT_READ(in_SHIFTER_CARRY_IN   [i])==true)?1:0;
58                else
59                  completion = PORT_READ(in_SHIFTER_COMPLETION [i]);
60
61                Tdata_t mask       ;
62
63                if (direction == _left)
64                  {
65                    mask       = gen_mask<Tdata_t> (shift_value);
66                  }
67                else
68                  {
[82]69                    mask       = gen_mask<Tdata_t> (shift_value)      << (_param->_size_data-shift_value);
[2]70                  }
71                 
72                data_out = (data_out & ~mask) | (completion & mask);
73              }
74          }
75        else
[82]76          data_out = rotate <Tdata_t> (_param->_size_data, data_in, shift_value, direction == _left);
[2]77
78        // Write
79        PORT_WRITE(out_SHIFTER_DATA [i], data_out);
80      }
81  };
82
83}; // end namespace shifter
84}; // end namespace generic
85}; // end namespace behavioural
86}; // end namespace morpheo             
87#endif
Note: See TracBrowser for help on using the repository browser.