@@ -211,4 +211,147 @@ def __init__(self):
211
211
self .assertEqual (coverage_model .covergroups [0 ].coverpoints [0 ].ignore_bins [0 ].count , 1 )
212
212
self .assertEqual (coverage_model .covergroups [0 ].coverpoints [0 ].illegal_bins [0 ].count , 1 )
213
213
214
+ def test_record_ignore (self ):
215
+ import sys
216
+ import vsc
217
+ from io import StringIO
218
+ from ucis .xml .xml_factory import XmlFactory
219
+ from ucis .report .text_coverage_report_formatter import TextCoverageReportFormatter
220
+ from ucis .report .coverage_report_builder import CoverageReportBuilder
221
+
222
+ @vsc .covergroup
223
+ class cg_t (object ):
224
+ def __init__ (self ):
225
+ self .with_sample (dict (
226
+ a = vsc .int8_t ()))
227
+ self .cp = vsc .coverpoint (self .a ,
228
+ bins = dict (rng = vsc .bin_array ([], [0 ,20 ])),
229
+ ignore_bins = dict (ignore = vsc .bin (0 )))
230
+
231
+ cg = cg_t ()
232
+ cg .sample (0 )
233
+ cg .sample (1 )
234
+
235
+ out = StringIO ()
236
+ vsc .write_coverage_db (out )
237
+ # vsc.report_coverage(details=True)
238
+ db = XmlFactory .read (StringIO (out .getvalue ()))
239
+ report = CoverageReportBuilder (db ).build (db )
240
+ # Confirm that the ignore bin was properly saved/restored
241
+ self .assertEqual (
242
+ len (report .covergroups [0 ].covergroups [0 ].coverpoints [0 ].ignore_bins ), 1 )
243
+ reporter = TextCoverageReportFormatter (report , sys .stdout )
244
+ reporter .details = True
245
+ reporter .report ()
246
+
247
+ def test_ignore_single_val_bin (self ):
248
+ import sys
249
+ import vsc
250
+ from io import StringIO
251
+ from ucis .xml .xml_factory import XmlFactory
252
+ from ucis .report .text_coverage_report_formatter import TextCoverageReportFormatter
253
+ from ucis .report .coverage_report_builder import CoverageReportBuilder
254
+
255
+ @vsc .covergroup
256
+ class cg_t (object ):
257
+ def __init__ (self ):
258
+ self .with_sample (dict (
259
+ a = vsc .int8_t ()))
260
+ self .cp = vsc .coverpoint (self .a ,
261
+ bins = dict (
262
+ ign = vsc .bin (0 ),
263
+ rng = vsc .bin_array ([], [1 ,20 ])),
264
+ ignore_bins = dict (ignore = vsc .bin (0 )))
265
+
266
+ cg = cg_t ()
267
+ cg .sample (0 )
268
+ cg .sample (1 )
269
+
270
+ out = StringIO ()
271
+ vsc .write_coverage_db (out )
272
+ vsc .report_coverage (details = True )
273
+ db = XmlFactory .read (StringIO (out .getvalue ()))
274
+ report = CoverageReportBuilder (db ).build (db )
275
+ # Confirm that the ignore bin was properly saved/restored
276
+ self .assertEqual (
277
+ len (report .covergroups [0 ].covergroups [0 ].coverpoints [0 ].bins ), 20 )
278
+ self .assertEqual (
279
+ len (report .covergroups [0 ].covergroups [0 ].coverpoints [0 ].ignore_bins ), 1 )
280
+ reporter = TextCoverageReportFormatter (report , sys .stdout )
281
+ reporter .details = True
282
+ reporter .report ()
283
+
284
+ # def test_ignore_full_array_bin(self):
285
+ # import sys
286
+ # import vsc
287
+ # from io import StringIO
288
+ # from ucis.xml.xml_factory import XmlFactory
289
+ # from ucis.report.text_coverage_report_formatter import TextCoverageReportFormatter
290
+ # from ucis.report.coverage_report_builder import CoverageReportBuilder
291
+
292
+ # @vsc.covergroup
293
+ # class cg_t(object):
294
+ # def __init__(self):
295
+ # self.with_sample(dict(
296
+ # a=vsc.int8_t()))
297
+ # self.cp = vsc.coverpoint(self.a,
298
+ # bins=dict(
299
+ # single=vsc.bin(0),
300
+ # rng=vsc.bin_array([], [1,20])),
301
+ # ignore_bins=dict(ignore=vsc.bin(1,20)))
302
+
303
+ # cg = cg_t()
304
+ # cg.sample(0)
305
+ # cg.sample(1)
306
+
307
+ # out = StringIO()
308
+ # vsc.write_coverage_db(out)
309
+ # vsc.report_coverage(details=True)
310
+ # db = XmlFactory.read(StringIO(out.getvalue()))
311
+ # report = CoverageReportBuilder(db).build(db)
312
+ # # Confirm that the ignore bin was properly saved/restored
313
+ # self.assertEqual(
314
+ # len(report.covergroups[0].covergroups[0].coverpoints[0].bins), 1)
315
+ # self.assertEqual(
316
+ # len(report.covergroups[0].covergroups[0].coverpoints[0].ignore_bins), 1)
317
+ # reporter = TextCoverageReportFormatter(report, sys.stdout)
318
+ # reporter.details = True
319
+ # reporter.report()
320
+
321
+ # def test_example(self):
322
+ # import vsc
323
+ # DATA_WIDTH = 4
324
+
325
+ # @vsc.covergroup
326
+ # class my_covergroup(object):
327
+ # def __init__(self,a,b,op):
328
+ # super().__init__()
329
+ # self.options.weight = 1
330
+ # self.operation_cvg = vsc.coverpoint(op,
331
+ # bins={"Ops.ADD":vsc.bin(0), "Ops.SUB":vsc.bin(1), "Ops.NOT":vsc.bin(2), "Ops.NOR":vsc.bin(3), "Ops.NAND":vsc.bin(4), "Ops.AND":vsc.bin(5), "Ops.OR":vsc.bin(6), "Ops.XOR":vsc.bin(7)},
332
+ # name="alu_op"
333
+ # )
334
+
335
+ # self.operanda_cvg = vsc.coverpoint(a,
336
+ # bins = {"illegal/ignore": vsc.bin(0), "low": vsc.bin_array([],[1,int(2**DATA_WIDTH/2)]), "high": vsc.bin_array([],[int(2**DATA_WIDTH/2)+1,2**DATA_WIDTH-1])},
337
+ # options=dict(weight=2),
338
+ # ignore_bins=dict(invalid_value=vsc.bin(1,2)),
339
+ # name="alu_operand_a")
340
+ # self.operandb_cvg = vsc.coverpoint(b,
341
+ # bins = {"low": vsc.bin_array([],[0,int(2**DATA_WIDTH/2)]), "high": vsc.bin_array([],[int(2**DATA_WIDTH/2)+1,2**DATA_WIDTH-1])},
342
+ # name="alu_operand_b")
343
+ # self.cross_a_b = vsc.cross([self.operanda_cvg,self.operandb_cvg])
344
+
345
+
346
+ # a = 0
347
+ # b = 0
348
+ # op = 0
349
+ # cg = my_covergroup(lambda:a, lambda:b, lambda:op)
350
+ # for i in range(1,16):
351
+ # a = i
352
+ # b = i
353
+ # cg.sample()
354
+ # vsc.report_coverage(details=True)
355
+ # vsc.write_coverage_db("pyvsc_coverage_result.xml")
356
+
214
357
0 commit comments