ist es eine extension?

Gast #1100994
Lesenswert?

mir ist beim Probieren aufgefallen, dass unter den VHDL Codeschnipsel
angegebener Code für Veroderung nicht in ghdl funktioniert.

http://www.mikrocontroller.net/articles/VHDL_Schnipsel#OR_.C3.BCber_alle_Bits_eines_Vectors
1
architecture test of test is
2
    signal ored, anded: bit;
3
    signal vec: bit_vector(3 downto 0);
4
begin
5
    anded <= '1' when vec = (others => '1') else '0';
6
    ored <= '0' when vec = (others => '0') else '1';
7
end;

$ ghdl -a --std=02 main.vhd
'others' choice not allowed for an aggregate in this context
'others' choice not allowed for an aggregate in this context

$ ghdl -a --std=93 main.vhd
'others' choice not allowed for an aggregate in this context
'others' choice not allowed for an aggregate in this context

$ ghdl -a --std=87 main.vhd
'others' choice not allowed for an aggregate in this context
'others' choice not allowed for an aggregate in this context

im Moment kann ich nicht mit XST und Quartus testen
aber wenn es auf der Seite steht, denke ich dass es sich um
eine Extension handelt.

Im Grunde möchte ghdl sagen, dass ein Konstrukt (others => '0')
die Bitbreite nicht ermitteln kann/darf. Eigentlich kommt ja
nur die Bitbreite vom anderen Parameter der "=" Funktion.
Weiss jemand wie es im Standard steht?
Gast #1101347
Lesenswert?

XST beschwert sich auch:
1
40:    anded <= '1' when vec = (others => '1') else '0';
2
41:    ored <= '0' when vec = (others => '0') else '1';
1
=========================================================================
2
*                          HDL Compilation                              *
3
=========================================================================
4
Compiling vhdl file "test.vhd" in Library work.
5
Entity <test> compiled.
6
ERROR:HDLParsers:3236 - "test.vhd" Line 40. Can not determine the "others" values in aggregate. (LRM 7.3.2.2)
7
ERROR:HDLParsers:3304 - "test.vhd" Line 40. Can not determine the "others" values in aggregate. (LRM 7.3.2)
8
ERROR:HDLParsers:3236 - "test.vhd" Line 41. Can not determine the "others" values in aggregate. (LRM 7.3.2.2)
9
ERROR:HDLParsers:3304 - "test.vhd" Line 41. Can not determine the "others" values in aggregate. (LRM 7.3.2)
10
-->

Duke
Gast #1101359
Lesenswert?

XST liefert ja sogar direkt das Kapitel im LRM (Language Reference 
Manual). Wenn Du da in Kapitel 7.3.2.2 schaust, wirst Du unter h) finden 
others nur in qualified expressions erlaubt ist. In 7.3.4 steht dann was 
eine qualified expression ist. Nämlich eine Angabe mit Typ. Ich kann es 
gerade nicht testen, aber
1
 anded <= '1' when vec = std_logic_vector'(others => '1') else '0';
2
 ored <= '0' when vec = std_logic_vector'(others => '0') else '1';

sollte demnach funktionieren. Lass mal wissen ob das so funktioniert 
hat!

Ach ja: das LRM findest Du online unter 
http://rti.etf.bg.ac.yu/rti/ri5rvl/tutorial/TUTORIAL/IEEE/HTML/1076_INA.HTM
Gast #1101377
Lesenswert?

@Mathi:
Deine Variante ändert leider nichts an der Fehlermeldung.
Aber Danke füe den Link zum LRM.

@all:
Diese Variante geht:
1
entity test is
2
    Port ( vec : in  bit_vector (3 downto 0);
3
           anded : out bit;
4
           ored : out bit);
5
end test;
6

7

8
architecture test of test is
9
  constant zero_vec : bit_vector( vec'range) := (others => '0');
10
  constant ones_vec : bit_vector( vec'range) := (others => '1');
11
begin
12

13
    anded <= '1' when vec = ones_vec else '0';
14
   ored <= '0' when vec = zero_vec else '1';
15
end;

Duke
Persönliche Seite #1101640
Lesenswert?

Duke Scarring wrote:
> architecture test of test is
>   constant zero_vec : bit_vector( vec'range) := (others => '0');
>   constant ones_vec : bit_vector( vec'range) := (others => '1');
> begin

Nicht der Typ ist das Problem, sondern der Bereich, der sich nicht aus 
dem Kontext ergibt. Es geht daher auch einfacher:
1
architecture test of test is
2
    signal ored, anded: bit;
3
    signal vec: bit_vector(3 downto 0);
4
begin
5
    anded <= '1' when vec = (vec'range => '1') else '0';
6
    ored  <= '0' when vec = (vec'range => '0') else '1';
7
end;

Gruß
Marcus
http://www.doulos.com/

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