Added machine plugin project to repository
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / Register.java
1 package net.mograsim.machine;
2
3 import java.util.Set;
4
5 /**
6  * A register in a machine is defined by this interface. A hardware register may
7  * have {@link Register#names() named sub-registers}.
8  *
9  *
10  * @author Christian Femers
11  *
12  */
13 public interface Register {
14         /**
15          * The unique identifier of the register. This does not have to be the display
16          * name or name in the assembly language.
17          * 
18          * @return the registers id as case sensitive String
19          * @author Christian Femers
20          */
21         String id();
22
23         /**
24          * The name(s) of this register. This is the displayed name and the name used in
25          * the assembly language. All names of all registers must be case-insensitive
26          * unique. A register can have multiple names if these names address different
27          * regions (but still have a common hardware structure), e.g. <code>EAX</code>,
28          * <code>AX</code>, <code>AL</code>, <code>AH</code>.
29          * 
30          * @return all the names of regions addressing this register, must be
31          *         case-insensitive.
32          * @author Christian Femers
33          */
34         Set<String> names();
35
36         /**
37          * Returns the complete width in bits of the underlying hardware structure the
38          * register and possible sub-registers are part of.
39          * 
40          * @param name the name of the register
41          * @return the width of the (sub-)register in bits.
42          * 
43          * @see #names()
44          * @author Christian Femers
45          */
46         int getWidth();
47
48         /**
49          * Returns the width in bits of the register or a named part of it.
50          * 
51          * @param name the name of the register
52          * @return the width of the (sub-)register in bits.
53          * 
54          * @see #names()
55          * @author Christian Femers
56          */
57         int getWidth(String name);
58 }