Skip to content
This repository
Browse code

Add method to bind assertions to verilog source lines.

  • Loading branch information...
commit b2e1db6adb71adb0d37257573dbd5978913345d9 1 parent 05efaa6
steve authored

Showing 2 changed files with 51 additions and 4 deletions. Show diff stats Hide diff stats

  1. +8 4 elab_net.cc
  2. +43 0 ivl_assert.h
12 elab_net.cc
@@ -17,7 +17,7 @@
17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 18 */
19 19 #ifdef HAVE_CVS_IDENT
20   -#ident "$Id: elab_net.cc,v 1.194 2007/01/20 02:10:45 steve Exp $"
  20 +#ident "$Id: elab_net.cc,v 1.195 2007/01/31 04:21:10 steve Exp $"
21 21 #endif
22 22
23 23 # include "config.h"
@@ -28,6 +28,7 @@
28 28 # include "compiler.h"
29 29
30 30 # include <iostream>
  31 +# include "ivl_assert.h"
31 32
32 33 /*
33 34 * This is a state flag that determines whether an elaborate_net must
@@ -1742,9 +1743,9 @@ NetNet* PEIdent::elaborate_net_array_(Design*des, NetScope*scope,
1742 1743 Link::strength_t drive0,
1743 1744 Link::strength_t drive1) const
1744 1745 {
1745   - assert(msb_ == 0);
1746   - assert(lsb_ == 0);
1747   - assert(idx_.size() == 1);
  1746 + ivl_assert(*this, msb_ == 0);
  1747 + ivl_assert(*this, lsb_ == 0);
  1748 + ivl_assert(*this, idx_.size() == 1);
1748 1749
1749 1750 NetExpr*index_ex = elab_and_eval(des, scope, idx_[0], -1);
1750 1751 if (index_ex == 0)
@@ -2894,6 +2895,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
2894 2895
2895 2896 /*
2896 2897 * $Log: elab_net.cc,v $
  2898 + * Revision 1.195 2007/01/31 04:21:10 steve
  2899 + * Add method to bind assertions to verilog source lines.
  2900 + *
2897 2901 * Revision 1.194 2007/01/20 02:10:45 steve
2898 2902 * Get argument widths right for shift results.
2899 2903 *
43 ivl_assert.h
... ... @@ -0,0 +1,43 @@
  1 +/*
  2 + * Copyright (c) 2007 Stephen Williams (steve@icarus.com)
  3 + *
  4 + * This source code is free software; you can redistribute it
  5 + * and/or modify it in source code form under the terms of the GNU
  6 + * General Public License as published by the Free Software
  7 + * Foundation; either version 2 of the License, or (at your option)
  8 + * any later version.
  9 + *
  10 + * This program is distributed in the hope that it will be useful,
  11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 + * GNU General Public License for more details.
  14 + *
  15 + * You should have received a copy of the GNU General Public License
  16 + * along with this program; if not, write to the Free Software
  17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  18 + */
  19 +#ifdef HAVE_CVS_IDENT
  20 +#ident "$Id: ivl_assert.h,v 1.1 2007/01/31 04:21:10 steve Exp $"
  21 +#endif
  22 +
  23 +#ifndef __ivl_assert_h
  24 +#define __ivl_assert_h
  25 +
  26 +# include <assert.h>
  27 +
  28 +#define ivl_assert(tok, expression) \
  29 + do { \
  30 + if (! (expression)) \
  31 + __ivl_assert(#expression, tok, __FILE__, __LINE__); \
  32 + } while(0)
  33 +
  34 +#define __ivl_assert(expression, tok, file, line) \
  35 + do { \
  36 + cerr << (tok).get_line() << ": assert: " \
  37 + << file << ":" << line \
  38 + << ": failed assertion " << (expression) << endl; \
  39 + abort(); \
  40 + } while(0)
  41 +
  42 +
  43 +#endif

0 comments on commit b2e1db6

Please sign in to comment.
Something went wrong with that request. Please try again.