Skip to content

Commit 239c097

Browse files
committed
Added assertions to all interfaces that interact with the simulation
1 parent 81133d2 commit 239c097

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

hw/hdl/pkg/assert_macros.svh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* This file is part of the Coyote <https://github.com/fpgasystems/Coyote>
3+
*
4+
* MIT Licence
5+
* Copyright (c) 2021-2025, Systems Group, ETH Zurich
6+
* All rights reserved.
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
27+
`ifndef COYOTE_ASSERT_MACROS_SVH
28+
`define COYOTE_ASSERT_MACROS_SVH
29+
30+
`define STRINGIFY(x) $sformatf("%0s", `"x`")
31+
32+
`define ASSERT_NOT_UNDEFINED(sig) \
33+
assert property (@(posedge aclk) disable iff (!aresetn) \
34+
!$isunknown(sig)) \
35+
else $fatal(1, "Signal %s needs to not be undefined!", `STRINGIFY(sig));
36+
37+
`define ASSERT_STABLE(sig, sig_valid, sig_ready) \
38+
assert property (@(posedge aclk) disable iff (!aresetn) \
39+
(sig_valid && !sig_ready && $past(aresetn)) |=> $stable(sig)) \
40+
else $fatal(1, "Signal %s needs to be stable while valid && !ready (old = 0b%0b, new = 0b%0b)!", `STRINGIFY(sig), $past(sig), sig);
41+
42+
`define ASSERT_SIGNAL_STABLE(sig) `ASSERT_STABLE(sig, tvalid, tready)
43+
44+
`endif

hw/hdl/pkg/axi_intf.sv

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import lynxTypes::*;
3333

34+
`include "libstf_macros.svh"
35+
3436
// ----------------------------------------------------------------------------
3537
// AXI4
3638
// ----------------------------------------------------------------------------
@@ -325,6 +327,35 @@ clocking cbs @(posedge aclk);
325327
output awready, arready, rresp, rdata, rvalid, wready, bresp, bvalid;
326328
endclocking
327329

330+
// Assertions
331+
`ASSERT_STABLE(awaddr, awvalid, awready);
332+
`ASSERT_STABLE(awprot, awvalid, awready);
333+
`ASSERT_STABLE(awqos, awvalid, awready);
334+
`ASSERT_STABLE(awregion, awvalid, awready);
335+
`ASSERT_NOT_UNDEFINED(awvalid);
336+
`ASSERT_NOT_UNDEFINED(awready);
337+
338+
`ASSERT_STABLE(araddr, arvalid, arready);
339+
`ASSERT_STABLE(arprot, arvalid, arready);
340+
`ASSERT_STABLE(arqos, arvalid, arready);
341+
`ASSERT_STABLE(arregion, arvalid, arready);
342+
`ASSERT_NOT_UNDEFINED(arvalid);
343+
`ASSERT_NOT_UNDEFINED(arready);
344+
345+
`ASSERT_STABLE(wdata, wvalid, wready);
346+
`ASSERT_STABLE(wstrb, wvalid, wready);
347+
`ASSERT_NOT_UNDEFINED(wvalid);
348+
`ASSERT_NOT_UNDEFINED(wready);
349+
350+
`ASSERT_STABLE(rresp, rvalid, rready);
351+
`ASSERT_STABLE(rdata, rvalid, rready);
352+
`ASSERT_NOT_UNDEFINED(rvalid);
353+
`ASSERT_NOT_UNDEFINED(rready);
354+
355+
`ASSERT_STABLE(bresp, bvalid, bready);
356+
`ASSERT_NOT_UNDEFINED(bvalid);
357+
`ASSERT_NOT_UNDEFINED(bready);
358+
328359
endinterface
329360

330361
// ----------------------------------------------------------------------------
@@ -373,6 +404,13 @@ modport s (
373404
output tready
374405
);
375406

407+
// Assertions
408+
`ASSERT_SIGNAL_STABLE(tdata);
409+
`ASSERT_SIGNAL_STABLE(tkeep);
410+
`ASSERT_SIGNAL_STABLE(tlast);
411+
`ASSERT_NOT_UNDEFINED(tvalid);
412+
`ASSERT_NOT_UNDEFINED(tready);
413+
376414
endinterface
377415

378416

@@ -439,6 +477,14 @@ clocking cbs @(posedge aclk);
439477
output tready;
440478
endclocking
441479

480+
// Assertions
481+
`ASSERT_SIGNAL_STABLE(tdata);
482+
`ASSERT_SIGNAL_STABLE(tid);
483+
`ASSERT_SIGNAL_STABLE(tkeep);
484+
`ASSERT_SIGNAL_STABLE(tlast);
485+
`ASSERT_NOT_UNDEFINED(tvalid);
486+
`ASSERT_NOT_UNDEFINED(tready);
487+
442488
endinterface
443489

444490
// ----------------------------------------------------------------------------

hw/hdl/pkg/lynx_intf.sv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import lynxTypes::*;
3333

34+
`include "libstf_macros.svh"
35+
3436
// ----------------------------------------------------------------------------
3537
// Generic meta interface
3638
// ----------------------------------------------------------------------------
@@ -81,6 +83,11 @@ clocking cbs @(posedge aclk);
8183
output ready;
8284
endclocking
8385

86+
// Assertions
87+
`ASSERT_STABLE(data, valid, ready);
88+
`ASSERT_NOT_UNDEFINED(valid);
89+
`ASSERT_NOT_UNDEFINED(ready);
90+
8491
endinterface
8592

8693
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)