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 5

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

Line No. Rev Author Line
1 2 eyalhoc
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
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
/////////////////////////////////////////////////////////////////////
29
 
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 5 eyalhoc
OUTFILE PREFIX.v
69 2 eyalhoc
 
70
INCLUDE def_apb_master.txt
71
 
72
VERIFY (DATA_BITS==32) else only 32 bit data supported
73
 
74 5 eyalhoc
module PREFIX(PORTS);
75 2 eyalhoc
 
76
 
77
   input                    clk;
78
   input                    reset;
79
 
80
   output                   psel;
81
   output                   penable;
82
   output [ADDR_BITS-1:0]   paddr;
83
   output                   pwrite;
84
   output [DATA_BITS-1:0]   pwdata;
85
   input [DATA_BITS-1:0]    prdata;
86
IFDEF APB3
87
   input                    pslverr;
88
   input                    pready;
89
ELSE APB3
90
 
91
   wire pslverr = 1'b0;
92
   wire pready = 1'b1;
93
ENDIF APB3
94
 
95
   wire                     GROUP_STUB_AXI;
96
 
97
 
98
   //set random tasks to be only 32 bit singles
99
   initial
100
     begin
101
        #1;
102 5 eyalhoc
        PREFIX_axi_master.enable_all;
103
        PREFIX_axi_master.use_addr_base=1;
104
        PREFIX_axi_master.len_min=0;
105
        PREFIX_axi_master.len_max=0;
106
        PREFIX_axi_master.size_min=2;
107
        PREFIX_axi_master.size_max=2;
108 2 eyalhoc
     end
109
 
110
 
111 5 eyalhoc
   CREATE axi_master.v DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi_master)
112 2 eyalhoc
 
113 5 eyalhoc
     PREFIX_axi_master PREFIX_axi_master(
114 2 eyalhoc
                           .clk(clk),
115
                           .reset(reset),
116
                           .GROUP_STUB_AXI(GROUP_STUB_AXI),
117
                           .idle()
118
                           );
119
 
120
 
121 5 eyalhoc
   CREATE axi2apb.v DEFCMD(SWAP CONST(SLAVE_NUM) 1) DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi2apb)
122 2 eyalhoc
 
123 5 eyalhoc
   PREFIX_axi2apb PREFIX_axi2apb(
124 2 eyalhoc
                           .clk(clk),
125
                           .reset(reset),
126
                           .GROUP_STUB_AXI(GROUP_STUB_AXI),
127
 
128
                           .penable(penable),
129
                           .pwrite(pwrite),
130
                           .paddr(paddr),
131
                           .pwdata(pwdata),
132
                           .psel(psel),
133
                           .prdata(prdata),
134
                           .pready(pready),
135
                           .pslverr(pslverr)
136
                           );
137
 
138
 
139
   task write_single;
140
      input [ADDR_BITS-1:0]  addr;
141
      input [DATA_BITS-1:0]  wdata;
142
      begin
143 5 eyalhoc
         PREFIX_axi_master.write_single(0, addr, wdata);
144 2 eyalhoc
      end
145
   endtask
146
 
147
   task read_single;
148
      input [ADDR_BITS-1:0]  addr;
149
      output [DATA_BITS-1:0]  rdata;
150
      begin
151 5 eyalhoc
         PREFIX_axi_master.read_single(0, addr, rdata);
152 2 eyalhoc
      end
153
   endtask
154
 
155
   task check_single;
156
      input [ADDR_BITS-1:0]  addr;
157
      input [DATA_BITS-1:0]  expected;
158
      begin
159 5 eyalhoc
         PREFIX_axi_master.check_single(0, addr, expected);
160 2 eyalhoc
      end
161
   endtask
162
 
163
   task write_and_check_single;
164
      input [ADDR_BITS-1:0]  addr;
165
      input [DATA_BITS-1:0]  data;
166
      begin
167 5 eyalhoc
         PREFIX_axi_master.write_and_check_single(0, addr, data);
168 2 eyalhoc
      end
169
   endtask
170
 
171
 
172
endmodule

powered by: WebSVN 2.1.0

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