Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AXI-Stream Formal Properties #3

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c70a583
First pass at AXI Stream formal properties
rlee287 Dec 5, 2020
ce90a76
Fix README typo
rlee287 Dec 6, 2020
b60c3c5
Add the property that TVALID cannot be deasserted until transfer
rlee287 Dec 6, 2020
0871812
Add note about lack of requirement for no combinational paths to AXIS
rlee287 Dec 9, 2020
985e786
Remove .keep from property_sets now that the directory is populated
rlee287 Dec 9, 2020
40c1b6c
Fix some reset related issues with AXIS properties
rlee287 Dec 9, 2020
06330b2
Fix missing negation of reset in an AXIS slave property
rlee287 Dec 10, 2020
34408c1
Add more checks for past_valid where they are needed
rlee287 Dec 10, 2020
f8921ca
Use nonblocking assignment for past_valid value
rlee287 Dec 11, 2020
43984c5
Fix reset things and use preprocessor to encourage code reuse
rlee287 Dec 16, 2020
cc16378
Check for positive width parameter before assuming/asserting stall st…
rlee287 Dec 19, 2020
7692bac
Adjust reset handling in AXI-Stream properties
rlee287 Dec 22, 2020
6b40ac0
Create a utility for assuming async resets are synchronously released
rlee287 Dec 22, 2020
8579c5c
Allow non-data bytes to vary when stream is stalled
rlee287 Dec 26, 2020
8b36055
Add script to compare AXI-Stream properties and ensure they match cor…
rlee287 Dec 27, 2020
0c478fa
Add README state for "complete but untested" and update statues
rlee287 Dec 27, 2020
ece2d1a
Fix README.md typo
rlee287 Dec 27, 2020
e19f039
Label the AXI-Stream properties with the version and issue of the spec
rlee287 Dec 27, 2020
bdd5b19
Bypass default input tready value when linting with Verilator
rlee287 Dec 27, 2020
674c736
Revert "Allow non-data bytes to vary when stream is stalled"
rlee287 Dec 27, 2020
5657264
Move up definition of TX_ASSERT (so that diff reference can be update…
rlee287 Dec 27, 2020
b1256c8
Move up Section 3.1.5 note and add keep_width for when byte_width=0
rlee287 Dec 27, 2020
22ba3fc
Account for the possibility of byte_width=0 in stall $stable checks
rlee287 Dec 27, 2020
870ac0b
Print out the diff output if the check_differences script fails
rlee287 Dec 29, 2020
0cebe36
Remove extraneous colon from Optional TREADY comment
rlee287 Dec 29, 2020
a4753bf
Add a property to ensure TVALID is raised "in a timely manner"
rlee287 Dec 29, 2020
149bcac
Reset handling should be fixed now...
rlee287 Jan 1, 2021
55f635a
Update diff file for AXI-Stream
rlee287 Jan 1, 2021
dc45ddf
Using not_in_reset requires past_valid
rlee287 Jan 2, 2021
447b415
Assert that valid is raised with backpressure only when no reset happens
rlee287 Jan 2, 2021
9f3b8f4
Update TODO notes in AXI-Stream properties
rlee287 Jan 2, 2021
0eb4261
Update comparison diff for two property sets
rlee287 Jan 2, 2021
aafee53
Merge branch 'main' into axi_stream
rlee287 Jan 3, 2021
e759e47
Rename clk and resetn to aclk and aresetn
rlee287 Jan 3, 2021
9ea22fa
Add TODO note about assuming master readiness in slave properties
rlee287 Jan 4, 2021
1bae26b
Allow valid-before-ready check to be disabled by parameters
rlee287 Jan 7, 2021
d5cd1e6
Add a .gitignore for SymbiYosys and note naming convention in CONTRIB…
rlee287 Jan 15, 2021
bf50f86
Update CONTRIBUTING.md
rlee287 Feb 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

## Introduction

The goal of this project is to develop formal verification properties for various bus standards, write documents to assist people in using these busses, and create verified example cores and infrastructure (e.g. interconnects) based on these properties. Lowering the entry barrier for formal verificationwill allow more people to write HDL modules with the guarantee that they will work properly.
The goal of this project is to develop formal verification properties for various bus standards, write documents to assist people in using these busses, and create verified example cores and infrastructure (e.g. interconnects) based on these properties. Lowering the entry barrier for formal verification will allow more people to write HDL modules with the guarantee that they will work properly.

## Status Table

Key to emojis:

* :x: : Item is not started
* :heavy_minus_sign: : Item is in progress
* :heavy_check_mark: : Item is completed
* :heavy_plus_sign: : Item is completed but has not been tested sufficiently
* :heavy_check_mark: : Item is completed and has been tested sufficiently

All entries may contain an issue number tracking progress on the item.

Item | Wishbone 4 Classic | Wishbone 4 Pipelined | AXI4-Stream | AXI4-Lite | AXI4
---- | ------------------ | -------------------- | ----------- | --------- | ----
Formal Property Set (SVA) | :x: | :x: | :x: | :x: | :x:
Formal Property Set (PSL) | :x: | :x: | :x: | :x: | :x:
Formal Property Set (SVA) | :x: | :x: | :heavy_plus_sign: (#1, #3, #4) | :x: | :x:
Formal Property Set (PSL) | :x: | :x: | :heavy_minus_sign: (#1, awaiting #3 merge) | :x: | :x:
Bus Summary | :x: | :x: | :x: | :x: | :x:
Example Cores (expand list later) | :x: | :x: | :x: | :x: | :x:
Example Cores (expand list later) | :x: | :x: | :x: (#5) | :x: | :x:

## Bus Standards

Expand Down
Empty file removed property_sets/.keep
Empty file.
141 changes: 141 additions & 0 deletions property_sets/axi_stream/axi_stream_master_monitor.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
`default_nettype none

/*
* Section 2.1 Signal list
* Section 3.1 Default value signaling
* Notes on defaults for specific signals in port list below
*/
module axi_stream_master_monitor #(
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
parameter byte_width = 4,
parameter id_width = 0,
parameter dest_width = 0,
parameter user_width = 0,
parameter USE_ASYNC_RESET = 1'b0
) (
input wire clk,
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
input wire resetn,

input wire tvalid,
// Section 3.1.1 Optional TREADY:
// Having a tready port is recommended
input wire tready = 1'b1,

input wire [(8*byte_width-1):0] tdata,
// Section 3.1.2 Optional TKEEP and TSTRB
// TODO: fix optional value declarations
input wire [(byte_width-1):0] tstrb,// = tkeep,
input wire [(byte_width-1):0] tkeep,// = {(byte_width-1){1'b1}},

// Section 3.1.3 Optional TLAST
// Recommended default TLAST value situation-dependent
input wire tlast,

// Section 3.1.4 Optional TID, TDEST, and TUSER
// Signals omitted by setting widths to 0
input wire [(id_width-1):0] tid,
input wire [(dest_width-1):0] tdest,
input wire [(user_width-1):0] tuser

// TODO add output signals for byte counts, etc.
);
reg past_valid = 1'b0;
always @(posedge clk)
past_valid <= 1'b1;

wire in_reset;
reg resetn_delayed;
always @(posedge clk)
resetn_delayed <= resetn;

/*
* If in async mode, reset is combinational
* If in sync mode, reset is registered
* WARNING: there may be off-by-(timestep) errors for reset release
*/
generate
if (USE_ASYNC_RESET)
assign in_reset = !resetn;
else
assign in_reset = !resetn_delayed;
endgenerate

`define TX_ASSERT assert

// TODO handle an asynchronous aresetn
rlee287 marked this conversation as resolved.
Show resolved Hide resolved

// Section 2.2.1 Handshake process

// Once TVALID is asserted it must be held until TVALID && TREADY
always @(posedge clk)
begin
// Write this as (TVALID falls implies previous data transfer or reset)
if (past_valid && $fell(tvalid))
begin
`TX_ASSERT($past(tvalid && tready) || in_reset);
end
end

// Master cannot wait on TREADY to signal TVALID
// TODO write out the below statement in Yosys-readable SVA
// `TX_ASSERT possible((always !tready) && (eventually tvalid))
rlee287 marked this conversation as resolved.
Show resolved Hide resolved

// When TVALID && !TREADY, data signals must be stable
always @(posedge clk)
begin
if (past_valid && !in_reset && $past(tvalid && !tready))
begin
`TX_ASSERT($stable(tstrb));
`TX_ASSERT($stable(tkeep));
`TX_ASSERT($stable(tlast));
if (id_width > 0)
`TX_ASSERT($stable(tid));
if (dest_width > 0)
`TX_ASSERT($stable(tdest));
if (user_width > 0)
`TX_ASSERT($stable(tuser));
end
end
// Section 2.4 Byte Qualifiers
// The data byte's value is only significant for data bytes
// Don't care if stalled position or null bytes change values
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
generate
genvar i;
for (i = 0; i < byte_width; i = i + 1)
begin
always @(posedge clk)
if (past_valid && !in_reset && $past(tvalid && !tready))
begin
// Data bytes are when tkeep[i] and tstrb[i] are asserted
if (tkeep[i] && tstrb[i])
`TX_ASSERT($stable(tdata[8*i+7:8*i]));
end
end
endgenerate

// Section 2.7.1 Clock
// Unlike regular AXI there is no requirement for no combinational paths
rlee287 marked this conversation as resolved.
Show resolved Hide resolved

// Section 2.7.2 Reset
always @(*)
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
begin
if (in_reset)
begin
`TX_ASSERT(!tvalid);
end
end

// Section 2.4.3 TKEEP and TSTRB combinations
// TSTRB can be asserted only if TKEEP is asserted
always @(*)
begin
if (tvalid)
begin
`TX_ASSERT(!(~tkeep & tstrb));
end
end

// Section 3.1.5 Optional TDATA
// no TDATA -> no TSTRB
// XXX: this isn't really representable as a formal property
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
endmodule
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
`undef TX_ASSERT
141 changes: 141 additions & 0 deletions property_sets/axi_stream/axi_stream_slave_monitor.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
`default_nettype none

/*
* Section 2.1 Signal list
* Section 3.1 Default value signaling
* Notes on defaults for specific signals in port list below
*/
module axi_stream_slave_monitor #(
parameter byte_width = 4,
parameter id_width = 0,
parameter dest_width = 0,
parameter user_width = 0,
parameter USE_ASYNC_RESET = 1'b0
) (
input wire clk,
input wire resetn,

input wire tvalid,
// Section 3.1.1 Optional TREADY:
// Having a tready port is recommended
input wire tready = 1'b1,

input wire [(8*byte_width-1):0] tdata,
// Section 3.1.2 Optional TKEEP and TSTRB
// TODO: fix optional value declarations
input wire [(byte_width-1):0] tstrb,// = tkeep,
input wire [(byte_width-1):0] tkeep,// = {(byte_width-1){1'b1}},

// Section 3.1.3 Optional TLAST
// Recommended default TLAST value situation-dependent
input wire tlast,

// Section 3.1.4 Optional TID, TDEST, and TUSER
// Signals omitted by setting widths to 0
input wire [(id_width-1):0] tid,
input wire [(dest_width-1):0] tdest,
input wire [(user_width-1):0] tuser

// TODO add output signals for byte counts, etc.
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
);
reg past_valid = 1'b0;
always @(posedge clk)
past_valid <= 1'b1;

wire in_reset;
reg resetn_delayed;
always @(posedge clk)
resetn_delayed <= resetn;

/*
* If in async mode, reset is combinational
* If in sync mode, reset is registered
* WARNING: there may be off-by-(timestep) errors for reset release
*/
generate
if (USE_ASYNC_RESET)
assign in_reset = !resetn;
else
assign in_reset = !resetn_delayed;
endgenerate

`define TX_ASSERT assume

// TODO handle an asynchronous aresetn

// Section 2.2.1 Handshake process

// Once TVALID is asserted it must be held until TVALID && TREADY
always @(posedge clk)
begin
// Write this as (TVALID falls implies previous data transfer or reset)
if (past_valid && $fell(tvalid))
begin
`TX_ASSERT($past(tvalid && tready) || in_reset);
end
end

// Master cannot wait on TREADY to signal TVALID
// TODO write out the below statement in Yosys-readable SVA
// `TX_ASSERT possible((always !tready) && (eventually tvalid))

// When TVALID && !TREADY, data signals must be stable
always @(posedge clk)
begin
if (past_valid && !in_reset && $past(tvalid && !tready))
begin
`TX_ASSERT($stable(tstrb));
`TX_ASSERT($stable(tkeep));
`TX_ASSERT($stable(tlast));
if (id_width > 0)
`TX_ASSERT($stable(tid));
if (dest_width > 0)
`TX_ASSERT($stable(tdest));
if (user_width > 0)
`TX_ASSERT($stable(tuser));
end
end
// Section 2.4 Byte Qualifiers
// The data byte's value is only significant for data bytes
// Don't care if stalled position or null bytes change values
generate
genvar i;
for (i = 0; i < byte_width; i = i + 1)
begin
always @(posedge clk)
if (past_valid && !in_reset && $past(tvalid && !tready))
begin
// Data bytes are when tkeep[i] and tstrb[i] are asserted
if (tkeep[i] && tstrb[i])
`TX_ASSERT($stable(tdata[8*i+7:8*i]));
end
end
endgenerate

// Section 2.7.1 Clock
// Unlike regular AXI there is no requirement for no combinational paths

// Section 2.7.2 Reset
always @(*)
begin
if (in_reset)
begin
`TX_ASSERT(!tvalid);
end
end

// Section 2.4.3 TKEEP and TSTRB combinations
// TSTRB can be asserted only if TKEEP is asserted
always @(*)
begin
if (tvalid)
begin
`TX_ASSERT(!(~tkeep & tstrb));
end
end

// Section 3.1.5 Optional TDATA
// no TDATA -> no TSTRB
// XXX: this isn't really representable as a formal property
endmodule
`undef TX_ASSERT
8 changes: 8 additions & 0 deletions property_sets/axi_stream/axis_m_to_s_diff.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
8c8
< module axi_stream_master_monitor #(
---
> module axi_stream_slave_monitor #(
62c62
< `define TX_ASSERT assert
---
> `define TX_ASSERT assume
11 changes: 11 additions & 0 deletions property_sets/axi_stream/check_differences.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
diff axi_stream_master_monitor.v axi_stream_slave_monitor.v | diff - axis_m_to_s_diff.diff > /dev/null

# Use true and false to avoid exiting the shell if this script is sourced
if [ $? -eq 0 ]; then
echo "AXI-Stream property pairs match"
true
else
echo "AXI-Stream property pairs differ"
false
fi
26 changes: 26 additions & 0 deletions property_sets/utils/assume_areset_sync_release.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
`default_nettype none

module assume_areset_sync_release #(
parameter reset_inverted = 1'b1
) (
input wire clk,
input wire async_reset
);
wire reset_asserted;
generate
if (reset_inverted)
assign reset_asserted = !async_reset;
else
assign reset_asserted = async_reset;
endgenerate

(* gclk *) reg formal_timestep;

always @(posedge formal_timestep)
begin
if ($fell(reset_asserted))
begin
assume($rose(clk));
end
end
endmodule