File: chapter_attributes.xml

package info (click to toggle)
covered 0.7.10-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,040 kB
  • sloc: ansic: 48,809; yacc: 11,650; xml: 8,838; tcl: 7,698; sh: 3,925; lex: 2,240; makefile: 362; perl: 329
file content (283 lines) | stat: -rw-r--r-- 12,030 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<chapter id="chapter.attr">
  <title>Inline Attributes</title>
  
  <sect1 id="section.attr">
    <title>What are inline attributes?</title>
    <para>
      In the IEEE Verilog 1364-2001 standard, an attribute is a way to add information to a Verilog object, statement or 
      groups of statements that is tool-specific and does not affect simulation of that design. All Verilog-2001 
      attributes begin with the token <code>(*</code> and end with the token <code>*)</code>. An attribute can be 
      multi-line and is "attached" to the Verilog object, statement, or group of statements that is specified immediately 
      beneath the attribute.
    </para>
    <para>
      Covered uses the Verilog-2001 attribute for allowing users to specify coverage-specific information about embedded 
      objects within a particular design. When an attribute is found, it is interrogated to see if it is a Covered 
      attribute. If the attribute is a Covered attribute, its contents are parsed. If the attribute is not found to be a 
      Covered attribute, it is ignored and parsing continues normally.
    </para>
    <para>
      The rest of this chapter specifies the attributes that Covered is capable of handling, along with their use and 
      syntax.
    </para>
  </sect1>
  
  <sect1 id="section.attr.fsm">
    <title>Adding FSM attributes</title>
    <para>
      There are two ways that Covered currently allows the user to specify the location of and information about FSMs 
      embedded in a particular design. The first way to specify an FSM is on the score command-line. The benefit to 
      specifying the location of a state machine this way is that the source code does not need to be modified. The 
      potential disadvantage to this method is that the FSM location and coverage information can get lost if the FSM is 
      used in a different testbench (or even a different project if the FSM code is reused in a later project). For more 
      information on specifying an FSM on the score command-line, please refer to 
      <xref linkend="section.score.fsm"/>.
    </para>
    <para>
      The second way that an FSM can be specified to Covered is through the use of the Verilog-2001 attribute. The 
      advantages to using this method are that the FSM information specified in an attribute stays embedded in the design 
      (for ease of reusing the FSM and still retaining information relevent to coverage). Additionally, at the current 
      release of Covered, using attributes to specify an FSM is the only way to tell Covered what all of the valid states 
      and state-transitions are for a specific FSM (the command-line specification does not allow for this). This 
      provides a unique advantage of this method over the command-line method. The potential disadvantage of this method 
      for specifying FSM information is that source code needs to be modified.
    </para>
    <para>
      To learn how to specify an FSM attribute within a design, let's use an example of an FSM that is embedded in a 
      design.
    </para>
    <para>
      <example xml:id="example.attr">
        <title>Module Containing an Embedded FSM</title>
        <programlisting><![CDATA[
  module foo (
    input clk,
    input reset,
    input head,
    input tail,
    input valid
  );
      
    parameter STATE_IDLE = 2'b00,
              STATE_HEAD = 2'b01,
              STATE_DATA = 2'b10,
              STATE_TAIL = 2'b11;
                
    reg [1:0] state;
    reg [1:0] next_state;
      
    always @(posedge clock)
      state <= reset ? STATE_IDLE : next_state;
        
    always @(reset or state or head or valid or tail)
      begin
        case( state )
          STATE_IDLE: next_state = (valid & head) ?
                                     STATE_HEAD : STATE_IDLE;
          STATE_HEAD: next_state = (valid & tail) ?
                                     STATE_TAIL : STATE_DATA;
          STATE_DATA: next_state = (valid & tail) ?
                                     STATE_TAIL : STATE_DATA;
          STATE_TAIL: next_state = (valid & head) ?
                                     STATE_HEAD : STATE_IDLE;
        endcase
      end   
      
  endmodule 
        ]]></programlisting>
      </example>
    </para>
    <para>
      This example shows an FSM that has an input FSM variable called "state" and an output FSM variable called 
      "next_state". There are four states in the state machine that are represented with the parameters located in this 
      module (STATE_IDLE, STATE_HEAD, STATE_DATA, STATE_TAIL). There are a total of eight (8) state transitions that this 
      FSM can take. They are the following:
    </para>
    <para>
      <orderedlist>
        <listitem><para><code>STATE_IDLE -> STATE_IDLE</code> (loopback)</para></listitem>
        <listitem><para><code>STATE_IDLE -> STATE_HEAD</code></para></listitem>
        <listitem><para><code>STATE_HEAD -> STATE_DATA</code></para></listitem>
        <listitem><para><code>STATE_HEAD -> STATE_TAIL</code></para></listitem>
        <listitem><para><code>STATE_DATA -> STATE_DATA</code> (loopback)</para></listitem>
        <listitem><para><code>STATE_DATA -> STATE_TAIL</code></para></listitem>
        <listitem><para><code>STATE_TAIL -> STATE_HEAD</code></para></listitem>
        <listitem><para><code>STATE_TAIL -> STATE_IDLE</code></para></listitem>
      </orderedlist>
    </para>
    <para>
      All attributes that specify information for an FSM are a comma-separated list of values that contain the following 
      information:
    </para>
    <para>
      <orderedlist>
        <listitem>
          <para>"covered_fsm" attribute keyword</para>
          <para>
            <itemizedlist>
              <listitem>
                <para>
                  MUST be first value in the attribute list
                </para>
              </listitem>
              <listitem>
                <para>
                  Specifies to Covered that this attribute contains information for an FSM that Covered needs to handle.
                </para>
              </listitem>
            </itemizedlist>
          </para>
        </listitem>
        <listitem>
          <para>FSM identifier</para>
          <para>
            <itemizedlist>
              <listitem>
                <para>
                  MUST be second value in the attribute list
                </para>
              </listitem>
              <listitem>
                <para>
                  Specifies a alphanumeric name for this FSM.
                </para>
              </listitem>
              <listitem>
                <para>
                  The name will eventually be used to tie individual attributes that specify information for the same FSM.
                </para>
              </listitem>
            </itemizedlist>
          </para>
        </listitem>
        <listitem>
          <para>Input state expression (optional)</para>
          <para>
            <itemizedlist>
              <listitem>
                <para>
                  Syntax: <code>is="<emphasis>expression</emphasis>"</code>
                </para>
              </listitem>
              <listitem>
                <para>
                  If this is specified, MUST be specified third in the list.
                </para>
              </listitem>
              <listitem>
                <para>
                  Specifies the input state expression.
                </para>
              </listitem>
              <listitem>
                <para>
                  Can be a combination of signal names, signal bit selects, and concatenation operators.
                </para>
              </listitem>
              <listitem>
                <para>
                  See <xref linkend="section.score.fsm"/> for more information on the specification of an input 
                  state expression.
                </para>
              </listitem>
            </itemizedlist>
          </para>
        </listitem>
        <listitem>
          <para>Output state expression</para>
          <para>
            <itemizedlist>
              <listitem>
                <para>
                  Syntax: <code>os="<emphasis>expression</emphasis>"</code>
                </para>
              </listitem>
              <listitem>
                <para>
                  If the input state expression is specified, MUST be fourth value in list; otherwise, MUST be third 
                  value in list.
                </para>
              </listitem>
              <listitem>
                <para>
                  Specifies the output state expression of the FSM.
                </para>
              </listitem>
              <listitem>
                <para>
                  Can be a combination of signal names, signal bit selects, and concatenation operators.
                </para>
              </listitem>
              <listitem>
                <para>
                  See <xref linkend="section.score.fsm"/> for more information on the specification of an output 
                  state expression.
                </para>
              </listitem>
            </itemizedlist>
          </para>
        </listitem>
        <listitem>
          <para>State-transition specifiers (optional)</para>
          <para>
            <itemizedlist>
              <listitem>
                <para>
                  Syntax: <code>trans="<emphasis>from_state</emphasis>-><emphasis>to_state</emphasis>"</code>
                </para>
              </listitem>
              <listitem>
                <para>
                  MUST be specified after the above has been specified in the list.
                </para>
              </listitem>
              <listitem>
                <para>
                  Arguments MUST be constant values (parameters; numerical values -- binary, octal, decimal, hexidecimal; 
                  and defines that equate to one of these two types of values).
                </para>
              </listitem>
              <listitem>
                <para>
                  Each transition that is specified is a unique value in the attribute list.
                </para>
              </listitem>
              <listitem>
                <para>
                  You may optionally add characters after the "trans" keyword and before the '=' character (with the
                  exception of the '=' character) to make each transition parameter name unique.  Covered will ignore
                  these extra characters, but this can be useful to avoid warning messages that may get emitted from
                  your Verilog compiler when these attributes are parsed (some compilers expect each parameter name
                  in an attribute list to have a unique name).  This feature was put in the 0.7.8 stable release.
                </para>
              </listitem>
            </itemizedlist>
          </para>
        </listitem>
      </orderedlist>
    </para>
    <para>
      To specify the FSM attribute in the above example, including input state, output state and all state transitions, 
      the code would be modified to look like:
    </para>
    <para>
      <example xml:id="example.attr.fsm">
        <title>FSM Attribute Code Sample</title>
        <programlisting><![CDATA[
  (* covered_fsm, channel, is="state", os="next_state",
                           trans="STATE_IDLE->STATE_IDLE",
                           trans="STATE_IDLE->STATE_HEAD",
                           trans="STATE_HEAD->STATE_DATA",
                           trans="STATE_HEAD->STATE_TAIL",
                           trans="STATE_DATA->STATE_DATA",
                           trans="STATE_DATA->STATE_TAIL",
                           trans="STATE_TAIL->STATE_HEAD",
                           trans="STATE_TAIL->STATE_IDLE" *)
  always @(reset or state or head or tail or valid)
    ...
        ]]></programlisting>
      </example>
    </para>
  </sect1>
  
</chapter>