Pjotr Kourzanov  committed 1bc5946

add fifo checking

  • Participants
  • Parent commits ed15e41
  • Branches karma

Comments (0)

Files changed (1)

File src/sequel/beseq.nw

 @ \section{Processing}\label{sec:process}
+  For this transformation module, processing consists of 
+\item hiding all connected ports (i.e., not passing then through)
+\item hiding all other internal structures (i.e., sub-nodes and codes)
+\item finding unconnected ports (covered in \ssrefer{unconnected})
+\item finding a static schedule (covered in \ssrefer{schedule})
+\item collapsing internal nodes and codes into one single code block
 @ \subsection{Finding unconnected ports}\label{ssec:unconnected}
 @ The main idea for the sequential \mac{BE} is to collect all unconnected ports and make them
 	  [imat (eval (cdr `(list quasiquote ,(lists->matrix ll actors))) (my-environment))]
 	  [G (imat->array imat)]	  
 	  [buf (list->vector (car (gxf:delays in)))]
-	  [repvec (gxf:rep-vector G)]
-	  [r repvec])
-      (begin ;(debug actors edges imat)
-	 (if (not (vector:check r positive?))
-	     (error "simulate" "data-flow graph is inconsistent" r)
-	     (begin ;(printf "r=~s~nb=~s~n" r buf)
+	  [repvec (gxf:rep-vector G)])
+      (begin (debug actors edges imat)
+	 (if (not (vector:check repvec positive?))
+	     (error "simulate" "data-flow graph is inconsistent" repvec)
+	     (begin (printf "r=~s~nb=~s~n" repvec buf)
 	 (let* ([sr (simulate G (vector->array buf '#(0) (incidence:edges G) 1)  '())]
 		[mb (car sr)]
 		[cy (cadr sr)])
-	    ;(debug cy mb);(debug (array->vector mb) (list->vector actors) (array->list mb))
+	    (debug cy (array->vector mb))
 	    (outs <<pre-compute and output static schedule>>)
 	   [new-rp (+ old-rp (if [is-prod p] 0 rate))]
 	   [new-wp (+ old-wp (if [is-cons p] 0 rate))]
 	   [bufsize (cadddr adm)]
+	   [buflen (+ bufsize 0)]
 	   [old-spill (cddddr adm)]
 	   [new-spill (- (if [is-cons p] new-rp new-wp) bufsize)]
-	   [new-adm (cons (modulo new-rp bufsize)
-			  (cons (modulo new-wp bufsize)
+	   [new-adm (cons (modulo new-rp buflen)
+			  (cons (modulo new-wp buflen)
 				(cons bufsize
-				      (max old-spill new-spill))))])
+				      (max old-spill new-spill))))]
+	   [avail (+ (- old-wp old-rp) (* buflen (if [< old-wp old-rp] 1 0)))]
+       	   [free  (+ (- old-rp old-wp) (* buflen (if [> old-rp old-wp] 0 1)) -1)])
        ;(debug new-spill)
        (if [> new-rp bufsize]
 	   (set-car! spill (cat nl
 				 (% new-spill)
        (set-cdr! adm new-adm)
-       (if [is-cons p] old-rp old-wp))))
+       (if [is-cons p]
+	   (begin ;(if [> rate avail] (error "gxf:access-pointer" "underflow" `(> ,rate ,avail ,p)))
+	      old-rp)
+	   (begin ;(if [> rate free] (error "gxf:access-pointer" "overflow" `(> ,rate ,free ,p)))
+	      old-wp)))))
 @ \subsection{Integration}\label{ssec:integration}