1 |
2 |
idiolatrie |
--------------------------------------------------------------------------------
|
2 |
|
|
-- 8-Color 100x37 Textmode Video Controller --
|
3 |
|
|
--------------------------------------------------------------------------------
|
4 |
|
|
-- Copyright (C)2011 Mathias Hörtnagl <mathias.hoertnagl@gmail.comt> --
|
5 |
|
|
-- --
|
6 |
|
|
-- This program is free software: you can redistribute it and/or modify --
|
7 |
|
|
-- it under the terms of the GNU General Public License as published by --
|
8 |
|
|
-- the Free Software Foundation, either version 3 of the License, or --
|
9 |
|
|
-- (at your option) any later version. --
|
10 |
|
|
-- --
|
11 |
|
|
-- This program is distributed in the hope that it will be useful, --
|
12 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
|
13 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --
|
14 |
|
|
-- GNU General Public License for more details. --
|
15 |
|
|
-- --
|
16 |
|
|
-- You should have received a copy of the GNU General Public License --
|
17 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>. --
|
18 |
|
|
--------------------------------------------------------------------------------
|
19 |
|
|
library ieee;
|
20 |
|
|
use ieee.std_logic_1164.all;
|
21 |
|
|
use ieee.numeric_std.all;
|
22 |
|
|
|
23 |
|
|
entity ram is
|
24 |
|
|
port(
|
25 |
|
|
clk : in std_logic;
|
26 |
|
|
adrs : in std_logic_vector(11 downto 0);
|
27 |
|
|
adru : in std_logic_vector(11 downto 0);
|
28 |
|
|
we : in std_logic;
|
29 |
|
|
stb : in std_logic;
|
30 |
|
|
din : in std_logic_vector(15 downto 0);
|
31 |
|
|
chr : out std_logic_vector(7 downto 0);
|
32 |
|
|
fgc : out std_logic_vector(2 downto 0);
|
33 |
|
|
bgc : out std_logic_vector(2 downto 0);
|
34 |
|
|
datu : out std_logic_vector(15 downto 0);
|
35 |
|
|
ack : out std_logic
|
36 |
|
|
);
|
37 |
|
|
end ram;
|
38 |
|
|
|
39 |
|
|
architecture rtl of ram is
|
40 |
|
|
|
41 |
|
|
-- Two bits are obsolete, since character color is 6 bit information only.
|
42 |
|
|
-- However, this will not reduce the number of block rams, so we stick to
|
43 |
|
|
-- 8 bit color. The remaining 396 halfwords, can be used for something else.
|
44 |
|
|
type mem_t is array (0 to 4095) of std_logic_vector(15 downto 0);
|
45 |
|
|
|
46 |
|
|
signal mem : mem_t := ( others => (others => '0') );
|
47 |
|
|
|
48 |
|
|
attribute RAM_STYLE : string;
|
49 |
|
|
attribute RAM_STYLE of mem: signal is "BLOCK";
|
50 |
|
|
|
51 |
|
|
signal dat : std_logic_vector(15 downto 0);
|
52 |
|
|
signal acki : std_logic;
|
53 |
|
|
begin
|
54 |
|
|
|
55 |
|
|
reg : process(clk)
|
56 |
|
|
begin
|
57 |
|
|
if rising_edge(clk) then
|
58 |
|
|
acki <= '0';
|
59 |
|
|
if (stb = '1') and (we = '1') then
|
60 |
|
|
mem( to_integer(unsigned(adru)) ) <= din;
|
61 |
|
|
acki <= '1';
|
62 |
|
|
elsif (stb = '1') and (we = '0') then
|
63 |
|
|
acki <= '1';
|
64 |
|
|
end if;
|
65 |
|
|
dat <= mem( to_integer(unsigned(adrs)) );
|
66 |
|
|
datu <= mem( to_integer(unsigned(adru)) );
|
67 |
|
|
end if;
|
68 |
|
|
end process;
|
69 |
|
|
|
70 |
|
|
fgc <= dat(14 downto 12);
|
71 |
|
|
bgc <= dat(10 downto 8);
|
72 |
|
|
chr <= dat(7 downto 0);
|
73 |
|
|
ack <= acki;
|
74 |
|
|
end rtl;
|