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 9

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
/* 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
                /* User trigger. */
47
                trigger:in boolean;
48
 
49
                /* BFM signalling. */
50
                readRequest,writeRequest:in t_bfm:=((others=>'X'),(others=>'X'),false); -- this is tauhop.transactor.t_bfm.
51
                readResponse,writeResponse:buffer t_bfm;                                                                        -- use buffer until synthesis tools support reading from out ports.
52
 
53
                /* AXI Master interface */
54
                axiMaster_in:in t_axi4StreamTransactor_s2m;
55
                axiMaster_out:buffer t_axi4StreamTransactor_m2s;
56
 
57
--              /* AXI Slave interface */
58
--              axiSlave_in:in tAxi4Transactor_m2s;
59
--              axiSlave_out:buffer tAxi4Transactor_s2m;
60
 
61
                symbolsPerTransfer:in t_cnt;
62
                outstandingTransactions:buffer t_cnt
63
 
64
                /* Debug ports. */
65
--              dbg_cnt:out unsigned(9 downto 0);
66
--              dbg_axiRxFsm:out axiBfmStatesRx:=idle;
67
--              dbg_axiTxFsm:out axiBfmStatesTx:=idle
68
        );
69
end entity axiBfmMaster;
70
 
71
architecture rtl of axiBfmMaster is
72
        /* Finite-state Machines. */
73
        signal axiTxState,next_axiTxState:axiBfmStatesTx:=idle;
74
 
75
        /* General pipelines. */
76
        signal i_axiMaster_out:t_axi4StreamTransactor_m2s;
77
 
78
        /* BFM signalling. */
79
        signal i_readRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
80
        signal i_writeRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
81
 
82
        signal response,i_response:boolean;
83
 
84
begin
85
        /* Transaction counter. */
86
        process(n_areset,symbolsPerTransfer,aclk) is begin
87
                if not n_areset then outstandingTransactions<=symbolsPerTransfer;
88
                elsif rising_edge(aclk) then
89
                        if outstandingTransactions>0 then outstandingTransactions<=outstandingTransactions-1;
90
                        else
91
                                outstandingTransactions<=symbolsPerTransfer;
92
                                report "No more pending transactions." severity note;
93
                        end if;
94
                end if;
95
        end process;
96
 
97
        /* next-state logic for AXI4-Stream Master Tx BFM. */
98
        axi_bfmTx_ns: process(all) is begin
99
                axiTxState<=next_axiTxState;
100
 
101
                if not n_areset then axiTxState<=idle;
102
                elsif writeRequest.trigger xor i_writeRequest.trigger then axiTxState<=payload;
103
                end if;
104
 
105
                case next_axiTxState is
106
                        when idle=>null;
107
                        when payload=>
108
                                if outstandingTransactions<1 then axiTxState<=idle; end if;
109
                        when others=>axiTxState<=idle;
110
                end case;
111
        end process axi_bfmTx_ns;
112
 
113
        /* output logic for AXI4-Stream Master Tx BFM. */
114
        axi_bfmTx_op: process(all) is begin
115
                axiMaster_out<=i_axiMaster_out;
116
 
117
                case next_axiTxState is
118
                        when payload=>
119
                                axiMaster_out.tValid<=true;
120
                                if axiMaster_in.tReady then
121
                                        axiMaster_out.tData<=writeRequest.message;
122
                                end if;
123
                        when others=> axiMaster_out.tValid<=false; axiMaster_out.tData<=(others=>'Z');          --TODO: set 'Z' to '0' for synthesis.
124
                end case;
125
        end process axi_bfmTx_op;
126
 
127
 
128
        /* state registers and pipelines for AXI4-Stream Tx BFM. */
129
        process(n_areset,aclk) is begin
130
                if not n_areset then next_axiTxState<=idle;
131
                elsif rising_edge(aclk) then
132
                        next_axiTxState<=axiTxState;
133
                        i_axiMaster_out<=axiMaster_out;
134
                        i_writeRequest<=writeRequest;
135
                end if;
136
        end process;
137
 
138
--      dbg_axiTxFsm<=axiTxState;
139
end architecture rtl;

powered by: WebSVN 2.1.0

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