OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

[/] [spacewiresystemc/] [trunk/] [rtl/] [DEBUG_VERILOG/] [clock_reduce.v] - Diff between revs 23 and 40

Show entire file | Details | Blame | View Log

Rev 23 Rev 40
Line 32... Line 32...
//-FHDR------------------------------------------------------------------------
//-FHDR------------------------------------------------------------------------
 
 
module clock_reduce(
module clock_reduce(
                        input clk,
                        input clk,
                        input reset_n,
                        input reset_n,
 
                        input [2:0] clock_sel,
 
 
 
                        output  clk_reduced,
 
                        output  clk_100_reduced
 
 
                        output reg clk_reduced
 
                   );
                   );
 
 
 
 
reg [10:0] counter;
reg [10:0] counter;
 
reg [10:0] counter_100;
 
 
 
assign clk_reduced     = clk_reduced_p | clk_reduced_n;
 
assign clk_100_reduced = clk_100_reduced_p | clk_100_reduced_n;
 
 
 
 
 
reg clk_reduced_i;
 
reg clk_100_reduced_i;
 
 
 
 
 
reg clk_reduced_p;
 
reg clk_100_reduced_p;
 
 
 
reg clk_reduced_n;
 
reg clk_100_reduced_n;
 
 
 
always@(*)
 
begin
 
 
 
        clk_reduced_p = 1'b0;
 
 
 
        if(clk_reduced_i)
 
        begin
 
                clk_reduced_p = 1'b1;
 
        end
 
 
 
end
 
 
 
 
 
always@(*)
 
begin
 
 
 
        clk_reduced_n = 1'b1;
 
 
 
        if(!clk_reduced_i)
 
        begin
 
                clk_reduced_n = 1'b0;
 
        end
 
 
 
end
 
 
 
always@(*)
 
begin
 
 
 
        clk_100_reduced_p = 1'b0;
 
 
 
        if(clk_100_reduced_i)
 
        begin
 
                clk_100_reduced_p = 1'b1;
 
        end
 
 
 
end
 
 
 
 
 
always@(*)
 
begin
 
 
 
        clk_100_reduced_n = 1'b1;
 
 
 
        if(!clk_100_reduced_i)
 
        begin
 
                clk_100_reduced_n = 1'b0;
 
        end
 
 
 
end
 
 
always@(posedge clk)
always@(posedge clk)
begin
begin
 
 
        if(!reset_n)
        if(!reset_n)
        begin
        begin
 
 
                counter <= 11'd0;
                counter <= 11'd0;
                clk_reduced <= 1'b0;
                counter_100 <= 11'd0;
 
                clk_reduced_i <= 1'b0;
 
                clk_100_reduced_i <= 1'b0;
 
        end
 
        else
 
        begin
 
 
 
 
 
                case(clock_sel)
 
                3'd0://2mhz - 500 ns
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd99 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter >=11'd100 && counter <=11'd199 )
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
        end
        end
        else
        else
        begin
        begin
                if(counter >=11'd0 && counter <=11'd24 )
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd1://5mhz
 
                begin
 
 
 
                        if(counter >=11'd0 && counter <=11'd39 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter >=11'd40 && counter <=11'd79 )
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd2://10mhz
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd19 )
                begin
                begin
                        clk_reduced <= 1'b1;
                                clk_reduced_i <= 1'b1;
                        counter <= counter + 11'd1;
                        counter <= counter + 11'd1;
                end
                end
                else if(counter >=11'd25 && counter <=11'd49 )
                        else if(counter >=11'd20 && counter <=11'd39 )
                begin
                begin
                        clk_reduced <= 1'b0;
                                clk_reduced_i <= 1'b0;
                        counter <= counter + 11'd1;
                        counter <= counter + 11'd1;
                end
                end
                else
                else
                begin
                begin
                        clk_reduced <= 1'b1;
                                clk_reduced_i <= 1'b1;
                        counter <= 11'd0;
                        counter <= 11'd0;
                end
                end
 
                end
 
                3'd3://50mhz
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd3 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter >=11'd4 && counter <=11'd7)
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd4://100mhz
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd1 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter >=11'd2 && counter <=11'd4)
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd5://150mhz
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd1 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter >=11'd2 && counter <=11'd3)
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd6://200mhz
 
                begin
 
                        if(counter >=11'd0 && counter <=11'd1 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter == 11'd2)
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                3'd7://300mhz
 
                begin
 
                        if(counter ==11'd0 )
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else if(counter ==11'd1)
 
                        begin
 
                                clk_reduced_i <= 1'b0;
 
                                counter <= counter + 11'd1;
 
                        end
 
                        else
 
                        begin
 
                                clk_reduced_i <= 1'b1;
 
                                counter <= 11'd0;
 
                        end
 
                end
 
                endcase
 
 
 
                if(counter_100 >=11'd0 && counter_100 <=11'd1 )
 
                begin
 
                        clk_100_reduced_i <= 1'b1;
 
                        counter_100 <= counter_100 + 11'd1;
 
                end
 
                else if(counter_100 >=11'd2 && counter_100 <=11'd4)
 
                begin
 
                        clk_100_reduced_i <= 1'b0;
 
                        counter_100 <= counter_100 + 11'd1;
 
                end
 
                else
 
                begin
 
                        clk_100_reduced_i <= 1'b1;
 
                        counter_100 <= 11'd0;
 
                end
 
 
        end
        end
 
 
end
end
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.