What you wrote is not correct to "delay the earlier signal". It sounds like you want to have a series of D-FlipFlops to delay the signals either 15 or 3 clocks. But looking at the code posted, this may be the least of your problems. d is set to '1' so you'll see X's at startup until there is a rising edge of clk. Then there is no need for a delay because q will always be '1'.
The sensitivity list has x in it, yet x is not declared. And there are mulitple case statements for r that sets g and y to different values when r is "0111". And r is in the sensitivity list. It does not need to be.
There is also no reset condition.