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

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

File size: 2.1 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id$
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Generic/Shifter/include/Shifter.h"
10#include "Include/BitManipulation.h"
11#include <bitset>
12
13using namespace std;
14namespace morpheo {
15namespace behavioural {
16namespace generic {
17namespace shifter {
18
19  void Shifter::genMealy_shift (void)
20  {
21    for (uint32_t i=0; i<_param._nb_port; i++)
22      {
23        // Read
24        Tdata_t      data_in     = PORT_READ(in_SHIFTER_DATA [i]);
25        Tdata_t      data_out    = data_in;
26        Tshift_t     shift_value = _param._shift_value;
27        if (shift_value == 0)
28          shift_value = PORT_READ(in_SHIFTER_SHIFT [i]);
29
30        Tdirection_t direction; 
31        if (_param._direction == external_direction)
32          direction = PORT_READ(in_SHIFTER_DIRECTION [i]);
33        else
34          direction = _param._internal_direction;
35
36        Ttype_t      type;
37        if (_param._rotate    == external_rotate)
38          type      = PORT_READ(in_SHIFTER_TYPE      [i]);
39        else
40          type      = _param._internal_type; 
41
42        Tcarry_t     carry;     
43        if (_param._carry     == external_carry)
44          carry     = PORT_READ(in_SHIFTER_CARRY     [i]);
45        else
46          carry     = _param._internal_carry; 
47       
48        if (type == _shift)
49          {
50            data_out = shift  <Tdata_t> (_param._size_data, data_in, shift_value, direction == _left, carry == _arithmetic);
51
52            if (_param._size_data_completion > 0)
53              {
54                Tdata_t completion;
55
56                if (_param._type_completion_bool == true)
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                  {
69                    mask       = gen_mask<Tdata_t> (shift_value)      << (_param._size_data-shift_value);
70                  }
71                 
72                data_out = (data_out & ~mask) | (completion & mask);
73              }
74          }
75        else
76          data_out = rotate <Tdata_t> (_param._size_data, data_in, shift_value, direction == _left);
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.