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

Subversion Repositories wb_tk

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

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_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 6 tantos
                reg_width : positive := 8;
27
                dat_width: positive := 8;
28 4 tantos
                offset: integer := 0
29
        );
30
        port (
31
                clk_i: in std_logic;
32
                rst_i: in std_logic;
33 6 tantos
                rst_val: std_logic_vector(reg_width-1 downto 0) := (others => '0');
34 4 tantos
 
35 6 tantos
                cyc_i: in std_logic := '1';
36 4 tantos
                stb_i: in std_logic;
37 6 tantos
                sel_i: in std_logic_vector (max2((dat_width/8)-1,0) downto 0) := (others => '1');
38 4 tantos
                we_i: in std_logic;
39
                ack_o: out std_logic;
40
                ack_oi: in std_logic := '-';
41 6 tantos
                adr_i: in std_logic_vector (size2bits((reg_width+offset+dat_width-1)/dat_width)-1 downto 0) := (others => '0');
42
                dat_i: in std_logic_vector (dat_width-1 downto 0);
43
                dat_oi: in std_logic_vector (dat_width-1 downto 0) := (others => '-');
44
                dat_o: out std_logic_vector (dat_width-1 downto 0);
45
                q: out std_logic_vector (reg_width-1 downto 0)
46 4 tantos
        );
47
end wb_out_reg;
48
 
49
architecture wb_out_reg of wb_out_reg is
50 6 tantos
        signal content : std_logic_vector (reg_width-1 downto 0);
51
        signal word_en: std_logic_vector ((reg_width / dat_width)-1 downto 0);
52 4 tantos
begin
53 6 tantos
    -- address demux
54
    adr_demux: process (adr_i)
55
    begin
56
        word_en <= (others => '0');
57
        word_en(to_integer(adr_i)) <= '1';
58
    end process;
59
 
60 4 tantos
        -- output bus handling with logic
61 6 tantos
        gen_dat_o: process(
62
                dat_oi, we_i, stb_i, content, word_en, cyc_i, sel_i
63
        )
64 4 tantos
                variable rd_sel: std_logic;
65 6 tantos
                variable dat_idx: integer;
66 4 tantos
        begin
67 6 tantos
        rd_sel := cyc_i and stb_i and not we_i;
68
 
69
                -- The default is the input, we'll override it if we need to
70
                for i in dat_o'RANGE loop
71
                dat_o(i) <= dat_oi(i);
72
                end loop;
73
                for i in content'RANGE loop
74
                    dat_idx := (i+offset) mod dat_width;
75
                        if (
76
--                          (sel_i((i/8) mod (dat_width/8)) = '1') and
77
                            (word_en(i/dat_width) = '1') and
78
                            (rd_sel = '1')
79
                        ) then
80
--                              dat_o(dat_idx) <= (dat_oi(dat_idx) and not rd_sel) or (content(i) and rd_sel);
81
                                dat_o(dat_idx) <= content(i);
82 4 tantos
                        end if;
83
                end loop;
84
        end process;
85 6 tantos
--    dat_o <= dat_oi;
86 4 tantos
 
87 6 tantos
        -- this item never generates any wait-states
88 4 tantos
        ack_o <= stb_i or ack_oi;
89 6 tantos
 
90
        reg: process
91
                variable dat_idx: integer;
92 4 tantos
        begin
93
                wait until clk_i'EVENT and clk_i='1';
94
                if (rst_i = '1') then
95
                        content <= rst_val;
96 6 tantos
                else
97 4 tantos
                        if (stb_i = '1' and cyc_i = '1' and we_i = '1') then
98 6 tantos
                                for i in content'RANGE loop
99
                                    dat_idx := (i+offset) mod dat_width;
100
                                        if (
101
--                                          (sel_i((i/8) mod (dat_width/8)) = '1') and
102
                                            (word_en(i/dat_width) = '1')
103
                                        ) then
104
                                                content(i) <=  dat_i(dat_idx);
105
                                        end if;
106 4 tantos
                                end loop;
107
                        end if;
108
                end if;
109
        end process;
110
        q <= content;
111
end wb_out_reg;

powered by: WebSVN 2.1.0

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