Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.72 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity parkeringshus is
  6.     port(
  7.             CLOCK_50 : in std_logic;
  8.             KEY     : in std_logic_vector(3 downto 0);
  9.             LEDR        : out std_logic_vector(17 downto 0);
  10.             SW          : in std_logic_vector(17 downto 0);
  11.             HEX0,
  12.             HEX1,
  13.             HEX2,
  14.             HEX3,
  15.             HEX4,
  16.             HEX5,
  17.             HEX6,
  18.             HEX7        : out std_logic_vector(6 downto 0)
  19.     );
  20. end entity parkeringshus;
  21.  
  22. architecture RTL of parkeringshus is
  23.  
  24. signal reset, synched_reset     : std_logic;
  25. signal sensor_inn, sensor_ut        : std_logic;
  26. signal synched_sensor_inn           : std_logic;
  27. signal synched_sensor_ut            : std_logic;
  28. signal input_Q_inn, input_Q_ut  : std_logic;
  29. signal puls_inn_input, puls_ut_input            : std_logic;
  30. signal puls_inn_output, puls_ut_output          : std_logic;
  31. signal antall_biler                 : std_logic_vector(7 downto 0);
  32. signal bcd_out                          : std_logic_vector(11 downto 0);
  33.  
  34. component antiprell is
  35.     port (
  36.                 clk             : in std_logic;
  37.                 reset_clk   : in std_logic;
  38.                 input           : in std_logic;
  39.                 passering   : out std_logic
  40.     );
  41. end component;
  42.  
  43. component Flanke_detektor is
  44.     port (
  45.             clock_50        : in std_logic;
  46.             reset_clk   : in std_logic;
  47.             sig_inn     : in std_logic;
  48.             sig_inn_ne  : out std_logic
  49.     );
  50. end component;
  51.  
  52.  
  53. component reset_sync is
  54.     port(
  55.             clk : in std_logic;
  56.             rst_n : in std_logic;
  57.             rst_clk_n : out std_logic
  58.         );
  59. end component;
  60.  
  61. component tell_biler is
  62.     port(
  63.             clock_50        : in std_logic;
  64.             reset_clk       : in std_logic;
  65.             bil_inn         : in std_logic;
  66.             bil_ut          : in std_logic;
  67.             antall_biler    : out std_logic_vector(7 downto 0)
  68.     );
  69. end component;
  70.  
  71. component ROM_7_seg is
  72.     port(
  73.         adresse : in std_logic_vector(3 downto 0);
  74.         HEX     : out std_logic_vector(0 to 6)
  75.     );
  76. end component;
  77.  
  78. component bin2bcd is
  79.     port(
  80.             bin_in  : in std_logic_vector(7 downto 0);
  81.             bcd_out     : out std_logic_vector(11 downto 0)
  82.     );
  83. end component;
  84.  
  85. begin
  86.     sensor_inn  <= KEY(1);
  87.     sensor_ut   <= KEY(2);
  88.     reset       <= KEY(3);
  89.     LEDR(7 downto 0) <= antall_biler;
  90.  
  91.     reset_sync_comp : reset_sync
  92.         port map(
  93.             clk             => CLOCK_50,
  94.             rst_n       => reset,
  95.             rst_clk_n   => synched_reset
  96.         );
  97.    
  98.     anti_prell_inn : antiprell
  99.         port map(
  100.             clk             =>  CLOCK_50,
  101.             reset_clk   => synched_reset,
  102.             input           => synched_sensor_inn,
  103.             passering   => puls_inn_input
  104.         );
  105.        
  106.     anti_prell_ut : antiprell
  107.         port map(
  108.             clk             =>  CLOCK_50,
  109.             reset_clk   => synched_reset,
  110.             input       => synched_sensor_ut,
  111.             passering   => puls_ut_input
  112.         );
  113.        
  114.        
  115.     flanke_detektor_inn : Flanke_detektor
  116.         port map(
  117.             clock_50    => CLOCK_50,
  118.             reset_clk   => synched_reset,
  119.             sig_inn         => puls_inn_input,
  120.             sig_inn_ne  => puls_inn_output
  121.         );
  122.        
  123.     flanke_detektor_ut : Flanke_detektor
  124.         port map(
  125.             clock_50    => CLOCK_50,
  126.             reset_clk   => synched_reset,
  127.             sig_inn         => puls_ut_input,
  128.             sig_inn_ne  => puls_ut_output
  129.         );
  130.    
  131.     bill_teller : tell_biler
  132.         port map(
  133.             clock_50        => CLOCK_50,
  134.             reset_clk       => synched_reset,
  135.             bil_inn             => puls_inn_output,
  136.             bil_ut          => puls_ut_output,
  137.             antall_biler    => antall_biler
  138.         );
  139.        
  140.     bin2bcd_comp : bin2bcd
  141.         port map(
  142.             bin_in  => antall_biler,
  143.             bcd_out => bcd_out
  144.         );
  145.        
  146.     ROM_7_seg_0 : ROM_7_seg
  147.         port map(
  148.             adresse => bcd_out(3 downto 0),
  149.             HEX     => HEX0
  150.         );
  151.        
  152.     ROM_7_seg_1 : ROM_7_seg
  153.         port map(
  154.             adresse => bcd_out(7 downto 4),
  155.             HEX     => HEX1
  156.         );
  157.        
  158.     ROM_7_seg_2 : ROM_7_seg
  159.         port map(
  160.             adresse => bcd_out(11 downto 8),
  161.             HEX     => HEX2
  162.         );
  163.            
  164.    
  165.     p_sync_signaler : process(CLOCK_50) is
  166.     begin
  167.         if rising_edge(CLOCK_50) then
  168.             input_Q_inn <= sensor_inn;
  169.             synched_sensor_inn <= input_Q_inn;
  170.            
  171.             input_Q_ut <= sensor_ut;
  172.             synched_sensor_ut <= input_Q_ut;
  173.         end if;
  174.     end process;
  175. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement