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/] [user-hw-tlm-paper.vhdl] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 23 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
        Synthesisable use case for AXI4 on-chip messaging.
8
 
9
        To Do:
10
 
11
        Author(s):
12
        - Daniel C.K. Kho, daniel.kho@opencores.org | daniel.kho@tauhop.com
13
 
14
        Copyright (C) 2012-2013 Authors and OPENCORES.ORG
15
 
16
        This source file may be used and distributed without
17
        restriction provided that this copyright statement is not
18
        removed from the file and that any derivative work contains
19
        the original copyright notice and the associated disclaimer.
20
 
21
        This source file is free software; you can redistribute it
22
        and/or modify it under the terms of the GNU Lesser General
23
        Public License as published by the Free Software Foundation;
24
        either version 2.1 of the License, or (at your option) any
25
        later version.
26
 
27
        This source is distributed in the hope that it will be
28
        useful, but WITHOUT ANY WARRANTY; without even the implied
29
        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
30
        PURPOSE. See the GNU Lesser General Public License for more
31
        details.
32
 
33
        You should have received a copy of the GNU Lesser General
34
        Public License along with this source; if not, download it
35
        from http://www.opencores.org/lgpl.shtml.
36
*/
37
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; use ieee.math_real.all;
38
--library tauhop; use tauhop.transactor.all, tauhop.axiTransactor.all;          --TODO just use axiTransactor here as transactor should already be wrapped up.
39
 
40
/* TODO remove once generic packages are supported. */
41
library tauhop; use tauhop.tlm.all, tauhop.axiTLM.all;
42
 
43
/* synthesis translate_off */
44
library osvvm; use osvvm.RandomPkg.all; use osvvm.CoveragePkg.all;
45
/* synthesis translate_on */
46
 
47
library altera; use altera.stp;
48
 
49
 
50
entity user is port(
51
        /* Comment-out for simulation. */
52
        clk,nReset:in std_ulogic;
53
 
54
        /* AXI Master interface */
55
        axiMaster_in:in t_axi4StreamTransactor_s2m;
56
        axiMaster_out:buffer t_axi4StreamTransactor_m2s;
57
 
58
        /* Debug ports. */
59
        dataIn:in t_msg;
60
        selTxn:in unsigned(3 downto 0)
61
);
62
end entity user;
63
 
64
architecture rtl of user is
65
        signal reset:std_ulogic:='0';
66
        signal locked:std_ulogic;
67
        signal porCnt:unsigned(3 downto 0);
68
        signal trigger:boolean;
69
 
70
        /* Global counters. */
71
        constant maxSymbols:positive:=2048;             --maximum number of symbols allowed to be transmitted in a frame. Each symbol's width equals tData's width. 
72
        signal symbolsPerTransfer:t_cnt;
73
        signal outstandingTransactions:t_cnt;
74
 
75
        /* BFM signalling. */
76
        signal readRequest,writeRequest:t_bfm:=(address=>(others=>'X'),message=>(others=>'X'),trigger=>false);
77
        signal readResponse,writeResponse:t_bfm;
78
 
79
        type txStates is (idle,transmitting);
80
        signal txFSM,i_txFSM:txStates;
81
 
82
        /* Tester signals. */
83
        /* synthesis translate_off */
84
        signal clk,nReset:std_ulogic:='0';
85
        attribute period:time; attribute period of clk:signal is 10 ps;
86
        /* synthesis translate_on */
87
 
88
        signal testerClk:std_ulogic;
89
        signal dbg_axiTxFSM:axiBfmStatesTx;
90
        signal anlysr_dataIn:std_logic_vector(255 downto 0);
91
        signal anlysr_trigger:std_ulogic;
92
 
93
        signal irq_write:std_ulogic;            -- clock gating.
94
 
95
 
96
begin
97
        /* Bus functional models. */
98
        axiMaster: entity tauhop.axiBfmMaster(rtl)
99
                port map(
100
                        aclk=>irq_write, n_areset=>not reset,
101
 
102
                        readRequest=>readRequest,       writeRequest=>writeRequest,
103
                        readResponse=>readResponse,     writeResponse=>writeResponse,
104
                        axiMaster_in=>axiMaster_in,
105
                        axiMaster_out=>axiMaster_out,
106
 
107
                        symbolsPerTransfer=>symbolsPerTransfer,
108
                        outstandingTransactions=>outstandingTransactions,
109
                        dbg_axiTxFSM=>dbg_axiTxFSM
110
        );
111
 
112
        /* Interrupt-request generator. */
113
        trigger<=txFSM/=i_txFSM or writeResponse.trigger;
114
        irq_write<=clk when not reset else '0';
115
 
116
        /* Simulation Tester. */
117
        /* PLL to generate tester's clock. */
118
        f100MHz: entity altera.pll(syn) port map(
119
                areset=>'0',     --not nReset,
120
                inclk0=>clk,
121
                c0=>testerClk,
122
                locked=>locked
123
        );
124
 
125
        /* synthesis translate_off */
126
        clk<=not clk after clk'period/2;
127
        process is begin
128
                nReset<='1'; wait for 1 ps;
129
                nReset<='0'; wait for 500 ps;
130
                nReset<='1';
131
                wait;
132
        end process;
133
        /* synthesis translate_on */
134
 
135
 
136
        /* Hardware tester. */
137
        /* Power-on Reset circuitry. */
138
        por: process(nReset,clk) is
139
                --variable porCnt:unsigned(7 downto 0):=(others=>'1');
140
        begin
141
                if not nReset then reset<='1'; porCnt<=(others=>'1');
142
                elsif rising_edge(clk) then
143
                        reset<='0';
144
 
145
                        if porCnt>0 then reset<='1'; porCnt<=porCnt-1; end if;
146
                end if;
147
        end process por;
148
 
149
 
150
        /* Stimuli sequencer. TODO move to tester/stimuli.
151
                This emulates the AXI4-Stream Slave.
152
        */
153
        /* Simulation-only stimuli sequencer. */
154
        /* synthesis translate_off */
155
        process is begin
156
                report "Performing fast read..." severity note;
157
 
158
                /* Fast read. */
159
                while not axiMaster_out.tLast loop
160
                        /* Wait for tValid to assert. */
161
                        while not axiMaster_out.tValid loop
162
                                wait until falling_edge(clk);
163
                        end loop;
164
 
165
                        axiMaster_in.tReady<=true;
166
 
167
                        wait until falling_edge(clk);
168
                        axiMaster_in.tReady<=false;
169
                end loop;
170
 
171
                wait until falling_edge(clk);
172
                report "Performing normal read..." severity note;
173
 
174
                /* Normal read. */
175
                while not axiMaster_out.tLast loop
176
                        /* Wait for tValid to assert. */
177
                        while not axiMaster_out.tValid loop
178
                                wait until falling_edge(clk);
179
                        end loop;
180
 
181
                        wait until falling_edge(clk);
182
                        wait until falling_edge(clk);
183
                        axiMaster_in.tReady<=true;
184
 
185
                        wait until falling_edge(clk);
186
                        axiMaster_in.tReady<=false;
187
 
188
                        wait until falling_edge(clk);
189
                end loop;
190
 
191
                report "Completed normal read." severity note;
192
 
193
                for i in 0 to 10 loop
194
                        wait until falling_edge(clk);
195
                end loop;
196
 
197
                /* One-shot read. */
198
                axiMaster_in.tReady<=true;
199
 
200
                wait until falling_edge(clk);
201
                axiMaster_in.tReady<=false;
202
 
203
                report "Completed one-shot read." severity note;
204
 
205
                wait;
206
        end process;
207
        /* synthesis translate_on */
208
 
209
 
210
        sequencer_ns: process(all) is begin
211
                txFSM<=i_txFSM;
212
                if reset then txFSM<=idle;
213
                else
214
                        case i_txFSM is
215
                                when idle=>
216
                                        if outstandingTransactions>0 then txFSM<=transmitting; end if;
217
                                when transmitting=>
218
                                        if axiMaster_out.tLast then
219
                                                txFSM<=idle;
220
                                        end if;
221
                                when others=> null;
222
                        end case;
223
                end if;
224
        end process sequencer_ns;
225
 
226
        sequencer_op: process(reset,irq_write) is
227
                /* Local procedures to map BFM signals with the package procedure. */
228
                procedure read(address:in t_addr) is begin
229
                        read(readRequest,address);
230
                end procedure read;
231
 
232
                procedure write(data:in t_msg) is begin
233
                        write(request=>writeRequest, address=>(others=>'-'), data=>data);
234
                end procedure write;
235
 
236
                variable isPktError:boolean;
237
 
238
                /* Tester variables. */
239
                /* Synthesis-only randomisation. */
240
 
241
                /* Simulation-only randomisation. */
242
                /* synthesis translate_off */
243
                variable rv0:RandomPType;
244
                /* synthesis translate_on */
245
 
246
        begin
247
                if falling_edge(irq_write) then
248
                        case txFSM is
249
                                when transmitting=>
250
                                        if trigger then
251
                                                /* synthesis translate_off */
252
                                                write(rv0.RandSigned(axiMaster_out.tData'length));
253
                                                /* synthesis translate_on */
254
 
255
                                                case selTxn is
256
                                                        when x"0"=> write(dataIn);
257
                                                        when x"1"=> write(32x"12345678");
258
                                                        when x"2"=> write(32x"87654321");
259
                                                        when x"3"=> write(32x"abcd1234");
260
                                                        when others=> write(32x"12ab34cd");
261
                                                end case;
262
                                        end if;
263
                                when others=>null;
264
                        end case;
265
                end if;
266
        end process sequencer_op;
267
 
268
        sequencer_regs: process(irq_write) is begin
269
                if falling_edge(irq_write) then
270
                        i_txFSM<=txFSM;
271
                end if;
272
        end process sequencer_regs;
273
 
274
        outstandingTransactions<=128x"fc";
275
end architecture rtl;

powered by: WebSVN 2.1.0

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