From: Peter Clifton Date: Wed, 13 Feb 2008 14:59:45 +0000 (+0000) Subject: Fix verilog and VHDL netlist backends X-Git-Url: http://git.gpleda.org/?p=gaf.git;a=commitdiff_plain;h=db168efbbe2656ef2103852e92e02ec3ce58e300 Fix verilog and VHDL netlist backends These were inadvertently broken when making core gnetlist changes to accomodate slotting in spice-sdb. Since the netlist backend is loaded before gnetlist has traversed the schematic, the backends must not execute any code which queries gnetlist on load. All such work is to be done only when gnetlist invokes the () method. --- diff --git a/gnetlist/scheme/gnet-verilog.scm b/gnetlist/scheme/gnet-verilog.scm index ad31a8b..2675d3d 100644 --- a/gnetlist/scheme/gnet-verilog.scm +++ b/gnetlist/scheme/gnet-verilog.scm @@ -343,102 +343,110 @@ ;; return a list of net description objects ;; -(define the-nets '()) - -(define verilog:get-nets - (begin - (for-each - (lambda (netname) - ; parse the netname, and see if it is already on the list - (let* ((parsed (verilog:net-parse netname)) - (listed (assoc (car parsed) the-nets))) - (if listed - (begin ; it is, do some checks, and update the record - ;; extract fields from list - (let* ((list-name (car listed)) - (list-n1 (car (cadr listed))) - (list-n2 (cadr (cadr listed))) - (list-increasing (caddr (cadr listed))) - (list-sure (cadddr (cadr listed))) - (list-real (cadddr (cdr (cadr listed)))) - - (name (car parsed)) - (n1 (car (cadr parsed))) - (n2 (cadr (cadr parsed))) - (increasing (caddr (cadr parsed))) - (sure (cadddr (cadr parsed))) - (real (cadddr (cdr (cadr parsed)))) - - (consistant (or (and list-increasing increasing) - (and (not list-increasing) - (not increasing)))) - - ) - - (cond - ((and list-sure consistant) - (begin - (set-cdr! listed - (verilog:update-record n1 n2 - list-n1 list-n2 - increasing - #t - real) - ))) - ((and list-sure (not sure) (zero? n1) (zero? n2)) - '() ;; this is a net without any expression, leave it - ) - ((and list-sure (not consistant)) - (begin ;; order is inconsistent - (display - (string-append "Warning: Net `" real "' has a " - "bit order that conflicts with " - "the original definition of `" - list-real "', ignoring `" - real "'" - )) - (newline))) - ((and (not list-sure) sure consistant) - (begin - (set-cdr! listed - (verilog:update-record n1 n2 - list-n1 list-n2 - increasing - #t - real)))) - - ((and (not list-sure) sure (not consistant)) - (begin - (set-cdr! listed - (verilog:update-record n1 n2 - list-n2 list-n1 - increasing - #t - real)))) - ((and (not list-sure) (not sure)) - (begin - (set-cdr! listed - (verilog:update-record n1 n2 - list-n1 list-n2 - increasing - #f - real)))) - (else - (begin - (display "This should never happen!") - (newline))) - ) - ) - ) - (begin ; it is not, just add it to the end - (set! the-nets - (append the-nets - (list parsed)))) - )) - ) - - all-unique-nets) - the-nets)) + +(define verilog:get-nets '()) + + +(define verilog:get-nets-once! + (lambda nil + (define the-nets '()) + (set! verilog:get-nets + (begin + (for-each + (lambda (netname) + ; parse the netname, and see if it is already on the list + (let* ((parsed (verilog:net-parse netname)) + (listed (assoc (car parsed) the-nets))) + (if listed + (begin ; it is, do some checks, and update the record + ;; extract fields from list + (let* ((list-name (car listed)) + (list-n1 (car (cadr listed))) + (list-n2 (cadr (cadr listed))) + (list-increasing (caddr (cadr listed))) + (list-sure (cadddr (cadr listed))) + (list-real (cadddr (cdr (cadr listed)))) + + (name (car parsed)) + (n1 (car (cadr parsed))) + (n2 (cadr (cadr parsed))) + (increasing (caddr (cadr parsed))) + (sure (cadddr (cadr parsed))) + (real (cadddr (cdr (cadr parsed)))) + + (consistant (or (and list-increasing increasing) + (and (not list-increasing) + (not increasing)))) + + ) + + (cond + ((and list-sure consistant) + (begin + (set-cdr! listed + (verilog:update-record n1 n2 + list-n1 list-n2 + increasing + #t + real) + ))) + ((and list-sure (not sure) (zero? n1) (zero? n2)) + '() ;; this is a net without any expression, leave it + ) + ((and list-sure (not consistant)) + (begin ;; order is inconsistent + (display + (string-append "Warning: Net `" real "' has a " + "bit order that conflicts with " + "the original definition of `" + list-real "', ignoring `" + real "'" + )) + (newline))) + ((and (not list-sure) sure consistant) + (begin + (set-cdr! listed + (verilog:update-record n1 n2 + list-n1 list-n2 + increasing + #t + real)))) + + ((and (not list-sure) sure (not consistant)) + (begin + (set-cdr! listed + (verilog:update-record n1 n2 + list-n2 list-n1 + increasing + #t + real)))) + ((and (not list-sure) (not sure)) + (begin + (set-cdr! listed + (verilog:update-record n1 n2 + list-n1 list-n2 + increasing + #f + real)))) + (else + (begin + (display "This should never happen!") + (newline))) + ) + ) + ) + (begin ; it is not, just add it to the end + (set! the-nets + (append the-nets + (list parsed)))) + )) + ) + + all-unique-nets) + the-nets) + ) + verilog:get-nets +)) ;; Retrieve the requested net record from the database. @@ -624,6 +632,7 @@ (lambda (output-filename) (let ((port (open-output-file output-filename))) (begin + (verilog:get-nets-once!) (verilog:write-top-header port) (verilog:write-wires port) (verilog:write-continuous-assigns port) diff --git a/gnetlist/scheme/gnet-vhdl.scm b/gnetlist/scheme/gnet-vhdl.scm index 0b4bcf1..dea8b66 100644 --- a/gnetlist/scheme/gnet-vhdl.scm +++ b/gnetlist/scheme/gnet-vhdl.scm @@ -418,8 +418,9 @@ ;;; (define unique-devices - (vhdl:get-unique-devices (map get-device packages)) -) + (lambda nil + (vhdl:get-unique-devices (map get-device packages)) +)) ;;; Signal Declaration @@ -516,7 +517,7 @@ ; Due to my taste will the component declarations go first ; XXX - Broken until someday ; THHE fixed today ;-) - (vhdl:write-component-declarations unique-devices p) + (vhdl:write-component-declarations (unique-devices) p) ; Then comes the signal declatations (vhdl:write-signal-declarations p) )