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

Subversion Repositories axi4_tlm_bfm

[/] [axi4_tlm_bfm/] [trunk/] [rtl/] [user.vhdl] - Blame information for rev 7

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

Line No. Rev Author Line
1 2 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 3 daniel.kho
library ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; use ieee.math_real.all;
38 2 daniel.kho
library tauhop; use tauhop.transactor.all, tauhop.axiTransactor.all;
39 3 daniel.kho
--/* synthesis translate_off */
40
--library osvvm; use osvvm.RandomPkg.all; use osvvm.CoveragePkg.all;
41
--/* synthesis translate_on */
42 2 daniel.kho
 
43
entity user is port(
44
        /* Comment-out for simulation. */
45
--      clk,reset:in std_ulogic;
46
 
47
        /* AXI Master interface */
48 5 daniel.kho
--      axiMaster_in:in t_axi4StreamTransactor_s2m;
49
        axiMaster_out:buffer t_axi4StreamTransactor_m2s
50 2 daniel.kho
 
51
        /* Debug ports. */
52
);
53
end entity user;
54
 
55
architecture rtl of user is
56
        /* Global counters. */
57
        constant maxSymbols:positive:=2048;             --maximum number of symbols allowed to be transmitted in a frame. Each symbol's width equals tData's width. 
58
        signal symbolsPerTransfer:t_cnt;
59
        signal outstandingTransactions:t_cnt;
60
 
61
        /* BFM signalling. */
62 5 daniel.kho
        signal readRequest,next_readRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
63
        signal writeRequest,next_writeRequest:t_bfm:=((others=>'0'),(others=>'0'),false);
64
        signal readResponse,next_readResponse:t_bfm;
65
        signal writeResponse,next_writeResponse:t_bfm;
66 2 daniel.kho
 
67
 
68
        /* Tester signals. */
69
        /* synthesis translate_off */
70
        signal clk,reset:std_ulogic:='0';
71 5 daniel.kho
        signal axiMaster_in:t_axi4StreamTransactor_s2m;
72 2 daniel.kho
        /* synthesis translate_on */
73
 
74
        signal irq_write:std_ulogic;            -- clock gating.
75
 
76
begin
77
        /* pipelines. */
78
        process(reset,clk) is begin
79
                if rising_edge(clk) then
80
                        next_readRequest<=readRequest;
81
                        next_writeRequest<=writeRequest;
82
                        next_readResponse<=readResponse;
83
                        next_writeResponse<=writeResponse;
84
                end if;
85
        end process;
86
 
87
 
88
        /* Bus functional models. */
89
        axiMaster: entity work.axiBfmMaster(rtl)
90
--              generic map(maxTransactions=>maxSymbols)
91
                port map(
92
                        aclk=>irq_write, n_areset=>not reset,
93
                        trigger=>irq_write='1',
94
 
95
                        readRequest=>readRequest,       writeRequest=>writeRequest,
96
                        readResponse=>readResponse,     writeResponse=>writeResponse,
97
                        axiMaster_in=>axiMaster_in,
98
                        axiMaster_out=>axiMaster_out,
99
 
100
                        symbolsPerTransfer=>symbolsPerTransfer,
101
                        outstandingTransactions=>outstandingTransactions,
102
 
103
                        dbg_cnt=>open,
104
                        dbg_axiRxFsm=>open,
105
                        dbg_axiTxFsm=>open
106
        );
107
 
108
        /* Simulation Tester. */
109
        /* synthesis translate_off */
110
        clk<=not clk after 10 ps;
111
        process is begin
112
                reset<='0'; wait for 1 ps;
113
                reset<='1'; wait for 500 ps;
114
                reset<='0';
115
                wait;
116
        end process;
117
 
118
        axiMaster_in.tReady<=true when axiMaster_out.tValid and falling_edge(clk);
119
        /* synthesis translate_on */
120
 
121
        /* Hardware tester. */
122
 
123
        /* Interrupt-request generator. */
124
        irq_write<=clk when not reset;
125
 
126
        /* Stimuli sequencer. */
127
        sequencer: process(reset,irq_write) is
128
                /* Local procedures to map BFM signals with the package procedure. */
129
                procedure read(address:in unsigned(31 downto 0)) is begin
130
                        read(readRequest,address);
131
                end procedure read;
132
 
133
                procedure write(
134
                        address:in t_addr;
135
                        data:in t_msg
136
                ) is begin
137
                        write(writeRequest,address,data);
138
                end procedure write;
139
 
140
                procedure writeStream(
141
                        data:in t_msg
142
                ) is begin
143
                        writeStream(writeRequest,data);
144
                end procedure writeStream;
145
 
146
                variable isPktError:boolean;
147
 
148
                /* Simulation-only randomisation. */
149 3 daniel.kho
                variable seed0,seed1:positive:=1;
150 6 daniel.kho
                variable rand0:real;
151 2 daniel.kho
 
152
        begin
153
                if reset then
154 3 daniel.kho
                        seed0:=1; seed1:=1;
155
 
156
                        uniform(seed0,seed1,rand0);
157 6 daniel.kho
                        symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8);
158 2 daniel.kho
                elsif falling_edge(irq_write) then
159
                        if outstandingTransactions>0 then
160 3 daniel.kho
                                uniform(seed0,seed1,rand0);
161 6 daniel.kho
                                writeStream(to_unsigned(integer(rand0 * 2.0**31),64));
162 2 daniel.kho
 
163
                        else
164
                                /* Testcase 1: number of symbols per transfer becomes 0 after first stream transfer. */
165
                                --symbolsPerTransfer<=(others=>'0');
166
 
167
                                /* Testcase 2: number of symbols per transfer is randomised. */
168 3 daniel.kho
                                uniform(seed0,seed1,rand0);
169 6 daniel.kho
                                symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8);    --symbolsPerTransfer'length
170
                                report "symbols per transfer = " & ieee.numeric_std.to_hstring(to_unsigned(integer(rand0 * 2.0**8),8)); --axiMaster_out.tData'length));
171 2 daniel.kho
                        end if;
172
                end if;
173
        end process sequencer;
174 7 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.