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