⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_count4.vhd

📁 Workshop vhdl code from Esperan
💻 VHD
字号:
-----------------------------------------------------------------------
-- 
-- Original Code Copyright (c) 1999 by Esperan. All rights reserved.
-- www.esperan.com
-- 
-- This source file may be used and distributed without restriction
-- provided that this copyright statement is not removed from the file
-- and that any derivative work contains this copyright notice. 
--
-- Esperan VHDL Alarm Clock Lab Exercise Design V5.0
--
-- T_count4.vhd
-- Test bench for the 4-digit counter 
--
--------------------------------------------------------------- 

Library IEEE;
use IEEE.Std_Logic_1164.all; 
use IEEE.Std_Logic_Unsigned.all;

entity T_COUNT4 is
end T_COUNT4 ;

architecture TEST of T_COUNT4 is
   component COUNT4
      port(NEW_CURRENT_TIME_LS_MIN, 
           NEW_CURRENT_TIME_MS_MIN, 
           NEW_CURRENT_TIME_LS_HR, 
           NEW_CURRENT_TIME_MS_HR     :  in std_logic_vector(3 downto 0);
           LOAD_NEW_C                 : in std_logic;
           CLK, ONE_MINUTE, RESET     : in std_logic;
           CURRENT_TIME_LS_MIN,   
           CURRENT_TIME_MS_MIN,  
           CURRENT_TIME_LS_HR,    
           CURRENT_TIME_MS_HR         :  out std_logic_vector(3 downto 0));
   end component;

  signal NEW_CURRENT_TIME_LS_MIN, 
         NEW_CURRENT_TIME_MS_MIN, 
         NEW_CURRENT_TIME_LS_HR, 
         NEW_CURRENT_TIME_MS_HR     : std_logic_vector(3 downto 0):= "0000";
  signal LOAD_NEW_C                 : std_logic:= '0';
  signal CLK                        : std_logic:= '0';
  signal RESET                      : std_logic:= '0';
  signal ONE_MINUTE                 : std_logic:= '0';
  signal CURRENT_TIME_LS_MIN,   
         CURRENT_TIME_MS_MIN,  
         CURRENT_TIME_LS_HR,    
         CURRENT_TIME_MS_HR         : std_logic_vector(3 downto 0):= "0000";

   constant PERIOD : time := 10 ns;
   constant SECOND : time := PERIOD * 2;



begin

   ---------------------------------------------
   -- instantiate UUT
   ---------------------------------------------

   uut : COUNT4 port map(
                      NEW_CURRENT_TIME_LS_MIN, 
                      NEW_CURRENT_TIME_MS_MIN, 
                      NEW_CURRENT_TIME_LS_HR, 
                      NEW_CURRENT_TIME_MS_HR,
                      LOAD_NEW_C,
                      CLK, ONE_MINUTE, RESET,
                      CURRENT_TIME_LS_MIN,   
                      CURRENT_TIME_MS_MIN,  
                      CURRENT_TIME_LS_HR,    
                      CURRENT_TIME_MS_HR);

   ---------------------------------------------
   -- infinite clock generator 
   ---------------------------------------------

      CLK <= not CLK after PERIOD/2;

   ---------------------------------------------
   -- one_minute generator - make equal to twice CLK to
   -- make testing quicker
   ---------------------------------------------

      ONE_MINUTE <= not ONE_MINUTE after PERIOD;

   --------------------------------------------------
   -- Stimulus: we want to
   --   1. pulse reset
   --   2. watch it count to the LS_MIN rollover
   --   3. Load 00:58 and watch the next rollover
   --   4. Load 09:58 and watch the rollover
   --   5. Load 11:58 and watch the rollover
   --   6. Load 23:58 and watch the rollover
   --   7. Just let it count
   -------------------------------------------------
   STIMULUS : process
   begin
      -- pulse reset
      wait for PERIOD;
      RESET <= '1';
      wait for PERIOD;
      RESET <= '0';
      wait for period/2;

      -- load 00:08 and count up
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0000";
      NEW_CURRENT_TIME_LS_HR <= "0000";
      NEW_CURRENT_TIME_MS_HR <= "0000";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;
     
      -- load 00:58 and watch rollover
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0101";
      NEW_CURRENT_TIME_LS_HR <= "0000";
      NEW_CURRENT_TIME_MS_HR <= "0000";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;
 
      -- load 09:58 and watch rollover
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0101";
      NEW_CURRENT_TIME_LS_HR <= "1001";
      NEW_CURRENT_TIME_MS_HR <= "0000";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;
      
      -- load 10:58 and watch rollover
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0101";
      NEW_CURRENT_TIME_LS_HR <= "0000";
      NEW_CURRENT_TIME_MS_HR <= "0001";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;
 
      -- load 11:58 and watch rollover
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0101";
      NEW_CURRENT_TIME_LS_HR <= "0001";
      NEW_CURRENT_TIME_MS_HR <= "0001";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;

      -- load 23:58 and watch rollover
      LOAD_NEW_C <= '1';
      NEW_CURRENT_TIME_LS_MIN <= "1000";
      NEW_CURRENT_TIME_MS_MIN <= "0101";
      NEW_CURRENT_TIME_LS_HR <= "0011";
      NEW_CURRENT_TIME_MS_HR <= "0010";
      wait for SECOND;
      LOAD_NEW_C <= '0';
      wait for 5 * SECOND;
      wait;

   end process STIMULUS;


end TEST;

configuration CFG_T_COUNT4 of T_COUNT4 is
   for TEST
   end for;
end CFG_T_COUNT4;

      
      


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -