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

Subversion Repositories vga_lcd

[/] [vga_lcd/] [tags/] [beta/] [wb_slave.vhd] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rherveille
--
2
-- file: wb_slave.vhd
3
-- project: VGA/LCD controller
4
-- author: Richard Herveille
5
-- rev.0.1 may 10th 2001
6
--
7
library ieee;
8
use ieee.std_logic_1164.all;
9
use ieee.std_logic_arith.all;
10
 
11
entity wb_slave is
12
        port (
13
                CLK_I : in std_logic;
14
                RST_I : in std_logic;
15
                NRESET : in std_logic;
16
                ADR_I : in unsigned(2 downto 0);
17
                DAT_I : in std_logic_vector(31 downto 0);
18
                DAT_O : out std_logic_vector(31 downto 0);
19
                SEL_I : in std_logic_vector(3 downto 0);
20
                WE_I : in std_logic;
21
                STB_I : in std_logic;
22
                CYC_I : in std_logic;
23
                ACK_O : out std_logic;
24
                ERR_O : out std_logic;
25
                INTA_O : out std_logic;
26
 
27
                -- control register settings
28
                BL : out std_logic;
29
                CSL : out std_logic;
30
                VSL : out std_logic;
31
                HSL : out std_logic;
32
                PC : out std_logic;
33
                CD : out std_logic_vector(1 downto 0);
34
                VBL : out std_logic_vector(1 downto 0);
35
                BSW : out std_logic;
36
                Ven : out std_logic;
37
 
38
                -- status register inputs
39
                AMP : in std_logic; -- active memory page
40
                bsint_in,
41
                hint_in,
42
                vint_in,
43
                luint_in,
44
                sint_in : in std_logic; -- interrupt request signals
45
 
46
                -- Horizontal Timing Register
47
                Thsync : out unsigned(7 downto 0);
48
                Thgdel : out unsigned(7 downto 0);
49
                Thgate : out unsigned(15 downto 0);
50
                Thlen : out unsigned(15 downto 0);
51
 
52
                -- Vertical Timing Register
53
                Tvsync : out unsigned(7 downto 0);
54
                Tvgdel : out unsigned(7 downto 0);
55
                Tvgate : out unsigned(15 downto 0);
56
                Tvlen : out unsigned(15 downto 0);
57
 
58
                VBARa,
59
                VBARb,
60
                CBAR : buffer unsigned(31 downto 0)
61
);
62
end entity wb_slave;
63
 
64
architecture structural of wb_slave is
65
        signal ctrl, stat, htim, vtim, hvlen : std_logic_vector(31 downto 0);
66
        signal HINT, VINT, BSINT, LUINT, SINT : std_logic;
67
        signal HIE, VIE, BSIE : std_logic;
68
        signal acc, acc32, reg_acc : std_logic;
69
begin
70
        acc     <= CYC_I and STB_I;
71
        acc32   <= SEL_I(3) and SEL_I(2) and SEL_I(1) and SEL_I(0);
72
        reg_acc <= acc and acc32 and WE_I;
73
        ACK_O   <= acc and acc32;
74
        ERR_O   <= acc and not acc32;
75
 
76
        gen_regs: process(CLK_I, nRESET)
77
        begin
78
                if (nReset = '0') then
79
                        ctrl  <= (others => '0');
80
                        htim  <= (others => '0');
81
                        vtim  <= (others => '0');
82
                        hvlen <= (others => '0');
83
                        VBARa <= (others => '0');
84
                        VBARb <= (others => '0');
85
                        CBAR  <= (others => '0');
