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

Last change on this file since 88 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 2.1 KB
RevLine 
[2]1#ifdef SYSTEMC
2/*
3 * $Id: Shifter_genMealy_shift.cpp 82 2008-05-01 16:48:45Z 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  {
[82]20    for (uint32_t i=0; i<_param->_nb_port; i++)
[2]21      {
22        // Read
23        Tdata_t      data_in     = PORT_READ(in_SHIFTER_DATA [i]);
24        Tdata_t      data_out    = data_in;
[82]25        Tshift_t     shift_value = _param->_shift_value;
[2]26        if (shift_value == 0)
27          shift_value = PORT_READ(in_SHIFTER_SHIFT [i]);
28
29        Tdirection_t direction; 
[82]30        if (_param->_direction == external_direction)
[2]31          direction = PORT_READ(in_SHIFTER_DIRECTION [i]);
32        else
[82]33          direction = _param->_internal_direction;
[2]34
35        Ttype_t      type;
[82]36        if (_param->_rotate    == external_rotate)
[2]37          type      = PORT_READ(in_SHIFTER_TYPE      [i]);
38        else
[82]39          type      = _param->_internal_type; 
[2]40
41        Tcarry_t     carry;     
[82]42        if (_param->_carry     == external_carry)
[2]43          carry     = PORT_READ(in_SHIFTER_CARRY     [i]);
44        else
[82]45          carry     = _param->_internal_carry; 
[2]46       
47        if (type == _shift)
48          {
[82]49            data_out = shift  <Tdata_t> (_param->_size_data, data_in, shift_value, direction == _left, carry == _arithmetic);
[2]50
[82]51            if (_param->_size_data_completion > 0)
[2]52              {
53                Tdata_t completion;
54
[82]55                if (_param->_type_completion_bool == true)
[2]56                  completion = (PORT_READ(in_SHIFTER_CARRY_IN   [i])==true)?1:0;
57                else
58                  completion = PORT_READ(in_SHIFTER_COMPLETION [i]);
59
60                Tdata_t mask       ;
61
62                if (direction == _left)
63                  {
64                    mask       = gen_mask<Tdata_t> (shift_value);
65                  }
66                else
67                  {
[82]68                    mask       = gen_mask<Tdata_t> (shift_value)      << (_param->_size_data-shift_value);
[2]69                  }
70                 
71                data_out = (data_out & ~mask) | (completion & mask);
72              }
73          }
74        else
[82]75          data_out = rotate <Tdata_t> (_param->_size_data, data_in, shift_value, direction == _left);
[2]76
77        // Write
78        PORT_WRITE(out_SHIFTER_DATA [i], data_out);
79      }
80  };
81
82}; // end namespace shifter
83}; // end namespace generic
84}; // end namespace behavioural
85}; // end namespace morpheo             
86#endif
Note: See TracBrowser for help on using the repository browser.