-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProgramCounter.vhd
35 lines (32 loc) · 1001 Bytes
/
ProgramCounter.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity ProgramCounter is
Port ( DIN : in STD_LOGIC_VECTOR (9 downto 0);
PC_LD : in STD_LOGIC;
PC_INC : in STD_LOGIC;
RST : in STD_LOGIC;
CLK : in STD_LOGIC;
PC_COUNT : out STD_LOGIC_VECTOR (9 downto 0));
end ProgramCounter;
architecture Behavioral of ProgramCounter is
signal cnt : std_logic_vector(9 downto 0);
begin
process (CLK, RST)
begin
if (rising_edge(CLK)) then
if (RST = '1') then
cnt <= "0000000000";
else
if (PC_LD = '1') then
cnt <= DIN;
else
if (PC_INC = '1') then
cnt <= std_logic_vector(unsigned(cnt) + 1);
end if;
end if;
end if;
end if;
end process;
PC_COUNT <= cnt;
end Behavioral;