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_gpr is
|
47 |
|
|
port( c : in std_logic_vector(7 downto 0);
|
48 |
|
|
wr_reg, inc_zp, dec_zp : in std_logic;
|
49 |
|
|
rd, rr, dest : in integer range 0 to 15;
|
50 |
|
|
clk, clrn : in std_logic;
|
51 |
|
|
reg_rd, reg_rr, addrbus : out std_logic_vector(7 downto 0)
|
52 |
|
|
);
|
53 |
|
|
end v_gpr;
|
54 |
|
|
|
55 |
|
|
architecture gpr of v_gpr is
|
56 |
|
|
|
57 |
|
|
type regfiletype is array (0 to 15) of std_logic_vector(7 downto 0);
|
58 |
|
|
|
59 |
|
|
signal reg : regfiletype;
|
60 |
|
|
|
61 |
|
|
begin
|
62 |
|
|
|
63 |
|
|
addrbus <= reg(14) - 16#61# when dec_zp = '1' else
|
64 |
|
|
reg(14) - 16#60#;
|
65 |
|
|
|
66 |
|
|
reg_rd <= reg(rd);
|
67 |
|
|
reg_rr <= reg(rr);
|
68 |
|
|
|
69 |
|
|
process(clk, clrn)
|
70 |
|
|
begin
|
71 |
|
|
if clrn = '0' then
|
72 |
|
|
for i in 0 to 15 loop
|
73 |
|
|
reg(i) <= "00000000";
|
74 |
|
|
end loop;
|
75 |
|
|
elsif clk'event and clk = '1' then
|
76 |
|
|
if wr_reg = '1' then
|
77 |
|
|
reg(dest) <= c;
|
78 |
|
|
end if;
|
79 |
|
|
if inc_zp = '1' then
|
80 |
|
|
reg(14) <= reg(14) + 1;
|
81 |
|
|
elsif dec_zp = '1' then
|
82 |
|
|
reg(14) <= reg(14) - 1;
|
83 |
|
|
end if;
|
84 |
|
|
end if;
|
85 |
|
|
end process;
|
86 |
|
|
|
87 |
|
|
end gpr;
|