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

Subversion Repositories axi4_tlm_bfm

[/] [axi4_tlm_bfm/] [trunk/] [rtl/] [quartus-synthesis/] [axi4-stream-bfm-master.vhdl] - Blame information for rev 44

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 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 Master BFM core according to AXI4 protocol
8
        specification document.
9
 
10
        To Do: Implement AXI4-Lite and full AXI4 protocols.
11
 
12
        Author(s):
13
        - Daniel C.K. Kho, daniel.kho@opencores.org | daniel.kho@tauhop.com
14
 
15
        Copyright (C) 2012-2013 Authors and OPENCORES.ORG
16
 
17
        This source file may be used and distributed without
18
        restriction provided that this copyright statement is not
19
        removed from the file and that any derivative work contains
20
        the original copyright notice and the associated disclaimer.
21
 
22
        This source file is free software; you can redistribute it
23
        and/or modify it under the terms of the GNU Lesser General
24
        Public License as published by the Free Software Foundation;
25
        either version 2.1 of the License, or (at your option) any
26
        later version.
27
 
28
        This source is distributed in the hope that it will be
29
        useful, but WITHOUT ANY WARRANTY; without even the implied
30
        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31
        PURPOSE. See the GNU Lesser General Public License for more
32
        details.
33
 
34
        You should have received a copy of the GNU Lesser General
35
        Public License along with this source; if not, download it
36
        from http://www.opencores.org/lgpl.shtml.
37
*/
38
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all;
39 13 daniel.kho
--library tauhop; use tauhop.axiTransactor.all;
40 9 daniel.kho
 
41 17 daniel.kho
/* TODO remove once generic packages are supported. */
42 44 daniel.kho
library tauhop; use tauhop.fsm.all, tauhop.tlm.all, tauhop.axiTLM.all;
43 9 daniel.kho
 
44 13 daniel.kho
entity axiBfmMaster is
45 9 daniel.kho
        port(aclk,n_areset:in std_ulogic;
46
                /* BFM signalling. */
47 17 daniel.kho
                readRequest,writeRequest:in t_bfm:=(address=>(others=>'X'), message=>(others=>'X'), trigger=>false);
48 9 daniel.kho
                readResponse,writeResponse:buffer t_bfm;                                                                        -- use buffer until synthesis tools support reading from out ports.
49
 
50
                /* AXI Master interface */
51
                axiMaster_in:in t_axi4StreamTransactor_s2m;
52
                axiMaster_out:buffer t_axi4StreamTransactor_m2s;
53
 
54
--              /* AXI Slave interface */
55
--              axiSlave_in:in tAxi4Transactor_m2s;
56
--              axiSlave_out:buffer tAxi4Transactor_s2m;
57
 
58 42 daniel.kho
                lastTransaction:in boolean;
59 9 daniel.kho
 
60
                /* Debug ports. */
61
--              dbg_cnt:out unsigned(9 downto 0);
62
--              dbg_axiRxFsm:out axiBfmStatesRx:=idle;
63 13 daniel.kho
                dbg_axiTxFsm:out axiBfmStatesTx:=idle
64 9 daniel.kho
        );
65
end entity axiBfmMaster;
66
 
67
architecture rtl of axiBfmMaster is
68
        /* Finite-state Machines. */
69
        signal axiTxState,next_axiTxState:axiBfmStatesTx:=idle;
70 44 daniel.kho
 
71 17 daniel.kho
        signal i_axiMaster_out:t_axi4StreamTransactor_m2s;
72
        signal i_trigger,trigger:boolean;
73
 
74 9 daniel.kho
        /* BFM signalling. */
75 17 daniel.kho
--      signal i_readRequest,i_writeRequest:t_bfm:=(address=>(others=>'X'),message=>(others=>'X'),trigger=>false);
76
--      signal i_readResponse,i_writeResponse:t_bfm;
77
        signal i_writeRequest:t_bfm:=(address=>(others=>'X'),message=>(others=>'X'),trigger=>false);
78
        signal i_writeResponse:t_bfm;
79 9 daniel.kho
 
80 44 daniel.kho
        /* DDR Pipelines. */
81
        signal next_axiTxState_rise,next_axiTxState_fall:axiBfmStatesTx;
82
        signal i_writeRequest_rise,i_writeRequest_fall:t_bfm;
83
        signal writeResponse_rise,writeResponse_fall:t_bfm;
84
        signal axiMaster_out_rise,axiMaster_out_fall:t_axi4StreamTransactor_m2s;
85
        signal trigger_rise,trigger_fall:boolean;
86
 
87 17 daniel.kho
begin
88
        i_trigger<=writeRequest.trigger xor i_writeRequest.trigger;
89 9 daniel.kho
 
90
        /* next-state logic for AXI4-Stream Master Tx BFM. */
91
        axi_bfmTx_ns: process(all) is begin
92
                axiTxState<=next_axiTxState;
93
 
94 13 daniel.kho
                if not n_areset then axiTxState<=idle;
95
                else
96
                        case next_axiTxState is
97
                                when idle=>
98 17 daniel.kho
                                        if i_trigger then axiTxState<=payload; end if;
99 13 daniel.kho
                                when payload=>
100 42 daniel.kho
                                        if lastTransaction then axiTxState<=endOfTx; end if;
101 13 daniel.kho
                                when endOfTx=>
102 44 daniel.kho
                                        if axiMaster_in.tReady then axiTxState<=idle; end if;
103 13 daniel.kho
                                when others=>axiTxState<=idle;
104
                        end case;
105
                end if;
106 9 daniel.kho
        end process axi_bfmTx_ns;
107
 
108
        /* output logic for AXI4-Stream Master Tx BFM. */
109
        axi_bfmTx_op: process(all) is begin
110 11 daniel.kho
                i_writeResponse<=writeResponse;
111 9 daniel.kho
 
112 42 daniel.kho
                i_axiMaster_out<=axiMaster_out;
113 17 daniel.kho
                i_axiMaster_out.tLast<=false;
114 11 daniel.kho
                i_writeResponse.trigger<=false;
115
 
116 17 daniel.kho
                case next_axiTxState is
117
                        when idle=>
118 42 daniel.kho
                                i_axiMaster_out.tValid<=false;
119
                                i_axiMaster_out.tData<=(others=>'Z');
120
 
121 17 daniel.kho
                                if i_trigger then
122
                                        i_axiMaster_out.tData<=writeRequest.message;
123
                                        i_axiMaster_out.tValid<=true;
124
                                end if;
125 42 daniel.kho
                        when payload | endOfTx =>
126
                                if i_trigger then
127
                                        i_axiMaster_out.tData<=writeRequest.message;
128
                                        i_axiMaster_out.tValid<=true;
129
                                end if;
130 17 daniel.kho
 
131
                                if axiMaster_in.tReady then
132
                                        i_writeResponse.trigger<=true;
133
                                end if;
134
 
135 42 daniel.kho
                                if lastTransaction then i_axiMaster_out.tLast<=true; end if;
136 17 daniel.kho
                        when others=> null;
137
                end case;
138 9 daniel.kho
        end process axi_bfmTx_op;
139
 
140
        /* state registers and pipelines for AXI4-Stream Tx BFM. */
141 17 daniel.kho
        process(aclk) is begin
142 44 daniel.kho
                if not n_areset then
143
                        next_axiTxState<=idle;
144
                        i_writeRequest<=(address=>(others=>'0'),message=>(others=>'0'),trigger=>false);
145
                        writeResponse<=(address=>(others=>'0'),message=>(others=>'0'),trigger=>false);
146
                        --axiMaster_out<=(others=>'0');
147
                        trigger<=false;
148
--              elsif rising_edge(aclk) then
149
--                      next_axiTxState<=axiTxState;
150
--                      i_writeRequest<=writeRequest;
151
--                      writeResponse<=i_writeResponse;
152
--                      axiMaster_out<=i_axiMaster_out;
153
--                      trigger<=i_trigger;
154
                elsif falling_edge(aclk) then
155 9 daniel.kho
                        next_axiTxState<=axiTxState;
156
                        i_writeRequest<=writeRequest;
157 11 daniel.kho
                        writeResponse<=i_writeResponse;
158 17 daniel.kho
                        axiMaster_out<=i_axiMaster_out;
159
                        trigger<=i_trigger;
160 11 daniel.kho
                end if;
161
        end process;
162 13 daniel.kho
 
