Remix.run Logo
commandlinefan 4 hours ago

It's still the same number of clock cycles, though, isn't it? You're using some extra circuitry during the SUB, but during the XOR, that circuitry is just sitting idle anyway, so it's still six of one/half a dozen of the other.

DSMan195276 3 hours ago | parent | next [-]

It all depends on the CPU architecture, if it supports something like out-of-order execution then both parts of the CPU could be in use at the same time to execute different instructions. Realistically any CPU with that level of complexity doesn't care about SUB vs XOR though.

monocasa 17 minutes ago | parent [-]

Also, because SUB is implemented internally with XOR, so it's normally the same gates, with different signals selecting a different function.

3 hours ago | parent | prev | next [-]
[deleted]
3 hours ago | parent | prev | next [-]
[deleted]
RiverCrochet 3 hours ago | parent | prev [-]

XOR can do everything in 1 cycle (which is hopefully far, far less than the clock). SUB-if done the simple way-has to take n cycles where n is the number of bits subtracted.

anvuong 3 hours ago | parent | next [-]

That's just not true. You think subtracting/adding 64-bit numbers actually take 64 cycles?

There is sequential implementation of ripple carry adder that uses clock and register, this will add 1-bit per cycle, but no body uses this for obvious reason, it's just a toy example for education. A normal ripple carry adder will have some delay in propagation time before the output is valid, but that is much less a clock cycle. You can also design a customized adder circuit for 4-bit 8-bit 16-bit etc separately that would greatly minimizes the propagation delay to only 2 or 3 levels of gates, instead of n gates like in the ripple carry adder.

valleyer 3 hours ago | parent [-]

Right. In other words, the clock cycle is already made to be long enough to allow a word-sized SUB to settle. An XOR-with-self surely settles faster, but it still has to wait for that same clock cycle before proceeding.

jonathrg 3 hours ago | parent | prev [-]

What do you mean by cycles? A ripple-carry adder needs to wait for the carry bits to ripple through yes, but there's no clock cycle involved.

toast0 2 hours ago | parent [-]

Maybe they mean gate delays?