3.4 STEP 4: A Three Digit 7-Segment Display Driver

3.4.1 Synopsis

In the final version, DISP_DRV has to drive a 7-segment display with three digits. Other than that, the design needs not to be modified. The most convenient way to handle the data within the design is to define a new type, i.e. an array of three integer respective bit vector values. As user-defined types are already used it is only necessary to change the definition of T_DIGITS respective T_DISPLAY.

It is one of the main advantages of using project-specific packages in bigger projects that the interface of the different modules is easily changed by modifying the type definition. Of course, it is also necessary to change the VHDL code accordingly. The multiplex process is already almost finished as the control signals have not changed. It is just the assignment of 10 in case of an error that must be augmented to be an array of '10's that is assigned.

The mapping functionality itself is also correct. The decoder process, however, needs to be modified as all three integer values have to be mapped to their corresponding vector representation. The easiest solution is to place the case-statement which performs the actual decoding within a loop that processes one digit per iteration.

3.4.2 Implementation

The modified display driver code

...
DISP_MUX:process (SHOW_TIME, ERROR,
                  EXP_TIME, NO_PICS)
begin
  if ERR = '1' then
    DISP_PHOTO <= (10, 10, 10);
  elsif SHOW_TIME = '0' then
    DISP_PHOTO <= NO_PICS;
  else
    DISP_PHOTO <= EXP_TIME;
  end if;
end process DISP_MUX;

DECODE: process (DISP_PHOTO)
begin
  for I in T_DISPLAY'range loop
    case DISP_PHOTO(I) is
      when 0     => DISPLAY(I) <= SEG_0;
      when 1     => DISPLAY(I) <= SEG_1;
      when 2     => DISPLAY(I) <= SEG_2;
      when 3     => DISPLAY(I) <= SEG_3;
      when 4     => DISPLAY(I) <= SEG_4;
      when 5     => DISPLAY(I) <= SEG_5;
      when 6     => DISPLAY(I) <= SEG_6;
      when 7     => DISPLAY(I) <= SEG_7;
      when 8     => DISPLAY(I) <= SEG_8;
      when 9     => DISPLAY(I) <= SEG_9;
      when others => DISPLAY(I) <= SEG_E;
    end case;
  end loop;
end process DECODE;
  • Entity and the declarative part of
    the architecture remain unchanged.
  • As data types have to match an
    array of 3 integer values is needed
    for the assignment to DISP_-
    PHOTO, i.e. the single integer
    value has been replaced by an
    aggregate construct.

 
  • The loop variable I is implicitly
    declared by the for-statement.
  • The 'range signal attribute is used
    for the loop range for better reusability.