fe7741d0413ae2c6f68dd81c74afe140b9aa7e59
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

1) LIBRARY IEEE;
2) USE IEEE.STD_LOGIC_1164.ALL;
3) USE IEEE.NUMERIC_STD.ALL;
4) 
5) ENTITY e_io_cyc_cnt IS
6)     PORT (
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

7)         rst:       IN  std_logic;
8)         clk:       IN  std_logic;
9)         o_rd_data: OUT std_logic_vector(31 DOWNTO 0);
10)         i_wr_data: IN  std_logic_vector(31 DOWNTO 0);
11)         i_wr_en:   IN  std_logic
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

12)     );
13) END ENTITY e_io_cyc_cnt;
14) 
15) ARCHITECTURE a_io_cyc_cnt OF e_io_cyc_cnt IS
16) 
17)     SIGNAL n_cnt: std_logic_vector(31 DOWNTO 0);
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

18)     SIGNAL r_cnt: std_logic_vector(31 DOWNTO 0) := (OTHERS => '0');
Stefan Schuermans added cycle counter peripheral

Stefan Schuermans authored 12 years ago

19) 
20) BEGIN
21) 
22)     p_write: PROCESS(r_cnt, i_wr_data, i_wr_en)
23)     BEGIN
24)         IF i_wr_en = '1' THEN
25)             n_cnt <= i_wr_data;
26)         ELSE
27)             n_cnt <= std_logic_vector(unsigned(r_cnt) + to_unsigned(1, 32));
28)         END IF;
29)     END PROCESS p_write;
30) 
31)     p_sync: PROCESS(rst, clk)
32)     BEGIN
33)         IF rst = '1' THEN
34)             r_cnt <= (OTHERS => '0');
35)         ELSIF rising_edge(clk) THEN
36)             r_cnt <= n_cnt;
37)         END IF;
38)     END PROCESS p_sync;
39) 
Stefan Schuermans read peripherals with one c...

Stefan Schuermans authored 12 years ago

40)     p_read: PROCESS(rst, clk)
41)     BEGIN
42)         IF rst = '1' THEN
43)             o_rd_data <= (OTHERS => '0');
44)         ELSIF rising_edge(clk) THEN
45)             o_rd_data <= r_cnt;
46)         END IF;
47)     END PROCESS p_read;
48)