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

Subversion Repositories axi4_tlm_bfm

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

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

Line No. Rev Author Line
1 7 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 12 daniel.kho
library tauhop; use tauhop.axiTransactor.all;
40 7 daniel.kho
 
41
--/* TODO remove once generic packages are supported. */
42
--library tauhop; use tauhop.tlm.all, tauhop.axiTLM.all;
43
 
44
entity axiBfmMaster is --generic(constant maxTransactions:positive);
45
        port(aclk,n_areset:in std_ulogic;
46
                /* BFM signalling. */
47 12 daniel.kho
                /* FIXME Generic package defect. ModelSim currently can't make tauhop.axiTransactor.i_transactor visible. */
48
                readRequest,writeRequest:in i_transactor.t_bfm:=((others=>'X'),(others=>'X'),false);
49
                --readRequest,writeRequest:in i_transactor.t_bfm:=((others=>'X'),(others=>'X'),false);
50
                readResponse,writeResponse:buffer i_transactor.t_bfm;                                                                   -- use buffer until synthesis tools support reading from out ports.
51 7 daniel.kho
 
52
                /* AXI Master interface */
53
                axiMaster_in:in t_axi4StreamTransactor_s2m;
54
                axiMaster_out:buffer t_axi4StreamTransactor_m2s;
55
 
56
--              /* AXI Slave interface */
57
--              axiSlave_in:in tAxi4Transactor_m2s;
58
--              axiSlave_out:buffer tAxi4Transactor_s2m;
59
 
60 12 daniel.kho
                symbolsPerTransfer:in i_transactor.t_cnt;
61
                outstandingTransactions:buffer i_transactor.t_cnt
62 7 daniel.kho
 
63
                /* Debug ports. */
64 8 daniel.kho
--              dbg_cnt:out unsigned(9 downto 0);
65
--              dbg_axiRxFsm:out axiBfmStatesRx:=idle;
66
--              dbg_axiTxFsm:out axiBfmStatesTx:=idle
67 7 daniel.kho
        );
68
end entity axiBfmMaster;
69
 
70
architecture rtl of axiBfmMaster is
71
        /* Finite-state Machines. */
72
        signal axiTxState,next_axiTxState:axiBfmStatesTx:=idle;
73
 
74 13 daniel.kho
        signal i_axiMaster_out:t_axi4StreamTransactor_m2s;
75
 
76 7 daniel.kho
        /* BFM signalling. */
77 12 daniel.kho
        signal i_readRequest:i_transactor.t_bfm:=((others=>'0'),(others=>'0'),false);
78
        signal i_writeRequest:i_transactor.t_bfm:=((others=>'0'),(others=>'0'),false);
79 7 daniel.kho
 
80 12 daniel.kho
        signal i_readResponse,i_writeResponse:i_transactor.t_bfm;
81 7 daniel.kho
 
82
begin
83
        /* Transaction counter. */
84 9 daniel.kho
        process(n_areset,symbolsPerTransfer,aclk) is begin
85 7 daniel.kho
                if not n_areset then outstandingTransactions<=symbolsPerTransfer;
86 10 daniel.kho
                elsif falling_edge(aclk) then
87
                        if outstandingTransactions<1 then
88 7 daniel.kho
                                outstandingTransactions<=symbolsPerTransfer;
89
                                report "No more pending transactions." severity note;
90 10 daniel.kho
                        elsif axiMaster_in.tReady then outstandingTransactions<=outstandingTransactions-1;
91 7 daniel.kho
                        end if;
92
                end if;
93 13 daniel.kho
 
94
                /* debug only. */
95
                /*if falling_edge(aclk) then
96
                        if not n_areset then outstandingTransactions<=symbolsPerTransfer;
97
                        else
98
                                if outstandingTransactions<1 then
99
                                        outstandingTransactions<=symbolsPerTransfer;
100
                                        report "No more pending transactions." severity note;
101
                                elsif axiMaster_in.tReady then outstandingTransactions<=outstandingTransactions-1;
102
                                end if;
103
                        end if;
104
                end if;
105
                */
106 7 daniel.kho
        end process;
107
 
108
        /* next-state logic for AXI4-Stream Master Tx BFM. */
109
        axi_bfmTx_ns: process(all) is begin
110
                axiTxState<=next_axiTxState;
111
 
112 13 daniel.kho
                if not n_areset then axiTxState<=idle;
113
                else
114
                        case next_axiTxState is
115
                                when idle=>
116
                                        if writeRequest.trigger xor i_writeRequest.trigger then axiTxState<=payload; end if;
117
                                when payload=>
118
                                        if outstandingTransactions<1 then axiTxState<=endOfTx; end if;
119
                                when endOfTx=>
120
                                        axiTxState<=idle;
121
                                when others=>axiTxState<=idle;
122
                        end case;
123
                end if;
124 7 daniel.kho
        end process axi_bfmTx_ns;
125
 
126
        /* output logic for AXI4-Stream Master Tx BFM. */
127
        axi_bfmTx_op: process(all) is begin
128 10 daniel.kho
                i_writeResponse<=writeResponse;
129 7 daniel.kho
 
130 13 daniel.kho
                i_axiMaster_out.tValid<=false;
131
                i_axiMaster_out.tLast<=false;
132
                i_axiMaster_out.tData<=(others=>'Z');
133 10 daniel.kho
                i_writeResponse.trigger<=false;
134
 
135 13 daniel.kho
                if writeRequest.trigger xor i_writeRequest.trigger then
136
                        i_axiMaster_out.tData<=writeRequest.message;
137
                        i_axiMaster_out.tValid<=true;
138
                end if;
139
 
140 7 daniel.kho
                case next_axiTxState is
141 10 daniel.kho
                        when idle=>
142 13 daniel.kho
                        /*      if writeRequest.trigger xor i_writeRequest.trigger then
143
                                        i_axiMaster_out.tData<=writeRequest.message;
144
                                        i_axiMaster_out.tValid<=true;
145 10 daniel.kho
                                end if;
146 13 daniel.kho
                        */
147
                                null;
148 7 daniel.kho
                        when payload=>
149 13 daniel.kho
                                i_axiMaster_out.tData<=writeRequest.message;
150
                                i_axiMaster_out.tValid<=true;
151 10 daniel.kho
 
152 7 daniel.kho
                                if axiMaster_in.tReady then
153 10 daniel.kho
                                        i_writeResponse.trigger<=true;
154 7 daniel.kho
                                end if;
155 10 daniel.kho
 
156
                                /* TODO change to a flag at user.vhdl. Move outstandingTransactions to user.vhdl. */
157 13 daniel.kho
                                if outstandingTransactions<1 then i_axiMaster_out.tLast<=true; end if;
158 10 daniel.kho
                        when others=> null;
159 7 daniel.kho
                end case;
160
        end process axi_bfmTx_op;
161
 
162 13 daniel.kho
        axiMaster_out<=i_axiMaster_out;
163 7 daniel.kho
 
164
        /* state registers and pipelines for AXI4-Stream Tx BFM. */
165
        process(n_areset,aclk) is begin
166 13 daniel.kho
                --if not n_areset then next_axiTxState<=idle;
167
                if falling_edge(aclk) then
168 7 daniel.kho
                        next_axiTxState<=axiTxState;
169
                        i_writeRequest<=writeRequest;
170 13 daniel.kho
                        --axiMaster_out<=i_axiMaster_out;
171 7 daniel.kho
                end if;
172
        end process;
173
 
174 10 daniel.kho
        process(aclk) is begin
175
                if rising_edge(aclk) then
176
                        writeResponse<=i_writeResponse;
177
                end if;
178
        end process;
179 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.