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 8

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 8 daniel.kho
                        outstandingTransactions=>outstandingTransactions
102 2 daniel.kho
        );
103
 
104
        /* Simulation Tester. */
105
        /* synthesis translate_off */
106
        clk<=not clk after 10 ps;
107
        process is begin
108
                reset<='0'; wait for 1 ps;
109
                reset<='1'; wait for 500 ps;
110
                reset<='0';
111
                wait;
112
        end process;
113
 
114
        axiMaster_in.tReady<=true when axiMaster_out.tValid and falling_edge(clk);
115
        /* synthesis translate_on */
116
 
117
        /* Hardware tester. */
118
 
119
        /* Interrupt-request generator. */
120
        irq_write<=clk when not reset;
121
 
122
        /* Stimuli sequencer. */
123
        sequencer: process(reset,irq_write) is
124
                /* Local procedures to map BFM signals with the package procedure. */
125 8 daniel.kho
                procedure read(address:in t_addr) is begin
126 2 daniel.kho
                        read(readRequest,address);
127
                end procedure read;
128
 
129 8 daniel.kho
                procedure write(data:in t_msg) is begin
130
                        write(request=>writeRequest, address=>(others=>'-'), data=>data);
131 2 daniel.kho
                end procedure write;
132
 
133 8 daniel.kho
--              procedure writeStream(
134
--                      data:in t_msg
135
--              ) is begin
136
--                      writeStream(writeRequest,data);
137
--              end procedure writeStream;
138 2 daniel.kho
 
139
                variable isPktError:boolean;
140
 
141
                /* Simulation-only randomisation. */
142 3 daniel.kho
                variable seed0,seed1:positive:=1;
143 6 daniel.kho
                variable rand0:real;
144 2 daniel.kho
 
145
        begin
146
                if reset then
147 3 daniel.kho
                        seed0:=1; seed1:=1;
148
 
149
                        uniform(seed0,seed1,rand0);
150 6 daniel.kho
                        symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8);
151 2 daniel.kho
                elsif falling_edge(irq_write) then
152
                        if outstandingTransactions>0 then
153 3 daniel.kho
                                uniform(seed0,seed1,rand0);
154 8 daniel.kho
                                write(to_unsigned(integer(rand0 * 2.0**31),64));
155 2 daniel.kho
 
156
                        else
157
                                /* Testcase 1: number of symbols per transfer becomes 0 after first stream transfer. */
158
                                --symbolsPerTransfer<=(others=>'0');
159
 
160
                                /* Testcase 2: number of symbols per transfer is randomised. */
161 3 daniel.kho
                                uniform(seed0,seed1,rand0);
162 6 daniel.kho
                                symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8);    --symbolsPerTransfer'length
163
                                report "symbols per transfer = " & ieee.numeric_std.to_hstring(to_unsigned(integer(rand0 * 2.0**8),8)); --axiMaster_out.tData'length));
164 2 daniel.kho
                        end if;
165
                end if;
166
        end process sequencer;
167 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.