📄 program_counter.vhd
字号:
library ieee;use ieee.std_logic_1164.all; -- each module will need to use std_logicuse ieee.numeric_std.all; -- program counter needs support for numerical operationsentity program_counter is port( reset : in std_logic; -- master reset, same for each sequential module clk : in std_logic; -- same clock drives each sequential module we: in std_logic; -- controller sets this signal when PC is loaded with branch address increment: in std_logic; -- controller sets this when an increment is required branch_address: in std_logic_vector(12 downto 0); PCout: out std_logic_vector(12 downto 0) ); -- this is the next instr addressend entity program_counter;architecture program_counter of program_counter issignal PC_count: unsigned(12 downto 0);begin process(clk) is begin if rising_edge(clk) then if (reset = '1') then PC_count <= (others => '0'); elsif (we = '1') then PC_count <= unsigned(branch_address); elsif (increment = '1') then PC_count <= (PC_count + 1); end if; end if; -- rising_edge(clk) end process; PCout <= std_logic_vector(PC_count);end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -