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 2

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

Line No. Rev Author Line
1 2 amulcock
-------------------------------------------------------------------------------
2
----                                                                       ----
3
---- WISHBONE XXX IP Core                                                  ----
4
----                                                                       ----
5
---- This file is part of the XXX project                                                          ----
6
---- http://www.opencores.org/cores/xxx/                                                   ----
7
----                                                                       ----
8
---- Description                                                           ----
9
---- Implementation of XXX IP core according to                            ----
10
---- XXX IP core specification document.                                   ----
11
----                                                                       ----
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
-- --------------------------------------------------------------------
73
-- --------------------------------------------------------------------
74
 
75
entity wb_master is
76
    port(
77
    -- sys_con control ports
78
    RST_sys    : out  std_logic;
79
    CLK_stop   : out  std_logic;
80
 
81
    -- WISHBONE master interface:
82
    RST_I   : in    std_logic;
83
    CLK_I   : in    std_logic;
84
 
85
    ADR_O   : out   std_logic_vector( 31 downto 0 );
86
    DAT_I   : in    std_logic_vector( 31 downto 0 );
87
    DAT_O   : out   std_logic_vector( 31 downto 0 );
88
    WE_O    : out   std_logic;
89
 
90
    STB_O   : out   std_logic;
91
    CYC_O   : out   std_logic;
92
    ACK_I   : in    std_logic;
93
    ERR_I   : in    std_logic;
94
    RTY_I   : in    std_logic;
95
 
96
    LOCK_O  : out   std_logic;
97
    SEL_O   : out   std_logic_vector( 3 downto 0 );
98
 
99
    CYCLE_IS : out cycle_type
100
    );
101
end entity wb_master;
102
 
103
-- --------------------------------------------------------------------
104
architecture Behavioral of wb_master is
105
-- --------------------------------------------------------------------
106
 
107
signal reset_int    : std_logic;
108
signal slv_32       : std_logic_vector( 31 downto 0);
109
 
110
-- --------------------------------------------------------------------
111
begin
112
-- --------------------------------------------------------------------
113
 
114
-- concurrent assignemente to map record to the wishbone bus
115
 
116
ADR_O   <= bus_c.add_o;   -- address bus out of master
117
DAT_O   <= bus_c.dat_o;   -- data bus out of master
118
WE_O    <= bus_c.we;      -- wite enable out of master
119
STB_O   <= bus_c.stb;     -- wishbone strobe out of master
120
CYC_O   <= bus_c.cyc;     -- wishbone cycle out of master
121
LOCK_O  <= bus_c.lock;    -- wishbone Lock out of master
122
SEL_O   <= bus_c.sel;     -- slelects which of the 4 bytes to use for 32 bit
123
CYCLE_IS <= bus_c.c_type; -- monitor output, to know what master is up to
124
 
125
bus_c.dat_i <= DAT_I;
126
bus_c.ack   <= ACK_I;
127
bus_c.err   <= ERR_I;
128
bus_c.rty   <= RTY_I;
129
bus_c.clk   <= CLK_I;
130
 
131
 
132
-- concurent signal as can't pass out port to procedure ?
133
RST_sys <= reset_int;
134
 
135
-- --------------------------------------------------------------------
136
test_loop : process
137
begin
138
 
139
                -- Wait 100 ns for global reset to finish
140
                wait for 100 ns;
141
 
142
--clock_wait( 2, bus_c );
143
 
144
 
145
wb_init( bus_c);        -- initalise wishbone bus
146
wb_rst( 2, reset_int, bus_c ); -- reset system for 2 clocks
147
 
148
wr_32( x"8000_0001", x"5555_5555", bus_c);  -- write 32 bits address of 32 bit data
149
 
150
clock_wait( 1, bus_c );
151
 
152
rd_32( x"8000_0004", slv_32, bus_c);  -- read 32 bits address of 32 bit data
153
 
154
 
155
clock_wait( 5, bus_c );
156
wb_rst( 2, reset_int, bus_c ); -- reset system for 2 clocks
157
 
158
 
159
 
160
 
161
 
162
 
163
-- --------------------------------------------------------------------
164
-- and stop the test running
165
-- --------------------------------------------------------------------
166
 
167
CLK_stop <= '1';
168
wait;
169
 
170
end process test_loop;
171
 
172
 
173
 
174
 
175
 
176
-- --------------------------------------------------------------------
177
end architecture Behavioral;
178
-- --------------------------------------------------------------------

powered by: WebSVN 2.1.0

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