cours2: sign_extend_32.h

File sign_extend_32.h, 400 bytes (added by fpecheux, 17 years ago)
Line 
1#ifndef _SIGN_EXTEND_32_H
2#define _SIGN_EXTEND_32_H
3#include "systemc.h"
4
5SC_MODULE(sign_extend_32)
6{
7 sc_in<sc_uint<16> > I;
8 sc_out<sc_uint<32> > O;
9
10 SC_CTOR(sign_extend_32)
11 {
12 SC_METHOD(mWrite);
13 sensitive << I ;
14 }
15
16 void mWrite()
17 {
18 sc_uint<16> i_value=I.read();
19
20 if (i_value[15]==1)
21 O.write(0xFFFF0000 | i_value);
22 else
23 O.write(i_value);
24 }
25};
26#endif
27