Page 147 - 3-2
P. 147

if(!reset) begin tone_cnt<=0; spk<=0; end
                    else if(warning_sig==1) begin
                            if(tone_cnt>=tone[addr]) begin tone_cnt<=0; spk<=~spk; end
                            else tone_cnt<=tone_cnt+1;
                    end
                    else begin tone_cnt<=0; spk<=0; end
            end
            always @(posedge clk, negedge reset) begin
                    if(!reset) begin tempo_cnt<=0; addr<=0; end
                    else if(warning_sig==1) begin
                            if(tempo_cnt>=tempo) begin
                                    tempo_cnt<=0; addr<=addr+1;
                            end
                            else tempo_cnt<=tempo_cnt+1;
                    end
                    else begin tempo_cnt<=0; addr<=0; end
            end

            endmodule




























































                                                         - 147 -
   142   143   144   145   146   147   148   149   150   151   152