source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Vhdl_std_logic.cpp @ 146

Last change on this file since 146 was 97, checked in by rosiere, 16 years ago

1) Update Prediction Table : statistics
2) Size instruction address on 30 bits
3) Change Log File
4) Add debug_level in simulation configuration file

  • Property svn:keywords set to Id
File size: 4.2 KB
RevLine 
[2]1#ifdef VHDL
2
3/*
4 * $Id: Vhdl_std_logic.cpp 97 2008-12-19 15:34:00Z rosiere $
5 *
6 * [ Description ]
7 *
8 */
9
10#include <math.h>
11#include "Behavioural/include/Vhdl.h"
[95]12#include "Common/include/ToBase2.h"
[2]13
14namespace morpheo              {
15namespace behavioural          {
16
[43]17#undef  FUNCTION
18#define FUNCTION "Vhdl::std_logic"
[71]19  std::string std_logic (uint32_t size)
[2]20  {
[43]21    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
22
[71]23    std::string type;
[2]24
25    if (size == 1)
26      type = "std_logic";
27    else
28      type = "std_logic_vector(" + toString(size-1) + " downto 0)";
29
[43]30    log_printf(FUNC,Behavioural,FUNCTION,"End");
31
[2]32    return type;
33  };
34
[43]35#undef  FUNCTION
36#define FUNCTION "Vhdl::std_logic_conv"
[71]37  std::string std_logic_conv (uint32_t size, std::string value)
[2]38  {
[43]39    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
40
[71]41    std::string conv;
[2]42
43    if (size == 1)
44      conv = "'"+toString(value)+"'";
45    else
46      conv = "conv_std_logic_vector("+value+","+toString(size)+")";
47
[43]48    log_printf(FUNC,Behavioural,FUNCTION,"End");
49
[2]50    return conv;
51  };
52
[71]53  std::string std_logic_conv (uint32_t size, uint32_t value)
[2]54  {
[43]55    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
[71]56    std::string _return = std_logic_conv(size,toString(value));
[43]57    log_printf(FUNC,Behavioural,FUNCTION,"End");
58
59    return _return;
[2]60  };
61
[43]62#undef  FUNCTION
[95]63#define FUNCTION "Vhdl::std_logic_cst"
64  std::string std_logic_cst (uint32_t size, uint32_t value)
65  {
66    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
67
68    std::string conv;
69
70    if (size == 1)
71      conv = "'"+toString(value&1)+"'";
72    else
73      conv = "\""+toBase2<uint32_t>(value,size)+"\"";
74
75    log_printf(FUNC,Behavioural,FUNCTION,"End");
76
77    return conv;
78  };
79
80#undef  FUNCTION
[43]81#define FUNCTION "Vhdl::std_logic_range"
[97]82  std::string std_logic_range (uint32_t size, uint32_t max, uint32_t min)
[67]83  {
84    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
[71]85    std::string type;
[67]86
[94]87      {
[97]88        if (size < 2)
89          type = "";
[94]90        else
91          {
[97]92            if (max == min)
93              {
94                type = "("+toString(max)+")";
95              }
[94]96            else
[97]97              {
98                type = "("+toString(max)+" downto "+toString(min)+")";
99              }
[94]100          }
101      }
[67]102
103    log_printf(FUNC,Behavioural,FUNCTION,"End");
104
105    return type;
106  };
107
[97]108  std::string std_logic_range (uint32_t max, uint32_t min)
[2]109  {
[43]110    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
[71]111    std::string type;
[2]112
[94]113      {
114        if (max == min)
115          {
116            type = "("+toString(max)+")";
117          }
118        else
119          {
120            if (max == 0)
121              type = "";
122            else
123              type = "("+toString(max)+" downto "+toString(min)+")";
124          }
125      }
[2]126
[43]127    log_printf(FUNC,Behavioural,FUNCTION,"End");
128
[2]129    return type;
130  };
131
[97]132  std::string std_logic_range (uint32_t size)
[2]133  {
[43]134    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
[97]135    std::string _return = std_logic_range(size,size-1,0);
[43]136    log_printf(FUNC,Behavioural,FUNCTION,"End");
137
138    return _return;
[2]139  }
140
[43]141#undef  FUNCTION
[97]142#define FUNCTION "Vhdl::_std_logic_range"
143  std::string _std_logic_range (uint32_t size, uint32_t max, uint32_t min)
144  {
145    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
146    std::string type=_std_logic_range(max,min);
147    log_printf(FUNC,Behavioural,FUNCTION,"End");
148
149    return type;
150  };
151
152  std::string _std_logic_range (uint32_t max, uint32_t min)
153  {
154    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
155    std::string type = "("+toString(max)+" downto "+toString(min)+")";
156    log_printf(FUNC,Behavioural,FUNCTION,"End");
157
158    return type;
159  };
160
161  std::string _std_logic_range (uint32_t size)
162  {
163    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
164    std::string _return = _std_logic_range(size,size-1,0);
165    log_printf(FUNC,Behavioural,FUNCTION,"End");
166
167    return _return;
168  }
169
170#undef  FUNCTION
[43]171#define FUNCTION "Vhdl::std_logic_others"
[94]172  std::string std_logic_others (uint32_t size, bool cst  )
[2]173  {
[43]174    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
175
[71]176    std::string _return;
[43]177
[2]178    if (size < 2)
[43]179      _return = "'"+toString(cst)+"'";
[2]180    else
[43]181      _return = "(others => '"+toString(cst)+"')";
182
183    log_printf(FUNC,Behavioural,FUNCTION,"End");
184
185    return _return;
[2]186  }
[67]187
[2]188}; // end namespace behavioural         
189}; // end namespace morpheo             
190
191#endif
Note: See TracBrowser for help on using the repository browser.