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

Subversion Repositories nanoblaze

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

Go to most recent revision | 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
 
45
END programCounter ;
46
 
47
--==============================================================================
48
 
49
ARCHITECTURE RTL OF programCounter IS
50
 
51
  signal pCounter: unsigned(progCounter'range);
52
 
53
BEGIN
54
 
55
  updateProgramCounter: process(reset, clock)
56
  begin
57
    if reset = '1' then
58
      pCounter <= (others => '0');
59
    elsif rising_edge(clock) then
60
      if incPC = '1' then
61
        pCounter <= pCounter + 1;
62
      elsif loadInstrAddress = '1' then
63
        pCounter <= instrAddress;
64
      elsif loadStoredPC = '1' then
65
        pCounter <= storedProgCounter;
66
      end if;
67
    end if;
68
  end process updateProgramCounter;
69
 
70
  progCounter <= pCounter;
71
 
72
END ARCHITECTURE RTL;

powered by: WebSVN 2.1.0

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