Skip to content

Commit e8e0cd7

Browse files
author
steve
committed
Support / and % in synthesized contexts.
1 parent f2d4966 commit e8e0cd7

File tree

1 file changed

+59
-5
lines changed

1 file changed

+59
-5
lines changed

expr_synth.cc

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
1818
*/
1919
#ifdef HAVE_CVS_IDENT
20-
#ident "$Id: expr_synth.cc,v 1.56 2004/06/01 01:04:57 steve Exp $"
20+
#ident "$Id: expr_synth.cc,v 1.57 2004/06/12 15:00:02 steve Exp $"
2121
#endif
2222

2323
# include "config.h"
@@ -363,10 +363,61 @@ NetNet* NetEBMult::synthesize(Design*des)
363363

364364
NetNet* NetEBDiv::synthesize(Design*des)
365365
{
366-
cerr << get_line() << ": internal error: cannot synthesize division: "
367-
<< *this << endl;
368-
des->errors += 1;
369-
return 0;
366+
NetNet*lsig = left_->synthesize(des);
367+
NetNet*rsig = right_->synthesize(des);
368+
369+
NetScope*scope = lsig->scope();
370+
371+
NetNet*osig = new NetNet(scope, scope->local_symbol(),
372+
NetNet::IMPLICIT, expr_width());
373+
osig->local_flag(true);
374+
375+
switch (op()) {
376+
377+
case '/': {
378+
NetDivide*div = new NetDivide(scope, scope->local_symbol(),
379+
expr_width(),
380+
lsig->pin_count(),
381+
rsig->pin_count());
382+
des->add_node(div);
383+
384+
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
385+
connect(div->pin_DataA(idx), lsig->pin(idx));
386+
for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
387+
connect(div->pin_DataB(idx), rsig->pin(idx));
388+
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1)
389+
connect(div->pin_Result(idx), osig->pin(idx));
390+
break;
391+
}
392+
393+
case '%': {
394+
NetModulo*div = new NetModulo(scope, scope->local_symbol(),
395+
expr_width(),
396+
lsig->pin_count(),
397+
rsig->pin_count());
398+
des->add_node(div);
399+
400+
for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1)
401+
connect(div->pin_DataA(idx), lsig->pin(idx));
402+
for (unsigned idx = 0 ; idx < rsig->pin_count() ; idx += 1)
403+
connect(div->pin_DataB(idx), rsig->pin(idx));
404+
for (unsigned idx = 0 ; idx < osig->pin_count() ; idx += 1)
405+
connect(div->pin_Result(idx), osig->pin(idx));
406+
break;
407+
}
408+
409+
default: {
410+
cerr << get_line() << ": internal error: "
411+
<< "NetEBDiv has unexpeced op() code: "
412+
<< op() << endl;
413+
des->errors += 1;
414+
415+
delete osig;
416+
return 0;
417+
}
418+
}
419+
420+
return osig;
370421
}
371422

372423
NetNet* NetEBLogic::synthesize(Design*des)
@@ -828,6 +879,9 @@ NetNet* NetESignal::synthesize(Design*des)
828879

829880
/*
830881
* $Log: expr_synth.cc,v $
882+
* Revision 1.57 2004/06/12 15:00:02 steve
883+
* Support / and % in synthesized contexts.
884+
*
831885
* Revision 1.56 2004/06/01 01:04:57 steve
832886
* Fix synthesis method for logical and/or
833887
*

0 commit comments

Comments
 (0)