1 |
2 |
daniel.kho |
/*
|
2 |
|
|
This file is part of the AXI4 Transactor and Bus Functional Model
|
3 |
|
|
(axi4_tlm_bfm) project:
|
4 |
|
|
http://www.opencores.org/project,axi4_tlm_bfm
|
5 |
|
|
|
6 |
|
|
Description
|
7 |
|
|
Implementation of AXI4 transactor data structures and high-level API.
|
8 |
|
|
|
9 |
|
|
To Do:
|
10 |
|
|
|
11 |
|
|
Author(s):
|
12 |
|
|
- Daniel C.K. Kho, daniel.kho@opencores.org | daniel.kho@tauhop.com
|
13 |
|
|
|
14 |
|
|
Copyright (C) 2012-2013 Authors and OPENCORES.ORG
|
15 |
|
|
|
16 |
|
|
This source file may be used and distributed without
|
17 |
|
|
restriction provided that this copyright statement is not
|
18 |
|
|
removed from the file and that any derivative work contains
|
19 |
|
|
the original copyright notice and the associated disclaimer.
|
20 |
|
|
|
21 |
|
|
This source file is free software; you can redistribute it
|
22 |
|
|
and/or modify it under the terms of the GNU Lesser General
|
23 |
|
|
Public License as published by the Free Software Foundation;
|
24 |
|
|
either version 2.1 of the License, or (at your option) any
|
25 |
|
|
later version.
|
26 |
|
|
|
27 |
|
|
This source is distributed in the hope that it will be
|
28 |
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied
|
29 |
|
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
30 |
|
|
PURPOSE. See the GNU Lesser General Public License for more
|
31 |
|
|
details.
|
32 |
|
|
|
33 |
|
|
You should have received a copy of the GNU Lesser General
|
34 |
|
|
Public License along with this source; if not, download it
|
35 |
|
|
from http://www.opencores.org/lgpl.shtml.
|
36 |
|
|
*/
|
37 |
|
|
/* FIXME VHDL-2008 instantiated package. Unsupported by VCS-MX, Quartus, and Vivado. QuestaSim/ModelSim supports well. */
|
38 |
|
|
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all;
|
39 |
|
|
--use std.textio.all;
|
40 |
|
|
library tauhop;
|
41 |
|
|
|
42 |
|
|
/* Record I/O data structures for AXI interface transactor (block interface). */
|
43 |
|
|
package axiTLM is
|
44 |
|
|
generic(
|
45 |
|
|
type t_qualifier; type t_id; type t_dest; type t_user; type t_resp;
|
46 |
10 |
daniel.kho |
package i_transactor is new tauhop.tlm generic map(<>)
|
47 |
2 |
daniel.kho |
);
|
48 |
10 |
daniel.kho |
/* Makes i_transactor.t_addr, i_transactor.t_msg, and i_transactor.t_cnt visible. */
|
49 |
|
|
use i_transactor.all;
|
50 |
2 |
daniel.kho |
|
51 |
|
|
-- /* TODO remove once generic packages are supported. */
|
52 |
|
|
-- use tauhop.tlm.all;
|
53 |
|
|
-- subtype t_qualifier is std_ulogic_vector(32/8-1 downto 0);
|
54 |
|
|
-- subtype t_id is unsigned(31 downto 0);
|
55 |
|
|
-- subtype t_resp is unsigned(1 downto 0); --2 bits. b"00" = OKAY, b"01" = ExOKAY, b"10" = SLVERR (slave error), b"11" = DECERR (decode error).
|
56 |
|
|
|
57 |
|
|
/* AXI Transactor block interfaces. */
|
58 |
5 |
daniel.kho |
type t_axi4Transactor_m2s is record
|
59 |
2 |
daniel.kho |
/* Address must be unresolved, because you need to drive the read address only when read is asserted, and
|
60 |
|
|
drive the write address when write is asserted. Resolution functions are not expected to know how to decide this.
|
61 |
|
|
*/
|
62 |
|
|
/* Write address channel. */
|
63 |
|
|
awId:t_id;
|
64 |
|
|
-- awLen:unsigned(7 downto 0); --8 bits as defined by the standard.
|
65 |
|
|
-- awSize:unsigned(2 downto 0); --3 bits as defined by the standard. Burst size for write transfers.
|
66 |
|
|
-- awBurst:
|
67 |
|
|
-- awLock:
|
68 |
|
|
-- awCache:
|
69 |
|
|
-- awQoS:
|
70 |
|
|
-- awRegion:
|
71 |
|
|
-- awUser:
|
72 |
|
|
-- AXI4-Lite required signals.
|
73 |
|
|
awAddr:t_addr;
|
74 |
|
|
awProt:boolean;
|
75 |
|
|
awValid:boolean;
|
76 |
|
|
|
77 |
|
|
/* Write data channel. */
|
78 |
|
|
wId:t_id;
|
79 |
|
|
-- wLast:
|
80 |
|
|
-- wUser:
|
81 |
|
|
-- AXI4-Lite required signals.
|
82 |
|
|
wValid:boolean;
|
83 |
|
|
wData:t_msg;
|
84 |
|
|
-- wStrb:std_ulogic_vector(wData'length/8-1 downto 0); --default is all ones if master always performs full datawidth write transactions.
|
85 |
|
|
wStrb:t_qualifier; --default is all ones if master always performs full datawidth write transactions.
|
86 |
|
|
|
87 |
|
|
/* Write response channel. */
|
88 |
|
|
bReady:boolean;
|
89 |
|
|
|
90 |
|
|
/* Read address channel. */
|
91 |
|
|
arId:t_id;
|
92 |
|
|
-- arLen:unsigned(7 downto 0); --8 bits as defined by the standard.
|
93 |
|
|
-- arSize:unsigned(2 downto 0); --3 bits as defined by the standard.
|
94 |
|
|
-- arBurst:
|
95 |
|
|
-- arLock:
|
96 |
|
|
-- arCache:
|
97 |
|
|
-- arQoS:
|
98 |
|
|
-- arRegion:
|
99 |
|
|
-- arUser:
|
100 |
|
|
-- AXI4-Lite required signals.
|
101 |
|
|
arValid:boolean;
|
102 |
|
|
arAddr:t_addr;
|
103 |
|
|
arProt:boolean;
|
104 |
|
|
|
105 |
|
|
/* Read data channel. */
|
106 |
|
|
rReady:boolean;
|
107 |
5 |
daniel.kho |
end record t_axi4Transactor_m2s;
|
108 |
2 |
daniel.kho |
|
109 |
5 |
daniel.kho |
type t_axi4Transactor_s2m is record
|
110 |
2 |
daniel.kho |
/* Write address channel. */
|
111 |
|
|
awReady:boolean;
|
112 |
|
|
|
113 |
|
|
/* Write data channel. */
|
114 |
|
|
wReady:boolean;
|
115 |
|
|
|
116 |
|
|
/* Write response channel. */
|
117 |
|
|
bId:t_id;
|
118 |
|
|
-- bUser:
|
119 |
|
|
-- AXI4-Lite required signals.
|
120 |
|
|
bValid:boolean;
|
121 |
|
|
bResp:t_resp;
|
122 |
|
|
|
123 |
|
|
/* Read address channel. */
|
124 |
|
|
arReady:boolean;
|
125 |
|
|
|
126 |
|
|
/* Read data channel. */
|
127 |
|
|
rId:t_id;
|
128 |
|
|
-- rLast:
|
129 |
|
|
-- rUser:
|
130 |
|
|
-- AXI4-Lite required signals.
|
131 |
|
|
rValid:boolean;
|
132 |
|
|
rData:t_msg;
|
133 |
|
|
rResp:t_resp;
|
134 |
5 |
daniel.kho |
end record t_axi4Transactor_s2m;
|
135 |
2 |
daniel.kho |
|
136 |
5 |
daniel.kho |
type t_axi4StreamTransactor_m2s is record
|
137 |
2 |
daniel.kho |
/* AXI4 streaming interface. */
|
138 |
|
|
tValid:boolean;
|
139 |
|
|
tData:t_msg;
|
140 |
|
|
tStrb:t_qualifier;
|
141 |
|
|
tKeep:t_qualifier;
|
142 |
|
|
tLast:boolean;
|
143 |
17 |
daniel.kho |
-- tId:t_id;
|
144 |
|
|
-- tDest:t_dest;
|
145 |
|
|
-- tUser:t_user;
|
146 |
5 |
daniel.kho |
end record t_axi4StreamTransactor_m2s;
|
147 |
2 |
daniel.kho |
|
148 |
5 |
daniel.kho |
type t_axi4StreamTransactor_s2m is record
|
149 |
2 |
daniel.kho |
tReady:boolean;
|
150 |
5 |
daniel.kho |
end record t_axi4StreamTransactor_s2m;
|
151 |
2 |
daniel.kho |
|
152 |
|
|
-- /* AXI Low-power interface. */
|
153 |
|
|
-- type tAxiTransactor_lp is record
|
154 |
|
|
-- cSysReq:
|
155 |
|
|
-- cSysAck:
|
156 |
|
|
-- cActive:
|
157 |
|
|
-- end record tAxiTransactor_lp;
|
158 |
|
|
|
159 |
24 |
daniel.kho |
type t_fsm is (idle,sendAddr,startOfPacket,payload,endOfPacket,endOfTx);
|
160 |
17 |
daniel.kho |
type axiBfmStatesTx is (idle,payload,endOfTx);
|
161 |
2 |
daniel.kho |
type axiBfmStatesRx is (idle,checkAddr,startOfPacket,payload);
|
162 |
24 |
daniel.kho |
|
163 |
|
|
function to_std_logic_vector(fsm:axiBfmStatesTx) return std_logic_vector;
|
164 |
2 |
daniel.kho |
end package axiTLM;
|
165 |
|
|
|
166 |
|
|
package body axiTLM is
|
167 |
24 |
daniel.kho |
function to_std_logic_vector(fsm:axiBfmStatesTx) return std_logic_vector is
|
168 |
|
|
variable r:std_logic_vector(1 downto 0);
|
169 |
|
|
begin
|
170 |
|
|
case fsm is
|
171 |
|
|
when idle=> r:=2x"0";
|
172 |
|
|
when payload=> r:=2x"1";
|
173 |
|
|
when endOfTx=> r:=2x"2";
|
174 |
|
|
when others=> null;
|
175 |
|
|
end case;
|
176 |
|
|
return r;
|
177 |
|
|
end function to_std_logic_vector;
|
178 |
2 |
daniel.kho |
end package body axiTLM;
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
/* AXI Transactor API.
|
182 |
|
|
* Generally, transactors are high-level bus interface models that perform
|
183 |
|
|
* read/write transactions to/from the bus. These models are not concerned
|
184 |
|
|
* with the low-level implementation of the bus protocol. However, the
|
185 |
|
|
* TLM models encapsulate the lower-level models known as the BFM.
|
186 |
|
|
* axiTLM uses generic package tauhop.tlm, hence inherits basic TLM types and
|
187 |
|
|
* procedures generally used in any messaging system (i.e. address and message
|
188 |
|
|
* information, and bus read/write methods). It also extends the tauhop.tlm
|
189 |
|
|
* package with application-specific types, such as record structures specific
|
190 |
|
|
* to the AXI protocol.
|
191 |
|
|
* axiTransactor instantiates the axiTLM, and assigns specific types to the
|
192 |
|
|
* transactor model.
|
193 |
|
|
*/
|
194 |
|
|
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all;
|
195 |
|
|
library tauhop;
|
196 |
|
|
package transactor is new tauhop.tlm generic map(
|
197 |
8 |
daniel.kho |
t_addr=>unsigned(31 downto 0), -- default assignment. Used only for non-stream interfaces.
|
198 |
17 |
daniel.kho |
-- t_msg=>signed(63 downto 0),
|
199 |
|
|
t_msg=>signed(31 downto 0),
|
200 |
2 |
daniel.kho |
t_cnt=>unsigned(127 downto 0)
|
201 |
|
|
);
|
202 |
|
|
|
203 |
|
|
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all;
|
204 |
|
|
library tauhop; use tauhop.transactor.all;
|
205 |
|
|
package axiTransactor is new tauhop.axiTLM generic map(
|
206 |
|
|
t_qualifier=>boolean_vector(32/8-1 downto 0),
|
207 |
|
|
t_id=>unsigned(7 downto 0),
|
208 |
|
|
t_dest=>unsigned(3 downto 0),
|
209 |
|
|
t_user=>unsigned(7 downto 0), --unsigned(86*2-1 downto 0),
|
210 |
|
|
t_resp=>unsigned(1 downto 0), --only used for AXI4-Lite (non-streaming).
|
211 |
10 |
daniel.kho |
i_transactor=>tauhop.transactor
|
212 |
9 |
daniel.kho |
);
|