瀏覽代碼

allow to control FIFO channel depth from the AC code; use default channel depth setting in case when the user did not specify channel depth explicitly e.g. by calling connect without the third parameter or using stream operators

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6917 8c9fc860-2736-0410-a75d-ab315db34111
eth.morozova 9 年之前
父節點
當前提交
785e72c864
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      source/ActiveCellsRunner.mod

+ 9 - 4
source/ActiveCellsRunner.mod

@@ -8,7 +8,9 @@ import system,ActiveCellsRuntime, Commands, Modules,D:=Diagnostics;
 
 
 const
-	EnableTrace = false;
+	DefaultChanDepth* = 2048; (** default FIFO channel depth in number of address-wide items *)
+	
+	EnableTrace* = false;
 
 type
 	Cell = object
@@ -18,7 +20,7 @@ type
 
 	Fifo=object
 	var
-		data: array 8*1024 of system.byte;   
+		data: pointer to array of system.byte;
 (*		inPos, outPos: longint; *)
 		length: longint;  
 		rdPos,numEle: longint;
@@ -30,8 +32,11 @@ type
 			(*inPos := 0; outPos := 0; *)
 			rdPos:=0; 
 			numEle:=0;
-			self.length := length; (*for some reason this is -1 usually. don't trust it!*)
-			assert(length < len(data));
+			if length <= 0 then (* channel depth is 0 or not specified explicitly by the user (-1) - use default depth *)
+				length := DefaultChanDepth;
+			end;
+			self.length := length;
+			new(data,length*sizeof(address));
 			inPort := inP; outPort := outP;
 			inPort.SetFifo(self); outPort.SetFifo(self);
 		end Init;