27 |
|
|
28 |
#include "circuit.h" |
#include "circuit.h" |
29 |
|
|
30 |
|
// in[0] = Mpx4 ~= A1 ~= reg[src1] |
31 |
|
// in[1] = Mpx5 ~= A2 ~= (reg[src2] || imm13 ) |
32 |
|
// |
33 |
|
|
34 |
class shifter : public circuit { |
class shifter : public circuit { |
35 |
public: |
public: |
36 |
enum dir { left, right }; |
enum dir { left, right }; |
37 |
shifter( int nout ) |
shifter( int nout ) |
38 |
: circuit(2, nout) {}; |
: circuit(2, nout) {}; |
39 |
void process( dir d ) { |
void process( dir d ) { |
40 |
for( int i = 0 ; i < num_out() ; i++ ) |
// FIXME: is this right?? |
41 |
if ( d == left ) |
// imm13 shr R[src1] == imm13 >> R[src1] ? |
42 |
set_out( i, get_in(0) << get_in(1) ); |
// is specification right? |
43 |
else |
if ( d == left ) |
44 |
set_out( i, get_in(0) >> get_in(1) ); |
set_out_all( get_in(1) << get_in(0) ); |
45 |
|
else |
46 |
|
set_out_all( get_in(1) >> get_in(0) ); |
47 |
} |
} |
48 |
|
|
49 |
}; |
}; |