Skip to content

Commit 89b4751

Browse files
committed
Increase coverage of TileLink traffic generator
Signed-off-by: Daniel Bates <Daniel.Bates@cl.cam.ac.uk>
1 parent 8d3c5a8 commit 89b4751

File tree

9 files changed

+188
-118
lines changed

9 files changed

+188
-118
lines changed

test/tilelink/rtl/tl_assert.sv

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -92,38 +92,9 @@ module tl_assert import tl_pkg::*; #(
9292

9393
// Copy input TileLink fields to local variables.
9494
`TL_DECLARE(DataWidth, AddrWidth, SourceWidth, SinkWidth, tl);
95-
// `TL_BIND_TAP_PORT(tl, tl);
9695

9796
// Latch the previous input so we can look at transitions.
9897
`TL_DECLARE(DataWidth, AddrWidth, SourceWidth, SinkWidth, prev_tl);
99-
`TL_DECLARE(DataWidth, AddrWidth, SourceWidth, SinkWidth, prev_accepted);
100-
`TL_DECLARE(DataWidth, AddrWidth, SourceWidth, SinkWidth, prev_declined);
101-
102-
// Capture the last accepted/declined beats from a named channel.
103-
// TODO: this is for functional coverage. Not tested yet.
104-
// TODO: focus on non-continuous matches.
105-
// TODO: accepted being valid doesn't make declined invalid.
106-
`define COVERAGE_CAPTURE(CHANNEL) \
107-
if (tl_``CHANNEL``_valid) begin \
108-
prev_accepted_``CHANNEL``_valid <= tl_``CHANNEL``_ready; \
109-
prev_declined_``CHANNEL``_valid <= !tl_``CHANNEL``_ready; \
110-
\
111-
if (tl_``CHANNEL``_ready) begin \
112-
prev_accepted_``CHANNEL`` <= tl_``CHANNEL``; \
113-
end else begin \
114-
prev_declined_``CHANNEL`` <= tl_``CHANNEL``; \
115-
end \
116-
end
117-
118-
always_ff @(posedge clk_i) begin
119-
`COVERAGE_CAPTURE(a);
120-
`COVERAGE_CAPTURE(b);
121-
`COVERAGE_CAPTURE(c);
122-
`COVERAGE_CAPTURE(d);
123-
`COVERAGE_CAPTURE(e);
124-
end
125-
126-
`undef COVERAGE_CAPTURE
12798

12899
////////////////////////////////////
129100
// Keep track of pending requests //
@@ -883,15 +854,13 @@ module tl_assert import tl_pkg::*; #(
883854
`S_COVER(``CHANNEL``BackToBack_C, ``CHANNEL``BackToBack_S)
884855

885856
// A valid signal is deasserted before it is accepted by the recipient.
886-
// TODO: check that this is doing what we expect
887857
`define VALID_NOT_ACCEPTED(CHANNEL) \
888858
`SEQUENCE(``CHANNEL``ValidNotAccepted_S, \
889859
prev_tl_``CHANNEL``_valid && !prev_tl_``CHANNEL``_ready && !tl_``CHANNEL``_valid \
890860
); \
891861
`S_COVER(``CHANNEL``ValidNotAccepted_C, ``CHANNEL``ValidNotAccepted_S)
892862

