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 | |
---|
13 | namespace morpheo { |
---|
14 | namespace behavioural { |
---|
15 | |
---|
16 | string std_logic (uint32_t size) |
---|
17 | { |
---|
18 | string type; |
---|
19 | |
---|
20 | if (size == 1) |
---|
21 | type = "std_logic"; |
---|
22 | else |
---|
23 | type = "std_logic_vector(" + toString(size-1) + " downto 0)"; |
---|
24 | |
---|
25 | return type; |
---|
26 | }; |
---|
27 | |
---|
28 | string std_logic_conv (uint32_t size, string value) |
---|
29 | { |
---|
30 | string conv; |
---|
31 | |
---|
32 | if (size == 1) |
---|
33 | conv = "'"+toString(value)+"'"; |
---|
34 | else |
---|
35 | conv = "conv_std_logic_vector("+value+","+toString(size)+")"; |
---|
36 | |
---|
37 | return conv; |
---|
38 | }; |
---|
39 | |
---|
40 | string std_logic_conv (uint32_t size, uint32_t value) |
---|
41 | { |
---|
42 | return std_logic_conv(size,toString(value)); |
---|
43 | }; |
---|
44 | |
---|
45 | string std_logic_range (uint32_t max, uint32_t min) |
---|
46 | { |
---|
47 | string type; |
---|
48 | |
---|
49 | if (max == min) |
---|
50 | type = "("+toString(max)+")"; |
---|
51 | else |
---|
52 | type = "("+toString(max)+" downto "+toString(min)+")"; |
---|
53 | |
---|
54 | return type; |
---|
55 | }; |
---|
56 | |
---|
57 | string std_logic_range (uint32_t size) |
---|
58 | { |
---|
59 | return std_logic_range(size-1,0); |
---|
60 | } |
---|
61 | |
---|
62 | string std_logic_others (uint32_t size, uint32_t cst ) |
---|
63 | { |
---|
64 | if (size < 2) |
---|
65 | return "'"+toString(cst)+"'"; |
---|
66 | else |
---|
67 | return "(others => '"+toString(cst)+"')"; |
---|
68 | } |
---|
69 | }; // end namespace behavioural |
---|
70 | }; // end namespace morpheo |
---|
71 | |
---|
72 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.