using d_ff in always block
Erm, your d_ff module is a self contained unit, it will contain an always block. You instantiate the module separately (i.e. not in an always block), and use wire for all the outputs and reg or wire for all the inputs.

Once you connect up mainclk to the clock input of your d_ff module and also rst, then it will behave as a flip flop synchronous to all those in your always block.



You don't have to stick everything in the same always block, you can have as many as you need. Any that have the same edge sensitivity list will be synchronous to each other regardless of whether or not they are in the same block.