Advertisement
Mihailo21

PrinterTB

Feb 11th, 2024
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.77 KB | None | 0 0
  1. ---------------------------------------------
  2. -- Ime i prezime:
  3. -- Broj indeksa:
  4. ---------------------------------------------
  5. library ieee;
  6. use ieee.std_logic_1164.all;
  7.  
  8. entity Printer_tb is
  9. end entity;
  10.  
  11. architecture Test of Printer_tb is
  12.  
  13.    signal sCLK          : std_logic := '0';
  14.    signal sRST      : std_logic := '0';
  15.    signal sPRINT        : std_logic := '0';
  16.     signal sADD_PAPER   : std_logic := '0';
  17.     signal sAMOUNT      : std_logic_vector(7 downto 0) := "00000000";
  18.     signal soPRINT      : std_logic;
  19.     signal sERROR       : std_logic;
  20.    
  21.     constant iCLK_period : time := 10 ns;
  22.    
  23.     component Printer is port (
  24.     iCLK        : in  std_logic;
  25.     iRST        : in  std_logic;
  26.     iPRINT          : in  std_logic;
  27.     iADD_PAPER  : in  std_logic;
  28.     iAMOUNT     : in  std_logic_vector(7 downto 0);
  29.     oPRINT      : out std_logic;
  30.     oERROR      : out std_logic
  31.     );
  32.     end component;
  33.  
  34. begin
  35.  
  36.    uut: Printer port map (
  37.           iCLK      => sCLK,
  38.           iRST      => sRST,
  39.              iPRINT     => sPRINT,
  40.              iADD_PAPER => sADD_PAPER,
  41.           iAMOUNT   => sAMOUNT,
  42.           oPRINT        => soPRINT,
  43.              oERROR     => sERROR
  44.         );
  45.          
  46.     iCLK_process: process
  47.     begin
  48.         sCLK <= '0';
  49.         wait for iCLK_period / 2; -- iCLK_period je konstanta
  50.         sCLK <= '1';
  51.         wait for iCLK_period / 2;
  52.     end process;
  53.  
  54.    stim_proc : process
  55.    begin       
  56.    
  57.     sRST <= '1';
  58.     wait for 5.25*iCLK_period;
  59.     sRST <= '0';
  60.     sADD_PAPER <= '1';
  61.     sAMOUNT <= "00000011";
  62.     wait for iCLK_period;
  63.     sADD_PAPER <= '0';
  64.     sAMOUNT <= (others=>('0'));
  65.    
  66.     sPrint <= '1';
  67.     sPrint <= '1';
  68.     wait for 27*iCLK_period;
  69.    
  70.    
  71.     sPrint <= '1';
  72.     sPrint <= '1';
  73.     wait for 27*iCLK_period;
  74.    
  75.     sADD_PAPER <= '1';
  76.     sAMOUNT <= "00001110"; -- 15 papira
  77.     sPrint <= '1';
  78.     sADD_PAPER <= '0';
  79.     wait for iCLK_period;
  80.    
  81.     sRST <= '1';
  82.  
  83.        
  84.         wait;
  85.    end process;
  86. end architecture;
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement