z80 flags - how to generate?
===

I'm designing a z80 compatible project. I'm up to designing the flags register.

I originally thought that the flags were generated straight from the ALU depending on the inputs and type of ALU operation.

But after looking at the instructions and the flags result it doesn't seem that the flags are always consistent with this logic.

As a result i'm then assuming i also have to feed the ALU the op-code as well to generate the correct flags each time. But this would seem to make the design over complicated. And before making this huge design step I wanted to check with the internet.

Am i correct? OR just really confused and it is as simple as i originally thought?

Thannks.