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

Subversion Repositories iicmb

[/] [iicmb/] [trunk/] [src/] [wishbone.vhd] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 sshuv2
 
2
--==============================================================================
3
--                                                                             |
4
--    Project: IIC Multiple Bus Controller (IICMB)                             |
5
--                                                                             |
6
--    Module:  Wishbone adapter.                                               |
7
--    Version:                                                                 |
8
--             1.0,   April 29, 2016                                           |
9
--                                                                             |
10
--    Author:  Sergey Shuvalkin, (sshuv2@opencores.org)                        |
11
--                                                                             |
12
--==============================================================================
13
--==============================================================================
14
-- Copyright (c) 2016, Sergey Shuvalkin                                        |
15
-- All rights reserved.                                                        |
16
--                                                                             |
17
-- Redistribution and use in source and binary forms, with or without          |
18
-- modification, are permitted provided that the following conditions are met: |
19
--                                                                             |
20
-- 1. Redistributions of source code must retain the above copyright notice,   |
21
--    this list of conditions and the following disclaimer.                    |
22
-- 2. Redistributions in binary form must reproduce the above copyright        |
23
--    notice, this list of conditions and the following disclaimer in the      |
24
--    documentation and/or other materials provided with the distribution.     |
25
--                                                                             |
26
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
27
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   |
28
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  |
29
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE    |
30
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR         |
31
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF        |
32
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS    |
33
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN     |
34
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)     |
35
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  |
36
-- POSSIBILITY OF SUCH DAMAGE.                                                 |
37
--==============================================================================
38
 
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
 
43
 
44
--==============================================================================
45
entity wishbone is
46
  port
47
  (
48
    ------------------------------------
49 3 sshuv2
    clk_i       : in    std_logic;                              -- Clock input
50
    rst_i       : in    std_logic;                              -- Synchronous reset (active high)
51 2 sshuv2
    ------------------------------------
52
    ------------------------------------
53
    -- Wishbone slave interface:
54 3 sshuv2
    cyc_i       : in    std_logic;                              -- Valid bus cycle indication
55
    stb_i       : in    std_logic;                              -- Slave selection
56
    ack_o       :   out std_logic;                              -- Acknowledge output
57
    adr_i       : in    std_logic_vector( 1 downto 0);          -- Low bits of Wishbone address
58
    we_i        : in    std_logic;                              -- Write enable
59
    dat_i       : in    std_logic_vector( 7 downto 0);          -- Data input
60
    dat_o       :   out std_logic_vector( 7 downto 0);          -- Data output
61 2 sshuv2
    ------------------------------------
62
    ------------------------------------
63
    -- Regblock interface:
64 3 sshuv2
    wr          :   out std_logic_vector( 3 downto 0);          -- Write (active high)
65
    rd          :   out std_logic_vector( 3 downto 0);          -- Read (active high)
66
    idata       :   out std_logic_vector(31 downto 0);          -- Data from System Bus
67
    odata       : in    std_logic_vector(31 downto 0)           -- Data to System Bus
68 2 sshuv2
    ------------------------------------
69
  );
70
end entity wishbone;
71
--==============================================================================
72
 
73
--==============================================================================
74
architecture rtl of wishbone is
75
 
76
  signal ack_o_y      : std_logic                    := '0';
77
  signal dat_o_y      : std_logic_vector(7 downto 0) := (others => '0');
78
 
79
begin
80
 
81
  ack_o   <= ack_o_y;
82
  dat_o   <= dat_o_y;
83
 
84
  ------------------------------------------------------------------------------
85
  ack_o_proc:
86
  process(clk_i)
87
  begin
88
    if rising_edge(clk_i) then
89
      if (rst_i = '1') then
90
        ack_o_y <= '0';
91
      else
92
        if (ack_o_y = '0') then
93
          ack_o_y <= stb_i and cyc_i;
94
        else
95
          ack_o_y <= '0';
96
        end if;
97
      end if;
98
    end if;
99
  end process ack_o_proc;
100
  ------------------------------------------------------------------------------
101
 
102
  wr(0) <= stb_i and cyc_i and     we_i  and not(ack_o_y) when (adr_i = "00") else '0';
103
  wr(1) <= stb_i and cyc_i and     we_i  and not(ack_o_y) when (adr_i = "01") else '0';
104
  wr(2) <= stb_i and cyc_i and     we_i  and not(ack_o_y) when (adr_i = "10") else '0';
105
  wr(3) <= stb_i and cyc_i and     we_i  and not(ack_o_y) when (adr_i = "11") else '0';
106
  rd(0) <= stb_i and cyc_i and not(we_i) and not(ack_o_y) when (adr_i = "00") else '0';
107
  rd(1) <= stb_i and cyc_i and not(we_i) and not(ack_o_y) when (adr_i = "01") else '0';
108
  rd(2) <= stb_i and cyc_i and not(we_i) and not(ack_o_y) when (adr_i = "10") else '0';
109
  rd(3) <= stb_i and cyc_i and not(we_i) and not(ack_o_y) when (adr_i = "11") else '0';
110
  idata <= dat_i & dat_i & dat_i & dat_i;
111
 
112
  ------------------------------------------------------------------------------
113
  dat_o_proc:
114
  process(clk_i)
115
  begin
116
    if rising_edge(clk_i) then
117
      if (rst_i = '1') then
118
        dat_o_y <= (others => '0');
119
      else
120
        case (adr_i) is
121
          when "00"   => dat_o_y <= odata( 7 downto  0);
122
          when "01"   => dat_o_y <= odata(15 downto  8);
123
          when "10"   => dat_o_y <= odata(23 downto 16);
124
          when others => dat_o_y <= odata(31 downto 24);
125
        end case;
126
      end if;
127
    end if;
128
  end process dat_o_proc;
129
  ------------------------------------------------------------------------------
130
 
131
end architecture rtl;
132
--==============================================================================
133
 

powered by: WebSVN 2.1.0

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