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

Subversion Repositories wb4pb

[/] [wb4pb/] [trunk/] [rtl/] [wbm_picoblaze.vhd] - Blame information for rev 18

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

Line No. Rev Author Line
1 2 ste.fis
--------------------------------------------------------------------------------
2
-- This sourcecode is released under BSD license.
3
-- Please see http://www.opensource.org/licenses/bsd-license.php for details!
4
--------------------------------------------------------------------------------
5
--
6
-- Copyright (c) 2010, Stefan Fischer <Ste.Fis@OpenCores.org>
7
-- All rights reserved.
8
--
9
-- Redistribution and use in source and binary forms, with or without 
10
-- modification, are permitted provided that the following conditions are met:
11
--
12
--  * Redistributions of source code must retain the above copyright notice, 
13
--    this list of conditions and the following disclaimer.
14
--  * Redistributions in binary form must reproduce the above copyright notice,
15
--    this list of conditions and the following disclaimer in the documentation
16
--    and/or other materials provided with the distribution. 
17
--  * Neither the name of the author nor the names of his contributors may be 
18
--    used to endorse or promote products derived from this software without 
19
--    specific prior written permission.
20
--
21
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
22
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
23
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
24
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
25
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
26
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
27
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
28
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
29
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
30
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
31
-- POSSIBILITY OF SUCH DAMAGE.
32
--
33
--------------------------------------------------------------------------------
34
-- filename: wbm_picoblaze.vhd
35
-- description: synthesizable wishbone master adapter for PicoBlaze (TM),
36
--              working together with "wb_wr" and "wb_rd" assembler subroutines
37
-- todo4user: module should not be changed!
38
-- version: 0.0.0
39
-- changelog: - 0.0.0, initial release
40
--            - ...
41
--------------------------------------------------------------------------------
42
 
43
 
44
library ieee;
45
use ieee.std_logic_1164.all;
46
 
47
 
48
entity wbm_picoblaze is
49
  port
50
  (
51
    rst : in std_logic;
52
    clk : in std_logic;
53
 
54
    wbm_cyc_o : out std_logic;
55
    wbm_stb_o : out std_logic;
56
    wbm_we_o : out std_logic;
57
    wbm_adr_o : out std_logic_vector(7 downto 0);
58
    wbm_dat_m2s_o : out std_logic_vector(7 downto 0);
59
    wbm_dat_s2m_i : in std_logic_vector(7 downto 0);
60
    wbm_ack_i : in std_logic;
61
 
62
    pb_port_id_i : in std_logic_vector(7 downto 0);
63
    pb_write_strobe_i : in std_logic;
64
    pb_out_port_i : in std_logic_vector(7 downto 0);
65
    pb_read_strobe_i : in std_logic;
66
    pb_in_port_o : out std_logic_vector(7 downto 0)
67
  );
68
end wbm_picoblaze;
69
 
70
 
71
architecture rtl of wbm_picoblaze is
72
 
73
  signal wbm_cyc : std_logic := '0';
74
  signal wbm_stb : std_logic := '0';
75
  signal wbm_we : std_logic := '0';
76
  signal wbm_adr : std_logic_vector(7 downto 0) := (others => '0');
77
  signal wbm_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
78
 
79
  signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
80
 
81
  signal wb_buffer : std_logic_vector(7 downto 0) := (others => '0');
82
 
83
  constant WB_ACK_FLAG : std_logic_vector(7 downto 0) := x"01";
84
 
85
  type t_states is
86
  (
87
    S_IDLE,
88
    S_WAIT_ON_WB_ACK,
89
    S_SOFTWARE_HANDSHAKE,
90
    S_SOFTWARE_READ
91
  );
92
  signal state : t_states := S_IDLE;
93
 
94
begin
95
 
96
  wbm_cyc_o <= wbm_cyc;
97
  wbm_stb_o <= wbm_stb;
98
  wbm_we_o <= wbm_we;
99
  wbm_adr_o <= wbm_adr;
100
  wbm_dat_m2s_o <= wbm_dat_m2s;
101
 
102
  pb_in_port_o <= pb_in_port;
103
 
104
  wbm_cyc <= wbm_stb;
105
 
106
  process(clk)
107
  begin
108
    if clk'event and clk = '1' then
109
 
110
      case state is
111
        when S_IDLE =>
112
          -- setting up wishbone address, data and control signals from 
113
          -- PicoBlaze (TM) signals
114
          if pb_write_strobe_i = '1' then
115
            wbm_stb <= '1';
116
            wbm_we <= '1';
117
            wbm_adr <= pb_port_id_i;
118
            wbm_dat_m2s <= pb_out_port_i;
119
            state <= S_WAIT_ON_WB_ACK;
120
          elsif pb_read_strobe_i = '1' then
121
            wbm_stb <= '1';
122
            wbm_we <= '0';
123
            wbm_adr <= pb_port_id_i;
124
            state <= S_WAIT_ON_WB_ACK;
125
          end if;
126
        when S_WAIT_ON_WB_ACK =>
127
          -- waiting on slave peripheral to complete wishbone transfer cycle
128
          if wbm_ack_i = '1' then
129
            wbm_stb <= '0';
130
            wb_buffer <= wbm_dat_s2m_i;
131
            pb_in_port <= WB_ACK_FLAG;
132
            state <= S_SOFTWARE_HANDSHAKE;
133
          end if;
134
        when S_SOFTWARE_HANDSHAKE =>
135
          -- software recognition of wishbone handshake
136
          if pb_read_strobe_i = '1' then
137
            -- transfer complete for a write access
138
            if wbm_we = '1' then
139
              pb_in_port <= (others => '0');
140
              state <= S_IDLE;
141
            -- presenting valid wishbone data to PicoBlaze (TM) port in read 
142
            -- access
143
            else
144
              pb_in_port <= wb_buffer;
145
              state <= S_SOFTWARE_READ;
146
            end if;
147
          end if;
148
        when S_SOFTWARE_READ =>
149
          -- transfer complete for a read access after software recognition of
150
          -- wishbone data
151
          if pb_read_strobe_i = '1' then
152
            pb_in_port <= (others => '0');
153
            state <= S_IDLE;
154
          end if;
155
        when others => null;
156
      end case;
157
 
158
      if rst = '1' then
159
        wbm_stb <= '0';
160
        pb_in_port <= (others => '0');
161
        state <= S_IDLE;
162
      end if;
163
 
164
    end if;
165
  end process;
166
 
167
end rtl;

powered by: WebSVN 2.1.0

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