Page 184 - 3-2
P. 184

always @(posedge clk)
            if(bot_idle)
                    bot_cnt<=0;
            else
            begin
                    bot_cnt<=bot_cnt+16'd1;
                    if(bot_cnt_max) bot_state<=~bot_state;
            end




            reg oneu_state;
            reg oneu_up;
            reg oneu_sync_0;
            always @(posedge clk) oneu_sync_0<=~oneu;
            reg oneu_sync_1;
            always @(posedge clk) oneu_sync_1<=oneu_sync_0;


            reg [15:0] oneu_cnt;


            wire oneu_idle = (oneu_state==oneu_sync_1);
            wire oneu_cnt_max = &oneu_cnt;


            always @(posedge clk)
            if(oneu_idle)
                    oneu_cnt<=0;
            else
            begin
                    oneu_cnt<=oneu_cnt+16'd1;
                    if(oneu_cnt_max) oneu_state<=~oneu_state;
            end




            reg twou_state;
            reg twou_up;


            reg twou_sync_0;
            always @(posedge clk) twou_sync_0<=~twou;
            reg twou_sync_1;
            always @(posedge clk) twou_sync_1<=twou_sync_0;


            reg [15:0] twou_cnt;


            wire twou_idle = (twou_state==twou_sync_1);
            wire twou_cnt_max = &twou_cnt;


                                                         - 184 -
   179   180   181   182   183   184   185   186   187   188   189