In my design, a local clock is generated by a clock divider, which looks like follow:
process ( iARM7_CLK )
begin
if ( rising_edge( iARM7_CLK ) ) then
spiclkcon <= spiclkcon + 1;
if ( spiclkcon = spiclk_gen ) then
spiclkcon <= x"00";
spiclk <= not spiclk;
elsif ( spiclkcon = x"32" and spiclk = '0' ) then
.. check the data from ARM7 CLOCK domain…
whato you should do is keep using your , let's call it system clock, and the use your devided clock as clock enable.
if risinge_edge(sys_clk) then
if divide_clk = '1' then
(
put your logic here;
)
your outputs are now aligned with system clock.
pay attentio your outputs to your domain are now allign with sys_clk, and not divide_clk. so you need to shift them.
looks about right, but I was told you before, you should separate your processes, make code more readble, and also make compilier job easy. Also when you read your timing report, it makes more easy to analyze when you have more structured code