Forum: FPGA, VHDL & Co. IEEE.fixed_pkg


von Jean F. (maturain)


Lesenswert?

Hallo alles zusammen,
ich bin Student und möchte mit festkommazahlen in VHDL arbeiten, hatte 
in Forum ein paar Beispiel gesehen aber in Xilinx fehlt mir die 
Bibiothek IEEE.Fixed_Pkg. Ich benutze Xilinx ISE 10.1. Wie kann ich 
diese bibiothek in xilinx hinzufügen? bei Syntax check kriege ich 
folgende Fehlermeldung: Library unit Fixed_Pkg is not available.

Danke Im Voraus für Ihre Hilfe
MFG
Maturain

von Rudolph (Gast)


Lesenswert?

Xilinx unterstützt das Package noch nicht richtig. In einem aktuellen 
ISE muss man das Package so einbinden:
1
library ieee_proposed;
2
use ieee_proposed.fixed_pkg.all;

Jean Fankam schrieb:
> Ich benutze Xilinx ISE 10.1.

Es gibt da angepasste Packageversionen für alte Tools, siehe hier: 
http://www.eda-stds.org/fphdl/

von maturain (Gast)


Lesenswert?

danke Rudolph,
das hat fast geklapt. Das ist di multiplication von 2 fixed point 
Zahlen: ich bekomme diese fehler meldung:" ERROR:HDLParsers:800 - 
"C:/Dropbox/Lyrtech_Fankam/FIR_VHDLnew/MAC.vhd" Line 75. Type of product 
is incompatible with type of *".


das ist der code. Dank in voraus für die Rückmeldung.
beste Grüsse.
Maturain
1
library IEEE;
2
use IEEE.NUMERIC_STD.all;
3
use IEEE.STD_LOGIC_1164.ALL;
4
use IEEE.STD_LOGIC_ARITH.ALL;
5
use IEEE.STD_LOGIC_SIGNED.ALL;
6
library ieee_proposed;
7
use ieee_proposed.fixed_pkg.all;
8
use ieee.fixed_float_types.all;
9
10
 
11
entity transpose_fir is
12
    Port ( din : in ufixed (13 downto 0);
13
           clk : in std_logic;
14
           ce : in std_logic;
15
        rst : in std_logic;
16
            dout : out sfixed (12 downto -15));
17
end transpose_fir;
18
19
architecture Behavioral of transpose_fir is
20
21
component mac
22
  generic (
23
       coef_value : ufixed (0 downto -15) := 0000000000000000;
24
  );
25
  
26
  port(
27
       din : in ufixed (13 downto 0);
28
       cin : in sfixed (14 downto -15);
29
       clk : in std_logic;
30
       ce : in std_logic;
31
      rst : in std_logic;
32
       dout : out sfixed (14 downto -15));
33
end component;
34
35
constant N : integer := 9;                      -- Number of Coefficients
36
type coef_array is array (0 to N-1) of integer;    -- Coefficient Values
37
38
constant coefficient : coef_array := (0001110101010101,0000001101101100,0000001111010011,0000001111100111,0000001111100111,0000001111100111,0000001111010011,0000001101101100,0001110101010101);
39
40
41
42
signal cin_temp : sfixed(30*N downto 0) := CONV_STD_LOGIC_VECTOR (0, 30*N+1);  
43
44
  
45
46
begin
47
48
   G0: for I in 0 to N-1 generate
49
        
50
        G_first: if I = 0 generate
51
    
52
    M0: MAC 
53
      generic map (
54
            coef_value => coefficient(I)
55
      )
56
      port map (
57
              din => din, 
58
           cin => "00000000000000000000000000",
59
              clk => clk,
60
            ce => ce,
61
          rst => rst,
62
           dout => cin_temp(14 downto -15));
63
      end generate;
64
  
65
  GX: if (I >= 1 and I < N-1) generate
66
    M1: MAC 
67
      generic map (
68
           coef_value => coefficient(I)
69
      )
70
      port map (
71
             din => din, 
72
           cin => cin_temp(I*30+(I-1) downto ((I-1)*31)),
73
             clk => clk,
74
           ce => ce,
75
          rst => rst,
76
           dout => cin_temp((I+1)*30+I downto I*31));
77
      end generate;
78
  
79
  
80
  G_last: if I = N-1 generate
81
    M2: MAC 
82
      generic map(
83
           coef_value => coefficient(I)
84
      )      
85
      port map (
86
              din => din, 
87
           cin => cin_temp(I*30+(I-1) downto ((I-1)*31)),
88
              clk => clk,
89
            ce => ce,
90
          rst => rst,
91
            dout => dout);
92
      end generate;
93
   end generate;
