Both instructions "CP" and "CPC" are not properly setting the S flag !
The alu.vhd file is the problem. I have published a correction in a French WIKIVERSITE book but it would be better to know if the core's author agree or not. See : http://fr.wikiversity.org/wiki/VeryHigh_Speed_Integrated_Circuit_Hardware_Description_Language/Embarquer_un_Atmel_ATMega8#Une_correction_partielle.3F
Finally I propose the correction :
function si(D, R, S: std_logic) return std_logic is begin
--< Changed by Serge Moutou 03/15/2011 -- return S xor ov(D, R, S);
return D xor ov(D, R, S);
--> end;
in the file alu.vhd
I haven't checked evry conditional jump which uses the S flag.
Hello,
I believe you are using a rather old version of the code.
This bug was hopefully fixed in SVN r17 on Jan. 25 2010. Function si() was replaced by two functions si_add() (for add, inc etc. instructions) and si_sub() (for sub, decm etc. instructions.
Try 'svn update' on your repository.
I am normally not updating the .pdf and .html documentation for small changes like this.
Kind Regards, Juergen Sauermann