86
                elsif(CLK_I'event and CLK_I = '1') then
87
                        if (RST_I = '1') then
88
                                ctrl  <= (others => '0');
89
                                htim  <= (others => '0');
90
                                vtim  <= (others => '0');
91
                                hvlen <= (others => '0');
92
                                VBARa <= (others => '0');
93
                                VBARb <= (others => '0');
94
                                CBAR  <= (others => '0');
95
                        elsif (reg_acc = '1') then
96
                                case ADR_I is
97
                                        when "000" => ctrl <= DAT_I;
98
                                        when "001" => null; -- status register (see gen_stat process)
99
                                        when "010" => htim <= DAT_I;
100
                                        when "011" => vtim <= DAT_I;
101
                                        when "100" => hvlen <= DAT_I;
102
                                        when "101" => VBARa <= unsigned(DAT_I);
103
                                        when "110" => VBARb <= unsigned(DAT_I);
104
                                        when "111" => CBAR <= unsigned(DAT_I);
105
 
106
                                        when others => null; -- should never happen
107
                                end case;
108
                        end if;
109
                end if;
110
        end process gen_regs;
111
 
112
        -- generate status register
113
        gen_stat: process(CLK_I, nRESET)
114
        begin
115
                if (nReset = '0') then
116
                        stat <= (others => '0');
117
                elsif(CLK_I'event and CLK_I = '1') then
118
                        if (RST_I = '1') then
119
                                stat <= (others => '0');
120
                        else
121
                                stat(16) <= AMP;
122
                                stat(6) <= bsint_in or (stat(6) and not (reg_acc and WE_I and DAT_I(6)) );
123
                                stat(5) <= hint_in  or (stat(5) and not (reg_acc and WE_I and DAT_I(5)) );
124
                                stat(4) <= vint_in  or (stat(4) and not (reg_acc and WE_I and DAT_I(4)) );
125
                                stat(1) <= luint_in or (stat(1) and not (reg_acc and WE_I and DAT_I(1)) );
126
                                stat(0) <= sint_in  or (stat(0) and not (reg_acc and WE_I and DAT_I(0)) );
127
                        end if;
128
                end if;
129
        end process gen_stat;
130
 
131
        -- decode control register
132
        BL   <= ctrl(15);
133
        CSL  <= ctrl(14);
134
        VSL  <= ctrl(13);
135
        HSL  <= ctrl(12);
136
        PC   <= ctrl(11);
137
        CD   <= ctrl(10 downto 9);
138
        VBL  <= ctrl(8 downto 7);
139
        BSW  <= ctrl(4);
140
        BSIE <= ctrl(3);
141
        HIE  <= ctrl(2);
142
        VIE  <= ctrl(1);
143
        Ven  <= ctrl(0);
144
 
145
        -- decode status register
146
        BSINT <= stat(6);
147
        HINT  <= stat(5);
148
        VINT  <= stat(4);
149
        LUINT <= stat(1);
150
        SINT  <= stat(0);
151
 
152
        -- decode Horizontal Timing Register
153
        Thsync <= unsigned(htim(31 downto 24));
154
        Thgdel <= unsigned(htim(23 downto 16));
155
        Thgate <= unsigned(htim(15 downto 0));
156
        Thlen  <= unsigned(hvlen(31 downto 16));
157
 
158
        -- decode Vertical Timing Register
159
        Tvsync <= unsigned(vtim(31 downto 24));
160
        Tvgdel <= unsigned(vtim(23 downto 16));
161
        Tvgate <= unsigned(vtim(15 downto 0));
162
        Tvlen  <= unsigned(hvlen(15 downto 0));
163
 
164
 
165
        -- assign output
166
        with ADR_I select
167
                DAT_O <= ctrl  when "000",
168
                         stat  when "001",
169
                         htim  when "010",
170
                         vtim  when "011",
171
                         hvlen when "100",
172
                         std_logic_vector(VBARa) when "101",
173
                         std_logic_vector(VBARb) when "110",
174
                         std_logic_vector(CBAR)  when others;
175
 
176
        -- generate interrupt request signal
177
        INTA_O <= (HINT and HIE) or (VINT and VIE) or (BSINT and BSIE) or LUINT or SINT;
178
end architecture structural;

powered by: WebSVN 2.1.0

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