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

Subversion Repositories wb_tk

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 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_in_reg is
25
    generic (
26
        reg_width : positive := 8;
27
        dat_width: positive := 8;
28
        offset: integer := 0
29
    );
30
    port (
31
        clk_i: in std_logic;
32
        rst_i: in std_logic;
33
 
34
        cyc_i: in std_logic := '1';
35
        stb_i: in std_logic;
36
        sel_i: in std_logic_vector (max2((dat_width/8)-1,0) downto 0) := (others => '1');
37
        we_i: in std_logic;
38
        ack_o: out std_logic;
39
        ack_oi: in std_logic := '-';
40
        adr_i: in std_logic_vector (size2bits((reg_width+offset+dat_width-1)/dat_width)-1 downto 0) := (others => '0');
41
        dat_oi: in std_logic_vector (dat_width-1 downto 0) := (others => '-');
42
        dat_o: out std_logic_vector (dat_width-1 downto 0);
43
        i: in std_logic_vector (reg_width-1 downto 0)
44
    );
45
end wb_in_reg;
46
 
47
architecture wb_in_reg of wb_in_reg is
48
    signal content : std_logic_vector (reg_width-1 downto 0);
49
    signal word_en: std_logic_vector ((reg_width / dat_width)-1 downto 0);
50
begin
51
    -- address demux
52
    adr_demux: process (adr_i)
53
    begin
54
        word_en <= (others => '0');
55
        --:::TA Possible problem: index range can be out of bounds at least accroding to XST
56
        word_en(to_integer(adr_i)) <= '1';
57
    end process;
58
 
59
    -- output bus handling with logic
60
    gen_dat_o: process(
61
        dat_oi, we_i, stb_i, content, word_en, cyc_i, sel_i
62
    )
63
        variable rd_sel: std_logic;
64
        variable dat_idx: integer;
65
    begin
66
        rd_sel := cyc_i and stb_i and not we_i;
67
 
68
        -- The default is the input, we'll override it if we need to
69
        for i in dat_o'RANGE loop
70
            dat_o(i) <= dat_oi(i);
71
        end loop;
72
        for i in content'RANGE loop
73
            dat_idx := (i+offset) mod dat_width;
74
            if (
75
--              (sel_i((i/8) mod (dat_width/8)) = '1') and
76
                (word_en(i/dat_width) = '1') and
77
                (rd_sel = '1')
78
            ) then
79
--              dat_o(dat_idx) <= (dat_oi(dat_idx) and not rd_sel) or (content(i) and rd_sel);
80
                dat_o(dat_idx) <= content(i);
81
            end if;
82
        end loop;
83
    end process;
84
--    dat_o <= dat_oi;
85
 
86
    -- this item never generates any wait-states
87
    ack_o <= stb_i or ack_oi;
88
 
89
    reg: process
90
    begin
91
        wait until clk_i'EVENT and clk_i='1';
92
        content <=  i;
93
    end process;
94
end wb_in_reg;

powered by: WebSVN 2.1.0

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