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_ram is
|
47 |
|
|
port( addrbus : in std_logic_vector(7 downto 0);
|
48 |
|
|
rd_ram, wr_ram, ld_mar, ld_mbr : in std_logic;
|
49 |
|
|
clk, clrn : in std_logic;
|
50 |
|
|
c : inout std_logic_vector(7 downto 0)
|
51 |
|
|
);
|
52 |
|
|
end entity;
|
53 |
|
|
|
54 |
|
|
architecture ram of v_ram is
|
55 |
|
|
|
56 |
|
|
component lpm_ram_dq
|
57 |
|
|
generic( lpm_width: positive := 8;
|
58 |
|
|
lpm_widthad: positive := 8;
|
59 |
|
|
lpm_numwords: natural := 256;
|
60 |
|
|
lpm_file: string := "ram.mif";
|
61 |
|
|
lpm_indata: string := "unregistered";
|
62 |
|
|
lpm_address_control: string := "unregistered";
|
63 |
|
|
lpm_outdata: string := "unregistered"
|
64 |
|
|
);
|
65 |
|
|
port( data: in std_logic_vector(lpm_width-1 downto 0);
|
66 |
|
|
address: in std_logic_vector(lpm_widthad-1 downto 0);
|
67 |
|
|
we: in std_logic;
|
68 |
|
|
inclock: in std_logic := '0';
|
69 |
|
|
outclock: in std_logic := '0';
|
70 |
|
|
q: out std_logic_vector(lpm_width-1 downto 0)
|
71 |
|
|
);
|
72 |
|
|
end component;
|
73 |
|
|
|
74 |
|
|
signal mar, mbr, ram_out : std_logic_vector(7 downto 0);
|
75 |
|
|
|
76 |
|
|
begin
|
77 |
|
|
|
78 |
|
|
sram: lpm_ram_dq
|
79 |
|
|
port map(data => mbr, address => mar, we => wr_ram, q => ram_out);
|
80 |
|
|
|
81 |
|
|
c <= ram_out when rd_ram = '1' else
|
82 |
|
|
"ZZZZZZZZ";
|
83 |
|
|
|
84 |
|
|
process(clk,clrn)
|
85 |
|
|
begin
|
86 |
|
|
if clrn = '0' then
|
87 |
|
|
mar <= "00000000";
|
88 |
|
|
mbr <= "00000000";
|
89 |
|
|
elsif clk'event and clk = '1' then
|
90 |
|
|
if ld_mbr = '1' then
|
91 |
|
|
mbr <= c;
|
92 |
|
|
end if;
|
93 |
|
|
if ld_mar = '1' then
|
94 |
|
|
mar <= addrbus;
|
95 |
|
|
end if;
|
96 |
|
|
end if;
|
97 |
|
|
end process;
|
98 |
|
|
|
99 |
|
|
end ram;
|