Facebook
From Chartreuse Guinea Pig, 5 Years ago, written in VHDL.
Embed
Download Paste or View Raw
Hits: 220
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    13:14:18 03/22/2019
  6. -- Design Name:
  7. -- Module Name:    modul - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity modul is
  33.   Port ( clk      : in STD_LOGIC;
  34.          reset    : in STD_LOGIC;
  35.          start    : in STD_LOGIC;
  36.          OW_DQ    : inout STD_LOGIC;
  37.          ow_pres  : out STD_LOGIC);    
  38. end modul;
  39.  
  40. architecture Behavioral of modul is
  41. type state_type is (INIT,B,C,D)
  42. signal state: state_type;
  43.  
  44. component IOBUF
  45.    Port ( IO : inout STD_LOGIC;
  46.           I  : in STD_LOGIC;
  47.           O  : out STD_LOGIC;
  48.           T  : in STD_LOGIC);
  49. end component;
  50.  
  51. signal ow_in   :std_logic;
  52. signal ow_out  :std_logic;
  53.  
  54.  
  55. begin
  56.  
  57. buff : IOBUF
  58.    port map( I => '0',
  59.              T => ow_out,
  60.              O => ow_in,
  61.              IO => OW_DQ);
  62.  
  63.    when init =>   if start = '1' then
  64.                     ow_out <= '0';
  65.                     counter <= 5000;
  66.                     state <= B;
  67.                   end;
  68.                  
  69.         when B =>      if clk = 0 then  
  70.                     ow_out <= '1';
  71.                     state <= C;
  72.                   end if;
  73.  
  74.    when C =>      reset <= '0'
  75.                   if(clk = 150) then  
  76.                     reset <= '1';
  77.                     state <= D;
  78.    
  79.    when D =>      ow_pres <= not ow_in;
  80.                   state<= init;
  81.    
  82. end Behavioral;
  83.  
  84.