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 11

Go to most recent revision | 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
--library tauhop; use tauhop.transactor.all, tauhop.axiTransactor.all;
40
 
41 11 daniel.kho
--/* TODO remove once generic packages are supported. */
42 9 daniel.kho
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 11 daniel.kho
                readRequest,writeRequest:in t_bfm:=((others=>'X'),(others=>'X'),false);         -- this is tauhop.transactor.t_bfm.
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
                symbolsPerTransfer:in t_cnt;
59
                outstandingTransactions:buffer t_cnt
60
 
61
                /* Debug ports. */
62
--              dbg_cnt:out unsigned(9 downto 0);
63
--              dbg_axiRxFsm:out axiBfmStatesRx:=idle;
64
--              dbg_axiTxFsm:out axiBfmStatesTx:=idle
65
        );
66
end entity axiBfmMaster;
67
 
68
architecture rtl of axiBfmMaster is
69
        /* Finite-state Machines. */
70
        signal axiTxState,next_axiTxState:axiBfmStatesTx:=idle;
71
 
72
        /* BFM signalling. */
73
        signal i_readRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
74
        signal i_writeRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
75
 
76 11 daniel.kho
        signal i_readResponse,i_writeResponse:t_bfm;
77 9 daniel.kho
 
78
begin
79
        /* Transaction counter. */
80
        process(n_areset,symbolsPerTransfer,aclk) is begin
81
                if not n_areset then outstandingTransactions<=symbolsPerTransfer;
82 11 daniel.kho
                elsif falling_edge(aclk) then
83
                        if outstandingTransactions<1 then
84 9 daniel.kho
                                outstandingTransactions<=symbolsPerTransfer;
85
                                report "No more pending transactions." severity note;
86 11 daniel.kho
                        elsif axiMaster_in.tReady then outstandingTransactions<=outstandingTransactions-1;
87 9 daniel.kho
                        end if;
88
                end if;
89
        end process;
90
 
91
        /* next-state logic for AXI4-Stream Master Tx BFM. */
92
        axi_bfmTx_ns: process(all) is begin
93
                axiTxState<=next_axiTxState;
94
 
95 11 daniel.kho
                if not n_areset then axiTxState<=idle; end if;
96 9 daniel.kho
 
97
                case next_axiTxState is
98 11 daniel.kho
                        when idle=>
99
                                if writeRequest.trigger xor i_writeRequest.trigger then axiTxState<=payload; end if;
100 9 daniel.kho
                        when payload=>
101 11 daniel.kho
                                if outstandingTransactions<1 then axiTxState<=endOfTx; end if;
102
                        when endOfTx=>
103
                                axiTxState<=idle;
104 9 daniel.kho
                        when others=>axiTxState<=idle;
105
                end case;
106
        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 11 daniel.kho
                axiMaster_out.tValid<=false;
113
                axiMaster_out.tLast<=false;
114
                axiMaster_out.tData<=(others=>'Z');
115
                i_writeResponse.trigger<=false;
116
 
117 9 daniel.kho
                case next_axiTxState is
118 11 daniel.kho
                        when idle=>
119
                                if writeRequest.trigger xor i_writeRequest.trigger then
120
                                        axiMaster_out.tData<=writeRequest.message;
121
                                        axiMaster_out.tValid<=true;
122
                                end if;
123 9 daniel.kho
                        when payload=>
124
                                axiMaster_out.tValid<=true;
125 11 daniel.kho
                                axiMaster_out.tData<=writeRequest.message;
126
 
127 9 daniel.kho
                                if axiMaster_in.tReady then
128 11 daniel.kho
                                        i_writeResponse.trigger<=true;
129 9 daniel.kho
                                end if;
130 11 daniel.kho
 
131
                                /* TODO change to a flag at user.vhdl. Move outstandingTransactions to user.vhdl. */
132
                                if outstandingTransactions<1 then axiMaster_out.tLast<=true; end if;
133
                        when others=> null;
134 9 daniel.kho
                end case;
135
        end process axi_bfmTx_op;
136
 
137
 
138
        /* state registers and pipelines for AXI4-Stream Tx BFM. */
139
        process(n_areset,aclk) is begin
140
                if not n_areset then next_axiTxState<=idle;
141 11 daniel.kho
                elsif falling_edge(aclk) then
142 9 daniel.kho
                        next_axiTxState<=axiTxState;
143
                        i_writeRequest<=writeRequest;
144
                end if;
145
        end process;
146
 
147 11 daniel.kho
        process(aclk) is begin
148
                if rising_edge(aclk) then
149
                        writeResponse<=i_writeResponse;
150
                end if;
151
        end process;
152 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.