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

Subversion Repositories RISCMCU

[/] [RISCMCU/] [trunk/] [vhdl/] [v_pc.vhd] - Blame information for rev 28

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 yapzihe
----------------------------------------------------------------------------
2
----                                                                    ----
3
---- WISHBONE RISCMCU IP Core                                           ----
4
----                                                                    ----
5
---- This file is part of the RISCMCU project                           ----
6
---- http://www.opencores.org/projects/riscmcu/                         ----
7
----                                                                    ----
8
---- Description                                                        ----
9
---- Implementation of a RISC Microcontroller based on Atmel AVR        ----
10
---- AT90S1200 instruction set and features with Altera Flex10k20 FPGA. ----
11
----                                                                    ----
12
---- Author(s):                                                         ----
13
----    - Yap Zi He, yapzihe@hotmail.com                                ----
14
----                                                                    ----
15
----------------------------------------------------------------------------
16
----                                                                    ----
17
---- Copyright (C) 2001 Authors and OPENCORES.ORG                       ----
18
----                                                                    ----
19
---- This source file may be used and distributed without               ----
20
---- restriction provided that this copyright statement is not          ----
21
---- removed from the file and that any derivative work contains        ----
22
---- the original copyright notice and the associated disclaimer.       ----
23
----                                                                    ----
24
---- This source file is free software; you can redistribute it         ----
25
---- and/or modify it under the terms of the GNU Lesser General         ----
26
---- Public License as published by the Free Software Foundation;       ----
27
---- either version 2.1 of the License, or (at your option) any         ----
28
---- later version.                                                     ----
29
----                                                                    ----
30
---- This source is distributed in the hope that it will be             ----
31
---- useful, but WITHOUT ANY WARRANTY; without even the implied         ----
32
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ----
33
---- PURPOSE. See the GNU Lesser General Public License for more        ----
34
---- details.                                                           ----
35
----                                                                    ----
36
---- You should have received a copy of the GNU Lesser General          ----
37
---- Public License along with this source; if not, download it         ----
38
---- from http://www.opencores.org/lgpl.shtml                           ----
39
----                                                                    ----
40
----------------------------------------------------------------------------
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44
use ieee.std_logic_unsigned.all;
45
 
46
entity v_pc is
47
 port(  offset : in std_logic_vector(8 downto 0);
48
                en, addoffset, push, pull, vec2, vec4 : in std_logic;
49
                clk, clrn : in std_logic;
50
                pc : buffer std_logic_vector(8 downto 0)
51
 );
52
end v_pc;
53
 
54
architecture pc of v_pc is
55
constant vector2 : std_logic_vector(8 downto 0) := "000000001";
56
constant vector4 : std_logic_vector(8 downto 0) := "000000010";
57
signal pcb, stack0, stack1, stack2, stack3 : std_logic_vector(8 downto 0);
58
begin
59
 
60
process(clk, clrn)
61
begin
62
        if clrn = '0' then
63
                pc <= "000000000";
64
                pcb <= "000000000";
65
                stack0 <= "000000000";
66
                stack1 <= "000000000";
67
                stack2 <= "000000000";
68
                stack3 <= "000000000";
69
        elsif clk'event and clk = '1' then
70
                if en = '1' then
71
                        pcb <= pc;
72
                        if addoffset = '1' then
73
                                pc <= pcb + offset;
74
                        elsif pull = '1' then
75
                                pc <= stack0;
76
                        elsif vec2 = '1' then
77
                                pc <= vector2;
78
                        elsif vec4 = '1' then
79
                                pc <= vector4;
80
                        else
81
                                pc <= pc + 1;
82
                        end if;
83
 
84
                        if push = '1' then
85
                                if addoffset = '1' then
86
                                        stack0 <= pcb;
87
                                else
88
                                        stack0 <= pcb - 1;
89
                                end if;
90
                                stack1 <= stack0;
91
                                stack2 <= stack1;
92
                                stack3 <= stack2;
93
                        elsif pull = '1' then
94
                                stack0 <= stack1;
95
                                stack1 <= stack2;
96
                                stack2 <= stack3;
97
                        end if;
98
                end if;
99
        end if;
100
end process;
101
end pc;

powered by: WebSVN 2.1.0

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