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

Last change on this file since 67 was 67, checked in by rosiere, 17 years ago

Ajout d'un nouveau composant : fifo generic (un port lecture et un port ecriture).

File size: 2.7 KB
Line 
1#ifdef VHDL
2
3/*
4 * $Id$
5 *
6 * [ Description ]
7 *
8 */
9
10#include <math.h>
11#include "Behavioural/include/Vhdl.h"
12
13namespace morpheo              {
14namespace behavioural          {
15
16#undef  FUNCTION
17#define FUNCTION "Vhdl::std_logic"
18  string std_logic (uint32_t size)
19  {
20    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
21
22    string type;
23
24    if (size == 1)
25      type = "std_logic";
26    else
27      type = "std_logic_vector(" + toString(size-1) + " downto 0)";
28
29    log_printf(FUNC,Behavioural,FUNCTION,"End");
30
31    return type;
32  };
33
34#undef  FUNCTION
35#define FUNCTION "Vhdl::std_logic_conv"
36  string std_logic_conv (uint32_t size, string value)
37  {
38    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
39
40    string conv;
41
42    if (size == 1)
43      conv = "'"+toString(value)+"'";
44    else
45      conv = "conv_std_logic_vector("+value+","+toString(size)+")";
46
47    log_printf(FUNC,Behavioural,FUNCTION,"End");
48
49    return conv;
50  };
51
52  string std_logic_conv (uint32_t size, uint32_t value)
53  {
54    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
55    cout << toString(value) << endl;
56    string _return = std_logic_conv(size,toString(value));
57    log_printf(FUNC,Behavioural,FUNCTION,"End");
58
59    return _return;
60  };
61
62#undef  FUNCTION
63#define FUNCTION "Vhdl::std_logic_range"
64  string std_logic_range (uint32_t size, uint32_t max, uint32_t min)
65  {
66    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
67    string type;
68
69    if (size < 2)
70      type = "";
71    else
72      if (max == min)
73        type = "("+toString(max)+")";
74      else
75        type = "("+toString(max)+" downto "+toString(min)+")";
76
77    log_printf(FUNC,Behavioural,FUNCTION,"End");
78
79    return type;
80  };
81
82  string std_logic_range (uint32_t max, uint32_t min)
83  {
84    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
85    string type;
86
87    if (max == 0)
88      type = "";
89    else
90      if (max == min)
91        type = "("+toString(max)+")";
92      else
93        type = "("+toString(max)+" downto "+toString(min)+")";
94
95    log_printf(FUNC,Behavioural,FUNCTION,"End");
96
97    return type;
98  };
99
100  string std_logic_range (uint32_t size)
101  {
102    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
103    string _return = std_logic_range(size-1,0);
104    log_printf(FUNC,Behavioural,FUNCTION,"End");
105
106    return _return;
107  }
108
109#undef  FUNCTION
110#define FUNCTION "Vhdl::std_logic_others"
111  string std_logic_others (uint32_t size, uint32_t cst  )
112  {
113    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
114
115    string _return;
116
117    if (size < 2)
118      _return = "'"+toString(cst)+"'";
119    else
120      _return = "(others => '"+toString(cst)+"')";
121
122    log_printf(FUNC,Behavioural,FUNCTION,"End");
123
124    return _return;
125  }
126
127
128
129}; // end namespace behavioural         
130}; // end namespace morpheo             
131
132#endif
Note: See TracBrowser for help on using the repository browser.