1
package com.sun.electric.tool.simulation.test;
4
import java.util.ArrayList;
5
import java.util.Random;
6
import java.util.Iterator;
11
* Copyright (c) 2004,2005 by Sun Microsystems, Inc.
13
* Created on Apr 20, 2005
17
* A JtagTester that interfaces with a verilog model of the Device Under Test.
21
public class VerilogJtagTester extends JtagTesterModel {
24
* Create a new Verilog JtagTester. This implements a JtagTester, but does so
25
* as an interface to a Verilog simulation of the chip under test. This should only
26
* be called by VerilogModel.
27
* @param vm the verilog model that the tester will interface with
28
* @param tck the name of the tck port
29
* @param tms the name of the tms port
30
* @param trstb the name of the trstb port
31
* @param tdi the name of the tdi port
32
* @param tdob the name of the tdob port
34
VerilogJtagTester(VerilogModel vm, String tck, String tms, String trstb, String tdi, String tdob) {
35
super(vm, tck, tms, trstb, tdi, tdob);
38
String formatDataNetName(String dataNetName) {
39
return VerilogModel.formatDataNetName(dataNetName);
44
public static void main(String args[]) {
45
VerilogModel vm = new VerilogModel();
46
VerilogJtagTester tester = (VerilogJtagTester)vm.createJtagTester("TCK", "TMS", "TRSTb", "TDI", "TDOb");
47
vm.start("verilog", VerilogModel.getExampleVerilogChipFile(), VerilogModel.NORECORD);
49
// test private methods separately
51
tester.task_load_instruction("11000010");
52
tester.task_scan_data("1000100010001111");
54
// test public methods which use private methods
55
ChainNode testNode = new ChainNode("testNode", "1001", 156, "node for unit test");
56
Random rand = new Random(309402934);
57
for (int i=0; i<testNode.getInBits().getNumBits(); i++) {
58
testNode.getInBits().set(i, rand.nextBoolean());
60
System.out.println("Note that data shifted out is inverted sense of data shifted in,");
61
System.out.println(" unless it goes through one of our inverting output pads first.");
62
System.out.println("Unit Test: Shifting in: "+testNode.getInBits().getState());
63
tester.shift(testNode, true, true, 0);
64
System.out.println("Unit Test: Shifted out: "+testNode.getOutBits().getState());
66
// We sent to a chain that had no elements, so scan in == scan out.
68
for (int i=0; i<testNode.getInBits().getNumBits(); i++) {
69
if (testNode.getInBits().get(i) != !testNode.getOutBits().get(i)) {
75
System.out.println("Unit Test Error: scan data in should match scan data out when chain is looped back.");
77
System.out.println("Unit Test OK.");