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 |
9 |
daniel.kho |
library tauhop; use tauhop.transactor.all, tauhop.axiTransactor.all; --TODO just use axiTransactor here as transactor should already be wrapped up.
|
39 |
|
|
/* 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 |
9 |
daniel.kho |
process(clk) is begin
|
79 |
2 |
daniel.kho |
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 |
9 |
daniel.kho |
/* Interrupt-request generator. */
|
105 |
|
|
irq_write<=clk when not reset else '0';
|
106 |
|
|
|
107 |
2 |
daniel.kho |
/* Simulation Tester. */
|
108 |
|
|
/* synthesis translate_off */
|
109 |
|
|
clk<=not clk after 10 ps;
|
110 |
|
|
process is begin
|
111 |
|
|
reset<='0'; wait for 1 ps;
|
112 |
|
|
reset<='1'; wait for 500 ps;
|
113 |
|
|
reset<='0';
|
114 |
|
|
wait;
|
115 |
|
|
end process;
|
116 |
|
|
/* synthesis translate_on */
|
117 |
|
|
|
118 |
|
|
/* Hardware tester. */
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
/* Stimuli sequencer. */
|
122 |
9 |
daniel.kho |
axiMaster_in.tReady<=true when axiMaster_out.tValid and falling_edge(clk);
|
123 |
|
|
|
124 |
2 |
daniel.kho |
sequencer: process(reset,irq_write) is
|
125 |
|
|
/* Local procedures to map BFM signals with the package procedure. */
|
126 |
8 |
daniel.kho |
procedure read(address:in t_addr) is begin
|
127 |
2 |
daniel.kho |
read(readRequest,address);
|
128 |
|
|
end procedure read;
|
129 |
|
|
|
130 |
8 |
daniel.kho |
procedure write(data:in t_msg) is begin
|
131 |
|
|
write(request=>writeRequest, address=>(others=>'-'), data=>data);
|
132 |
2 |
daniel.kho |
end procedure write;
|
133 |
|
|
|
134 |
|
|
variable isPktError:boolean;
|
135 |
|
|
|
136 |
|
|
/* Simulation-only randomisation. */
|
137 |
9 |
daniel.kho |
variable rv0,rv1:RandomPType;
|
138 |
|
|
-- variable seed0,seed1:positive:=1;
|
139 |
|
|
-- variable rand0:real;
|
140 |
2 |
daniel.kho |
|
141 |
|
|
begin
|
142 |
|
|
if reset then
|
143 |
9 |
daniel.kho |
-- seed0:=1; seed1:=1;
|
144 |
|
|
-- uniform(seed0,seed1,rand0);
|
145 |
|
|
--
|
146 |
|
|
-- symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8);
|
147 |
3 |
daniel.kho |
|
148 |
9 |
daniel.kho |
rv0.InitSeed(rv0'instance_name);
|
149 |
|
|
rv1.InitSeed(rv1'instance_name);
|
150 |
|
|
symbolsPerTransfer<=120x"0" & rv0.RandUnsigned(8);
|
151 |
2 |
daniel.kho |
elsif falling_edge(irq_write) then
|
152 |
|
|
if outstandingTransactions>0 then
|
153 |
9 |
daniel.kho |
-- uniform(seed0,seed1,rand0);
|
154 |
|
|
-- write(to_signed(integer(rand0 * 2.0**31),64));
|
155 |
2 |
daniel.kho |
|
156 |
9 |
daniel.kho |
write(rv1.RandSigned(axiMaster_out.tData'length));
|
157 |
2 |
daniel.kho |
else
|
158 |
|
|
/* Testcase 1: number of symbols per transfer becomes 0 after first stream transfer. */
|
159 |
|
|
--symbolsPerTransfer<=(others=>'0');
|
160 |
|
|
|
161 |
|
|
/* Testcase 2: number of symbols per transfer is randomised. */
|
162 |
9 |
daniel.kho |
-- uniform(seed0,seed1,rand0);
|
163 |
|
|
-- symbolsPerTransfer<=120x"0" & to_unsigned(integer(rand0 * 2.0**8),8); --symbolsPerTransfer'length
|
164 |
|
|
-- report "symbols per transfer = " & ieee.numeric_std.to_hstring(to_unsigned(integer(rand0 * 2.0**8),8)); --axiMaster_out.tData'length));
|
165 |
|
|
|
166 |
|
|
/* Truncate symbolsPerTransfer to 8 bits, so that it uses a "small" value for simulation. */
|
167 |
|
|
symbolsPerTransfer<=120x"0" & rv0.RandUnsigned(8);
|
168 |
|
|
report "symbols per transfer = 0x" & ieee.numeric_std.to_hstring(rv0.RandUnsigned(axiMaster_out.tData'length));
|
169 |
2 |
daniel.kho |
end if;
|
170 |
|
|
end if;
|
171 |
|
|
end process sequencer;
|
172 |
9 |
daniel.kho |
end architecture rtl;
|