answer:

I would create a class for registers, a class for each important combinational unit, such as adder, a class for bus, and a class for controller (a finite-state machine). Each of these classes would have a constructor indicating how many bits the item is, etc. For a finite-state machine, there would be a way to specify state-transition information as an array. Objects such as register and controller would have internal state. Stateless objects such as adder might be represented by static functions in the class.

I will give an example of the Register class:

class Register 
{ 
int bits; 
boolean contents[ ]; 
Register(int bits) // constructor 
{ 
this.bits = bits; 
} 
void clear() // clear the register 
{ 
for( int i = 0; i < bits; i++ ) 
  contents[i] = false; 
} 
void set(boolean new_contents[]) // set the register contents 
{ 
for( int i = 0; i < bits; i++ ) 
  contents[i] = new_contents[i]; 
} 
boolean[ ] value() // get the contents 
{ 
boolean result = new boolean[bits]; 
for( int i = 0; i < bits; i++ ) 
  result[i] = contents[i]; 
} 
boolean shiftRight() // shift right one bit 
{ 
boolean result = contents[0]; 
for( int i = 0; i < bits-1; i++ ) 
  contents[i] = contents[i+1]; 
return result; 
} 
}