94
95
end Behavioral;
96
97
98
---------------------------------------------------------------------------------
99
library IEEE;
100
use IEEE.STD_LOGIC_1164.ALL;
101
use IEEE.STD_LOGIC_ARITH.ALL;
102
use IEEE.STD_LOGIC_UNSIGNED.ALL;
103
104
library ieee_proposed;
105
use ieee_proposed.fixed_pkg.all;
106
107
108
entity mac is
109
   generic( 
110
     coef_value : ufixed (0 downto -15) := "0000000000000000"
111
        
112
    
113
  );
114
  
115
  port(
116
       din : in ufixed(13 downto 0);
117
       cin : in sfixed (14 downto -15);
118
       clk : in std_logic;
119
       ce : in std_logic;
120
      rst : in std_logic;
121
        dout : out sfixed (14 downto -15));
122
end mac;
123
124
125
architecture Behavioral of mac is
126
127
signal coef : ufixed(0 downto -15);
128
129
signal product : sfixed (14 downto -15); --??
130
signal addition : sfixed (14 downto -15); 
131
132
begin
133
134
  --coef <= CONV_STD_LOGIC_VECTOR (coef_value, 12);
135
136
  --sign extend the coefficients
137
138
139
140
  -- Multiplication
141
  process(clk, ce, din, coef)
142
  begin
143
144
    if clk'event and clk='1' then
145
      if (ce='1') then
146
147
148
149
        product <= din * coef;
150
151
      end if;
152
    end if;
153
154
  end process;
155
156
  -- Addition  chain
157
  addition <= product + cin;
158
159
160
  -- Register result
161
  process(clk, ce, addition, rst)
162
  begin
163
164
    if (rst = '0') then
165
166
      dout <= "000000000000000000000000000000";
167
168
    elsif (clk'event and clk='1') then
169
      if (ce='1') then
170
171
        dout <= addition;   
172
173
      end if;
174
    end if;
175
176
  end process;
177
178
end Behavioral;

von berndl (Gast)


Lesenswert?

maturain schrieb:
> library IEEE;
> use IEEE.NUMERIC_STD.all;
> use IEEE.STD_LOGIC_1164.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
> use IEEE.STD_LOGIC_SIGNED.ALL;
> library ieee_proposed;
> use ieee_proposed.fixed_pkg.all;
> use ieee.fixed_float_types.all;

Viel hilft viel?

von Rudolph (Gast)


Lesenswert?

maturain schrieb:
> use IEEE.NUMERIC_STD.all;
> use IEEE.STD_LOGIC_ARITH.ALL;

Du solltest Dich für eine der Librarys entscheiden. Hier im Forum wird 
NUMERIC_STD empfohlen.

maturain schrieb:
> " ERROR:HDLParsers:800 -
> "C:/Dropbox/Lyrtech_Fankam/FIR_VHDLnew/MAC.vhd" Line 75. Type of product
> is incompatible with type of *".

Ohne genau hinzuschauen: Da passen Typen nicht zusammen und es wird 
irgendein Cast benötigt. Rechnen in VHDL bietet da ein paar 
Hinweise.

von Lothar M. (Firma: Titel) (lkmiller) (Moderator) Benutzerseite


Lesenswert?

maturain schrieb:
> ich bekomme diese fehler meldung:" ERROR:HDLParsers:800 -
> "C:/Dropbox/Lyrtech_Fankam/FIR_VHDLnew/MAC.vhd" Line 75.
Wo ist sie denn, diese Zeile 75?
Aha, wer sucht, der findet...
> Type of product is incompatible with type of *".
Und: wie ist der Operator * im fixed_pck überladen?
Passen die Faktoren und das Ergebnis zusammen?

berndl schrieb:
> Viel hilft viel?
Siehe dazu den Beitrag "IEEE.STD_LOGIC_ARITH.ALL obsolete"

> Viel hilft viel?
Sicher!
Nehmen wir mal die Sensitivliste dieses Prozesses:
1
process(clk, ce, din, coef)
2
  begin
3
    if clk'event and clk='1' then
4
       :
5
    end if;
6
  end process;
Was ist da zuviel drin?

Zwei Sachen noch:
VHDL-Code bitte in die Token [ vhdl ] und [ /vhdl ]  (ohne Leerzeichen) 
einschliessen.
Und:
1
Wichtige Regeln - erst lesen, dann posten!
2
    Längeren Sourcecode nicht im Text einfügen, sondern als Dateianhang
Und zwar mit der Dateiendung *.vhd

von maturain (Gast)


Lesenswert?

dank für prompt Rückmeldung.
das Problem kommt from packages   IEEE.fixed_pkg.
die Datentypes sfixed*ufixed führt zu einem Fehler.
Entweder  ufixed*ufixed ist ok.
oder  sfixed*sfixed.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.