使用门控时钟可以起到节约能耗的作用。这里只是简单额仿真一下利用门控时钟近视时钟的控制。
我们控制如果输入的数据是一长串的0或1则时钟保持不变,这样在传输这段数据的时候就会降低能耗。
`timescale 1ns / 1ps
//
// Company:
// Engineer:
//
// Create Date: 09:58:05 08/14/2015
// Design Name:
// Module Name: ctrol_gate
// Project Name:
// Target Devices:
// Tool versions:
// Description: 门控时钟,在输入的数据为一连串的0或1时,时钟保持不变,这样可以节约能耗
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//
module ctrol_gate( clk,rst_n,data_in,data_out
);
//****************************
//parameter declaration
//****************************
parameter U_DLY = 1'b1;
//****************************
//input port
//****************************
input clk; //100mhz
input rst_n; //active low
input data_in;
//****************************
//output port
//****************************
output data_out;
//****************************
//wire or reg declaration
//****************************
reg data_out;
wire r_clk; //clk creat by gate
wire ctrol_gate;
//
//
//LOGIC DESIGN
//
//
assign ctrol_gate = data_in^data_out;
assign r_clk = ctrol_gate & clk;
always @(posedge r_clk)
begin
if(!rst_n) begin
data_out <= #U_DLY 1'b0;
end
else begin
data_out <= #U_DLY data_in;
end
end
endmodule
仿真图:
图中r_clk即为经过门控之后输出的控制时钟,只有在数据变换的时候才会有时钟的产生。