Try testing OLC
[fleet.git] / testCode / com / sun / vlsi / chips / marina / test / InstructionStopper.java
1 package com.sun.vlsi.chips.marina.test;
2
3 import com.sun.async.test.BitVector;
4 import com.sun.async.test.ChainControl;
5 import com.sun.async.test.ChipModel;
6
7 /** InstructionStopper is a scaffold that lets us create a 36 bit propperStopper
8  * by using a 52 bit propperStopper and throwing away the unused bits. */
9 public class InstructionStopper extends ProperStopper {
10         public static final int INSTR_SZ = 36;
11         private String formatDecodedInstr(BitVector dta) {
12                 BitVector instr = dta.get(0, INSTR_SZ).bitReverse(); 
13                 StringBuffer sb = new StringBuffer();
14                 String pred = instr.get(0, 6)  .getState();
15                 String rq = instr.get(6, 1).getState();
16                 String unused2 = instr.get(7, 2).getState();
17                 String op = instr.get(9, 6).getState();
18                 String tail = instr.get(15, 1).getState();
19                 String rest = instr.get(16, 20).getState();
20                 
21                 return pred+" "+rq+" "+unused2+" "+op+" "+tail+" "+rest;
22         }
23         public InstructionStopper(String propInst,
24                                           String controlChain, String dataChain,
25                                           String reportChain,
26                                           ChainControl cc, ChipModel model,
27                                           Indenter indenter) {
28                 super(propInst, controlChain, dataChain, reportChain, cc, model, indenter);
29                 
30         }
31         @Override
32     public void fill(BitVector instr) {
33                 int n = instr.getNumBits();
34         fatal(n!=INSTR_SZ, "InstructionStopper.fill: wrong num bits: "+n+", expect: "+INSTR_SZ);
35                 fatal(INSTR_SZ>37, "Instructions can't be more than 37 bits");
36                 if (INSTR_SZ<37) {
37                         BitVector pad = new BitVector(37-INSTR_SZ, "pad");
38                         pad.setFromLong(0);
39                         instr = instr.cat(pad);
40                 }
41         BitVector t = new BitVector(1, "token");   t.setFromLong(1);
42         BitVector a = new BitVector(14, "addr");   a.setFromLong(0);
43         super.fill(instr.cat(t).cat(a));
44     }
45         @Override 
46         public BitVector drain() {
47                 BitVector dta = super.drain();
48                 return dta.get(0, INSTR_SZ);
49         }
50         @Override
51         public String formatDataTokAddr(BitVector dta) {
52                 return formatDecodedInstr(dta);
53         }
54         /** Take the Berkeley BitVector */
55         public void fill(edu.berkeley.fleet.api.BitVector instr) {
56         BitVector bitVector = new BitVector(INSTR_SZ, "instr");
57         for(int i=0; i<INSTR_SZ; i++) bitVector.set(i, instr.get(i));
58         fill(bitVector);
59         }
60 }