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

Subversion Repositories wb4pb

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

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 31 ste.fis
--    and/or other materials provided with the distribution.
17 2 ste.fis
--
18
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
19
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
20
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
21
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
22
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
23
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
24
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
25
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
26
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
27
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
28
-- POSSIBILITY OF SUCH DAMAGE.
29
--
30
--------------------------------------------------------------------------------
31
-- filename: wbm_picoblaze.vhd
32
-- description: synthesizable wishbone master adapter for PicoBlaze (TM),
33
--              working together with "wb_wr" and "wb_rd" assembler subroutines
34
-- todo4user: module should not be changed!
35
-- version: 0.0.0
36
-- changelog: - 0.0.0, initial release
37
--            - ...
38
--------------------------------------------------------------------------------
39
 
40
 
41
library ieee;
42
use ieee.std_logic_1164.all;
43
 
44
 
45
entity wbm_picoblaze is
46
  port
47
  (
48
    rst : in std_logic;
49
    clk : in std_logic;
50
 
51
    wbm_cyc_o : out std_logic;
52
    wbm_stb_o : out std_logic;
53
    wbm_we_o : out std_logic;
54
    wbm_adr_o : out std_logic_vector(7 downto 0);
55
    wbm_dat_m2s_o : out std_logic_vector(7 downto 0);
56
    wbm_dat_s2m_i : in std_logic_vector(7 downto 0);
57
    wbm_ack_i : in std_logic;
58
 
59
    pb_port_id_i : in std_logic_vector(7 downto 0);
60
    pb_write_strobe_i : in std_logic;
61
    pb_out_port_i : in std_logic_vector(7 downto 0);
62
    pb_read_strobe_i : in std_logic;
63
    pb_in_port_o : out std_logic_vector(7 downto 0)
64
  );
65
end wbm_picoblaze;
66
 
67
 
68
architecture rtl of wbm_picoblaze is
69
 
70
  signal wbm_cyc : std_logic := '0';
71
  signal wbm_stb : std_logic := '0';
72
  signal wbm_we : std_logic := '0';
73
  signal wbm_adr : std_logic_vector(7 downto 0) := (others => '0');
74
  signal wbm_dat_m2s : std_logic_vector(7 downto 0) := (others => '0');
75
 
76
  signal pb_in_port : std_logic_vector(7 downto 0) := (others => '0');
77
 
78
  signal wb_buffer : std_logic_vector(7 downto 0) := (others => '0');
79
 
80
  constant WB_ACK_FLAG : std_logic_vector(7 downto 0) := x"01";
81
 
82
  type t_states is
83
  (
84
    S_IDLE,
85
    S_WAIT_ON_WB_ACK,
86
    S_SOFTWARE_HANDSHAKE,
87
    S_SOFTWARE_READ
88
  );
89
  signal state : t_states := S_IDLE;
90
 
91
begin
92
 
93
  wbm_cyc_o <= wbm_cyc;
94
  wbm_stb_o <= wbm_stb;
95
  wbm_we_o <= wbm_we;
96
  wbm_adr_o <= wbm_adr;
97
  wbm_dat_m2s_o <= wbm_dat_m2s;
98
 
99
  pb_in_port_o <= pb_in_port;
100
 
101
  wbm_cyc <= wbm_stb;
102
 
103
  process(clk)
104
  begin
105
    if clk'event and clk = '1' then
106
 
107
      case state is
108
        when S_IDLE =>
109
          -- setting up wishbone address, data and control signals from 
110
          -- PicoBlaze (TM) signals
111
          if pb_write_strobe_i = '1' then
112
            wbm_stb <= '1';
113
            wbm_we <= '1';
114
            wbm_adr <= pb_port_id_i;
115
            wbm_dat_m2s <= pb_out_port_i;
116
            state <= S_WAIT_ON_WB_ACK;
117
          elsif pb_read_strobe_i = '1' then
118
            wbm_stb <= '1';
119
            wbm_we <= '0';
120
            wbm_adr <= pb_port_id_i;
121
            state <= S_WAIT_ON_WB_ACK;
122
          end if;
123
        when S_WAIT_ON_WB_ACK =>
124
          -- waiting on slave peripheral to complete wishbone transfer cycle
125
          if wbm_ack_i = '1' then
126
            wbm_stb <= '0';
127
            wb_buffer <= wbm_dat_s2m_i;
128
            pb_in_port <= WB_ACK_FLAG;
129
            state <= S_SOFTWARE_HANDSHAKE;
130
          end if;
131
        when S_SOFTWARE_HANDSHAKE =>
132
          -- software recognition of wishbone handshake
133
          if pb_read_strobe_i = '1' then
134
            -- transfer complete for a write access
135
            if wbm_we = '1' then
136
              pb_in_port <= (others => '0');
137
              state <= S_IDLE;
138
            -- presenting valid wishbone data to PicoBlaze (TM) port in read 
139
            -- access
140
            else
141
              pb_in_port <= wb_buffer;
142
              state <= S_SOFTWARE_READ;
143
            end if;
144
          end if;
145
        when S_SOFTWARE_READ =>
146
          -- transfer complete for a read access after software recognition of
147
          -- wishbone data
148
          if pb_read_strobe_i = '1' then
149
            pb_in_port <= (others => '0');
150
            state <= S_IDLE;
151
          end if;
152
        when others => null;
153
      end case;
154
 
155
      if rst = '1' then
156
        wbm_stb <= '0';
157
        pb_in_port <= (others => '0');
158
        state <= S_IDLE;
159
      end if;
160
 
161
    end if;
162
  end process;
163
 
164
end rtl;

powered by: WebSVN 2.1.0

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