Docsity

Generics and Constants - Sequential Logic Design - Lecture Slides, Slides of Digital Logic Design and Programming

Partial preview of the text

Download Generics and Constants - Sequential Logic Design - Lecture Slides and more Slides Digital Logic Design and Programming in PDF only on Docsity!

Lecture

  • Agenda
    1. Decoders using Structural VHDL
    2. VHDL : Generics and Constants
  • Announcements
    1. n/a

Sequential Logic Design

Decoders using Structural VHDL

  • Decoder Example
    • Let's design a 2-to-4 Decoder using Structural VHDL
    • We know we need to describe the following structure:
    • We know what we'll need:

2 n^ AND gates = 4 AND gates n Inverters = 2 Inverters (^) Showing more inverters than necessary to illustrate concept

Decoders using Structural VHDL

  • Decoder Example
    • Let's design the AND gate using concurrent signal assignments….

entity and2 is port (In1,In2 : in STD_LOGIC; Out1 : out STD_LOGIC); end entity and2;

architecture and2_arch of and2 is begin Out1 <= In1 and In2; end architecture and2_arch;

Decoders using Structural VHDL

  • Decoder Example
    • Now let's work on the top level design entity called "decoder_2to4"

entity decoder_2to4 is port (A,B : in STD_LOGIC; Y0,Y1,Y2,Y3 : out STD_LOGIC); end entity decoder_2to4;

Decoders using Structural VHDL

  • Decoder Example
    • cont….

begin U1 : inv port map (A, A_n); U2 : inv port map (B, B_n);

U3 : and2 port map (A_n, B_n, Y0); U4 : and2 port map (A, B_n, Y1); U5 : and2 port map (A_n, B, Y2); U6 : and2 port map (A, B, Y3);

end architecture decoder_2to4 _arch;

Generics vs. Constants

  • Generics vs. Constants
    • it is very useful to be able to design using variables/parameters instead of hard coded values

ex) width of bus, delay, loop counters,

  • VHDL Provides two methods for this functionality
  1. Generics
  2. Constants
  • These are similar but have subtle differences

Generics vs. Constants

  • Constants
    • declared in Architecture
    • needs to be initialized
    • only visible to the architecture it is defined in

syntax: constant (const-name : const-type := init-val) ;

NOTE: init-val is NOT optional

ex) architecture inv_n_arch of inv_n is

constant (t_dly : time := 1ns);

begin Out1 <= not In1 after t_dly;

end architecture inv_n_arch;