Issues of this kind usually result from issues that are not related to the software code. This situation often occurs when the device was improperly programmed. Please check the length of the ISR cable being used to program the device. If the cable and ribbon put together is longer than 6 feet, the problem may be in the fact that the PC is unable to drive a coherent signal over the length of the cable. Another thing to check for is to see if the JTAGen pin is toggled properly after programming has completed.
Please be noted our entire Cypress CPLD product are Obsolete and not recommended for new design and development. For more information on CPLD product, please visit our webpage: http://www.cypress.com/go/cpld