Lothar Millers VectorToBCD Koverter mit großen Zahlen

Gast #4204538
Lesenswert?

Hallo,

ich benötige einen VectorToBCD Konverter, der einen langen Vector (44bit 
breit) einen BCD-Code umwandelt.

Nun habe ich mir als Vorlage den VectorToBCD-Wandler von Lothar Miller 
hergenommen. Jedoch ist hier das Problem, dass das alles mit dem 
Datentype Integer realisiert ist und dadurch maximal 32 bit moeglich 
sind.

"Kein Problem! Verwende ich einfach unsigned!" - dachte ich mir. Jedoch 
Pustekuchen.

Nun bekomme ich immernoch die Fehler:
1
** Error:.../VectorToBCD.vhd(30): Integer literal 8 is not of type ieee.NUMERIC_STD.UNSIGNED.
2
** Error:.../VectorToBCD.vhd(37): near "90000000000000": (vcom-119) Integer value exceeds INTEGER'high.
3
** Error:.../VectorToBCD.vhd(37): near "90000000000000": (vcom-119) Integer value exceeds INTEGER'high.
4
** Error:.../VectorToBCD.vhd(37): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
5
** Error:.../VectorToBCD.vhd(37): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
6
** Error:.../VectorToBCD.vhd(38): near "80000000000000": (vcom-119) Integer value exceeds INTEGER'high.
7
** Error:.../VectorToBCD.vhd(38): near "80000000000000": (vcom-119) Integer value exceeds INTEGER'high.
8
** Error:.../VectorToBCD.vhd(38): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
9
** Error:.../VectorToBCD.vhd(38): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
10
** Error:.../VectorToBCD.vhd(39): near "70000000000000": (vcom-119) Integer value exceeds INTEGER'high.
11
** Error:.../VectorToBCD.vhd(39): near "70000000000000": (vcom-119) Integer value exceeds INTEGER'high.
12
** Error:.../VectorToBCD.vhd(39): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
13
** Error:.../VectorToBCD.vhd(39): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
14
** Error:.../VectorToBCD.vhd(40): near "60000000000000": (vcom-119) Integer value exceeds INTEGER'high.
15
** Error:.../VectorToBCD.vhd(40): near "60000000000000": (vcom-119) Integer value exceeds INTEGER'high.
16
** Error:.../VectorToBCD.vhd(40): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
17
** Error:.../VectorToBCD.vhd(40): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
18
** Error:.../VectorToBCD.vhd(41): near "50000000000000": (vcom-119) Integer value exceeds INTEGER'high.
19
** Error:.../VectorToBCD.vhd(41): near "50000000000000": (vcom-119) Integer value exceeds INTEGER'high.
20
** Error:.../VectorToBCD.vhd(41): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
21
** Error:.../VectorToBCD.vhd(41): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
22
** Error:.../VectorToBCD.vhd(42): near "40000000000000": (vcom-119) Integer value exceeds INTEGER'high.
23
** Error:.../VectorToBCD.vhd(42): near "40000000000000": (vcom-119) Integer value exceeds INTEGER'high.
24
** Error:.../VectorToBCD.vhd(42): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
25
** Error:.../VectorToBCD.vhd(42): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
26
** Error:.../VectorToBCD.vhd(43): near "30000000000000": (vcom-119) Integer value exceeds INTEGER'high.
27
** Error:.../VectorToBCD.vhd(43): near "30000000000000": (vcom-119) Integer value exceeds INTEGER'high.
28
** Error:.../VectorToBCD.vhd(43): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
29
** Error:.../VectorToBCD.vhd(43): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
30
** Error:.../VectorToBCD.vhd(44): near "20000000000000": (vcom-119) Integer value exceeds INTEGER'high.
31
** Error:.../VectorToBCD.vhd(44): near "20000000000000": (vcom-119) Integer value exceeds INTEGER'high.
32
** Error:.../VectorToBCD.vhd(44): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
33
** Error:.../VectorToBCD.vhd(44): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
34
** Error:.../VectorToBCD.vhd(45): near "10000000000000": (vcom-119) Integer value exceeds INTEGER'high.
35
** Error:.../VectorToBCD.vhd(45): near "10000000000000": (vcom-119) Integer value exceeds INTEGER'high.
36
** Error:.../VectorToBCD.vhd(45): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
37
** Error:.../VectorToBCD.vhd(45): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
38
** Error:.../VectorToBCD.vhd(46): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
39
** Error:.../VectorToBCD.vhd(46): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
40
** Warning: [14].../VectorToBCD.vhd(28): (vcom-1272) Length of expected is 48; length of actual is 44.
41

