This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > FPGA Technical Tutorials > Design Recipes for FPGAs Using Verilog and VHDL > Mixed Signal Modeling > Basic VHDL-AMS Comparator Model

TABLE OF CONTENTS

Xilinx FPGA FPGA Forum

Basic VHDL-AMS Comparator Model

FONT SIZE : AAA

Consider a simple comparator that has two electrical inputs (p and m), an electrical ground (gnd) and a digital output (d). The comparator has a digital output of 1 when p is greater than m and 0 otherwise (Figure 18.5).

The entity defines the terminals (p, m, gnd), digital output (d), input hysteresis (hys), and the propagation delay (td).

propagation delay (td).

1 use ieee.electrical_system.all; 2 use ieee.std_logic_1164.all; 3 entity comparator is

4 generic ( 5 td : time := 10 ns;

6 hys : real := 1.0e−6;

7 );

8 port ( 9 d : out std_logic := ’0’;

10 terminal p,m,gnd : electrical

11 );

12 end entity comparator;

The first step in the architecture is to define the input voltage and basic process structure:

1 architecture simple of comparator is

2 quantity vin across p to m;

3 begin

4 p1 : process

5 constant vh : real := abs(hys)/2.0;

6 constant vl : real := −abs(hys)/2.0;

7 begin

8 −− The comparator digital handler goes here

9 wait on vin’above(vh), vin’above(vl);

10 end process;

11 end architecture simple;

Figure 18.5.png


The quantity vin is defined as the voltage across the input pins p and m.

1 quantity vin across p to m;

Notice that no current is defined (i.e., assumed to be zero) so there is no input current to the comparator. Also notice that there is no input voltage offset defined; this could be added as a refinement to the model later. The process defines the upper and lower thresholds (vh and vl) based on the hysteresis:

1 constant vh : real := abs(hys)/2.0;

2 constant vl : real := −abs(hys)/2.0;

The process then defines a wait statement, checking vin for crossing either of those threshold values:

wait on vin’above(vh), vin’above(vl);

The final part of the process is to add the digital output logic state dependent on the threshold status of vin:

1 if vin’above(vh) then

2 d <= ’1’ after td;

3 elsif not vin’above(vl) then

4 d <= ’0’ after td;

5 end if;

The output state (d) is then scheduled after the delay time defined by td.

The completed architecture is shown as follows:

he completed architecture is shown as follows:

1 architecture simple of comparator is

2 quantity vin across p to m;

3 begin

4 p1 : process

5 constant vh : real := ABS(hys)/2.0;

6 constant vl : real := −ABS(hys)/2.0;

7 begin

8 if vinabove(vh) then

9 d <= ’1’ after td;

10 elsif not vinabove(vl) then

11 d <= ’0’ after td;

12 end if;

13 wait on vin’above(vh), vin’above(vl);

14 end process;

15 end architecture simple;




  • XC4028XLA-09HQ160C

    Manufacturer:Xilinx

  • FPGA XC4000XLA Family 28K Gates 2432 Cells 227MHz 0.35um Technology 3.3V 160-Pin HSPQFP EP
  • Product Categories: FPGAs

    Lifecycle:Obsolete -

    RoHS: No RoHS

  • XC5VLX155-2FF1760C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LX Family 65nm Technology 1V 1760-Pin FCBGA
  • Product Categories: Rangée de condensateur

    Lifecycle:Active Active

    RoHS: No RoHS

  • XC5VLX155-2FFG1760C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LX Family 65nm Technology 1V 1760-Pin FCBGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Active Active

    RoHS:

  • XC5VLX155-3FFG1760C

    Manufacturer:Xilinx

  • FPGA Virtex-5 LX Family 65nm Technology 1V 1760-Pin FCBGA
  • Product Categories: FPGAs

    Lifecycle:Active Active

    RoHS:

  • XCS30XL-5PQ240C

    Manufacturer:Xilinx

  • Spartan and Spartan-XL Families Field Programmable Gate Arrays FPGA
  • Product Categories: FPGAs (Field Programmable Gate Array)

    Lifecycle:Obsolete -

    RoHS: -

Need Help?

Support

If you have any questions about the product and related issues, Please contact us.