]> rtime.felk.cvut.cz Git - fpga/spartan2/qcounter.git/blob - top_counter.vhd
Component instances replaced by entity instances.
[fpga/spartan2/qcounter.git] / top_counter.vhd
1 library IEEE;
2 use IEEE.STD_LOGIC_1164.all;
3 use IEEE.STD_LOGIC_ARITH.all;
4 use IEEE.STD_LOGIC_UNSIGNED.all;
5
6 --------------------------------------------------------------------------------
7 -- This is the top module instantiating quadratic counter with output to the
8 -- on-board LCD. See 'top_counter.ucf' and read how a quadratic encoder is
9 -- connected.
10 --------------------------------------------------------------------------------
11
12 entity top_counter is
13   port(
14     clk       : in  std_logic;
15     reset     : in  std_logic;
16     
17     rot_A     : in  std_logic;
18     rot_B     : in  std_logic;
19     rot_press : in  std_logic;
20     rot_feed  : out std_logic;
21     
22     lcd_com   : out std_logic;
23     lcd2_dp   : out std_logic;
24     lcd1_dp   : out std_logic;
25     lcd1      : out std_logic_vector(6 downto 0);
26     lcd2      : out std_logic_vector(6 downto 0));
27 end top_counter;
28
29 --------------------------------------------------------------------------------
30
31 architecture behavioral of top_counter is
32   
33   signal lcd_clk  : std_logic;
34   signal lcd1_out : std_logic_vector (6 downto 0);
35   signal lcd2_out : std_logic_vector (6 downto 0);
36
37   signal qcount_data  : std_logic_vector (31 downto 0);
38   signal qcount_reset : std_logic;
39
40 --------------------------------------------------------------------------------
41   
42 begin
43   
44   div_20_1 : entity work.div_20
45     port map (
46       clk    => clk,
47       clk_2k => lcd_clk);
48
49   hex2lcd_1 : entity work.hex2lcd
50     port map (
51       hex => qcount_data(5 downto 2),
52       lcd => lcd1_out);
53
54   hex2lcd_2 : entity work.hex2lcd
55     port map (
56       hex => qcount_data(9 downto 6),
57       lcd => lcd2_out);
58
59   lcd_mux_1 : entity work.lcd_mux
60     port map (
61       clk     => clk,
62       cnt     => lcd_clk,
63       data_in => lcd1_out,
64       lcd_seg => lcd1,
65       lcd_com => lcd_com,
66       lcd_dp  => lcd1_dp);
67
68   lcd_mux_2 : entity work.lcd_mux
69     port map (
70       clk     => clk,
71       cnt     => lcd_clk,
72       data_in => lcd2_out,
73       lcd_seg => lcd2,
74       lcd_com => open,
75       lcd_dp  => lcd2_dp);
76
77   qcounter_1 : entity work.qcounter
78     port map (
79       clock    => clk,
80       reset    => qcount_reset,
81       a0       => rot_A,
82       b0       => rot_B,
83       qcount   => qcount_data,
84       a_rise   => open,
85       a_fall   => open,
86       b_rise   => open,
87       b_fall   => open,
88       ab_event => open,
89       ab_error => open);
90
91 --------------------------------------------------------------------------------
92
93   rot_feed <= '1';
94
95   qcount_reset <= not reset or rot_press;
96   
97 end Behavioral;
98