42
** Warning: [14].../VectorToBCD.vhd(38): (vcom-1144) Value -589934592 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
43

44
** Warning: [14].../VectorToBCD.vhd(38): (vcom-1144) Value -589934592 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
45

46
** Warning: [14].../VectorToBCD.vhd(39): (vcom-1144) Value -1589934592 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
47

48
** Warning: [14].../VectorToBCD.vhd(39): (vcom-1144) Value -1589934592 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
49

50
** Warning: [14].../VectorToBCD.vhd(42): (vcom-1144) Value -294967296 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
51

52
** Warning: [14].../VectorToBCD.vhd(42): (vcom-1144) Value -294967296 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
53

54
** Warning: [14].../VectorToBCD.vhd(43): (vcom-1144) Value -1294967296 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
55

56
** Warning: [14].../VectorToBCD.vhd(43): (vcom-1144) Value -1294967296 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
57

58
** Warning: [14].../VectorToBCD.vhd(44): (vcom-1144) Value -1474836480 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
59

60
** Warning: [14].../VectorToBCD.vhd(44): (vcom-1144) Value -1474836480 (of type std.STANDARD.NATURAL) is out of range 0 to 2147483647.
61

62
** Warning: [14].../VectorToBCD.vhd(48): (vcom-1272) Length of expected is 48; length of actual is 96.
63

64
** Error:.../VectorToBCD.vhd(60): VHDL Compiler exiting

Könntet ihr mir bitte helfen? Code ist im Anhang.

Vielen Dank!
Angehängte Dateien:
Gast #4204618
Lesenswert?

Guest schrieb:
> Naja die 90000000000000 ist halt ein integer. Musst halt die hex zahl
> als Vektor hinschreiben...

Okay, stimmt! - Danke!!!

Habe das nun geändert in:
1
type states is (idle,calc);                          
2
signal state : states := idle;                       
3
signal stelle : unsigned(3 downto 0) := "1101";
4
signal wert : unsigned(47 downto 0) := (others => '0');
5

6
begin              
7
   process
8
   variable x : unsigned(47 downto 0):= (others => '0');
9
   begin
10
      wait until rising_edge(clk);
11
      busy <= '0';
12
      case state is
13
         when idle => 
14
           -- wert <= to_integer(unsigned(vector));
15
      wert <= unsigned(vector);            --Zeile28
16
            if (start='1') then 
17
               stelle <= "1101";
18
               busy <= '1';
19
               state<=calc;
20
            end if;
21
                      
22
when calc => 
23
            x := wert;
24
            if    (x>=x"51DAC207A000") then x:=x-x"51DAC207A000"; bcd(stelle*4+3 downto stelle*4) <= x"9";
25
            elsif (x>=x"48C273950000") then x:=x-x"48C273950000"; bcd(stelle*4+3 downto stelle*4) <= x"8";
26
            elsif (x>=x"3FAA25226000") then x:=x-x"3FAA25226000"; bcd(stelle*4+3 downto stelle*4) <= x"7";
27
            elsif (x>=x"3691D6AFC000") then x:=x-x"3691D6AFC000"; bcd(stelle*4+3 downto stelle*4) <= x"6";
28
            elsif (x>=x"2D79883D2000") then x:=x-x"2D79883D2000"; bcd(stelle*4+3 downto stelle*4) <= x"5";
29
            elsif (x>=x"246139CA8000") then x:=x-x"246139CA8000"; bcd(stelle*4+3 downto stelle*4) <= x"4";
30
            elsif (x>=x"1B48EB57E000") then x:=x-x"1B48EB57E000"; bcd(stelle*4+3 downto stelle*4) <= x"3";
31
            elsif (x>=x"12309CE54000") then x:=x-x"12309CE54000"; bcd(stelle*4+3 downto stelle*4) <= x"2";
32
            elsif (x>=x"09184E72A000") then x:=x-x"09184E72A000"; bcd(stelle*4+3 downto stelle*4) <= x"1";
33
            else                              bcd(stelle*4+3 downto stelle*4) <= x"0";
34
            end if;
35
            wert <= x*10;  --Zeile48

jedoch noch immer die Fehlermeldung:
1
** Error: ...\Vector2BCD.vhd(37): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
2
** Error: ...\Vector2BCD.vhd(37): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
3
** Error: ...\Vector2BCD.vhd(38): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
4
** Error: ...\Vector2BCD.vhd(38): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
5
** Error: ...\Vector2BCD.vhd(39): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
6
** Error: ...\Vector2BCD.vhd(39): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
7
** Error: ...\Vector2BCD.vhd(40): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
8
** Error: ...\Vector2BCD.vhd(40): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
9
** Error: ...\Vector2BCD.vhd(41): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
10
** Error: ...\Vector2BCD.vhd(41): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
11
** Error: ...\Vector2BCD.vhd(42): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
12
** Error: ...\Vector2BCD.vhd(42): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
13
** Error: ...\Vector2BCD.vhd(43): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
14
** Error: ...\Vector2BCD.vhd(43): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
15
** Error: ...\Vector2BCD.vhd(44): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
16
** Error: ...\Vector2BCD.vhd(44): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
17
** Error: ...\Vector2BCD.vhd(45): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
18
** Error: ...\Vector2BCD.vhd(45): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
19
** Error: ...\Vector2BCD.vhd(46): Range type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED is not a scalar type.
20
** Error: ...\Vector2BCD.vhd(46): Range expression is type ieee.NUMERIC_STD.UNRESOLVED_UNSIGNED; expecting type std.STANDARD.NATURAL.
21
** Warning: [14] ...\Vector2BCD.vhd(28): (vcom-1272) Length of expected is 48; length of actual is 44.
22

23
** Warning: [14] ...\Vector2BCD.vhd(48): (vcom-1272) Length of expected is 48; length of actual is 96.
24

25
** Error: ...\Vector2BCD.vhd(60): VHDL Compiler exiting
Gast #4205319
Lesenswert?

Lothar M. schrieb:
> Valko Z. schrieb:
>> Jetzt noch "stelle" als INTEGER darstellen
> ... denn ein Index darf nur ein Integer sein.
>
> BTW: welches ist die Zeile 37?

Prima, jetzt lässt es sich synthetisieren.. Vielen Dank!

Zeile 37 ist diese Zeile:
1
            if    (x>=x"51DAC207A000") then x:=x-x"51DAC207A000"; bcd(stelle*4+3 downto stelle*4) <= x"9";

Nun habe ich aber ein Problem beim simulieren:
1
force -freeze sim:/VectorToBCD/clk 1 0, 0 {5000 ps} -r {10 ns}
2
force -freeze sim:/VectorToBCD/start 1 0
3
force -freeze sim:/VectorToBCD/vector 11111111111111111111111111111111111111111111 0
4
run
5
# ** Fatal: (vsim-3420) Array lengths do not match. Left is 48 (47 downto 0). Right is 96 (95 downto 0).
6
#    Time: 20 ns  Iteration: 0  Process: /VectorToBCD/line__21 File: .../VectorToBCD.vhd
7
# Fatal error in Process line__21 at .../VectorToBCD.vhd line 48
8
# 
9
# HDL call sequence:
10
# Stopped at .../VectorToBCD.vhd 48 Process line__21
11
# 
12
run
13
# Cannot continue because of fatal error.
14
# HDL call sequence:
15
# Stopped at .../VectorToBCD.vhd 48 Process line__21
16
#

Zeile 48 ist:
1
 wert <= x*10;

Leuchtet mir aber nicht ganz ein... Als Beispiel:

Wenn ich dem Eingang "Vector" die größtmöglichste Zahl übergebe (44x 
'1'),
dann ist...

 Vector(Binär) = 17 592 186 044 415

Da dieser kleiner als x"12309CE54000" aber größer als x"09184E72A000" 
ist, passiert folgendes:

  17 592 186 044 415 (b"11111111111111111111111111111111111111111111")
- 10 000 000 000 000 (x"09184E72A000")
--------------------
=  7 592 186 044 415 (x"6E7B18D5FFF" / 43-bit Zahl)
 *                10
  ------------------
 =75 921 860 444 150 (x"450CEF85BFF6" / 47-bit Zahl)
  ------------------
  ------------------

Dieses Ergebnis wird in "wert" gespeichert, welches eine maximale Länge 
von 48 bit hat. So müsste das dann ja aussreichen.
--> Wie kommt Modelsim nun auf die Fehlermeldung:
1
 Array lengths do not match. Left is 48 (47 downto 0). Right is 96 (95 downto 0).

Vielen Dank im voraus für eure Hilfe!
Moderator (Firma: Titel) Persönliche Seite #4205404
Lesenswert?

JitterFratz schrieb:
> Wie kommt Modelsim nun auf die Fehlermeldung
Weil Modelsim die ganzen Optimierungen und Analysen nicht macht und 
einfach sagt: x ist 48Bit breit, und es werden nur gleiche Vektorbreiten 
miteinander multipliziert. Damit sind 48Bit mal 48 Bit wie zu erwarten 
96Bit.

Ich würde mal auf den Ergebnisvektor gleich ein resize() ansetzen, und 
ihn danach erst zuweisen...

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren