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

Subversion Repositories apb_mstr

[/] [apb_mstr/] [trunk/] [src/] [base/] [apb_master.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 eyalhoc
<##//////////////////////////////////////////////////////////////////
2 2 eyalhoc
////                                                             ////
3
////  Author: Eyal Hochberg                                      ////
4
////          eyal@provartec.com                                 ////
5
////                                                             ////
6
////  Downloaded from: http://www.opencores.org                  ////
7
/////////////////////////////////////////////////////////////////////
8
////                                                             ////
9
//// Copyright (C) 2010 Provartec LTD                            ////
10
//// www.provartec.com                                           ////
11
//// info@provartec.com                                          ////
12
////                                                             ////
13
//// This source file may be used and distributed without        ////
14
//// restriction provided that this copyright statement is not   ////
15
//// removed from the file and that any derivative work contains ////
16
//// the original copyright notice and the associated disclaimer.////
17
////                                                             ////
18
//// This source file is free software; you can redistribute it  ////
19
//// and/or modify it under the terms of the GNU Lesser General  ////
20
//// Public License as published by the Free Software Foundation.////
21
////                                                             ////
22
//// This source is distributed in the hope that it will be      ////
23
//// useful, but WITHOUT ANY WARRANTY; without even the implied  ////
24
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     ////
25
//// PURPOSE.  See the GNU Lesser General Public License for more////
26
//// details. http://www.gnu.org/licenses/lgpl.html              ////
27
////                                                             ////
28 12 eyalhoc
//////////////////////////////////////////////////////////////////##>
29 8 eyalhoc
 
30
//////////////////////////////////////
31
//
32
// General:
33
//   The APB master is built of an AXI master and an AXI2APB bridge. 
34
//   The stub support APB (Amba2) and APB3 (Amba3) protocols, 
35
//   the define APB3 determines this (in def_apb_master.txt)
36
// 
37
//
38
// Tasks:
39
//
40
// write_single(input addr, input wdata)
41
//   Description: write a single APB burst
42
//   Parameters:
43
//               addr  - address
44
//               wdata - write data
45
// 
46
// read_single(input master_num, input addr, output rdata)
47
//   Description: read a single AB burst
48
//   Parameters:
49
//               addr  - address
50
//               rdata - return read data
51
//
52
// check_single(input master_num, input addr, input expected)
53
//   Description: read a single AB burst and give an error if the data read does not match expected
54
//   Parameters:
55
//               addr  - address
56
//               expected - expected read data
57
//
58
// write_and_check_single(input master_num, input addr, input data)
59
//   Description: write a single AB burst read it back and give an error if the write and read data don't match
60
//   Parameters:
61
//               addr  - address
62
//               data - data to write and expect on read
63
//
64
//
65
//////////////////////////////////////
66
 
67
 
68
OUTFILE PREFIX.v
69
 
70
INCLUDE def_apb_master.txt
71
 
72
module PREFIX(PORTS);
73
 
74
 
75
   input                    clk;
76
   input                    reset;
77
 
78
   output                   psel;
79
   output                   penable;
80
   output [ADDR_BITS-1:0]   paddr;
81
   output                   pwrite;
82
   output [DATA_BITS-1:0]   pwdata;
83
   input [DATA_BITS-1:0]    prdata;
84
IFDEF APB3
85
   input                    pslverr;
86
   input                    pready;
87
ELSE APB3
88
 
89
   wire pslverr = 1'b0;
90
   wire pready = 1'b1;
91
ENDIF APB3
92
 
93
   wire                     GROUP_STUB_AXI;
94
 
95
 
96
   //set random tasks to be only 32 bit singles
97
   initial
98
     begin
99
        #1;
100
        PREFIX_axi_master.enable_all;
101
        PREFIX_axi_master.use_addr_base=1;
102
        PREFIX_axi_master.len_min=0;
103
        PREFIX_axi_master.len_max=0;
104
        PREFIX_axi_master.size_min=2;
105
        PREFIX_axi_master.size_max=2;
106
     end
107
 
108
 
109 12 eyalhoc
   CREATE axi_master.v \\
110
DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi_master) \\
111
DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
112
DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
113
   DEFCMD(GROUP.USER AXI_ID overrides {)  \\
114
   DEFCMD(0) \\
115
   DEFCMD(})
116 8 eyalhoc
 
117
     PREFIX_axi_master PREFIX_axi_master(
118
                           .clk(clk),
119
                           .reset(reset),
120
                           .GROUP_STUB_AXI(GROUP_STUB_AXI),
121
                           .idle()
122
                           );
123
 
124
 
125 12 eyalhoc
   CREATE axi2apb.v \\
126
DEFCMD(SWAP CONST(SLAVE_NUM) 1) \\
127
DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi2apb) \\
128
DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
129
DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS)
130 8 eyalhoc
 
131
   PREFIX_axi2apb PREFIX_axi2apb(
132
                           .clk(clk),
133
                           .reset(reset),
134
                           .GROUP_STUB_AXI(GROUP_STUB_AXI),
135
 
136
                           .penable(penable),
137
                           .pwrite(pwrite),
138
                           .paddr(paddr),
139
                           .pwdata(pwdata),
140
                           .psel(psel),
141
                           .prdata(prdata),
142
                           .pready(pready),
143
                           .pslverr(pslverr)
144
                           );
145
 
146
 
147
   task write_single;
148
      input [ADDR_BITS-1:0]  addr;
149
      input [DATA_BITS-1:0]  wdata;
150
      begin
151
         PREFIX_axi_master.write_single(0, addr, wdata);
152
      end
153
   endtask
154
 
155
   task read_single;
156
      input [ADDR_BITS-1:0]  addr;
157
      output [DATA_BITS-1:0]  rdata;
158
      begin
159
         PREFIX_axi_master.read_single(0, addr, rdata);
160
      end
161
   endtask
162
 
163
   task check_single;
164
      input [ADDR_BITS-1:0]  addr;
165
      input [DATA_BITS-1:0]  expected;
166
      begin
167
         PREFIX_axi_master.check_single(0, addr, expected);
168
      end
169
   endtask
170
 
171
   task write_and_check_single;
172
      input [ADDR_BITS-1:0]  addr;
173
      input [DATA_BITS-1:0]  data;
174
      begin
175
         PREFIX_axi_master.write_and_check_single(0, addr, data);
176
      end
177
   endtask
178
 
179
 
180
endmodule

powered by: WebSVN 2.1.0

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