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 42

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 17 daniel.kho
entity axiBfmMaster is
45 7 daniel.kho
        port(aclk,n_areset:in std_ulogic;
46
                /* BFM signalling. */
47 15 daniel.kho
                readRequest,writeRequest:in i_transactor.t_bfm:=(address=>(others=>'X'), message=>(others=>'X'), trigger=>false);
48 12 daniel.kho
                readResponse,writeResponse:buffer i_transactor.t_bfm;                                                                   -- use buffer until synthesis tools support reading from out ports.
49 7 daniel.kho
 
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 39 daniel.kho
                lastTransaction:in boolean;
59 7 daniel.kho
 
60
                /* Debug ports. */
61 8 daniel.kho
--              dbg_cnt:out unsigned(9 downto 0);
62
--              dbg_axiRxFsm:out axiBfmStatesRx:=idle;
63 24 daniel.kho
                dbg_axiTxFsm:out axiBfmStatesTx:=idle
64 7 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
 
71 13 daniel.kho
        signal i_axiMaster_out:t_axi4StreamTransactor_m2s;
72 17 daniel.kho
        signal i_trigger,trigger:boolean;
73 13 daniel.kho
 
74 7 daniel.kho
        /* BFM signalling. */
75 17 daniel.kho
        signal i_writeRequest:i_transactor.t_bfm:=(address=>(others=>'X'),message=>(others=>'X'),trigger=>false);
76
        signal i_writeResponse:i_transactor.t_bfm;
77 7 daniel.kho
 
78
begin
79 17 daniel.kho
        i_trigger<=writeRequest.trigger xor i_writeRequest.trigger;
80
 
81 7 daniel.kho
        /* next-state logic for AXI4-Stream Master Tx BFM. */
82
        axi_bfmTx_ns: process(all) is begin
83
                axiTxState<=next_axiTxState;
84
 
85 13 daniel.kho
                if not n_areset then axiTxState<=idle;
86
                else
87
                        case next_axiTxState is
88
                                when idle=>
89 17 daniel.kho
                                        if i_trigger then axiTxState<=payload; end if;
90 13 daniel.kho
                                when payload=>
91 39 daniel.kho
                                        if lastTransaction then axiTxState<=endOfTx; end if;
92 13 daniel.kho
                                when endOfTx=>
93 42 daniel.kho
                                        if axiMaster_in.tReady then axiTxState<=idle; end if;
94 13 daniel.kho
                                when others=>axiTxState<=idle;
95
                        end case;
96
                end if;
97 7 daniel.kho
        end process axi_bfmTx_ns;
98
 
99
        /* output logic for AXI4-Stream Master Tx BFM. */
100
        axi_bfmTx_op: process(all) is begin
101 10 daniel.kho
                i_writeResponse<=writeResponse;
102 7 daniel.kho
 
103 42 daniel.kho
                i_axiMaster_out<=axiMaster_out;
104 13 daniel.kho
                i_axiMaster_out.tLast<=false;
105 10 daniel.kho
                i_writeResponse.trigger<=false;
106
 
107 7 daniel.kho
                case next_axiTxState is
108 17 daniel.kho
                        when idle=>
109 39 daniel.kho
                                i_axiMaster_out.tValid<=false;
110
                                i_axiMaster_out.tData<=(others=>'Z');
111
 
112 17 daniel.kho
                                if i_trigger then
113
                                        i_axiMaster_out.tData<=writeRequest.message;
114
                                        i_axiMaster_out.tValid<=true;
115
                                end if;
116 39 daniel.kho
                        when payload | endOfTx =>
117
                                if i_trigger then
118
                                        i_axiMaster_out.tData<=writeRequest.message;
119
                                        i_axiMaster_out.tValid<=true;
120
                                end if;
121 10 daniel.kho
 
122 7 daniel.kho
                                if axiMaster_in.tReady then
123 10 daniel.kho
                                        i_writeResponse.trigger<=true;
124 7 daniel.kho
                                end if;
125 10 daniel.kho
 
126 39 daniel.kho
                                if lastTransaction then i_axiMaster_out.tLast<=true; end if;
127 10 daniel.kho
                        when others=> null;
128 7 daniel.kho
                end case;
129
        end process axi_bfmTx_op;
130
 
131
        /* state registers and pipelines for AXI4-Stream Tx BFM. */
132 17 daniel.kho
        process(aclk) is begin
133 42 daniel.kho
                if rising_edge(aclk) or falling_edge(aclk) then
134 7 daniel.kho
                        next_axiTxState<=axiTxState;
135
                        i_writeRequest<=writeRequest;
136 17 daniel.kho
                        writeResponse<=i_writeResponse;
137
                        axiMaster_out<=i_axiMaster_out;
138
                        trigger<=i_trigger;
139 7 daniel.kho
                end if;
140
        end process;
141
 
142 42 daniel.kho
        /*
143
        fastPipelines: entity work.ddr(rtl) generic map(busWidth=>8)
144
                port map(reset=>reset,
145
                        clk=>aclk,
146
                        d=>next_axiTxState,
147
                        q=>axiTxState
148
                );
149
        */
150
 
151 24 daniel.kho
        dbg_axiTxFSM<=axiTxState;
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.