OpenCores
URL https://opencores.org/ocsvn/nanoblaze/nanoblaze/trunk

Subversion Repositories nanoblaze

[/] [nanoblaze/] [trunk/] [Circuit/] [programCounter.vhd] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 fcorthay
--##############################################################################
2
--
3
--  programCounter
4
--      Program counter
5
--
6
--      Addresses the instruction ROM.
7
--      Capable of incrementation, jump and function return
8
--
9
--------------------------------------------------------------------------------
10
--
11
--  Versions / Authors
12
--      1.0 Francois Corthay    first implementation
13
--
14
--  Provided under GNU LGPL licence: <http://www.gnu.org/copyleft/lesser.html>
15
--
16
--  by the electronics group of "HES-SO//Valais Wallis", in Switzerland:
17
--  <http://www.hevs.ch/en/rad-instituts/institut-systemes-industriels/>.
18
--
19
--------------------------------------------------------------------------------
20
--
21
--  Hierarchy
22
--      Used by "nanoblaze/nanoProcessor".
23
--
24
--##############################################################################
25
 
26
LIBRARY ieee;
27
  USE ieee.std_logic_1164.all;
28
  USE ieee.numeric_std.all;
29
 
30
ENTITY programCounter IS
31
  GENERIC(
32
    programCounterBitNb : positive := 10
33
  );
34
  PORT(
35
    reset             : IN  std_ulogic;
36
    clock             : IN  std_ulogic;
37
    instrAddress      : IN  unsigned(programCounterBitNb-1 DOWNTO 0);
38
    storedProgCounter : IN  unsigned(programCounterBitNb-1 DOWNTO 0);
39
    incPC             : IN  std_ulogic;
40
    loadInstrAddress  : IN  std_ulogic;
41
    loadStoredPC      : IN  std_ulogic;
42
    progCounter       : OUT unsigned(programCounterBitNb-1 DOWNTO 0)
43
  );
44
END programCounter ;
45
 
46
--==============================================================================
47
 
48
ARCHITECTURE RTL OF programCounter IS
49
 
50
  signal pCounter: unsigned(progCounter'range);
51
 
52
BEGIN
53
 
54
  updateProgramCounter: process(reset, clock)
55
  begin
56
    if reset = '1' then
57
      pCounter <= (others => '0');
58
    elsif rising_edge(clock) then
59
      if incPC = '1' then
60
        pCounter <= pCounter + 1;
61
      elsif loadInstrAddress = '1' then
62
        pCounter <= instrAddress;
63
      elsif loadStoredPC = '1' then
64
        pCounter <= storedProgCounter;
65
      end if;
66
    end if;
67
  end process updateProgramCounter;
68
 
69
  progCounter <= pCounter;
70
 
71
END ARCHITECTURE RTL;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.