893863
// Content is changed without being accepted.
894-
// TODO: check that this is doing what we expect
895864
`define CHANGED_WITHOUT_ACCEPTED(CHANNEL, NAME) \
896865
`SEQUENCE(``CHANNEL``_``NAME``ChangedNotAccepted_S, \
897866
tl_``CHANNEL``_valid && prev_declined_``CHANNEL``_valid && \
@@ -997,9 +966,9 @@ module tl_assert import tl_pkg::*; #(
997966

998967
// TODO: current macro can't accept multibit properties.
999968
if (Protocol == TL_C) begin : gen_tlc_simultaneous_cov
1000-
`S_COVER(tlc_simultaneous, tlc_accepted);
969+
//`S_COVER(tlc_simultaneous, tlc_accepted);
1001970
end else begin : gen_tluh_simultaneous_cov
1002-
`S_COVER(tluh_simultaneous, tluh_accepted);
971+
//`S_COVER(tluh_simultaneous, tluh_accepted);
1003972
end
1004973

1005974
endmodule

test/tilelink/rtl/tl_wrapper.sv

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module tl_wrapper #(
77
parameter int unsigned DataWidth = 64,
88
parameter int unsigned HostSourceWidth = 3,
99
parameter int unsigned DeviceSourceWidth = 7, // HSW + 2 (TL-UH) + 2 (TL-UL)
10-
parameter int unsigned SinkWidth = 2,
10+
parameter int unsigned SinkWidth = 3,
1111
parameter int unsigned MaxSize = 5
1212
) (
1313
// Clock and reset
@@ -116,7 +116,7 @@ module tl_wrapper #(
116116

117117
// TileLink structure:
118118
//
119-
// host0 (TL-C) host1 (TL-UH) host2 (TL-UL)
119+
// host0 (TL-C) host1 (TL-C) host2 (TL-UL)
120120
// |_________________________|_________________________|
121121
// | (host_tl)
122122
// socket_m1
@@ -142,12 +142,16 @@ module tl_wrapper #(
142142
.MaxSize (MaxSize),
143143

144144
// TODO: Not 100% sure of the difference between these two
145-
.NumCachedHosts (1),
146-
.NumCachedLinks (1),
147-
148-
.NumSourceRange (2), // Excluding default source 0
149-
.SourceBase ({{{HostSourceWidth-2{1'b0}}, 2'd1}, {{HostSourceWidth-2{1'b0}}, 2'd2}}),
150-
.SourceMask ({{HostSourceWidth{1'b0}}, {HostSourceWidth{1'b0}}}),
145+
.NumCachedHosts (2),
146+
.NumCachedLinks (2),
147+
148+
// Routing table:
149+
// Source IDs 0-3: host 0 (default)
150+
// Source IDs 4-5: host 1
151+
// Source IDs 6-7: host 2
152+
.NumSourceRange (2), // Excludes default host
153+
.SourceBase ({3'd4, 3'd6}), //
154+
.SourceMask ({3'b001, 3'b001}), // TODO: ensure this matches HostSourceWidth
151155
.SourceLink ({2'd1, 2'd2})
152156
) socket_m1 (
153157
.clk_i,
@@ -163,13 +167,18 @@ module tl_wrapper #(
163167
.SinkWidth (SinkWidth),
164168
.MaxSize (MaxSize),
165169
.NumLinks (3),
166-
.NumAddressRange (2), // Excluding default sink 0
170+
171+
// Routing tables:
172+
// Addresses 0x0xxxxxxx, sink IDs 0-3: device 0 (default)
173+
// Addresses 0x1xxxxxxx, sink IDs 4-5: device 1
174+
// Addresses 0x2xxxxxxx, sink IDs 6-7: device 2
175+
.NumAddressRange (2), // Excludes default device 0
167176
.AddressBase ({56'h10000000, 56'h20000000}),
168177
.AddressMask ({56'h0fffffff, 56'h0fffffff}),
169178
.AddressLink ({2'd 1, 2'd 2}),
170179
.NumSinkRange (2),
171-
.SinkBase ({{{SinkWidth-2{1'b0}}, 2'd1}, {{SinkWidth-2{1'b0}}, 2'd2}}),
172-
.SinkMask ({{SinkWidth{1'b0}}, {SinkWidth{1'b0}}}),
180+
.SinkBase ({3'd4, 3'd6}), //
181+
.SinkMask ({3'b001, 3'b001}), // TODO: ensure this matches SinkWidth
173182
.SinkLink ({2'd1, 2'd2})
174183
) socket_1n (
175184
.clk_i,

test/tilelink/src/tl_channels.cc

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ void TileLinkSenderB::queue_request(bool randomise,
127127

128128
tl_message<tl_b> request(*this, randomise, requirements);
129129

130-
// Send Probe requests out to all masters.
130+
// Prepare to send Probe requests out to all masters.
131+
// Don't send anything yet though - first need to confirm that transaction
132+
// IDs are available.
133+
vector<tl_message<tl_b>> pending;
131134
for (int i=0; i<the_sim->num_hosts(); i++) {
132135
auto& host = the_sim->host(i);
133136
if (host.protocol != TL_C)
@@ -137,6 +140,16 @@ void TileLinkSenderB::queue_request(bool randomise,
137140
// associated with the host, or just the index of the host.
138141
request.header.source = host.c.get_routing_id(randomise);
139142

143+
int id = get_b_id(request.header.source, request.header.address);
144+
145+
if (this->transaction_id_available(id))
146+
pending.push_back(request);
147+
else
148+
return; // Could try another source/address, but this is simpler.
149+
}
150+
151+
// Send requests now that everything is confirmed safe.
152+
for (auto request : pending) {
140153
// We only support a subset of B requests, which are all single beats.
141154
this->to_send.push(request);
142155
this->start_transaction(get_b_id(request.header.source, request.header.address));
@@ -250,12 +263,28 @@ extern bool requires_response(tl_d_op_e opcode);
250263
void TileLinkSenderD::respond(bool randomise, tl_a& request) {
251264
tl_message<tl_d> response(*this, request, randomise);
252265
this->to_send.push(response);
266+
267+
// ArithmeticData and LogicalData are multibeat requests, but we respond to
268+
// each beat individually, so we need to lock the output buffer until we
269+
// have responded to all beats.
270+
if (request.opcode == ArithmeticData || request.opcode == LogicalData) {
271+
// First beat.
272+
if (beats_remaining == 0)
273+
beats_remaining = std::max(1, (1 << request.size) / (this->bit_width() / 8));
274+
275+
beats_remaining--;
276+
277+
lock_output_buffer = (beats_remaining > 0);
278+
}
279+
else
280+
assert(!lock_output_buffer);
253281

254282
if (requires_response(response.header.opcode))
255283
this->start_transaction(response.header.sink);
256284
}
257285

258286
void TileLinkSenderD::respond(bool randomise, tl_c& request) {
287+
assert(!lock_output_buffer);
259288
tl_message<tl_d> response(*this, request, randomise);
260289
this->to_send.push(response);
261290

@@ -283,6 +312,11 @@ void TileLinkSenderD::respond() {
283312
}
284313
}
285314

315+
// The output buffer may become locked if only a partial response has been
316+
// queued so far.
317+
if (lock_output_buffer)
318+
return;
319+
286320
int num_c_requests = c_requests.size();
287321
for (int i=0; i<num_c_requests; i++) {
288322
auto request = c_requests.front();

0 commit comments

Comments
 (0)