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

Subversion Repositories wb_vga

[/] [wb_vga/] [trunk/] [wb_tk/] [wb_out_reg.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 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_out_reg: Wishbone bus compatible output register.
10
 
11
-------------------------------------------------------------------------------
12
--
13
--  wb_out_reg
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_out_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
        );
47
end wb_out_reg;
48
 
49
architecture wb_out_reg of wb_out_reg is
50
        signal content : std_logic_vector (width-1 downto 0);
51
begin
52
        -- output bus handling with logic
53
        gen_dat_o: process is
54
                variable rd_sel: std_logic;
55
            variable adr: integer;
56
            variable reg_i: integer;
57
        begin
58
                wait on dat_oi, we_i, stb_i, content, adr_i, cyc_i, sel_i;
59
                rd_sel := cyc_i and stb_i and not we_i;
60
            for i in dat_i'RANGE loop
61
                adr := CONV_INTEGER(adr_i);
62
                reg_i := i-offset+adr*bus_width;
63
                if ((reg_i >= 0) and (reg_i < width) and (sel_i(i/8) = '1')) then
64
                                dat_o(i) <= (dat_oi(i) and not rd_sel) or (content(reg_i) and rd_sel);
65
                        else
66
                                dat_o(i) <= dat_oi(i);
67
                        end if;
68
                end loop;
69
        end process;
70
 
71
        -- this item never generates any wait-states    
72
        ack_o <= stb_i or ack_oi;
73
 
74
        reg: process is
75
            variable adr: integer;
76
            variable reg_i: integer;
77
        begin
78
                wait until clk_i'EVENT and clk_i='1';
79
                if (rst_i = '1') then
80
                        content <= rst_val;
81
                else
82
                        if (stb_i = '1' and cyc_i = '1' and we_i = '1') then
83
                            for i in dat_i'RANGE loop
84
                                adr := CONV_INTEGER(adr_i);
85
                                reg_i := i-offset+adr*bus_width;
86
                                if ((reg_i >= 0) and (reg_i < width) and (sel_i(i/8) = '1')) then
87
                                        content(reg_i) <=  dat_i(i);
88
                                    end if;
89
                                end loop;
90
                        end if;
91
                end if;
92
        end process;
93
        q <= content;
94
end wb_out_reg;

powered by: WebSVN 2.1.0

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