When you start working with CPLDs and FPGAs, the easiest way to get going is to look at existing modules and adapt them for your needs. Xilinx provide some excellent and very comprehensive cores but they tend to be fairly complex and thus a bit more difficult to unpick. A better option can be to look at tutorial sites such as the excellent Papilio Learning Centre at the Gadget Factory. Another good starting point is the FPGA4FUN site as this has a good selection of simple cores complete with functional descriptions. Don’t worry that they are FPGA orientated as many can be loaded into a CPLD. For a more comprehensive selection of cores, OpenCores maintains an extensive library of cores that are free to download. These are great when you need to add specific functionality to your project.