OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [java/] [src/] [edu/] [byu/] [cc/] [plieber/] [fpgaenet/] [examples/] [ClockControl.java] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 peteralieb
/**
2
 *
3
 */
4
package edu.byu.cc.plieber.fpgaenet.examples;
5
 
6
import java.util.ArrayList;
7
 
8
import edu.byu.cc.plieber.fpgaenet.fcp.FCPException;
9
import edu.byu.cc.plieber.fpgaenet.fcp.FCPProtocol;
10
 
11
/**
12
 * @author Peter Lieber
13
 *
14
 */
15
public class ClockControl {
16
 
17
        private FCPProtocol protocol;
18
        private int channel;
19
        /**
20
         *
21
         */
22
        public ClockControl(FCPProtocol p, int c) {
23
                protocol = p;
24
                channel = c;
25
        }
26
 
27
        public void deassertAll() {
28
                try {
29
                        protocol.sendData(channel, (byte)0);
30
                } catch (FCPException e) {
31
                        // TODO Auto-generated catch block
32
                        e.printStackTrace();
33
                }
34
        }
35
 
36
        public void assertReset() {
37
                try {
38
                        protocol.sendData(channel, (byte)0);
39
                        protocol.sendData(channel, (byte)0x04);
40
                } catch (FCPException e) {
41
                        // TODO Auto-generated catch block
42
                        e.printStackTrace();
43
                }
44
        }
45
 
46
        public void singleStep() {
47
                try {
48
                        protocol.sendData(channel, (byte)0);
49
                        ArrayList<Byte> data = new ArrayList<Byte>();
50
                        data.add((byte)0x00);
51
                        data.add((byte)0x00);
52
                        data.add((byte)0x00);
53
                        data.add((byte)0x01);
54
                        data.add((byte)0x01);
55
                        protocol.sendData(channel, data);
56
                } catch (FCPException e) {
57
                        // TODO Auto-generated catch block
58
                        e.printStackTrace();
59
                }
60
        }
61
 
62
        public void runClock(int numClocks) {
63
                try {
64
                        protocol.sendData(channel, (byte)0);
65
                        ArrayList<Byte> data = new ArrayList<Byte>();
66
                        data.add((byte)((numClocks >> 24) & 0xff));
67
                        data.add((byte)((numClocks >> 16) & 0xff));
68
                        data.add((byte)((numClocks >> 8) & 0xff));
69
                        data.add((byte)(numClocks & 0xff));
70
                        data.add((byte)0x01);
71
                        protocol.sendData(channel, data);
72
                } catch (FCPException e) {
73
                        // TODO Auto-generated catch block
74
                        e.printStackTrace();
75
                }
76
        }
77
 
78
        public void freeRunClock() {
79
                try {
80
                        protocol.sendData(channel, (byte)0);
81
                        protocol.sendData(channel, (byte)0x02);
82
                } catch (FCPException e) {
83
                        // TODO Auto-generated catch block
84
                        e.printStackTrace();
85
                }
86
        }
87
 
88
        public int getChannel() {
89
                return channel;
90
        }
91
 
92
        public void setChannel(int channel) {
93
                this.channel = channel;
94
        }
95
 
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.