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

Subversion Repositories wishbone_bfm

[/] [wishbone_bfm/] [trunk/] [rtl/] [wb_master.vhd] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 amulcock
-------------------------------------------------------------------------------
2
----                                                                       ----
3 10 amulcock
---- WISHBONE Wishbone_BFM IP Core                                         ----
4 2 amulcock
----                                                                       ----
5 10 amulcock
---- This file is part of the Wishbone_BFM project                         ----
6
---- http://www.opencores.org/cores/Wishbone_BFM/                          ----
7 2 amulcock
----                                                                       ----
8
---- Description                                                           ----
9 10 amulcock
---- Implementation of Wishbone_BFM IP core according to                   ----
10
---- Wishbone_BFM IP core specification document.                          ----
11 2 amulcock
----                                                                       ----
12
---- To Do:                                                                ----
13
----    NA                                                                 ----
14
----                                                                       ----
15
---- Author(s):                                                            ----
16
----   Andrew Mulcock, amulcock@opencores.org                              ----
17
----                                                                       ----
18
-------------------------------------------------------------------------------
19
----                                                                       ----
20
---- Copyright (C) 2008 Authors and OPENCORES.ORG                          ----
21
----                                                                       ----
22
---- This source file may be used and distributed without                  ----
23
---- restriction provided that this copyright statement is not             ----
24
---- removed from the file and that any derivative work contains           ----
25
---- the original copyright notice and the associated disclaimer.          ----
26
----                                                                       ----
27
---- This source file is free software; you can redistribute it            ----
28
---- and/or modify it under the terms of the GNU Lesser General            ----
29
---- Public License as published by the Free Software Foundation           ----
30
---- either version 2.1 of the License, or (at your option) any            ----
31
---- later version.                                                        ----
32
----                                                                       ----
33
---- This source is distributed in the hope that it will be                ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied            ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR               ----
36
---- PURPOSE. See the GNU Lesser General Public License for more           ----
37
---- details.                                                              ----
38
----                                                                       ----
39
---- You should have received a copy of the GNU Lesser General             ----
40
---- Public License along with this source; if not, download it            ----
41
---- from http://www.opencores.org/lgpl.shtml                              ----
42
----                                                                       ----
43
-------------------------------------------------------------------------------
44
----                                                                       ----
45
-- CVS Revision History                                                    ----
46
----                                                                       ----
47
-- $Log: not supported by cvs2svn $                                                                   ----
48
----                                                                       ----
49
 
50
 
51
-- file to 'exercise' the Wishbone bus.
52
--
53
--  Idea is to look like a wishbone master, 
54
--   and provide procedures to exercise the bus.
55
--
56
--  syscon is an external module that provides the reset and clocks 
57
--   to all the other modules in the design.
58
--
59
--  to enable the test script in this master to control
60
--   the syscon reset and clock stop,
61
--    this master provides tow 'extra' outputs
62
--   rst_i and clk_stop
63
--
64
--    when rst_sys is high, then syscon will issue a reset
65
--    when clk_stop is high, then syscon will stop the clock
66
--     on the next low transition. i.e. stopped clock is low.
67
 
68
use work.io_pack.all;
69
 
70
library ieee;
71
use ieee.std_logic_1164.all;
72 8 amulcock
use ieee.std_logic_textio.all;
73
 
74 2 amulcock
-- --------------------------------------------------------------------
75
-- --------------------------------------------------------------------
76
 
77
entity wb_master is
78
    port(
79
    -- sys_con control ports
80
    RST_sys    : out  std_logic;
81
    CLK_stop   : out  std_logic;
82
 
83
    -- WISHBONE master interface:
84
    RST_I   : in    std_logic;
85
    CLK_I   : in    std_logic;
86
 
87
    ADR_O   : out   std_logic_vector( 31 downto 0 );
88
    DAT_I   : in    std_logic_vector( 31 downto 0 );
89
    DAT_O   : out   std_logic_vector( 31 downto 0 );
90
    WE_O    : out   std_logic;
91
 
92
    STB_O   : out   std_logic;
93
    CYC_O   : out   std_logic;
94
    ACK_I   : in    std_logic;
95
    ERR_I   : in    std_logic;
96
    RTY_I   : in    std_logic;
97
 
98
    LOCK_O  : out   std_logic;
99
    SEL_O   : out   std_logic_vector( 3 downto 0 );
100
 
101
    CYCLE_IS : out cycle_type
102
    );
103
end entity wb_master;
104
 
105
-- --------------------------------------------------------------------
106
architecture Behavioral of wb_master is
107
-- --------------------------------------------------------------------
108
 
109
signal reset_int    : std_logic;
110
 
111 12 amulcock
 
112 2 amulcock
-- --------------------------------------------------------------------
113
begin
114
-- --------------------------------------------------------------------
115
 
116
-- concurrent assignemente to map record to the wishbone bus
117
 
118
ADR_O   <= bus_c.add_o;   -- address bus out of master
119
DAT_O   <= bus_c.dat_o;   -- data bus out of master
120
WE_O    <= bus_c.we;      -- wite enable out of master
121
STB_O   <= bus_c.stb;     -- wishbone strobe out of master
122
CYC_O   <= bus_c.cyc;     -- wishbone cycle out of master
123
LOCK_O  <= bus_c.lock;    -- wishbone Lock out of master
124
SEL_O   <= bus_c.sel;     -- slelects which of the 4 bytes to use for 32 bit
125
CYCLE_IS <= bus_c.c_type; -- monitor output, to know what master is up to
126
 
127
bus_c.dat_i <= DAT_I;
128
bus_c.ack   <= ACK_I;
129
bus_c.err   <= ERR_I;
130
bus_c.rty   <= RTY_I;
131
bus_c.clk   <= CLK_I;
132
 
133
 
134
-- concurent signal as can't pass out port to procedure ?
135
RST_sys <= reset_int;
136
 
137
-- --------------------------------------------------------------------
138
test_loop : process
139 8 amulcock
 
140
-- need to use variables to get 'data' down from the procedures,
141
--  if we used a signal, then we get the value after the clock edge, 
142
--   which is not what we want, we need the value at the clock edge.
143
--
144
variable slv_32       : std_logic_vector( 31 downto 0);
145
 
146 12 amulcock
variable bka_test_array : block_type :=
147
    ( others => x"0000_0000");
148
variable bkd_test_array : block_type :=
149
    ( others => x"0000_0000");
150 8 amulcock
 
151 12 amulcock
 
152
 
153
 
154 2 amulcock
begin
155
 
156
                -- Wait 100 ns for global reset to finish
157
                wait for 100 ns;
158
 
159
--clock_wait( 2, bus_c );
160
 
161
 
162
wb_init( bus_c);        -- initalise wishbone bus
163
wb_rst( 2, reset_int, bus_c ); -- reset system for 2 clocks
164
 
165 12 amulcock
-- set up some address / data pairs
166
bka_test_array(0) := X"0000_0002";
167
bkd_test_array(0) := X"5555_0002";
168 2 amulcock
 
169 12 amulcock
bka_test_array(1) := X"0000_0004";
170
bkd_test_array(1) := X"55AA_0004";
171 2 amulcock
 
172 12 amulcock
bka_test_array(2) := X"0000_0006";
173
bkd_test_array(2) := X"AAAA_0006";
174 2 amulcock
 
175 10 amulcock
 
176 12 amulcock
bkw_32( bka_test_array, bkd_test_array, 3, bus_c);
177 10 amulcock
 
178 12 amulcock
clock_wait( 1, bus_c );
179 10 amulcock
 
180 12 amulcock
bkr_32( bka_test_array, bkd_test_array, 3, bus_c);
181 10 amulcock
 
182 12 amulcock
report to_hex(bkd_test_array(0));
183
report to_hex(bkd_test_array(1));
184
report to_hex(bkd_test_array(2));
185 10 amulcock
 
186 12 amulcock
--
187
--wr_32( x"8000_0004", x"5555_5555", bus_c);  -- write 32 bits address of 32 bit data
188
--
189
--rd_32( x"8000_0004", slv_32, bus_c);  -- read 32 bits address of 32 bit data
190
--report to_hex( slv_32);
191
--
192
--clock_wait( 2, bus_c );
193
--
194
--rmw_32( x"8000_0004", slv_32, x"ABCD_EF01", bus_c ); 
195
--report to_hex( slv_32);
196
--
197
--clock_wait( 2, bus_c );
198
--
199
--rmw_32( x"8000_0004", slv_32, x"01CD_EFAB", bus_c ); 
200
--report to_hex( slv_32);
201
--
202 10 amulcock
 
203 12 amulcock
 
204 6 amulcock
clock_wait( 1, bus_c );
205 2 amulcock
wb_rst( 2, reset_int, bus_c ); -- reset system for 2 clocks
206
 
207
 
208
 
209
 
210
 
211
 
212
-- --------------------------------------------------------------------
213
-- and stop the test running
214
-- --------------------------------------------------------------------
215
 
216
CLK_stop <= '1';
217
wait;
218
 
219
end process test_loop;
220
 
221
 
222
 
223
 
224
 
225
-- --------------------------------------------------------------------
226
end architecture Behavioral;
227
-- --------------------------------------------------------------------

powered by: WebSVN 2.1.0

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