163 44 daniel.kho
        /*
164
        process(n_areset,aclk) is begin
165
                if not n_areset then
166
                        next_axiTxState_rise<=idle;
167
                elsif rising_edge(aclk) then
168
                        next_axiTxState_rise<=axiTxState;
169
                        i_writeRequest_rise<=writeRequest;
170
                        writeResponse_rise<=i_writeResponse;
171
                        axiMaster_out_rise<=i_axiMaster_out;
172
                        trigger_rise<=i_trigger;
173
                end if;
174
        end process;
175
 
176
        process(n_areset,aclk) is begin
177
                if not n_areset then
178
                        next_axiTxState_fall<=idle;
179
                elsif falling_edge(aclk) then
180
                        next_axiTxState_fall<=axiTxState;
181
                        i_writeRequest_fall<=writeRequest;
182
                        writeResponse_fall<=i_writeResponse;
183
                        axiMaster_out_fall<=i_axiMaster_out;
184
                        trigger_fall<=i_trigger;
185
                end if;
186
        end process;
187
 
188
        next_axiTxState<=idle when not n_areset else next_axiTxState_rise xor next_axiTxState_fall;
189
        */
190
 
191
--      pseudo dual-edge-triggered D-Flip-Flop (Refer Ralf Hildebrant's paper: http://www.ralf-hildebrandt.de/publication/pdf_dff/pde_dff.pdf).
192
        /*
193
        process(async_clr,clk)
194
        begin
195
                if impl_rp=0 and async_clr='0' then ff_rise<='0';
196
                elsif impl_rp=1 and async_clr='0' then ff_rise<='1';
197
                elsif rising_edge(clk) then
198
                        if d='1' then ff_rise<=not ff_fall;
199
                        else ff_rise<=ff_fall;
200
                        end if;
201
                end if;
202
        end process;
203
 
204
        process(async_clr,clk)
205
        begin
206
                if impl_rp=0 and async_clr='0' then ff_fall<='0';
207
                elsif impl_rp=1 and async_clr='0' then ff_fall<='1';
208
                elsif falling_edge(clk) then
209
                        if d='1' then ff_fall<=not ff_rise;
210
                        else ff_fall<=ff_rise;
211
                        end if;
212
                end if;
213
        end process;
214
 
215
        q<='0' when impl_rp=0 and async_clr='0' else
216
                '1' when impl_rp=1 and async_clr='0' else
217
                ff_rise xor ff_fall;
218
        */
219
-- end pseudo dual-edge-triggered DFF
220
 
221
/*
222
--      process(n_areset,aclk) is
223
        process(aclk) is
224
--              variable q1,q2:std_ulogic_vector(q'length-1 downto 0);
225
                variable q_a1,q_a2:axiBfmStatesTx;              --std_ulogic_vector(axiTxState'range);
226
                variable q_b1,q_b2:t_bfm;                               --std_ulogic_vector(writeRequest'range);
227
                variable q_c1,q_c2:t_bfm;
228
                variable q_d1,q_d2:t_axi4StreamTransactor_m2s;
229
                variable q_e1,q_e2:boolean;
230
        begin
231
--              if not n_areset then
232
--                      q_a1:=idle; q_a2:=idle;
233
--                      q_b1:=(others=>'0'); q_b2:=(others=>'0');
234
--                      q_c1:=(others=>'0'); q_c2:=(others=>'0');
235
--                      q_d1:=(others=>'0'); q_d2:=(others=>'0');
236
--                      q_e1:=(others=>'0'); q_e2:=(others=>'0');
237
                if rising_edge(aclk) then
238
                        q_a1:=axiTxState xor q_a2;
239
                        q_b1:=writeRequest xor q_b2;
240
                        q_c1:=i_writeResponse xor q_c2;
241
                        q_d1:=i_axiMaster_out xor q_d2;
242
                        q_e1:=i_trigger xor q_e2;
243
                elsif falling_edge(aclk) then
244
                        q_a2:=axiTxState xor q_a1;
245
                        q_b2:=writeRequest xor q_b1;
246
                        q_c2:=i_writeResponse xor q_c1;
247
                        q_d2:=i_axiMaster_out xor q_d1;
248
                        q_e2:=i_trigger xor q_e1;
249
                end if;
250
 
251
                next_axiTxState<=q_a1 xor q_a2;
252
                i_writeRequest<=q_b1 xor q_b2;
253
                writeResponse<=q_c1 xor q_c2;
254
                axiMaster_out<=q_d1 xor q_d2;
255
                trigger<=q_e1 xor q_e2;
256
        end process;
257
*/
258
 
259 13 daniel.kho
        dbg_axiTxFSM<=axiTxState;
260 9 daniel.kho
end architecture rtl;

powered by: WebSVN 2.1.0

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