ALU description ambiguity

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ALU description ambiguity

insan-e
In the ALU.hdl file, the description says the following:

// Implementation: the ALU logic manipulates the x and y inputs
// and operates on the resulting values, as follows:
// if (zx == 1) set x = 0        // 16-bit constant
// if (nx == 1) set x = !x       // bitwise not

It is not clear to me should the second operation (bitwise not) depend on previous value of x or the first one.

If both flags are 1 what should the result be? !x or !0 ?

Thank you for your time, this is one of most useful courses in CS ever! :)
Reply | Threaded
Open this post in threaded view
|

Re: ALU description ambiguity

cadet1620
Administrator
insan-e wrote
// Implementation: the ALU logic manipulates the x and y inputs
// and operates on the resulting values, as follows:
// if (zx == 1) set x = 0        // 16-bit constant
// if (nx == 1) set x = !x       // bitwise not

It is not clear to me should the second operation (bitwise not) depend on previous value of x or the first one.
This is a program-like description of the ALU. If x was a variable, the first "if" will replace the value of x, so the second "if" will affect the new value of x.

If zx = nx = 1, then x = ! 0. (0xFFFF or -1.)

--Mark