数字电路设计之低功耗设计方法五:门控
2014-06-30 12:57
465 查看
Clock-gating:在时钟频率加快的同时,有时候会产生不必要的跳转。有的时候输入并没有改变,但是由于时钟的跳转,寄存器的值会被一遍一遍的刷新。可能输入才更改一次,结果时钟已经跳了几万次,这样的差距是可怕的。每次时钟上升沿,输出就要重新计算一遍,这样带来的功耗是巨大的。如果使用门控的话,我们就可以增加一个逻辑,就是只有在满足某种条件之下,时钟的上升沿才会对使得整个电路重新计算。(比如这个条件就是输入发生变化)这样的话就可大大降低功耗。
没有门控的代码:
module clock(
a,
b,
c,
clock,
rst
);
input wire clock;
input wire rst;
input wire [31:0]a;
input wire [31:0]b;
output reg [63:0]c;
always@(posedge clock,posedge rst)
begin
if(rst)
c = 0;
else
c = a*b + a + b;
end
endmodule
有门控的代码:
module clk_gating(
clk,
a,
b,
c,
clr
);
input wire [31:0]a;
input wire [31:0]b;
input wire clk;
input wire clr;
output reg [63:0]c;
reg [31:0]temp_a;
reg [31:0]temp_b;
wire gating;
assign gating = (temp_a==a) & (temp_b==b);
always@(posedge clk,posedge clr)
begin
if(clr)
begin
temp_a <= 0;
temp_b <= 0;
end
else
begin
temp_a <= a;
temp_b <= b;
end
end
always@(posedge clr,posedge clk)
begin
if(clr)
c <= 0;
else if(clk&(~gating))
c <= a*b + a + b;
else;
end
endmodule
仿真代码:
module test;
// Inputs
reg [31:0] a;
reg [31:0] b;
reg clock;
reg rst;
// Outputs
wire [63:0] c;
// Instantiate the Unit Under Test (UUT)
clock uut (
.a(a),
.b(b),
.c(c),
.clock(clock),
.rst(rst)
);
always #1 clock = ~clock;
parameter DELAY = 200;
integer k;
initial begin
// Initialize Inputs
$dumpfile("clock.vcd");
$dumpvars(1,test.uut);
a = 0;
b = 0;
rst = 1;
clock = 0;
#100;
rst = 0;
// Wait 200 ns for global reset to finish
for(k = 0;k < 100;k=k+1)
begin
a <= ~a;
b <= ~b;
#DELAY;
end
// Add stimulus here
$finish;
end
endmodule
没有门控的代码:
module clock(
a,
b,
c,
clock,
rst
);
input wire clock;
input wire rst;
input wire [31:0]a;
input wire [31:0]b;
output reg [63:0]c;
always@(posedge clock,posedge rst)
begin
if(rst)
c = 0;
else
c = a*b + a + b;
end
endmodule
有门控的代码:
module clk_gating(
clk,
a,
b,
c,
clr
);
input wire [31:0]a;
input wire [31:0]b;
input wire clk;
input wire clr;
output reg [63:0]c;
reg [31:0]temp_a;
reg [31:0]temp_b;
wire gating;
assign gating = (temp_a==a) & (temp_b==b);
always@(posedge clk,posedge clr)
begin
if(clr)
begin
temp_a <= 0;
temp_b <= 0;
end
else
begin
temp_a <= a;
temp_b <= b;
end
end
always@(posedge clr,posedge clk)
begin
if(clr)
c <= 0;
else if(clk&(~gating))
c <= a*b + a + b;
else;
end
endmodule
仿真代码:
module test;
// Inputs
reg [31:0] a;
reg [31:0] b;
reg clock;
reg rst;
// Outputs
wire [63:0] c;
// Instantiate the Unit Under Test (UUT)
clock uut (
.a(a),
.b(b),
.c(c),
.clock(clock),
.rst(rst)
);
always #1 clock = ~clock;
parameter DELAY = 200;
integer k;
initial begin
// Initialize Inputs
$dumpfile("clock.vcd");
$dumpvars(1,test.uut);
a = 0;
b = 0;
rst = 1;
clock = 0;
#100;
rst = 0;
// Wait 200 ns for global reset to finish
for(k = 0;k < 100;k=k+1)
begin
a <= ~a;
b <= ~b;
#DELAY;
end
// Add stimulus here
$finish;
end
endmodule
相关文章推荐
- 数字电路设计之低功耗设计方法四:预计算
- 数字信号抗干扰电路的设计及实现方法
- 数字电路设计中的亚稳态及其解决方法
- 关于数字电路的设计方法的进一步认识
- 设计一个类,该类中有一个方法,该方法使用Random类随机产生10个三位数字(如636)的随机数,并把产生的10个随机数存入数组中。然后在另一个类中输出这10个数
- 数字电路设计之低功耗设计方法一:bus总线翻转
- 数字电路设计之五级流水线设计(CPU)
- [转贴]寄存器传输级的低功耗设计方法
- 数字电路设计之低功耗设计方法六:旁路(by-passing)
- 数字信号在不同时钟域间同步电路的设计
- 寄存器传输级的低功耗设计方法
- 数字电路设计之低功耗设计方法三:操作数隔离
- 电子电路设计方法
- 汽车尾灯控制电路设计的第一种方法
- 数字转汉语读法的方法设计(C#)
- 利用ADS2009来设计微带双枝节匹配电路的方法
- 基于信号完整性分析的高速数字PCB 的设计方法
- 一种低功耗触摸按键应用的设计方法
- 流水线技术在高速数字电路设计中的应用
- 电子电路课程设计——8位数字抢答器设计论文