ChainControls: make getChainControlFromPath() public
[fleet.git] / src / com / sun / vlsi / chips / marina / test / ChainControls.java
1 package com.sun.vlsi.chips.marina.test;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import com.sun.async.test.BitVector;
7 import com.sun.async.test.ChainControl;
8
9 /** One or more ChainControl. If we have a JTAG controller then one
10  * ChainControl. If we don't have a JTAG controller then we need
11  * one ChainControl per scan chain.
12  * 
13  * ChainControls duplicates much of the ChainControl interface. It
14  * allows the testing code to remain oblivious of whether or not the
15  * JTAG controller exists. 
16  */
17 public class ChainControls {
18     private Map<String,ChainControl> chainToControl = 
19         new HashMap<String,ChainControl>();
20         
21     /** The path has the form:
22      *  chipName.chainName.instanceName1.instanceName2 ...
23      */
24     public ChainControl getChainControlFromPath(String path) {
25         for (String chainName : chainToControl.keySet()) {
26             if (path.startsWith(chainName)) return chainToControl.get(chainName);
27         }
28         MarinaTest.fatal(true, "Can't find chain for path: "+path);
29         return null;
30     }
31     public void addChain(String chain, ChainControl control) {
32         chainToControl.put(chain, control);
33     }
34         
35     //--------------------------------------------------------------------------------
36     // Replicate interface of ChainControl
37     public BitVector getInBits(String path) {
38         ChainControl cc = getChainControlFromPath(path);
39         return cc.getInBits(path);
40     }
41     public BitVector getOutBits(String path) {
42         ChainControl cc = getChainControlFromPath(path);
43         return cc.getOutBits(path);
44     }
45     public void setInBits(String path, BitVector bits) {
46         ChainControl cc = getChainControlFromPath(path);
47         cc.setInBits(path, bits);
48     }
49     public void shift(String chainName, boolean readEnable, boolean writeEnable) {
50         ChainControl cc = getChainControlFromPath(chainName);
51         cc.shift(chainName, readEnable, writeEnable);
52     }
53     public void resetInBits() {
54         for (String chainName : chainToControl.keySet()) {
55             ChainControl cc = chainToControl.get(chainName);
56             cc.resetInBits();
57         }
58     }
59 }