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

Subversion Repositories wb_vga

[/] [wb_vga/] [trunk/] [wb_io_reg.vhd] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 tantos
--
2
--  Wishbone bus toolkit.
3
--
4
--  (c) Copyright Andras Tantos <andras_tantos@yahoo.com> 2001/03/31
5
--  This code is distributed under the terms and conditions of the GNU General Public Lince.
6
--
7
--
8
-- ELEMENTS:
9
--   wb_io_reg: A slightly modified version of the wb_out_reg component
10
 
11
-------------------------------------------------------------------------------
12
--
13
--  wb_io_reg. A slightly modified version of the wb_out_reg component
14
--
15
-------------------------------------------------------------------------------
16
 
17
library IEEE;
18
use IEEE.std_logic_1164.all;
19
use IEEE.STD_LOGIC_UNSIGNED.all;
20
 
21
library wb_tk;
22
use wb_tk.technology.all;
23
 
24
entity wb_io_reg is
25
        generic (
26
                width : positive := 8;
27
                bus_width: positive := 8;
28
                offset: integer := 0
29
        );
30
        port (
31
                clk_i: in std_logic;
32
                rst_i: in std_logic;
33
                rst_val: std_logic_vector(width-1 downto 0) := (others => '0');
34
 
35
        cyc_i: in std_logic := '1';
36
                stb_i: in std_logic;
37
        sel_i: in std_logic_vector ((bus_width/8)-1 downto 0) := (others => '1');
38
                we_i: in std_logic;
39
                ack_o: out std_logic;
40
                ack_oi: in std_logic := '-';
41
                adr_i: in std_logic_vector (size2bits((width+offset+bus_width-1)/bus_width)-1 downto 0) := (others => '0');
42
                dat_i: in std_logic_vector (bus_width-1 downto 0);
43
                dat_oi: in std_logic_vector (bus_width-1 downto 0) := (others => '-');
44
                dat_o: out std_logic_vector (bus_width-1 downto 0);
45
                q: out std_logic_vector (width-1 downto 0);
46
                ext_d: in std_logic_vector (width-1 downto 0) := (others => '-');
47
                ext_we: in std_logic := '0'
48
        );
49
end wb_io_reg;
50
 
51
architecture wb_io_reg of wb_io_reg is
52
        signal content : std_logic_vector (width-1 downto 0);
53
begin
54
        -- output bus handling with logic
55
        gen_dat_o: process is
56
                variable rd_sel: std_logic;
57
            variable adr: integer;
58
            variable reg_i: integer;
59
        begin
60
                wait on dat_oi, we_i, stb_i, content, adr_i, cyc_i, sel_i;
61
                rd_sel := cyc_i and stb_i and not we_i;
62
            for i in dat_i'RANGE loop
63
                adr := CONV_INTEGER(adr_i);
64
                reg_i := i-offset+adr*bus_width;
65
                if ((reg_i >= 0) and (reg_i < width) and (sel_i(i/8) = '1')) then
66
                                dat_o(i) <= (dat_oi(i) and not rd_sel) or (content(reg_i) and rd_sel);
67
                        else
68
                                dat_o(i) <= dat_oi(i);
69
                        end if;
70
                end loop;
71
        end process;
72
 
73
        -- this item never generates any wait-states unless an external write is under process
74
--      ack_o <= (stb_i or ack_oi) and (not (ext_we and we_i));
75
        ack_o <= (ack_oi and not stb_i) or ((not (ext_we and we_i)) and stb_i);
76
--      ack_o <= (stb_i or ack_oi);
77
 
78
        reg: process is
79
            variable adr: integer;
80
            variable reg_i: integer;
81
        begin
82
                wait until clk_i'EVENT and clk_i='1';
83
                if (rst_i = '1') then
84
                        content <= rst_val;
85
                else
86
                        if (ext_we = '1') then
87
                        content <= ext_d;
88
                        else
89
                                if (stb_i = '1' and cyc_i = '1' and we_i = '1') then
90
                                    for i in dat_i'RANGE loop
91
                                        adr := CONV_INTEGER(adr_i);
92
                                        reg_i := i-offset+adr*bus_width;
93
                                        if ((reg_i >= 0) and (reg_i < width) and (sel_i(i/8) = '1')) then
94
                                                content(reg_i) <=  dat_i(i);
95
                                            end if;
96
                                        end loop;
97
                                end if;
98
                        end if;
99
                end if;
100
        end process;
101
        q <= content;
102
end wb_io_reg;
103
 
104
 

powered by: WebSVN 2.1.0

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