OpenCores
URL https://opencores.org/ocsvn/wb2axip/wb2axip/trunk

Subversion Repositories wb2axip

[/] [wb2axip/] [trunk/] [bench/] [formal/] [fav_slave.v] - Blame information for rev 13

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    fav_slave.v
4
//
5
// Project:     Pipelined Wishbone to AXI converter
6
//
7
// Purpose:     Formal properties of an Avalon slave.  These are the properties
8
//              the module owning the slave should use: they assume inputs from
9
//      the bus master, and assert that the outputs from the slave are valid.
10
//
11
// Creator:     Dan Gisselquist, Ph.D.
12
//              Gisselquist Technology, LLC
13
//
14
////////////////////////////////////////////////////////////////////////////////
15
//
16
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
17
//
18
// This program is free software (firmware): you can redistribute it and/or
19
// modify it under the terms of  the GNU General Public License as published
20
// by the Free Software Foundation, either version 3 of the License, or (at
21
// your option) any later version.
22
//
23
// This program is distributed in the hope that it will be useful, but WITHOUT
24
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
25
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
26
// for more details.
27
//
28
// You should have received a copy of the GNU General Public License along
29
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
30
// target there if the PDF file isn't present.)  If not, see
31
// <http://www.gnu.org/licenses/> for a copy.
32
//
33
// License:     GPL, v3, as defined and found on www.gnu.org,
34
//              http://www.gnu.org/licenses/gpl.html
35
//
36
//
37
////////////////////////////////////////////////////////////////////////////////
38
//
39
//
40
`default_nettype        none
41
//
42
module  fav_slave(i_clk, i_reset,
43
                i_av_read,
44
                i_av_write,
45
                i_av_address,
46
                i_av_writedata,
47
                        i_av_byteenable,
48
                i_av_lock,
49
                i_av_waitrequest,       // = wb_stall
50
                //
51
                i_av_writeresponsevalid,
52
                //
53
                i_av_readdatavalid,
54
                i_av_readdata,
55
                i_av_response,  // Error response = 2'b11
56
                f_rd_nreqs, f_rd_nacks, f_rd_outstanding,
57
                f_wr_nreqs, f_wr_nacks, f_wr_outstanding);
58
        parameter       DW=32, AW=14;
59
        parameter       F_LGDEPTH=6;
60
        parameter       [(F_LGDEPTH-1):0]        F_MAX_REQUESTS = 62;
61
        input   wire                    i_clk, i_reset;
62
        input   wire                    i_av_read;
63
        input   wire                    i_av_write;
64
        input   wire    [(AW-1):0]       i_av_address;
65
        input   wire    [(DW-1):0]       i_av_writedata;
66
        input   wire    [(DW/8-1):0]     i_av_byteenable;
67
        input   wire                    i_av_lock;
68
        //
69
        input   wire                    i_av_waitrequest;
70
        input   wire                    i_av_writeresponsevalid;
71
        input   wire                    i_av_readdatavalid;
72
        input   wire    [(DW-1):0]       i_av_readdata;
73
        input   wire    [1:0]            i_av_response;
74
        //
75
        output  reg     [(F_LGDEPTH-1):0] f_rd_nreqs, f_rd_nacks;
76
        output  wire    [(F_LGDEPTH-1):0] f_rd_outstanding;
77
        output  reg     [(F_LGDEPTH-1):0] f_wr_nreqs, f_wr_nacks;
78
        output  wire    [(F_LGDEPTH-1):0] f_wr_outstanding;
79
 
80
        assert  property(F_MAX_REQUESTS < {(F_LGDEPTH){1'b1}});
81
 
82
 
83
 
84
        reg     f_past_valid;
85
        initial f_past_valid = 1'b0;
86
        always @(posedge i_clk)
87
                f_past_valid <= 1'b1;
88
        always @(*)
89
                assert((f_past_valid) || (i_reset));
90
 
91
        wire    [AW:0]   f_rd_request;
92
        assign  f_rd_request = { i_av_read,  i_av_address };
93
 
94
        wire    [(AW+DW+(DW/8)):0]       f_wr_request;
95
        assign  f_wr_request = { i_av_write, i_av_address, i_av_writedata,
96
                                        i_av_byteenable };
97
 
98
 
99
        always @($global_clock)
100
        if ((f_past_valid)&&(!$rose(i_clk)))
101
        begin
102
                assume($stable(f_rd_request));
103
                assume($stable(f_wr_request));
104
                assume($stable(i_av_lock));
105
 
106
                assert($stable(i_av_readdatavalid));
107
                assert($stable(i_av_writeresponsevalid));
108
                assert($stable(i_av_readdata));
109
                assert($stable(i_av_response));
110
        end
111
 
112
        always @(posedge i_clk)
113
                if ((f_past_valid)&&(!$past(i_av_lock)))
114
                        assume((!i_av_lock)||(i_av_read)||(i_av_write));
115
 
116
        initial f_rd_nreqs = 0;
117
        always @(posedge i_clk)
118
                if (i_reset)
119
                        f_rd_nreqs <= 0;
120
                else if ((i_av_read)&&(!i_av_waitrequest))
121
                        f_rd_nreqs <= f_rd_nreqs + 1'b1;
122
 
123
        initial f_rd_nacks = 0;
124
        always @(posedge i_clk)
125
                if (i_reset)
126
                        f_rd_nacks <= 0;
127
                else if (i_av_readdatavalid)
128
                        f_rd_nacks <= f_rd_nacks + 1'b1;
129
 
130
        assign  f_rd_outstanding = f_rd_nreqs - f_rd_nacks;
131
 
132
        initial f_wr_nreqs = 0;
133
        always @(posedge i_clk)
134
                if (i_reset)
135
                        f_wr_nreqs <= 0;
136
                else if ((i_av_write)&&(!i_av_waitrequest))
137
                        f_wr_nreqs <= f_wr_nreqs + 1'b1;
138
 
139
        initial f_wr_nacks = 0;
140
        always @(posedge i_clk)
141
                if (i_reset)
142
                        f_wr_nacks <= 0;
143
                else if (i_av_writeresponsevalid)
144
                        f_wr_nacks <= f_wr_nacks + 1'b1;
145
 
146
        assign  f_wr_outstanding = f_wr_nreqs - f_wr_nacks;
147
 
148
 
149
        initial assume(!i_av_read);
150
        initial assume(!i_av_write);
151
        initial assume(!i_av_lock);
152
        //
153
        initial assert(!i_av_readdatavalid);
154
        initial assert(!i_av_writeresponsevalid);
155
        //
156
 
157
        always @(posedge i_clk)
158
                if (i_reset)
159
                begin
160
                        assume(!i_av_read);
161
                        assume(!i_av_write);
162
                end
163
 
164
        always @(posedge i_clk)
165
                if ((f_past_valid)&&($past(i_reset)))
166
                begin
167
                        assert(!i_av_readdatavalid);
168
                        assert(!i_av_writeresponsevalid);
169
                        assert(f_rd_nreqs == 0);
170
                        assert(f_rd_nacks == 0);
171
                        assert(f_wr_nreqs == 0);
172
                        assert(f_wr_nacks == 0);
173
                end
174
 
175
        always @(posedge i_clk)
176
        if ((f_past_valid)&&($past(i_av_waitrequest))&&($past(i_av_read)))
177
                assume($stable(f_rd_request));
178
 
179
        always @(posedge i_clk)
180
        if ((f_past_valid)&&($past(i_av_waitrequest))&&($past(i_av_write)))
181
                assume($stable(f_wr_request));
182
 
183
        always @(*)
184
                assume((!i_av_read)||(!i_av_write));
185
 
186
        always @(*)
187
                assert((!i_av_writeresponsevalid)||(!i_av_readdatavalid));
188
 
189
        always @(posedge i_clk)
190
                if (f_rd_outstanding == 0)
191
                        assert(!i_av_readdatavalid);
192
 
193
        always @(posedge i_clk)
194
                if (f_wr_outstanding == 0)
195
                        assert(!i_av_writeresponsevalid);
196
 
197
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.