====== LAB 4: A Three Digit 7-Segment Display Driver ====== ===== 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. ==== Behaviour ==== The basic behaviour remains unchanged. ==== Data types ==== The names of the data types of the signals remain the same. It is just the definition of the **T_DIGITS** and **T_DISPLAY** types that has to be changed to an array type. ==== To do ==== * Edit the P_DISPLAY package so that T_DIGITS and T_DISPLAY are arrays of type integer and std_ulogic_vector, respectively. The length of the arrays shall be 3. Do not forget to include the range specification for the array elements! * Adjust the two processes of the DISP_DRV architecture so that they cope with the new data types. * Modify the stimuli generation in the testbench to verify the correct behaviour. * Compile all source files and run the simulation. * Synthesize the design. ===== Implementation ===== -- include packages entity DISP_DRV is port(ERROR : in std_ulogic; SHOW_TIME : in std_ulogic; NO_PICS : in T_DIGITS; EXP_TIME : in T_DIGITS; DISPLAY : out T_DISPLAY); end DISP_DRV; architecture RTL of DISP_DRV is signal DISP_PHOTO : T_DIGITS; begin DISP_MUX:process (SHOW_TIME, ERROR, EXP_TIME, NO_PICS) begin if ERROR = '1' then DISP_PHOTO <= (10; 10; 10); elsif SHOW_TIME = '0' then -- output = picture count else -- output = exposure time end if; end process DISP_MUX; DECODE: process (DISP_PHOTO) begin -- Process all elements of the data arrays case DISP_PHOTO is when 0 => DISPLAY <= SEG_0; when 1 => DISPLAY <= SEG_1; when 2 => DISPLAY <= SEG_2; when 3 => DISPLAY <= SEG_3; when 4 => DISPLAY <= SEG_4; when 5 => DISPLAY <= SEG_5; when 6 => DISPLAY <= SEG_6; when 7 => DISPLAY <= SEG_7; when 8 => DISPLAY <= SEG_8; when 9 => DISPLAY <= SEG_9; when others => DISPLAY <= SEG_E; end case; end process DECODE; end RTL; ===== Testbench ===== library ieee; use ieee.std_logic_1164.all; use work.P_DISPLAY.all; entity TB_DISP_DRV is end TB_DISP_DRV; architecture TEST of TB_DISP_DRV is component DISP_DRV port(ERROR : in std_ulogic; SHOW_TIME : in std_ulogic; NO_PICS : in T_DIGITS; EXP_TIME : in T_DIGITS; DISPLAY : out T_DISPLAY); end component; signal W_ERROR : std_ulogic :='0'; signal W_SHOW_TIME : std_ulogic :='0'; signal W_NO_PICS : T_DIGITS; signal W_EXP_TIME : T_DIGITS; signal W_DISPLAY : T_DISPLAY; begin DUT : DISP_DRV port map( ERROR => W_ERROR, NO_PICS => W_NO_PICS, EXP_TIME => W_EXP_TIME, SHOW_TIME => W_SHOW_TIME, DISPLAY => W_DISPLAY); STIMULI : process begin -- DISPLAY = (0,0,0) wait for 30 ns; W_NO_PICS <= (0,0,0); W_EXP_TIME <= (5,0,0); -- no changes wait for 20 ns; for I in 1 to 10 loop W_NO_PICS <= (0,0,I); -- DISPLAY = (0,0,1)..(0,0,E) wait for 20 ns; end loop; W_SHOW_TIME <= '1'; -- DISPLAY = (5,0,0) wait for 20 ns; W_EXP_TIME <= (0,6,0); W_NO_PICS <= (4,0,0); -- DISPLAY = (0,6,0) wait for 20 ns; W_SHOW_TIME <= '0'; -- DISPLAY = (4,0,0) wait for 20 ns; W_ERROR <= '1'; -- DISPLAY = (E,E,E) wait for 20 ns; W_SHOW_TIME <= '1'; -- no changes wait for 20 ns; W_ERROR <= '0'; -- DISPLAY = (0,6,0) wait for 20 ns; W_SHOW_TIME <= '0'; -- DISPLAY = (4,0,0) wait for 20 ns; wait; end process STIMULI; DISPLAY_DIGIT(W_DISPLAY); end TEST; configuration CFG_TB_DISP_DRV of TB_DISP_DRV is for TEST end for; end CFG_TB_DISP_DRV; ===== Package ===== {{page>.:package}}