Mehrbit A2D Wandler in VHDL-AMS

Gast #3310910
Hello World =)
Vielleicht kennt sich jemand besser aus mit AMS, als ich! Aufgabe ist, 
einen AD-Wandler zu schreiben, der für eine Eingangsspannung zwischen 0 
und 5 V 8 digitale Werte ausgibt. Hier mein Code:
--library ieee;
--use ieee.electrical_systems.all;
LIBRARY DISCIPLINES;      -- Ich benutze hAMSter
USE DISCIPLINES.ELECTROMAGNETIC_SYSTEM.ALL;

entity a2d is
generic (vthreshold : real := 0.625);
        port (D_output : out bit_vector (2 downto 0);
        terminal a_input, electrical_ref : electrical);
end entity a2d;

architecture behavioral of a2d is
quantity vin ACROSS a_input to electrical_ref;
begin
process (vin) is

begin
IF (vin'above(vthreshold)) then   -- 0 - 0,625 V
d_output <= '000';
ELSE IF  (vin'above(vthreshold*2)) then   -- 0,626 - 1,25 V
d_output <=           '001';
ELSE IF  (vin'above(vthreshold*3)) then   -- ... - 1,875 V
d_output <=            '010';
ELSE IF  (vin'above(vthreshold*4)) then   -- ... - 2,5 V
d_output <=            '011';
ELSE IF  (vin'above(vthreshold*5)) then   -- ... - 3,125 V
d_output <=            '100';
ELSE IF    (vin'above(vthreshold*6)) then   -- ... - 3,75 V
d_output <=            '101';
ELSE IF    (vin'above(vthreshold*7)) then   -- ... - 4,375 V
d_output <=            '110';
ELSE    -- (vin'above(vthreshold*8)) then   -- ... - 5 V
d_output <=            '111';
end process;
end architecture behavioral;

begin
vin == sin(2.0  math_pi  f * NOW);
end;

Ich müsste unbedingt noch abgrenzen, also z.B. '001' bei (not 
(vin'above(vthreshold)) && vin'above(vthreshold*2)) oder so...
Hat jemand eine Idee?
Gast #3310917
Hi,

wie wäre es einfach die Reihenfolge der Abfragen zu vertauschen. Also 
erst auf die höchste Spannung abzufragen, dann auf die zweithöchste, ...

Gruß
Gast #3311000
Mein Simulator hAMSter scheint diese Ausdrücke nicht zu mögen: 
vthreshold*7
Ist es micht so, dass man auch den Rest ausschließen muss??


LIBRARY DISCIPLINES;
USE DISCIPLINES.ELECTROMAGNETIC_SYSTEM.ALL;

entity a2d is
generic (vthreshold : real := 0.625);
        port (D_output : out bit_vector (2 downto 0);
        terminal a_input, electrical_ref : electrical);
end entity a2d;

architecture behavioral of a2d is
quantity vin ACROSS a_input to electrical_ref;
begin
process (vin) is

begin
IF (vin'above(vthreshold*7)) then   -- ... - 5 V  7*vthreshold
d_output <= "111";
ELSE IF  (vin'above(vthreshold*6)) then   --  ... - 4,375 V
d_output <=           "110";
ELSE IF  (vin'above(vthreshold*5)) then   --   ... - 3,75 V
d_output <=            "101";
ELSE IF  (vin'above(vthreshold*4)) then   --   ... - 3,125 V
d_output <=            "100";
ELSE IF  (vin'above(vthreshold*3)) then   --   ... - 2,5 V
d_output <=            "011";
ELSE IF    (vin'above(vthreshold*2)) then   --   ... - 1,875 V
d_output <=            "010";
ELSE IF    (vin'above(vthreshold)) then   --   0,626 - 1,25 V
d_output <=            "001";
ELSE    --                                --   0 - 0,625 V
d_output <=            "000";
end process;
end architecture behavioral;

begin
vin == sin(2.0  math_pi  f * NOW);
end;
Persönliche Seite #3311157
Ich würde den Term mit dem Threshhold getrennt ausrechnen und damit den 
Multiplexer statisch machen. Im Grunde kannst Du diesen einfache ADC 
aber auch voll analytisch schreiben, da er ja offenbar global linear 
ist.

AMS braucht man ja im Grunde nur bei partiell nichtlinearem Verhalten 
wie bei gesättigtem und invertiertem Kurvenverhalten sowie bei 
nichtlinearen Energiespeichern wie diesen hier:

Beitrag "Re: Simulation von Spulen und Übertragern in VHDL"
Gast #3311239
Das hier funktioniert nicht: Unerwartete Eingabe: PROCESS

LIBRARY DISCIPLINES;
USE DISCIPLINES.ELECTROMAGNETIC_SYSTEM.ALL;

entity a2d is
        port (D_output : out bit_vector (2 downto 0);
        terminal a_input, electrical_ref : electrical);
end entity a2d;

architecture behavioral of a2d is
quantity vin ACROSS a_input to electrical_ref;
begin
process (vin) is

begin
IF vin'above(4.375) then   -- ... - 5 V  7*vthreshold
d_output <= "111";
ELSIF  vin'above(3.75) then   --  ... - 4,375 V
d_output <=           "110";
ELSIF  vin'above(3.125) then   --   ... - 3,75 V
d_output <=            "101";
ELSIF  vin'above(2.5) then   --   ... - 3,125 V
d_output <=            "100";
ELSIF  vin'above(1.875) then   --   ... - 2,5 V
d_output <=            "011";
ELSIF    vin'above(1.25) then   --   ... - 1,875 V
d_output <=            "010";
ELSIF    vin'above(0.625) then   --   0,626 - 1,25 V
d_output <=            "001";
ELSE    --                                --   0 - 0,625 V
d_output <=            "000";

end process;  -- Fehler: unerwartete Eingabe: Process
end architecture behavioral;

begin
vin == sin(2.0  math_pi  f * NOW);
end;
Gast #3311296
port (D_output : out bit_vector (2 downto 0);
 terminal (a_input, electrical_ref : electrical);

Wenn Du die meinst, dann heißt es "unerwartete Eingabe"!

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 13 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.