source: vis_dev/vis-2.1/examples/production_cell/prodcell.v @ 11

Last change on this file since 11 was 11, checked in by cecile, 13 years ago

Add vis

File size: 52.9 KB
Line 
1/*
2 * prodcell.v
3 *
4 * Model of the production cell circuit. Based on the description given in:
5 *
6 * @InBook{Lindne94,
7 *   author =       {Thomas Lindner},
8 *   title =        {Case Study "Production Cell": A Comparative Study in Formal
9 *                   Software Development},
10 *   chapter =      2,
11 *   publisher =    {FZI},
12 *   year =         1994,
13 *   pages =        {9,21}
14 * }
15 *
16 * author: Abelardo Pardo (abel@vlsi.colorado.edu)
17 * date: 96/8/16
18 *
19 *
20 */
21
22/* Types */
23typedef enum {Y, N} sensor;
24typedef enum {on, off} switch;
25typedef enum {GoLeft, GoRight, Stop} craneHorizontalMovement;
26typedef enum {GoUp, GoDown, Stop} craneVerticalMovement;
27typedef enum {Grab, Free} craneGrip;
28typedef enum {OverFB, Middle, OverDB} tcHorizontalPosition;
29typedef enum {UpMost, DBHight, FBHight} tcVerticalPosition;
30typedef enum {E, F} unitInBelt;
31typedef enum {S, SSE, SE} rtAnglePosition;
32typedef enum {Top, Mid, Bot} rtVerticalPosition;
33typedef enum {CWise, Stop, CCWise} rtAngleMovement;
34typedef enum {GoUp, GoDown, Stop} rtVerticalMovement;
35typedef enum {GoUp, GoDown, Stop} pressVerticalMovement;
36typedef enum {Top, Mid, Bot} pressVerticalPosition;
37typedef enum {Extend, Retract, Stop} armHorizontalMovement;
38typedef enum {OverRT, OverLoadedPress, OverDB, OverUnLoadedPress} armAnglePosition;
39typedef enum {CWise, Stop, CCWise} armAngleMovement;
40typedef enum {Extended, Retracted, Middle} armPosition;
41
42/*
43 *
44 * MAIN MODULE: The production cell
45 *
46 */
47module ProductionCell(clk);
48   input clk;
49   
50   sensor wire PieceOutDB;
51   sensor wire PieceOutFB;
52   sensor wire PieceGrabbedFromDB;
53   sensor wire PieceGrabbedFromRT;
54   sensor wire PieceGrabbedFromFB;
55   sensor wire FBReady;
56   sensor wire PieceOutArm;
57   sensor wire PieceReleasedOnFB;
58   sensor wire DBReady;
59   sensor wire ArmUnLoadedPress;
60   sensor wire PressReadyToBeUnLoaded;
61   sensor wire ArmLoadedPress;
62   sensor wire PressReadyToBeLoaded;
63   sensor wire RTOutReady;
64   
65   TravellingCraneSet TC(clk, PieceOutDB, FBReady, PieceGrabbedFromDB,
66                         PieceReleasedOnFB);
67
68   DepositBeltSet DB(clk, PieceGrabbedFromDB, PieceOutArm, PieceOutDB,
69                     DBReady);
70   
71   FeedBeltSet FB(clk, PieceGrabbedFromFB, PieceReleasedOnFB, FBReady, 
72                  PieceOutFB);
73   
74   RotaryTableSet RT(clk, PieceOutFB, PieceGrabbedFromRT,
75                     PieceGrabbedFromFB, RTOutReady);
76   
77   PressSet PR(clk, ArmLoadedPress, ArmUnLoadedPress,
78               PressReadyToBeLoaded, PressReadyToBeUnLoaded);
79   
80   ArmSet AR(clk, DBReady, PressReadyToBeUnLoaded, PressReadyToBeLoaded, 
81             RTOutReady, PieceOutArm, ArmUnLoadedPress, ArmLoadedPress, 
82             PieceGrabbedFromRT);
83
84endmodule // ProductionCell
85
86/*
87 *
88 * TRAVELLING CRANE SET
89 *
90 */
91module TravellingCraneSet(clk, PieceOutDB, FBReady, PieceGrabbedFromDB,
92                          PieceReleasedOnFB);
93   input  clk;
94   input  PieceOutDB;
95   input  FBReady;
96   output PieceGrabbedFromDB;
97   output PieceReleasedOnFB;
98
99   sensor wire PieceOutDB;
100   sensor wire FBReady;
101   sensor wire PieceGrabbedFromDB;
102   sensor wire PieceReleasedOnFB;
103
104   craneHorizontalMovement wire HorizontalMove;
105   craneVerticalMovement wire VerticalMove;
106   
107   sensor wire CraneOnTheLeft;
108   sensor wire CraneOnTheRight;
109   
110   tcVerticalPosition wire VerticalPos;
111
112   TravellingCrane Crane(clk, HorizontalMove, VerticalMove,
113                   CraneOnTheLeft, CraneOnTheRight, VerticalPos);
114
115   TravellingCraneCNTR CraneCNTR(clk, FBReady, PieceOutDB, CraneOnTheLeft, 
116                                 CraneOnTheRight, VerticalPos, HorizontalMove, 
117                                 VerticalMove, PieceReleasedOnFB, 
118                                 PieceGrabbedFromDB);
119endmodule // TravellingCraneSet
120
121/*
122 *
123 * TRAVELLING CRANE
124 *
125 */
126module TravellingCrane(clk, HorizontalMove, VerticalMove, CraneOnTheLeft, 
127                       CraneOnTheRight, VerticalPos);
128   input  clk;
129   input  HorizontalMove;  /* Signal controlling the horizontal movement */
130   input  VerticalMove;    /* Signal controlling the vertical movement */
131   output CraneOnTheLeft;  /* Crane is on the left most position */
132   output CraneOnTheRight; /* Crane is on the right most position */
133   output VerticalPos;     /* Which vertical position the crane is */
134   
135   craneHorizontalMovement wire HorizontalMove;
136   craneVerticalMovement wire VerticalMove;
137   
138   sensor wire CraneOnTheLeft;
139   sensor wire CraneOnTheRight;
140   
141   tcHorizontalPosition reg HorizontalPos;
142   tcVerticalPosition reg VerticalPos;
143
144   assign CraneOnTheLeft = (HorizontalPos == OverFB) ? Y : N;
145   assign CraneOnTheRight = (HorizontalPos == OverDB) ? Y : N;
146   
147   initial
148      begin
149         HorizontalPos = $ND(Middle, OverDB, OverFB);
150         VerticalPos = UpMost;
151      end // initial
152
153   always @(posedge clk) begin
154         
155      /* Horizontal Movement evolution */
156      if (HorizontalMove == GoLeft) begin
157         if (HorizontalPos == Middle) begin
158            HorizontalPos = OverFB;
159         end // if (HorizontalPos == Middle)
160         else if (HorizontalPos == OverDB) begin
161            HorizontalPos = Middle;
162         end // if (HorizontalPos == OverDB)
163      end // if (HorizontalMove == GoLeft)
164
165      if (HorizontalMove == GoRight) begin
166         if (HorizontalPos == Middle) begin
167            HorizontalPos = OverDB;
168         end // if (HorizontalPos == Middle)
169         else if (HorizontalPos == OverFB) begin
170            HorizontalPos = Middle;
171         end // if (HorizontalPos == OverFB)
172      end // if (HorizontalMove == GoRight)
173
174      /* VerticalMovement Evolution */
175      if (VerticalMove == GoUp) begin
176         if (VerticalPos == DBHight) begin
177            VerticalPos = UpMost;
178         end // if (VerticalPos == DBHight)
179         else if (VerticalPos == FBHight) begin
180            VerticalPos = DBHight;
181         end // if (VerticalPos == FBHight)
182      end // if (VerticalMove == GoUp)
183
184      if (VerticalMove == GoDown) begin
185         if (VerticalPos == UpMost) begin
186            VerticalPos = DBHight;
187         end // if (VerticalPos == UpMost)
188         else if (VerticalPos == DBHight) begin
189            VerticalPos = FBHight;
190         end // else: !if(VerticalPos == UpMost)
191      end // if (VerticalMove == GoDown)
192     
193   end     
194endmodule // TravellingCrane
195
196/*
197 *
198 * TRAVELLING CRANE CONTROLER
199 *
200 */
201module TravellingCraneCNTR(clk, FBReady, PieceOutDB, CraneOnTheLeft, 
202                           CraneOnTheRight, VerticalPos, HorizontalMove, 
203                           VerticalMove, PieceReleasedOnFB, PieceGrabbedFromDB);
204   input  clk;             
205   input  FBReady;            /* FBBelt is ready to receive a piece */
206   input  PieceOutDB;         /* Deposit Belt has a piece to be picked up */
207   input  CraneOnTheLeft;     /* Crane is on the left most position */
208   input  CraneOnTheRight;    /* Crane is on the right most position */
209   input  VerticalPos;        /* Register storing crane's vertical position */
210   output HorizontalMove;     /* Register controlling the horizontal motor */
211   output VerticalMove;       /* Register controlling the vertical motor */
212   output PieceReleasedOnFB;  /* A piece was dropped on FB */
213   output PieceGrabbedFromDB; /* A piece has been grabbed from DB */
214   
215   sensor wire FBReady;
216   sensor wire CraneOnTheLeft;
217   sensor wire CraneOnTheRight;
218   tcVerticalPosition wire VerticalPos;
219   sensor wire PieceOutDB;
220
221   craneHorizontalMovement reg HorizontalMove;
222   craneVerticalMovement reg VerticalMove;
223   craneGrip reg Grip;
224   sensor reg PieceReleasedOnFB;
225   sensor reg PieceGrabbedFromDB;
226   
227   
228   initial
229      begin
230         HorizontalMove = Stop;
231         VerticalMove = Stop;
232         Grip = Free;
233         PieceReleasedOnFB = N;
234         PieceGrabbedFromDB = N;
235      end // initial
236
237   always @(posedge clk) begin
238      case (Grip)
239        Grab: begin
240           case (VerticalPos)
241             UpMost: begin
242                Grip = Grab;
243                if (CraneOnTheLeft == Y) begin
244                   HorizontalMove = Stop;
245                   VerticalMove = GoDown;
246                end // if (CraneOnTheLeft)
247                else begin
248                   if (CraneOnTheRight == N && CraneOnTheLeft == N) begin
249                      if (HorizontalMove == GoLeft) begin
250                         HorizontalMove = Stop;
251                         VerticalMove = GoDown;
252                      end // if (HorizontalMove == GoLeft)
253                      else begin
254                         HorizontalMove = GoLeft;
255                         VerticalMove = Stop;
256                      end // else: !if(HorizontalMove == GoLeft)
257                   end // if (CraneOnTheRight == N && CraneOnTheLeft == N)
258                   else begin
259                      HorizontalMove = GoLeft;
260                      VerticalMove = Stop;
261                   end // else: !if(CraneOnTheRight == N && CraneOnTheLeft == Y)
262                end // else: !if(CraneOnTheLeft == Y)
263             end // case: UpMost
264             DBHight: begin
265                if (CraneOnTheLeft == Y) begin
266                   if (VerticalMove == GoDown) begin
267                      if (FBReady == Y) begin
268                         Grip = Free;
269                         HorizontalMove = Stop;
270                         VerticalMove = GoUp;
271                         PieceReleasedOnFB = Y;
272                      end // if (FBReady == Y)
273                      else begin
274                         Grip = Grab;
275                         HorizontalMove = Stop;
276                         VerticalMove = Stop;
277                      end // else: !if(FBReady == Y)
278                   end // if (VerticalMove == GoDown)
279                   else begin
280                      Grip = Grab;
281                      HorizontalMove = Stop;
282                      VerticalMove = GoDown;
283                   end // else: !if(VerticalMove == GoDown)
284                end // if (CraneOnTheLeft == Y)
285                if (CraneOnTheRight == Y) begin
286                   Grip = Grab;
287                   if (VerticalMove == GoUp) begin
288                      HorizontalMove = GoLeft;
289                      VerticalMove = Stop;
290                   end // if (VerticalMove == GoUp)
291                   else begin
292                      HorizontalMove = Stop;
293                      VerticalMove = GoUp;
294                   end // else: !if(VerticalMove == GoUp)
295                end // if (CraneOnTheRight == Y)
296             end // case: DBHight
297             FBHight: begin
298                if (CraneOnTheLeft == Y) begin
299                   if (FBReady == Y) begin
300                      Grip = Free;
301                      HorizontalMove = Stop;
302                      VerticalMove = GoUp;
303                      PieceReleasedOnFB = Y;
304                   end // if (FBReady == Y)
305                   else begin
306                      Grip = Grab;
307                      HorizontalMove = Stop;
308                      VerticalMove = Stop;
309                   end // else: !if(FBReady == Y)
310                end // if (CraneOnTheLeft == Y)
311             end // case: FBHight
312           endcase // _case (VerticalPos)
313        end // case: Grab
314        Free: begin
315           case (VerticalPos)
316             UpMost: begin
317                if (CraneOnTheLeft == Y) begin
318                   Grip = Free;
319                   HorizontalMove = GoRight;
320                   VerticalMove = Stop; 
321                end // if (CraneOnTheLeft == Y)
322                else begin
323                   if (CraneOnTheRight == N) begin
324                      if (HorizontalMove == GoRight) begin
325                         Grip = Free;
326                         HorizontalMove = Stop;
327                         VerticalMove = GoDown;
328                      end // if (HorizontalMove == GoRight)
329                      else begin
330                         Grip = Free;
331                         HorizontalMove = GoRight;
332                         VerticalMove = Stop;
333                      end // else: !if(HorizontalMove = GoRight)
334                   end // if (CraneOnTheRight == N)
335                   else begin
336                      if (PieceOutDB == Y) begin
337                         if (VerticalMove == GoDown) begin
338                            Grip = Grab;
339                            HorizontalMove = Stop;
340                            VerticalMove = GoUp;
341                            PieceGrabbedFromDB = Y;
342                         end // if (VerticalMove == GoDown)
343                         else begin
344                            Grip = Free;
345                            HorizontalMove = Stop;
346                            VerticalMove = GoDown;
347                         end // else: !if(VerticalMove == GoDown)
348                      end // if (PieceOutDB == Y)
349                      else begin
350                         Grip = Free;
351                         HorizontalMove = Stop;
352                         if (VerticalMove == GoDown) begin
353                            VerticalMove = Stop;
354                         end // if (VerticalMove == GoDown)
355                         else begin 
356                            VerticalMove = GoDown;
357                         end // else: !if(VerticalMove == GoDown)
358                      end // else: !if(PieceOutDB == Y)
359                   end // else: !if(CraneOnTheRight == N)
360                end // else: !if(CraneOnTheLeft == Y)
361             end // case: UpMost
362             DBHight: begin
363                if (CraneOnTheLeft == Y) begin
364                   Grip = Free;
365                   if (VerticalMove == GoUp) begin
366                      HorizontalMove = GoRight;
367                      VerticalMove = Stop;
368                   end // if (VerticalMove == GoUp)
369                   else begin
370                      HorizontalMove = Stop;
371                      VerticalMove = GoUp;
372                   end // else: !if(VerticalMove == GoUp)
373                end // if (CraneOnTheLeft == Y)
374                if (CraneOnTheRight == Y) begin
375                   if (PieceOutDB == Y) begin
376                      Grip = Grab;
377                      HorizontalMove = Stop;
378                      VerticalMove = GoUp;
379                      PieceGrabbedFromDB = Y;
380                   end // if (PieceOutDB == Y)
381                   else begin
382                      Grip = Free;
383                      HorizontalMove = Stop;
384                      VerticalMove = Stop;
385                   end // else: !if(PieceOutDB == Y)
386                end // if (CraneOnTheRight == Y)
387             end // case: DBHight
388             FBHight: begin
389                if (CraneOnTheLeft == Y) begin
390                   Grip = Free;
391                   HorizontalMove = Stop;
392                   VerticalMove = GoUp;
393                end // if (CraneOnTheLeft == Y)
394             end // case: FBHight
395           endcase // _case (VerticalPos)
396        end // case: Free
397        endcase // _case (Grip)
398
399      /* Complete the handshake with both belts */
400      if (PieceOutDB == N && PieceGrabbedFromDB == Y) begin
401         PieceGrabbedFromDB = N;
402      end // if (PieceOutDB == N && PieceGrabbedFromDB == Y)
403
404      if (FBReady == N && PieceReleasedOnFB == Y) begin
405         PieceReleasedOnFB = N;
406      end // if (FBReady == N && PieceReleasedOnFB == Y)
407     
408     
409   end // always @ (posedge clk)
410endmodule // TravellingCraneCNTR
411
412/*
413 *
414 * DEPOSIT BELT SET
415 *
416 */
417module DepositBeltSet(clk, PieceGrabbedFromDB, PieceOutArm,
418                      PieceOutDB, DBReady);
419   input  clk;
420   input  PieceGrabbedFromDB;
421   input  PieceOutArm;
422   output PieceOutDB;
423   output DBReady;
424   
425   sensor wire PieceGrabbedFromDB;
426   sensor wire PieceOutArm;
427   sensor wire PieceOutDB;
428   sensor wire DBReady;
429   
430   switch wire DBMotorSwitch;
431   unitInBelt wire DBelt0, DBelt1, DBelt2, DBelt3;
432
433   DepositBelt DBelt(clk, DBMotorSwitch, PieceOutArm, PieceGrabbedFromDB, 
434                     DBReady, DBelt0, DBelt1, DBelt2, DBelt3);
435
436   DepositBeltCNTR DBeltCNTR(clk, DBelt0, DBelt1, DBelt2, DBelt3, 
437                             PieceGrabbedFromDB, PieceOutArm, DBMotorSwitch,
438                             DBReady, PieceOutDB);
439endmodule // DepositBeltSet
440
441/*
442 *
443 * DEPOSIT BELT
444 *
445 */
446module DepositBelt(clk, DBMotorSwitch, PieceOutArm, PieceGrabbedFromDB,
447                   DBReady, DBelt0, DBelt1, DBelt2, DBelt3);
448   input  clk;
449   input  DBMotorSwitch;      /* Signal controlling the motor */
450   input  PieceOutArm;        /* Presence of a piece in the arm */
451   input  PieceGrabbedFromDB; /* Piece was grabbed from the DB */
452   input  DBReady;            /* The belt is ready to accept another piece */
453   output DBelt0, DBelt1, DBelt2, DBelt3; /* Positions on the belt */
454   
455   switch wire DBMotorSwitch;
456   sensor wire PieceOutArm;
457   sensor wire PieceGrabbedFromDB;
458   sensor wire DBReady;
459   
460   unitInBelt reg DBelt0, DBelt1, DBelt2, DBelt3;
461
462   initial
463      begin
464         DBelt0 = F;
465         DBelt1 = $ND(E,F);
466         DBelt2 = $ND(E,F);
467         DBelt3 = $ND(E,F);
468      end // initial
469
470   always @(posedge clk) begin
471
472      /* Motion produced by the motor */
473      if (DBMotorSwitch == on) begin
474         DBelt0 = DBelt1;
475         DBelt1 = DBelt2;
476         DBelt2 = DBelt3;
477         DBelt3 = E;
478      end // if (DBMotorSwitch == on)
479      if (DBelt3 == E && PieceOutArm == Y && DBReady == Y) begin
480         DBelt3 = F;
481      end // if (DBelt3 == E && PieceOutArm == Y && DBReady == N)
482     
483      /* The piece was grabbed by the crane */
484      if (PieceGrabbedFromDB == Y) begin
485         DBelt0 = E;
486      end // if (PieceGrabbedFromDB == Y)
487   end // always @ (posedge clk)
488endmodule // DepositBelt
489
490
491/*
492 *
493 * DEPOSIT BELT CONTROL
494 *
495 */
496module DepositBeltCNTR(clk, DBelt0, DBelt1, DBelt2, DBelt3,
497                       PieceGrabbedFromDB, PieceOutArm, DBMotorSwitch, 
498                       DBReady, PieceOutDB);
499   input  clk;
500   input  DBelt0, DBelt1, DBelt2, DBelt3; /* Belt positions */
501   input  PieceGrabbedFromDB; /* A piece was grabbed from the DB */
502   input  PieceOutArm;        /* A piece is ready to be picked up by the belt */
503   output DBMotorSwitch;      /* Signal controlling the motor */
504   output DBReady;            /* The belt is ready to accept another piece */
505   output PieceOutDB;         /* Piece ready to be picked by the crane */
506   
507   unitInBelt wire DBelt0, DBelt1, DBelt2, DBelt3;
508   sensor wire PieceGrabbedFromDB;
509   sensor wire PieceOutArm;
510   
511   switch reg DBMotorSwitch;
512   sensor reg DBReady;
513   sensor reg PieceOutDB;         
514   
515   initial
516      begin
517         DBMotorSwitch = off;
518         DBReady = N;
519         PieceOutDB = N;
520      end
521
522   always @(posedge clk) begin
523
524      /* Control the handshake with the crane */
525      if ((DBelt0 == F && PieceOutDB == N && PieceGrabbedFromDB == N) ||
526          (DBelt0 == E && DBelt1 == F && DBMotorSwitch == on && 
527           PieceOutDB == N && PieceGrabbedFromDB == N)) begin
528         PieceOutDB = Y;
529      end // if (DBelt0 == F && PieceOutDB == N && PieceGrabbedFromDB == N)
530     
531      if (PieceOutDB == Y && PieceGrabbedFromDB == Y) begin
532         PieceOutDB = N;
533      end // if (PieceOutDB == Y && PieceGrabbedFromDB == Y)
534
535
536      /* Control The handshake with the Arm */
537      if (DBelt3 == E && PieceOutArm == N && DBReady == N) begin
538         DBReady = Y;
539      end // if (DBelt3 == E && PieceOutArm == Y && DBReady == N)
540
541      if (PieceOutArm == Y && DBReady == Y) begin
542         DBReady = N;
543         DBMotorSwitch = on;
544      end // if (PieceOutArm == Y && DBReady == Y)
545
546      /* Control the motor */
547      if (DBelt0 == F) begin
548         DBMotorSwitch = off;
549      end // if (DBelt0 == F)
550     
551      if (DBelt0 == E && DBMotorSwitch == off && (DBelt1 == F || DBelt2 == F
552                                                  || DBelt3 == F)) begin
553         DBMotorSwitch = on;
554      end
555      else begin
556         if (DBelt0 == E && DBMotorSwitch == on && DBelt1 == F) begin
557            DBMotorSwitch = off;
558         end // if (DBelt0 == E && DBMotorSwitch == on && DBelt1 == F)
559      end 
560     
561   end // always @ (posedge clk)
562endmodule // DepositBeltCNTR
563
564/*
565 *
566 * FEED BELT SET
567 *
568 */
569module FeedBeltSet(clk, PieceGrabbedFromFB, PieceReleasedOnFB,
570                   FBReady, PieceOutFB);
571   input  clk;
572   input  PieceGrabbedFromFB;
573   input  PieceReleasedOnFB;
574   output FBReady;
575   output PieceOutFB;
576
577   sensor wire PieceGrabbedFromFB;
578   sensor wire PieceReleasedOnFB;
579   sensor wire FBReady;
580   sensor wire PieceOutFB;
581   
582   switch wire FBMotorSwitch;
583   unitInBelt wire FBelt0, FBelt1, FBelt2, FBelt3;
584
585   FeedBelt FBelt(clk, FBMotorSwitch, PieceReleasedOnFB, PieceGrabbedFromFB,
586                  FBReady, FBelt0, FBelt1, FBelt2, FBelt3);
587
588   FeedBeltCNTR FBeltCNTR(clk, FBelt0, FBelt1, FBelt2, FBelt3,
589                          PieceGrabbedFromFB, PieceReleasedOnFB, FBMotorSwitch,
590                          FBReady, PieceOutFB);
591endmodule // FeedBeltSet
592
593
594/*
595 *
596 * FEED BELT
597 *
598 */
599module FeedBelt(clk, FBMotorSwitch, PieceReleasedOnFB, PieceGrabbedFromFB,
600                   FBReady, FBelt0, FBelt1, FBelt2, FBelt3);
601   input  clk;
602   input  FBMotorSwitch;      /* Motor controlling the belt */
603   input  PieceReleasedOnFB;  /* Piece has been released in the belt */
604   input  PieceGrabbedFromFB; /* Piece was picked from the belt */
605   input  FBReady;            /* Belt is ready to accept another piece */
606   output FBelt0, FBelt1, FBelt2, FBelt3; /* Belt positions */
607   
608   switch wire FBMotorSwitch;
609   sensor wire PieceReleasedOnFB;
610   sensor wire PieceGrabbedFromFB;
611   sensor wire FBReady;
612   
613   unitInBelt reg FBelt0, FBelt1, FBelt2, FBelt3;
614
615   initial
616      begin
617         FBelt0 = $ND(E,F);
618         FBelt1 = $ND(E,F);
619         FBelt2 = $ND(E,F);
620         FBelt3 = $ND(E,F);
621      end // initial
622
623   always @(posedge clk) begin
624
625      /* Motion produced by the motor */
626      if (FBMotorSwitch == on) begin
627         FBelt0 = FBelt1;
628         FBelt1 = FBelt2;
629         FBelt2 = FBelt3;
630         FBelt3 = E;
631      end // if (FBMotorSwitch == on)
632      if (FBelt3 == E && PieceReleasedOnFB == Y && FBReady == Y) begin
633         FBelt3 = F;
634      end // if (FBelt3 == E && PieceReleasedOnFB == Y && FBReady == N)
635     
636      /* The piece was grabbed by the crane */
637      if (PieceGrabbedFromFB == Y) begin
638         FBelt0 = E;
639      end // if (PieceGrabbedFromFB == Y)
640   end // always @ (posedge clk)
641endmodule // FeedBelt
642
643
644/*
645 *
646 * FEED BELT CONTROL
647 *
648 */
649module FeedBeltCNTR(clk, FBelt0, FBelt1, FBelt2, FBelt3,
650                       PieceGrabbedFromFB, PieceReleasedOnFB, FBMotorSwitch, 
651                       FBReady, PieceOutFB);
652   input  clk;
653   input  FBelt0, FBelt1, FBelt2, FBelt3; /* Belt Positions */
654   input  PieceGrabbedFromFB; /* Piece was grabbed from the belt */
655   input  PieceReleasedOnFB;  /* Piece was deposited on the belt */
656   output FBMotorSwitch;      /* Signal controlling the motor */
657   output FBReady;            /* Belt is ready to receive another piece */
658   output PieceOutFB;         /* Belt has a piece ready to be picked */
659   
660   unitInBelt wire FBelt0, FBelt1, FBelt2, FBelt3;
661   sensor wire PieceGrabbedFromFB;
662   sensor wire PieceReleasedOnFB;
663   
664   switch reg FBMotorSwitch;
665   sensor reg FBReady;
666   sensor reg PieceOutFB;         
667   
668   initial
669      begin
670         FBMotorSwitch = off;
671         FBReady = N;
672         PieceOutFB = N;
673      end
674
675   always @(posedge clk) begin
676
677      /* Control the handshake with the crane */
678      if ((FBelt0 == F && PieceOutFB == N && PieceGrabbedFromFB == N) ||
679          (FBelt0 == E && FBelt1 == F && FBMotorSwitch == on && 
680           PieceOutFB == N && PieceGrabbedFromFB == N)) begin
681         PieceOutFB = Y;
682      end // if (FBelt0 == F && PieceOutFB == N && PieceGrabbedFromFB == N)
683     
684      if (PieceOutFB == Y && PieceGrabbedFromFB == Y) begin
685         PieceOutFB = N;
686      end // if (PieceOutFB == Y && PieceGrabbedFromFB == Y)
687
688
689      /* Control The handshake with the Arm */
690      if (FBelt3 == E && PieceReleasedOnFB == N && FBReady == N) begin
691         FBReady = Y;
692      end // if (FBelt3 == E && PieceReleasedOnFB == Y && FBReady == N)
693
694      if (PieceReleasedOnFB == Y && FBReady == Y) begin
695         FBReady = N;
696         FBMotorSwitch = on;
697      end // if (PieceReleasedOnFB == Y && FBReady == Y)
698
699      /* Control the motor */
700      if (FBelt0 == F) begin
701         FBMotorSwitch = off;
702      end // if (FBelt0 == F)
703     
704      if (FBelt0 == E && FBMotorSwitch == off && (FBelt1 == F || FBelt2 == F
705                                                  || FBelt3 == F)) begin
706         FBMotorSwitch = on;
707      end // if (FBelt0 == E && FBMotorSwitch == off &&...
708      else begin
709         if (FBelt0 == E && FBMotorSwitch == on && FBelt1 == F) begin
710            FBMotorSwitch = off;
711         end // if (FBelt0 == E && FBMotorSwitch == on && FBelt1 == F)
712      end 
713     
714   end // always @ (posedge clk)
715endmodule // FeedBeltCNTR
716
717/*
718 *
719 * ROTARY TABLE SET
720 *
721 */
722module RotaryTableSet(clk, PieceOutFB, PieceGrabbedFromRT, 
723                 PieceGrabbedFromFB, RTOutReady);
724   input  clk;
725   input  PieceOutFB;
726   input  PieceGrabbedFromRT;
727   output PieceGrabbedFromFB;
728   output RTOutReady;
729   
730   sensor wire PieceOutFB;
731   sensor wire PieceGrabbedFromRT;
732   sensor wire PieceGrabbedFromFB;
733   sensor wire RTOutReady;
734
735   rtAngleMovement wire RTRotaryMotor;
736   rtVerticalMovement wire RTVerticalMotor;
737
738   sensor wire RTOnFB;
739   sensor wire RTOnArm;
740   sensor wire RTOnTop;
741   sensor wire RTOnBottom;
742
743   RotaryTable RTable(clk, RTRotaryMotor, RTVerticalMotor,
744                      RTOnFB, RTOnArm, RTOnTop, RTOnBottom);
745   RotaryTableCNTR RTableCNTR(clk, PieceOutFB, PieceGrabbedFromRT,
746                              RTOnFB, RTOnArm, RTOnTop, RTOnBottom,
747                              RTRotaryMotor, RTVerticalMotor,
748                              PieceGrabbedFromFB, RTOutReady);
749endmodule // RotarySet
750
751/*
752 *
753 * ROTARY TABLE
754 *
755 */
756module RotaryTable(clk, RTRotaryMotor, RTVerticalMotor, 
757                   RTOnFB, RTOnArm, RTOnTop, RTOnBottom);
758   input  clk;
759   input  RTRotaryMotor;
760   input  RTVerticalMotor;
761   output RTOnFB;
762   output RTOnArm;
763   output RTOnTop;
764   output RTOnBottom;
765
766   rtAngleMovement wire RTRotaryMotor;
767   rtVerticalMovement wire RTVerticalMotor;
768
769   sensor wire RTOnFB;
770   sensor wire RTOnArm;
771   sensor wire RTOnTop;
772   sensor wire RTOnBottom;
773
774   rtAnglePosition reg RTAngle;
775   rtVerticalPosition reg RTHight;
776   
777   assign RTOnFB = (RTAngle == S) ? Y : N;
778   assign RTOnArm = (RTAngle == SE) ? Y : N;
779   assign RTOnTop = (RTHight == Top) ? Y : N;
780   assign RTOnBottom = (RTHight == Bot) ? Y : N;
781   
782   initial
783      begin
784         RTAngle = $ND(S, SSE, SE);
785         RTHight = $ND(Top, Mid, Bot);
786      end // initial
787
788   always @(posedge clk) begin
789      /* Rotary movement of the table */
790      if (RTRotaryMotor == CWise) begin
791         case (RTAngle)
792           SE: begin
793              RTAngle = SSE;
794           end
795           SSE: begin 
796              RTAngle = S;
797           end
798         endcase // _case (RTAngle)
799      end // if (RTRotaryMotor == CWise)
800
801      if (RTRotaryMotor == CCWise) begin
802         case (RTAngle)
803           S: begin
804              RTAngle = SSE;
805           end
806           SSE: begin 
807              RTAngle = SE;
808           end
809         endcase // _case (RTAngle)
810      end // if (RTRotaryMotor == CCWise)
811
812      /* Vertical Movement of the table */
813      if (RTVerticalMotor == GoUp) begin
814         case (RTHight)
815           Mid: begin 
816              RTHight = Top;
817           end
818           Bot: begin
819              RTHight = Mid;
820           end
821         endcase // _case (RTHight)
822      end // if (RTVerticalMotor == GoUp)
823
824      if (RTVerticalMotor == GoDown) begin
825         case (RTHight)
826           Mid: begin
827              RTHight = Bot;
828           end
829           Top: begin
830              RTHight = Mid;
831           end
832         endcase // _case (RTHight)
833      end // if (RTVerticalMotor = GoDown)
834   end // always @ (posedge clk)
835endmodule // RotaryTable
836
837/*
838 *
839 * ROTARY TABLE CNTR
840 *
841 */
842module RotaryTableCNTR(clk, PieceOutFB, PieceGrabbedFromRT,
843                       RTOnFB, RTOnArm, RTOnTop, RTOnBottom,
844                       RTRotaryMotor, RTVerticalMotor,
845                       PieceGrabbedFromFB, RTOutReady);
846   input  clk;
847   input  PieceOutFB;
848   input  PieceGrabbedFromRT;
849   input  RTOnFB;
850   input  RTOnArm;
851   input  RTOnTop;
852   input  RTOnBottom;
853   output RTRotaryMotor;
854   output RTVerticalMotor;
855   output PieceGrabbedFromFB;
856   output RTOutReady;
857
858   sensor wire PieceOutFB;
859   sensor wire PieceGrabbedFromRT;
860   sensor wire RTOnFB;
861   sensor wire RTOnArm;
862   sensor wire RTOnBottom;
863   sensor wire RTOnTop;
864
865   rtAngleMovement wire CWiseChoice;
866   rtAngleMovement wire CCWiseChoice;
867   rtVerticalMovement wire UpChoice;
868   rtVerticalMovement wire DownChoice;
869   
870   rtAngleMovement reg RTRotaryMotor;
871   rtVerticalMovement reg RTVerticalMotor;
872   sensor reg PieceGrabbedFromFB;
873   sensor reg RTOutReady;
874   sensor reg TableLoaded;
875   
876//   assign CWiseChoice = $ND(Stop, CWise);
877//   assign CCWiseChoice = $ND(Stop, CCWise);
878//   assign UpChoice = $ND(Stop, GoUp);
879//   assign DownChoice = $ND(Stop, GoDown);
880   assign CWiseChoice = CWise;
881   assign CCWiseChoice = CCWise;
882   assign UpChoice = GoUp;
883   assign DownChoice = GoDown;
884   
885   initial
886      begin
887         RTRotaryMotor = Stop;
888         RTVerticalMotor = Stop;
889         PieceGrabbedFromFB = N;
890         RTOutReady = N;
891         TableLoaded = N;
892      end // initial
893
894   always @(posedge clk) begin
895      case (TableLoaded)
896        Y: begin
897           if (RTOnTop == Y) begin
898              if (RTOnFB == Y) begin
899                 RTRotaryMotor = CCWise;
900                 RTVerticalMotor = Stop;
901              end // if (RTOnFB == Y)
902              if (RTOnFB == N && RTOnArm == N) begin
903                 RTVerticalMotor = Stop;
904                 if (RTRotaryMotor == CCWise) begin
905                    RTRotaryMotor = Stop;
906                    RTOutReady = Y;
907                 end // if (RTRotaryMotor == CCWise)
908                 else begin
909                    if (RTRotaryMotor == Stop) begin
910                       RTRotaryMotor = CCWise;
911                    end // if (RTRotaryMotor == Stop)
912                 end // else: !if(RTRotaryMotor == CCWise)
913              end // if (RTOnFB == N && RTOnArm == N)
914              if (RTOnArm == Y) begin
915                 if (PieceGrabbedFromRT == Y) begin
916                    RTOutReady = N;
917                    RTRotaryMotor = CWiseChoice;
918                    RTVerticalMotor = DownChoice;
919                    TableLoaded = N;
920                 end // if (PieceGrabbedFromRT == Y)
921                 else begin
922                    RTOutReady = Y;
923                    RTRotaryMotor = Stop;
924                    RTVerticalMotor = Stop;
925                 end // else: !if(PieceGrabbedFromRT == Y)
926              end // if (RTOnArm == Y)
927           end // if (RTOnTop == Y)
928           if (RTOnTop == N && RTOnBottom == N) begin
929              if (RTOnFB ==Y) begin
930                 RTRotaryMotor = CCWiseChoice;
931                 if (RTVerticalMotor == GoUp) begin
932                    RTVerticalMotor = Stop;
933                 end // if (RTVerticalMotor == GoUp)
934                 else begin
935                    RTVerticalMotor = UpChoice;
936                 end // else: !if(RTVerticalMotor == GoUp)
937              end // if (RTOnFB ==Y)
938              if (RTOnFB == N && RTOnArm == N) begin
939                 if (RTRotaryMotor == CCWise && RTVerticalMotor == GoUp) begin
940                    RTRotaryMotor = Stop;
941                    RTVerticalMotor = Stop;
942                    RTOutReady = Y;
943                 end // if (RTRotaryMotor == CCWise && RTVerticalMotor == GoUp)
944                 else begin
945                    if (RTRotaryMotor!=CCWise && RTVerticalMotor == GoUp) begin
946                       RTRotaryMotor = CCWiseChoice;
947                       RTVerticalMotor = Stop;
948                    end 
949                    else begin
950                       if (RTRotaryMotor == CCWise && 
951                           RTVerticalMotor != GoUp) begin
952                          RTRotaryMotor = Stop;
953                          RTVerticalMotor = UpChoice;
954                       end 
955                       else begin
956                          if (RTRotaryMotor != CCWise
957                              && RTVerticalMotor != GoUp) begin
958                             RTRotaryMotor = CCWiseChoice;
959                             RTVerticalMotor = UpChoice;
960                          end 
961                       end 
962                    end 
963                 end 
964              end // if (RTOnFB == N && RTOnArm == N)
965              if (RTOnArm == Y) begin
966                 RTRotaryMotor = Stop;
967                 if (RTVerticalMotor == GoUp) begin
968                    RTVerticalMotor = Stop;
969                    RTOutReady = Y;
970                 end // if (RTVerticalMotor == GoUp)
971                 else begin
972                    RTVerticalMotor = GoUp;
973                 end // else: !if(RTVerticalMotor == GoUp)
974              end // if (RTOnArm == Y)
975           end // if (RTOnTop == N && RTOnBottom == N)
976           if (RTOnBottom == Y) begin
977              if (RTOnFB == Y) begin
978                 RTRotaryMotor = CCWiseChoice;
979                 RTVerticalMotor = UpChoice;
980              end // if (RTOnFB == Y)
981              if (RTOnFB == N && RTOnArm == N) begin
982                 RTVerticalMotor = UpChoice;
983                 if (RTRotaryMotor == CCWise) begin
984                    RTRotaryMotor = Stop;
985                 end // if (RTRotaryMotor == CCWise)
986                 else begin
987                    RTRotaryMotor = CCWiseChoice;
988                 end // else: !if(RTRotaryMotor == CCWise)
989              end // if (RTOnFB == N && RTOnArm == N)
990              if (RTOnArm == Y) begin
991                 RTRotaryMotor = Stop;
992                 RTVerticalMotor = GoUp;
993              end // if (RTOnArm == Y)
994           end // if (RTOnBottom == Y)
995        end // case: Y
996        N:begin
997           if (RTOnTop == Y) begin
998              if (RTOnFB == Y) begin
999                 RTRotaryMotor = Stop;
1000                 RTVerticalMotor = GoDown;
1001              end // if (RTOnFB == Y)
1002              if (RTOnFB == N && RTOnArm == N) begin
1003                 RTVerticalMotor = DownChoice;
1004                 if (RTRotaryMotor == CWise) begin
1005                    RTRotaryMotor = Stop;
1006                 end // if (RTRotaryMotor == CWise)
1007                 else begin
1008                    RTRotaryMotor = CWiseChoice;
1009                 end // else: !if(RTRotaryMotor == CWise)
1010              end // if (RTOnFB == N && RTOnArm == N)
1011              if (RTOnArm == Y) begin
1012                 RTRotaryMotor = CWiseChoice;
1013                 RTVerticalMotor = DownChoice;
1014              end // if (RTOnArm == Y)
1015           end // if (RTOnTop == Y)
1016           if (RTOnTop == N && RTOnBottom == N) begin
1017              if (RTOnFB == Y) begin
1018                 if (RTVerticalMotor == GoDown) begin
1019                    if (PieceOutFB == Y) begin
1020                       TableLoaded = Y;
1021                       PieceGrabbedFromFB = Y;
1022                       RTRotaryMotor = CCWiseChoice;
1023                       RTVerticalMotor = UpChoice;
1024                    end // if (PieceOutFB == Y)
1025                    else begin
1026                       RTRotaryMotor = Stop;
1027                       RTVerticalMotor = Stop;
1028                    end // else: !if(PieceOutFB == Y)
1029                 end // if (RTVerticalMotor == GoDown)
1030                 else begin
1031                    RTRotaryMotor = Stop;
1032                    RTVerticalMotor = GoDown;
1033                 end // else: !if(RTVerticalMotor == GoDown)
1034              end // if (RTOnFB == Y)
1035              if (RTOnFB == N && RTOnArm == N) begin
1036                 if (RTRotaryMotor == CWise && RTVerticalMotor == GoDown) begin
1037                    if (PieceOutFB == Y) begin
1038                       TableLoaded = Y;
1039                       PieceGrabbedFromFB = Y;
1040                       RTRotaryMotor = CCWiseChoice;
1041                       RTVerticalMotor = UpChoice;
1042                    end // if (PieceOutFB == Y)
1043                    else begin
1044                       RTRotaryMotor = Stop;
1045                       RTVerticalMotor = Stop;
1046                    end // else: !if(PieceOutFB == Y)
1047                 end // if (RTRotaryMotor == CWise && RTVerticalMotor == GoDown)
1048                 else begin
1049                    if (RTRotaryMotor != CWise && 
1050                        RTVerticalMotor == GoDown) begin
1051                       RTRotaryMotor = CWiseChoice;
1052                       RTVerticalMotor = Stop;
1053                    end 
1054                    else begin
1055                       if (RTRotaryMotor == CWise && 
1056                           RTVerticalMotor != GoDown) begin
1057                          RTRotaryMotor = Stop;
1058                          RTVerticalMotor = DownChoice;
1059                       end 
1060                       else begin
1061                          if (RTRotaryMotor != CWise && 
1062                              RTVerticalMotor != GoDown) begin
1063                             RTRotaryMotor = CWiseChoice;
1064                             RTVerticalMotor = DownChoice;
1065                          end 
1066                       end 
1067                    end 
1068                 end 
1069              end // if (RTOnFB == N && RTOnArm == N)
1070              if (RTOnArm == Y) begin
1071                 RTRotaryMotor = CWiseChoice;
1072                 if (RTVerticalMotor == GoDown) begin
1073                    RTVerticalMotor = Stop;
1074                 end // if (RTVerticalMotor == GoDown)
1075                 else begin
1076                    RTVerticalMotor = GoDown;
1077                 end // else: !if(RTVerticalMotor == GoDown)
1078              end // if (RTOnArm == Y)
1079           end // if (RTOnTop == N && RTOnBottom == N)
1080           if (RTOnBottom == Y) begin
1081              if (RTOnFB == Y) begin
1082                 if (PieceOutFB == Y) begin
1083                    PieceGrabbedFromFB = Y;
1084                    RTRotaryMotor = CCWiseChoice;
1085                    RTVerticalMotor = UpChoice;
1086                    TableLoaded = Y;
1087                 end // if (PieceOutFB == Y)
1088                 else begin
1089                    RTRotaryMotor = Stop;
1090                    RTVerticalMotor = Stop;
1091                 end // else: !if(PieceOutFB == Y)
1092              end // if (RTOnFB == Y)
1093              if (RTOnFB == N && RTOnArm == N) begin
1094                 RTVerticalMotor = Stop;
1095                 if (RTRotaryMotor == CWise) begin
1096                    RTRotaryMotor = Stop;
1097                 end // if (RTRotaryMotor == CWise)
1098                 else begin
1099                    RTRotaryMotor = CWise;
1100                 end // else: !if(RTRotaryMotor == CWise)
1101              end // if (RTOnFB == N && RTOnArm == N)
1102              if (RTOnArm == Y) begin
1103                 RTRotaryMotor = CWise;
1104                 RTVerticalMotor = Stop;
1105              end // if (RTOnArm == Y)
1106           end // if (RTOnBottom == Y)
1107        end // case: N
1108      endcase // _case (TableLoaded)
1109     
1110      if (PieceOutFB == N && PieceGrabbedFromFB == Y) begin
1111         PieceGrabbedFromFB = N;
1112      end // if (PieceOutFB == N && PieceGrabbedFromFB == Y)
1113
1114      if (RTOutReady == Y && PieceGrabbedFromRT == Y) begin
1115         RTOutReady = N;
1116      end // if (RTOutReady == Y && PieceGrabbedFromRT == Y)
1117     
1118   end // always @ (posedge clk)
1119endmodule // RotaryTableCNTR
1120
1121/*
1122 *
1123 * PRESS SET
1124 *
1125 */
1126module PressSet(clk, ArmLoadedPress, ArmUnLoadedPress,
1127                PressReadyToBeLoaded, PressReadyToBeUnLoaded);
1128   input  clk;
1129   input  ArmLoadedPress;
1130   input  ArmUnLoadedPress;
1131   output PressReadyToBeLoaded;
1132   output PressReadyToBeUnLoaded;
1133
1134   sensor wire ArmLoadedPress;
1135   sensor wire ArmUnLoadedPress;
1136   sensor wire PressReadyToBeLoaded;
1137   sensor wire PressReadyToBeUnLoaded;
1138   
1139   pressVerticalMovement wire PressMotor;
1140   pressVerticalPosition wire PressPosition;
1141
1142   Press Pr(clk, PressMotor, PressPosition);
1143   PressCNTR PrCNTR(clk, PressPosition, ArmLoadedPress, ArmUnLoadedPress,
1144                    PressMotor, PressReadyToBeLoaded, PressReadyToBeUnLoaded);
1145endmodule // PressSet
1146   
1147/*
1148 *
1149 * PRESS
1150 *
1151 */
1152module Press(clk, PressMotor, PressPosition);
1153   input  clk;
1154   input  PressMotor;
1155   output PressPosition;
1156
1157   pressVerticalMovement wire PressMotor;
1158
1159   pressVerticalPosition reg PressPosition;
1160
1161   initial 
1162      begin
1163         PressPosition = Mid;
1164      end // initial
1165
1166   always @(posedge clk) begin
1167      if (PressMotor == GoUp) begin
1168         case (PressPosition)
1169           Mid: begin
1170              PressPosition = Top;
1171           end // case: Mid
1172           Bot: begin
1173              PressPosition = Mid;
1174           end // case: Bot
1175         endcase // _case (PressPosition)
1176      end // if (PressMotor == GoUp)
1177
1178      if (PressMotor == GoDown) begin
1179         case (PressPosition)
1180           Top: begin
1181              PressPosition = Mid;
1182           end // case: Top
1183           Mid: begin
1184              PressPosition = Bot;
1185           end // case: Mid
1186         endcase // _case (PressPosition)
1187      end // if (PressMotor = GoDown)
1188
1189   end // always @ (posedge clk)
1190endmodule // Press
1191
1192/*
1193 *
1194 * PRESS CNTR
1195 *
1196 */
1197module PressCNTR(clk, PressPosition, ArmLoadedPress, ArmUnLoadedPress,
1198                 PressMotor, PressReadyToBeLoaded, PressReadyToBeUnLoaded);
1199   input  clk;
1200   input  PressPosition;
1201   input  ArmLoadedPress;
1202   input  ArmUnLoadedPress;
1203   output PressMotor;
1204   output PressReadyToBeLoaded;
1205   output PressReadyToBeUnLoaded;
1206   
1207   pressVerticalPosition wire PressPosition;
1208   sensor wire ArmLoadedPress;
1209   sensor wire ArmUnLoadedPress;
1210
1211   pressVerticalMovement reg PressMotor;
1212   sensor reg PressReadyToBeLoaded;
1213   sensor reg PressReadyToBeUnLoaded;
1214   sensor reg PressLoaded;
1215
1216   initial
1217      begin
1218         PressMotor = Stop;
1219         PressReadyToBeLoaded = N;
1220         PressReadyToBeUnLoaded = N;
1221         PressLoaded = N;
1222      end // initial
1223   
1224   always @(posedge clk) begin
1225     
1226      case (PressLoaded)
1227        Y: begin
1228           case (PressPosition)
1229             Top: begin
1230                PressMotor = GoDown;
1231             end
1232             Mid: begin
1233                if (PressMotor == GoDown) begin
1234                   PressMotor = Stop;
1235                   PressReadyToBeUnLoaded = Y;
1236                end // if (PressMotor == GoDown)
1237                else begin
1238                   PressMotor = GoDown;
1239                end // else: !if(PressMotor == GoDown)
1240             end // case: Mid
1241             Bot: begin
1242                if (ArmUnLoadedPress == Y && PressReadyToBeUnLoaded == Y) begin
1243                   PressMotor = GoUp;
1244                   PressLoaded = N;
1245                   PressReadyToBeUnLoaded = N;
1246                end // if (ArmUnLoadedPress == Y && PressReadyToBeUnLoaded == Y)
1247                else begin
1248                   PressMotor = Stop;
1249                end 
1250             end // case: Bot
1251           endcase // _case (PressPosition)
1252        end // case: Y
1253        N: begin
1254           case (PressPosition)
1255             Top: begin
1256                if (PressMotor == GoDown) begin
1257                   PressMotor = Stop;
1258                   PressReadyToBeLoaded = Y;
1259                end // if (PressMotor == GoDown)
1260                else begin
1261                   PressMotor = GoDown;
1262                end // else: !if(PressMotor == GoDown)
1263             end // case: Top
1264             Mid: begin
1265                if (ArmLoadedPress == Y) begin
1266                   PressLoaded = Y;
1267                   PressMotor = GoUp;
1268                end // if (ArmLoadedPress == Y)
1269                else begin
1270                   PressMotor = Stop;
1271                   PressReadyToBeLoaded = Y;
1272                end // else: !if(ArmLoadedPress == Y)
1273             end // case: Mid
1274           endcase // _case (PressPosition)
1275        end // case: N
1276        endcase // _case (PressLoaded)
1277
1278      if (ArmLoadedPress == Y && PressReadyToBeLoaded == Y) begin
1279         PressReadyToBeLoaded = N;
1280      end // if (ArmLoadedPress == N && PressReadyToBeLoaded == Y)
1281
1282      if (PressReadyToBeUnLoaded == Y && ArmUnLoadedPress == Y) begin
1283         PressReadyToBeUnLoaded = N;
1284      end // if (PressReadyToBeUnLoaded == Y && ArmUnLoadedPress == Y)
1285   end // always @ (posedge clk)
1286
1287endmodule // PressCNTR
1288
1289/*
1290 *
1291 * ARM SET
1292 *
1293 */
1294module ArmSet(clk, DBReady, PressReadyToBeUnLoaded, PressReadyToBeLoaded, 
1295              RTOutReady, PieceOutArm, ArmUnLoadedPress, ArmLoadedPress, 
1296              PieceGrabbedFromRT);
1297   input  clk; 
1298   input  DBReady;
1299   input  PressReadyToBeUnLoaded;
1300   input  PressReadyToBeLoaded;
1301   input  RTOutReady;
1302   output PieceOutArm;
1303   output ArmUnLoadedPress;
1304   output ArmLoadedPress;
1305   output PieceGrabbedFromRT;
1306
1307   sensor wire DBReady;
1308   sensor wire PressReadyToBeUnLoaded;
1309   sensor wire PressReadyToBeLoaded;
1310   sensor wire RTOutReady;
1311   sensor wire PieceOutArm;
1312   sensor wire ArmUnLoadedPress;
1313   sensor wire ArmLoadedPress;
1314   sensor wire PieceGrabbedFromRT;
1315   
1316   sensor wire RALoadArmExtended; 
1317   sensor wire RALoadArmRetracted; 
1318   sensor wire RAUnLoadArmExtended; 
1319   sensor wire RAUnLoadArmRetracted; 
1320   sensor wire RAArmOverRT; 
1321   sensor wire RAArmOverUnLoadedPress; 
1322   sensor wire RAArmOverLoadedPress; 
1323   sensor wire RAArmOverDB;
1324   armHorizontalMovement wire RAExtendLoadArm; 
1325   armHorizontalMovement wire RAExtendUnLoadArm;
1326   armAngleMovement wire RARotaryMotor;
1327
1328   RobotArm Arm(clk, RAExtendLoadArm, RAExtendUnLoadArm, RARotaryMotor,
1329                RALoadArmExtended, RALoadArmRetracted, RAUnLoadArmExtended,
1330                RAUnLoadArmRetracted, RAArmOverRT, RAArmOverUnLoadedPress, 
1331                RAArmOverLoadedPress, RAArmOverDB);
1332
1333   RobotArmCNTR ACNTR(clk, RALoadArmExtended, RALoadArmRetracted, 
1334                      RAUnLoadArmExtended, RAUnLoadArmRetracted, RAArmOverRT, 
1335                      RAArmOverUnLoadedPress, RAArmOverLoadedPress, RAArmOverDB,
1336                      DBReady, PressReadyToBeUnLoaded, PressReadyToBeLoaded, 
1337                      RTOutReady, RAExtendLoadArm, RAExtendUnLoadArm, 
1338                      RARotaryMotor, PieceOutArm, ArmUnLoadedPress, 
1339                      ArmLoadedPress, PieceGrabbedFromRT);
1340endmodule // ArmSet
1341
1342/*
1343 *
1344 * ROBOT ARM
1345 *
1346 */
1347module RobotArm(clk, RAExtendLoadArm, RAExtendUnLoadArm, RARotaryMotor,
1348                RALoadArmExtended, RALoadArmRetracted, RAUnLoadArmExtended,
1349                RAUnLoadArmRetracted, RAArmOverRT, RAArmOverUnLoadedPress, 
1350                RAArmOverLoadedPress, RAArmOverDB);
1351   input  clk; 
1352   input  RAExtendLoadArm;
1353   input  RAExtendUnLoadArm;
1354   input  RARotaryMotor;
1355   output RALoadArmExtended;
1356   output RALoadArmRetracted;
1357   output RAUnLoadArmExtended;
1358   output RAUnLoadArmRetracted;
1359   output RAArmOverRT;
1360   output RAArmOverUnLoadedPress;
1361   output RAArmOverLoadedPress;
1362   output RAArmOverDB;
1363   
1364   armHorizontalMovement wire RAExtendLoadArm;
1365   armHorizontalMovement wire RAExtendUnLoadArm;
1366   armAngleMovement wire RARotaryMotor;
1367   sensor wire RALoadArmExtended;
1368   sensor wire RALoadArmRetracted;
1369   sensor wire RAUnLoadArmExtended;
1370   sensor wire RAUnLoadArmRetracted;
1371   sensor wire RAArmOverRT;
1372   sensor wire RAArmOverUnLoadedPress;
1373   sensor wire RAArmOverLoadedPress;
1374   sensor wire RAArmOverDB;
1375   
1376   armPosition reg RALoadArm;
1377   armPosition reg RAUnLoadArm;
1378   armAnglePosition reg RAAnglePos; 
1379
1380   assign RALoadArmExtended = (RALoadArm == Extended) ? Y : N;
1381   assign RALoadArmRetracted = (RALoadArm == Retracted) ? Y : N;
1382   assign RAUnLoadArmExtended = (RAUnLoadArm == Extended) ? Y : N;
1383   assign RAUnLoadArmRetracted = (RAUnLoadArm == Retracted) ? Y : N; 
1384   assign RAArmOverRT = (RAAnglePos == OverRT) ? Y : N;
1385   assign RAArmOverUnLoadedPress = (RAAnglePos == OverUnLoadedPress) ? Y : N;
1386   assign RAArmOverLoadedPress = (RAAnglePos == OverLoadedPress) ? Y : N; 
1387   assign RAArmOverDB = (RAAnglePos == OverDB) ? Y : N;
1388   
1389   initial
1390      begin
1391         RALoadArm = Retracted;
1392         RAUnLoadArm = Retracted;
1393         RAAnglePos = $ND(OverRT, OverLoadedPress, OverDB, OverUnLoadedPress);
1394      end // initial
1395
1396   always @(posedge clk) begin
1397
1398      /* Control the horizontal movement of the load arm */
1399      if (RAExtendLoadArm == Extend) begin
1400         case (RALoadArm)
1401           Retracted: begin
1402              RALoadArm = Middle;
1403           end // case: Retracted
1404           Middle: begin
1405              RALoadArm = Extended;
1406           end // if (RALoadArm = Middle)
1407         endcase // _case (RALoadArm)
1408      end // if (RAExtendLoadArm == Extend)
1409
1410      if (RAExtendLoadArm == Retract) begin
1411         case (RALoadArm)
1412           Extended: begin
1413              RALoadArm = Middle;
1414           end // case: Extended
1415           Middle: begin
1416              RALoadArm = Retracted;
1417           end // if (RALoadArm == Middle)
1418         endcase // _case (RALoadArm)
1419      end // if (RAExtendLoadArm = Retract)
1420     
1421      /* Control the horizontal movement of the UnLoad arm */
1422      if (RAExtendUnLoadArm == Extend) begin
1423         case (RAUnLoadArm)
1424           Retracted: begin
1425              RAUnLoadArm = Middle;
1426           end // case: Retracted
1427           Middle: begin
1428              RAUnLoadArm = Extended;
1429           end // case: Middle
1430         endcase // _case (RAUnLoadArm)
1431      end // if (RAExtendLoadArm == Extend)
1432
1433      if (RAExtendUnLoadArm == Retract) begin
1434         case (RAUnLoadArm)
1435           Extended: begin
1436              RAUnLoadArm = Middle;
1437           end // case: Extended
1438           Middle: begin
1439              RAUnLoadArm = Retracted;
1440           end // case: Middle
1441         endcase // _case (RAUnLoadArm)
1442      end // if (RAExtendUnLoadArm = Retract)
1443     
1444      /* Control the rotation of the arm */
1445      if (RARotaryMotor == CCWise) begin
1446         case (RAAnglePos)
1447           OverRT: begin
1448              RAAnglePos = OverUnLoadedPress;
1449           end // case: OverRT
1450           OverUnLoadedPress: begin
1451              RAAnglePos = OverDB;
1452           end // case: OverLoadedPress
1453           OverDB: begin
1454              RAAnglePos = OverLoadedPress;
1455           end // case: OverDB
1456         endcase // _case (RAAnglePos)
1457      end // if (RARotaryMotor == CCWise)
1458      if (RARotaryMotor == CWise) begin
1459         case (RAAnglePos)
1460           OverLoadedPress: begin
1461              RAAnglePos = OverDB;
1462           end // case: OverLoadedPress
1463           OverDB: begin
1464              RAAnglePos = OverUnLoadedPress;
1465           end // case: OverDB
1466           OverUnLoadedPress: begin
1467              RAAnglePos = OverRT;
1468           end // case: OverUnLoadedPress
1469         endcase // _case (RAAnglePos)
1470      end // if (RARotaryMotor == CWise)
1471   end // always @ (posedge clk)
1472endmodule // RobotArm
1473
1474/*
1475 *
1476 * ROBOT ARM CNTR
1477 *
1478 */
1479module RobotArmCNTR(clk, RALoadArmExtended, RALoadArmRetracted, 
1480                    RAUnLoadArmExtended, RAUnLoadArmRetracted, RAArmOverRT, 
1481                    RAArmOverUnLoadedPress, RAArmOverLoadedPress, RAArmOverDB,
1482                    DBReady, PressReadyToBeUnLoaded, PressReadyToBeLoaded, 
1483                    RTOutReady, RAExtendLoadArm, RAExtendUnLoadArm, 
1484                    RARotaryMotor, PieceOutArm, ArmUnLoadedPress, 
1485                    ArmLoadedPress, PieceGrabbedFromRT);
1486   input  clk;
1487   input  RALoadArmExtended;
1488   input  RALoadArmRetracted;
1489   input  RAUnLoadArmExtended;
1490   input  RAUnLoadArmRetracted;
1491   input  RAArmOverRT;
1492   input  RAArmOverUnLoadedPress;
1493   input  RAArmOverLoadedPress;
1494   input  RAArmOverDB;
1495   input  DBReady;
1496   input  PressReadyToBeUnLoaded;
1497   input  PressReadyToBeLoaded;
1498   input  RTOutReady;
1499   output RAExtendLoadArm;
1500   output RAExtendUnLoadArm;
1501   output RARotaryMotor;
1502   output PieceOutArm;
1503   output ArmUnLoadedPress;
1504   output ArmLoadedPress;
1505   output PieceGrabbedFromRT;
1506   
1507   sensor wire DBReady;
1508   sensor wire PressReadyToBeUnLoaded;
1509   sensor wire PressReadyToBeLoaded;
1510   sensor wire RTOutReady;
1511   sensor wire RALoadArmExtended;
1512   sensor wire RALoadArmRetracted;
1513   sensor wire RAUnLoadArmExtended;
1514   sensor wire RAUnLoadArmRetracted;
1515   sensor wire RAArmOverRT;
1516   sensor wire RAArmOverUnLoadedPress;
1517   sensor wire RAArmOverLoadedPress;
1518   sensor wire RAArmOverDB;
1519   
1520   armHorizontalMovement reg RAExtendLoadArm;
1521   armHorizontalMovement reg RAExtendUnLoadArm;
1522   armAngleMovement reg RARotaryMotor;
1523   sensor reg PieceOutArm;
1524   sensor reg ArmUnLoadedPress;
1525   sensor reg ArmLoadedPress;
1526   sensor reg PieceGrabbedFromRT;
1527   sensor reg LoadArmLoaded;
1528   sensor reg UnLoadArmLoaded;
1529
1530   initial
1531      begin
1532         RAExtendLoadArm = Stop;
1533         RAExtendUnLoadArm = Stop;
1534         RARotaryMotor = Stop;
1535         PieceOutArm = N;
1536         ArmUnLoadedPress = N;
1537         ArmLoadedPress = N;
1538         PieceGrabbedFromRT = N;
1539         LoadArmLoaded = N;
1540         UnLoadArmLoaded = N;
1541      end // initial
1542
1543   always @(posedge clk) begin
1544      if (LoadArmLoaded == N && UnLoadArmLoaded == N) begin
1545         if (RAArmOverRT == Y) begin
1546            if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y &&
1547                RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1548               RARotaryMotor == Stop) begin
1549               if (RTOutReady == Y) begin
1550                  RAExtendLoadArm = Extend;
1551               end // if (RTOutReady == Y)
1552               else begin
1553                  if (PressReadyToBeUnLoaded == Y) begin
1554                     RARotaryMotor = CCWise;
1555                  end // if (PressReadyToBeUnLoaded == Y)
1556               end // else: !if(RTOutReady == Y)
1557            end 
1558            else begin
1559               if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y &&
1560                   RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1561                   RARotaryMotor == CCWise) begin
1562                      if (PressReadyToBeUnLoaded == Y) begin
1563                         RARotaryMotor = Stop;
1564                         RAExtendUnLoadArm = Extend;
1565                      end // if (PressReadyToBeUnLoaded == Y)
1566                   end 
1567               else begin
1568                  if (RALoadArmRetracted == N && RALoadArmExtended == N &&
1569                      RAUnLoadArmRetracted == Y && 
1570                      RAExtendLoadArm == Extend && RAExtendUnLoadArm == Stop &&
1571                      RARotaryMotor == Stop) begin
1572                         RAExtendLoadArm = Retract;
1573                         LoadArmLoaded = Y;
1574                         PieceGrabbedFromRT = Y;
1575                      end 
1576               end 
1577            end // else: !if(RALoadArmRetracted == Y &&...
1578         end // if (RAArmOverRT == Y)
1579         if (RAArmOverLoadedPress == Y) begin
1580            if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y &&
1581                RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1582                RARotaryMotor == Stop) begin
1583               RARotaryMotor = CWise;
1584            end // if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y ...
1585            if (RALoadArmRetracted == N && RALoadArmExtended == N &&
1586                RAUnLoadArmRetracted == Y && 
1587                RAExtendLoadArm == Retract && RAExtendUnLoadArm == Stop &&
1588                RARotaryMotor == Stop) begin
1589               RAExtendLoadArm = Stop;
1590               RARotaryMotor = CWise;
1591            end // if (RALoadArmRetracted == N && RALoadArmExtended == N &&...
1592         end // if (RAArmOverLoadedPress == Y)
1593         if (RAArmOverUnLoadedPress == Y) begin
1594            if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y &&
1595                RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1596               RARotaryMotor == Stop) begin
1597               if (PressReadyToBeUnLoaded == Y) begin
1598                  RAExtendLoadArm = Extend;
1599               end // if (RTOutReady == Y)
1600               else begin
1601                  RARotaryMotor = CWise;
1602               end // else: !if(RTOutReady == Y)
1603            end // if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y ...
1604            else begin
1605               if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y && 
1606                   RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1607                   RARotaryMotor == CWise) begin
1608                      RARotaryMotor = Stop;
1609                      if (RTOutReady == Y) begin
1610                         RAExtendLoadArm = Extend;
1611                      end // if (RTOutReady == Y)
1612                   end // if (RALoadArmRetracted == Y && ...
1613               else begin
1614                  if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == N && 
1615                      RAUnLoadArmExtended == N && 
1616                      RAExtendLoadArm == Stop && RAExtendUnLoadArm == Extend &&
1617                      RARotaryMotor == Stop) begin
1618                         RAExtendUnLoadArm = Retract;
1619                         ArmUnLoadedPress = Y;
1620                         UnLoadArmLoaded = Y;
1621                      end // if (RALoadArmRetracted == Y && RAUnLoadArmRetr...
1622               end // else: !if(RALoadArmRetracted == Y && RAUnLoadArmRetr...
1623            end // else: !if(RALoadArmRetracted == Y && RAUnLoadArmRetract...
1624         end // if (RAArmOverUnLoadedPress == Y)
1625         if (RAArmOverDB == Y) begin
1626            if (RALoadArmRetracted == Y && RAUnLoadArmRetracted == Y &&
1627                RAExtendLoadArm == Stop && RAExtendUnLoadArm == Stop &&
1628                RARotaryMotor == Stop) begin
1629               RARotaryMotor = CWise;
1630            end // if (RALoadArmRetracted == Y && RAUnLoadArmRetracte...
1631            if (RAExtendUnLoadArm == Retract && RAUnLoadArmExtended == N && 
1632                RAUnLoadArmRetracted == N) begin
1633               RAExtendUnLoadArm = Stop;
1634               RARotaryMotor = CWise;
1635            end 
1636            if (RARotaryMotor == CWise) begin
1637               if (PressReadyToBeUnLoaded == Y && RTOutReady == N) begin
1638                  RARotaryMotor = Stop;
1639                  RAExtendUnLoadArm = Extend;
1640               end // if (PressReadyToBeUnLoaded == Y && RTOutReady == N)
1641            end // if (RARotaryMotor == CWise)
1642         end // if (RAArmOverDB == Y)
1643      end // if (LoadArmLoaded == N && UnLoadArmLoaded == N)
1644      else begin
1645         if (LoadArmLoaded == N && UnLoadArmLoaded == Y) begin
1646            if (RAArmOverUnLoadedPress == Y) begin
1647               if (RARotaryMotor == CCWise) begin
1648                  RARotaryMotor = Stop;
1649                  RAExtendUnLoadArm = Extend;
1650               end // if (RARotaryMotor == CCWise)
1651               if (RAExtendUnLoadArm == Retract && RAUnLoadArmExtended == N
1652                   && RAUnLoadArmRetracted == N) begin
1653                  RAExtendUnLoadArm = Stop;
1654                  RARotaryMotor = CCWise;
1655               end 
1656            end // if (RAArmOverUnloadedPress == Y)
1657            if (RAArmOverDB == Y) begin
1658               if (RAExtendUnLoadArm == Extend && RAUnLoadArmExtended == N && 
1659                   RAUnLoadArmRetracted == N) begin
1660                  if (DBReady == Y) begin
1661                     RAExtendUnLoadArm = Retract;
1662                     PieceOutArm = Y;
1663                     UnLoadArmLoaded = N;
1664                  end // if (DBReady == Y)
1665                  else begin
1666                     RAExtendUnLoadArm = Stop;
1667                  end // else: !if(DBReady == Y)
1668               end 
1669               if (RAExtendUnLoadArm == Stop && RAUnLoadArmExtended == Y && 
1670                   DBReady == Y) begin
1671                  RAExtendUnLoadArm = Retract;
1672                  PieceOutArm = Y;
1673                  UnLoadArmLoaded = N;
1674               end 
1675            end // if (RAArmOverDB == Y)
1676         end // if (LoadArmLoaded == N && UnLoadArmLoaded == Y)
1677         else begin
1678            if (LoadArmLoaded == Y && UnLoadArmLoaded == N) begin
1679               if (RAArmOverRT == Y) begin
1680                  if (RARotaryMotor == CCWise) begin
1681                     if (PressReadyToBeUnLoaded == Y) begin
1682                        RARotaryMotor = Stop;
1683                        RAExtendUnLoadArm = Extend;
1684                     end // if (PressReadyToBeUnLoaded == Y)
1685                  end // if (RARotaryMotor == CCWise)
1686                  if (RAExtendLoadArm == Retract && RALoadArmExtended == N && 
1687                      RALoadArmRetracted == N) begin
1688                     RAExtendLoadArm = Stop;
1689                     RARotaryMotor = CCWise;
1690                  end 
1691               end // if (RAArmOverUnLoadedPress == Y)
1692               if (RAArmOverLoadedPress == Y) begin
1693                  if (RAExtendLoadArm == Stop && RARotaryMotor == Stop && 
1694                      RAExtendUnLoadArm == Stop &&
1695                      RALoadArmRetracted == Y) begin
1696                     if (PressReadyToBeLoaded == Y) begin
1697                        RAExtendLoadArm = Extend;
1698                     end // if (PressReadyToBeLoaded == Y)
1699                  end 
1700                  if (RAExtendLoadArm == Extend && RALoadArmExtended == N && 
1701                      RALoadArmRetracted == N) begin
1702                     RAExtendLoadArm = Retract;
1703                     ArmLoadedPress = Y;
1704                     LoadArmLoaded = N;
1705                  end 
1706               end // if (RAArmOverLoadedPress == Y)
1707               if (RAArmOverUnLoadedPress == Y) begin
1708                  if (RAExtendUnLoadArm == Extend && RAUnLoadArmExtended == N
1709                      && RAUnLoadArmRetracted == N) begin
1710                     if (PressReadyToBeUnLoaded == Y) begin
1711                        ArmUnLoadedPress = Y;
1712                        UnLoadArmLoaded = Y;
1713                        RAExtendUnLoadArm = Retract;
1714                     end // if (PressReadyToBeUnLoaded == Y)
1715                  end 
1716               end // if (RAArmOverUnLoadedPress == Y)
1717               if (RAArmOverDB == Y) begin
1718                  if (RARotaryMotor == CCWise) begin
1719                     RARotaryMotor = Stop;
1720                     if (PressReadyToBeLoaded == Y) begin
1721                        RAExtendLoadArm = Extend;
1722                     end // if (PressReadyToBeLoaded == Y)
1723                  end // if (RARotaryMotor == CCWise)
1724                  if (RAExtendUnLoadArm == Retract && RAUnLoadArmExtended == N
1725                      && RAUnLoadArmRetracted == N)begin
1726                     RAExtendUnLoadArm = Stop;
1727                     RARotaryMotor = CCWise;
1728                  end 
1729               end // if (RAArmOverDB == Y)
1730            end // if (LoadArmLoaded == Y && UnLoadArmLoaded == N)
1731            else begin
1732               if (LoadArmLoaded == Y && UnLoadArmLoaded == Y) begin
1733                  if (RAArmOverUnLoadedPress == Y) begin
1734                     if (RARotaryMotor == CCWise) begin
1735                        RARotaryMotor = Stop;
1736                        RAExtendUnLoadArm = Extend;
1737                     end // if (RARotaryMotor = CCWise)
1738                     if (RAExtendUnLoadArm == Retract && 
1739                         RAUnLoadArmExtended == N && 
1740                         RAUnLoadArmRetracted == N) begin
1741                        RAExtendUnLoadArm = Stop;
1742                        RARotaryMotor = CCWise;
1743                     end 
1744                  end // if (RAArmOverUnLoadedPress == Y)
1745                  if (RAArmOverDB == Y) begin
1746                     if (RAExtendUnLoadArm == Extend && RAUnLoadArmExtended == N
1747                         && RAUnLoadArmRetracted == N) begin
1748                        RAExtendUnLoadArm = Stop;
1749                        if (DBReady == Y) begin
1750                           RAExtendUnLoadArm = Retract;
1751                           UnLoadArmLoaded = N;
1752                           PieceOutArm = Y;
1753                        end // if (DBReady == Y)
1754                     end 
1755                     if (RAExtendUnLoadArm == Stop && 
1756                         RAUnLoadArmExtended == Y) begin
1757                        if (DBReady == Y) begin
1758                           RAExtendUnLoadArm = Retract;
1759                           UnLoadArmLoaded = N;
1760                           PieceOutArm = Y;
1761                        end // if (DBReady == Y)
1762                     end 
1763                  end // if (RAArmOverDB == Y)
1764               end // if (LoadArmLoaded == Y && UnLoadArmLoaded == Y)
1765
1766            end // else: !if(LoadArmLoaded == Y && UnLoadArmLoaded == N)
1767         end // else: !if(LoadArmLoaded == N && UnLoadArmLoaded == Y)
1768      end // else: !if(LoadArmLoaded == N && UnLoadArmLoaded == N)
1769     
1770      if (DBReady == N && PieceOutArm == Y) begin
1771         PieceOutArm = N;
1772      end // if (DBReady == N && PieceOutArm == Y)
1773     
1774      if (PressReadyToBeUnLoaded == N && ArmUnLoadedPress == Y) begin
1775         ArmUnLoadedPress = N;
1776      end // if (PressReadyToBeUnLoaded == N && ArmUnLoadedPress == Y)
1777     
1778      if (ArmLoadedPress == Y && PressReadyToBeLoaded == N) begin
1779         ArmLoadedPress = N;
1780      end // if (ArmLoadedPress == Y && PieceRecivedOnPress == N)
1781     
1782      if (RTOutReady == N && PieceGrabbedFromRT == Y) begin
1783         PieceGrabbedFromRT = N;
1784      end // if (RTOutReady == N && PieceGrabbedFromRT == Y)
1785   end // always @ (posedge clk)
1786endmodule // RobotArmCNTR
Note: See TracBrowser for help on using the repository browser.