数値調査

メモリのデータの最小値、最大値、平均値を調査します。 execを1にして調査を開始します、eopが1になったら調査 終了です。

file: sample23
topic17a.jpg(21834 byte)

論理譜

logicname yahoo35

entity main
input  reset;
input  exec;
input  data[8];
output cs;
output re;
output address[4];
output eop;
output minno[8];
output maxno[8];
output aveno[8];

bitr   point[4];
bitn   pointend;
bitr   min[8];
bitr   max[8];
bitr   acc[8];
bitn   ave[8];

   address=point;
   cs=!(exec&!pointend);
   re=!(exec&!pointend);
   eop=ave.8;
   minno=min;
   maxno=max;
   aveno=ave;

   if (reset)
      point=0;
   else
      if (exec)
         if (pointend)
            point=point;
         else
            point=point+1;
         endif
      else
         point=0;
      endif
   endif

   if (point==10) pointend=1; endif

   if (reset)
      min=255;
   else
      if (exec)
         if (pointend)
            min=min;
         else
            if (data<min)
               min=data;
            else
               min=min;
            endif
         endif
      else
         min=255;
      endif
   endif

   if (reset)
      max=0;
   else
      if (exec)
         if (pointend)
            max=max;
         else
            if (data>max)
               max=data;
            else
               max=max;
            endif
         endif
      else
         max=0;
      endif
   endif

   if (reset)
      acc=0;
   else
      if (exec)
         if (pointend)
            acc=acc;
         else
            acc=acc+data;
         endif
      else
         acc=0;
      endif
   endif

   if (pointend)
      ave=acc/point;
   endif


ende

entity sim
output reset;
output exec;
output data[8];
output cs;
output re;
output address[4];
output eop;
output minno[8];
output maxno[8];
output aveno[8];

output TB0P[8];
output TB1P[8];
output TB2P[8];
output TB3P[8];
output TB4P[8];
output TB5P[8];
output TB6P[8];
output TB7P[8];
output TB8P[8];
output TB9P[8];

bitr   tc[8];

bitr   memory0d[8];
bitr   memory1d[8];
bitr   memory2d[8];
bitr   memory3d[8];
bitr   memory4d[8];
bitr   memory5d[8];
bitr   memory6d[8];
bitr   memory7d[8];
bitr   memory8d[8];
bitr   memory9d[8];
bitn   node_cs;
bitn   node_re;
bitn   node_we;
bitn   node_address[4];
bitn   node_reset;

   TB0P=memory0d;
   TB1P=memory1d;
   TB2P=memory2d;
   TB3P=memory3d;
   TB4P=memory4d;
   TB5P=memory5d;
   TB6P=memory6d;
   TB7P=memory7d;
   TB8P=memory8d;
   TB9P=memory9d;

   cs=node_cs;
   re=node_re;
   address=node_address;
   reset=node_reset;

   part main(node_reset,exec,data,node_cs,node_re,node_address,eop,minno,maxno,aveno)

   tc=tc+1;

   if (tc<5) node_reset=1; endif
   if (tc>10) exec=1; endif

   if (node_reset) memory0d=10; else memory0d=memory0d; endif
   if (node_reset) memory1d=9 ; else memory1d=memory1d; endif
   if (node_reset) memory2d=8 ; else memory2d=memory2d; endif
   if (node_reset) memory3d=7 ; else memory3d=memory3d; endif
   if (node_reset) memory4d=6 ; else memory4d=memory4d; endif
   if (node_reset) memory5d=5 ; else memory5d=memory5d; endif
   if (node_reset) memory6d=4 ; else memory6d=memory6d; endif
   if (node_reset) memory7d=3 ; else memory7d=memory7d; endif
   if (node_reset) memory8d=2 ; else memory8d=memory8d; endif
   if (node_reset) memory9d=1 ; else memory9d=memory9d; endif

   if (!node_cs&!node_re)
      switch(node_address)
         case 0: data=memory0d;
         case 1: data=memory1d;
         case 2: data=memory2d;
         case 3: data=memory3d;
         case 4: data=memory4d;
         case 5: data=memory5d;
         case 6: data=memory6d;
         case 7: data=memory7d;
         case 8: data=memory8d;
         case 9: data=memory9d;
      endswitch
   endif

ende

endlogic