1 | #ifdef VHDL_TESTBENCH |
---|
2 | /* |
---|
3 | * $Id: Signal_testbench.cpp 113 2009-04-14 18:39:12Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/include/Signal.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | |
---|
14 | // à optimisé -> pointeur de fonction afin d'éviter le test et le switch |
---|
15 | void Signal::testbench (void) |
---|
16 | { |
---|
17 | log_printf(FUNC,Behavioural,"testbench","Begin"); |
---|
18 | |
---|
19 | if ((_presence_port == PORT_VHDL_YES_TESTBENCH_YES) or |
---|
20 | (_presence_port == PORT_VHDL_NO_TESTBENCH_YES ) or |
---|
21 | (_presence_port == RESET_VHDL_YES ) or |
---|
22 | (_presence_port == RESET_VHDL_NO ) ) |
---|
23 | { |
---|
24 | std::string str; |
---|
25 | |
---|
26 | switch (_type_info) |
---|
27 | { |
---|
28 | case BOOL : |
---|
29 | { |
---|
30 | bool value = read <bool> (); |
---|
31 | |
---|
32 | switch (_direction) |
---|
33 | { |
---|
34 | case IN : {str = toBase2 (value); break;} |
---|
35 | case OUT : {str = toBase2 (value); break;} |
---|
36 | default : {break;} |
---|
37 | } |
---|
38 | break; |
---|
39 | } |
---|
40 | case UINT8_T : |
---|
41 | { |
---|
42 | uint8_t value = read <uint8_t> (); |
---|
43 | |
---|
44 | switch (_direction) |
---|
45 | { |
---|
46 | case IN : {str = toBase2 (value,get_size()); break;} |
---|
47 | case OUT : {str = toBase2 (value,get_size()); break;} |
---|
48 | default : {break;} |
---|
49 | } |
---|
50 | break; |
---|
51 | } |
---|
52 | case UINT16_T : |
---|
53 | { |
---|
54 | uint16_t value = read <uint16_t> (); |
---|
55 | |
---|
56 | switch (_direction) |
---|
57 | { |
---|
58 | case IN : {str = toBase2 (value,get_size()); break;} |
---|
59 | case OUT : {str = toBase2 (value,get_size()); break;} |
---|
60 | default : {break;} |
---|
61 | } |
---|
62 | break; |
---|
63 | } |
---|
64 | case UINT32_T : |
---|
65 | { |
---|
66 | uint32_t value = read <uint32_t> (); |
---|
67 | |
---|
68 | switch (_direction) |
---|
69 | { |
---|
70 | case IN : {str = toBase2 (value,get_size()); break;} |
---|
71 | case OUT : {str = toBase2 (value,get_size()); break;} |
---|
72 | default : {break;} |
---|
73 | } |
---|
74 | break; |
---|
75 | } |
---|
76 | case UINT64_T : |
---|
77 | { |
---|
78 | uint64_t value = read <uint64_t> (); |
---|
79 | |
---|
80 | switch (_direction) |
---|
81 | { |
---|
82 | case IN : {str = toBase2 (value,get_size()); break;} |
---|
83 | case OUT : {str = toBase2 (value,get_size()); break;} |
---|
84 | default : {break;} |
---|
85 | } |
---|
86 | break; |
---|
87 | } |
---|
88 | default : |
---|
89 | throw (ErrorMorpheo ("Signal \""+_name+"\" : type unknow.")); |
---|
90 | } |
---|
91 | |
---|
92 | _list_value->push_back(str); |
---|
93 | } |
---|
94 | |
---|
95 | log_printf(FUNC,Behavioural,"testbench","End"); |
---|
96 | }; |
---|
97 | |
---|
98 | }; // end namespace behavioural |
---|
99 | }; // end namespace morpheo |
---|
100 | #endif |
---|