Cannot use posedge, negedge or edge with a real expression

This commit is contained in:
Cary R 2023-07-09 05:00:54 -07:00
parent 2249d224de
commit 095e6daa0a
4 changed files with 42 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2023 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -4886,6 +4886,29 @@ cerr << endl;
continue;
}
// posedge, negedge and edge are not allowed on real expressions.
if ((tmp->expr_type() == IVL_VT_REAL) &&
(expr_[idx]->type() != PEEvent::ANYEDGE)) {
cerr << get_fileline() << ": error: '";
switch (expr_[idx]->type()) {
case PEEvent::POSEDGE:
cerr << "posedge";
break;
case PEEvent::NEGEDGE:
cerr << "negedge";
break;
case PEEvent::EDGE:
cerr << "edge";
break;
default:
ivl_assert(*this, 0);
}
cerr << "' cannot be used with real expressions '"
<< *expr_[idx]->expr() << "'." << endl;
des->errors += 1;
continue;
}
NetNet*expr = tmp->synthesize(des, scope, tmp);
if (expr == 0) {
expr_[idx]->dump(cerr);

View File

@ -0,0 +1,4 @@
./ivltests/real_edges.v:5: error: 'posedge' cannot be used with real expressions 'rval'.
./ivltests/real_edges.v:6: error: 'negedge' cannot be used with real expressions 'rval'.
./ivltests/real_edges.v:7: error: 'edge' cannot be used with real expressions 'rval'.
3 error(s) during elaboration.

View File

@ -0,0 +1,13 @@
module top;
real rval;
always @(rval) $display("any change");
always @(posedge rval) $display("posedge");
always @(negedge rval) $display("negedge");
always @(edge rval) $display("edge");
initial begin
#1 rval = 1.0;
#1 rval = 0.0;
end
endmodule

View File

@ -996,3 +996,4 @@ br_gh840a CE,-g2012 ivltests
br_gh840b CE,-g2012 ivltests
bitsel_real_idx CE,-g2012 ivltests gold=bitsel_real_idx.gold
partsel_real_idx CE,-g2012 ivltests gold=partsel_real_idx.gold
real_edges CE,-g2012 ivltests gold=real_edges.gold