在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2317|回复: 5

[求助] 请教verilog中流水线的用途?

[复制链接]
发表于 2017-9-26 23:20:08 | 显示全部楼层 |阅读模式
10资产
本帖最后由 godjohsn 于 2017-9-26 23:26 编辑

看到很多资料里说“利用流水线的设计方法,可大大提高系统的工作速度。”

这是一个教材里很常用的例程:


(1)非流水线实现方式

module adder_8bits(din_1, clk, cin, dout, din_2, cout);   
   input [7:0] din_1;
    input clk;
    input cin;
    output [7:0] dout;
    input [7:0] din_2;
    output cout;

    reg [7:0] dout;
    reg       cout;

    always @(posedge clk) begin
            {cout,dout} <= din_1 + din_2 + cin;
    endendmodule

(2)2级流水线实现方式:

module adder_4bits_2steps(cin_a, cin_b, cin, clk, cout, sum);
    input [7:0] cin_a;
    input [7:0] cin_b;
    input cin;
    input clk;
    output cout;
    output [7:0] sum;

    reg cout;  
    reg cout_temp;
    reg [7:0] sum;   
    reg [3:0] sum_temp;

    always @(posedge clk) begin   
            {cout_temp,sum_temp} = cin_a[3:0] + cin_b[3:0] + cin;
    end         

    always @(posedge clk) begin   
            {cout,sum} = {{1'b0,cin_a[7:4]} + {1'b0,cin_b[7:4]} + cout_temp, sum_temp};  
    end

endmodule


注意:这里在always块内只能用阻塞赋值方式,否则会出现逻辑上的错误!

(3)4级流水线实现方式:

module adder_8bits_4steps(cin_a, cin_b, c_in, clk, c_out, sum_out);
    input [7:0] cin_a;
    input [7:0] cin_b;
    input c_in;
    input clk;
    output c_out;
    output [7:0] sum_out;

    reg c_out;   
    reg c_out_t1, c_out_t2, c_out_t3;   
    reg [7:0] sum_out;   
    reg [1:0] sum_out_t1;  
    reg [3:0] sum_out_t2;  
    reg [5:0] sum_out_t3;     

    always @(posedge clk) begin   
             {c_out_t1, sum_out_t1} = {1'b0, cin_a[1:0]} + {1'b0, cin_b[1:0]} + c_in;
    end      

    always @(posedge clk) begin   
             {c_out_t2, sum_out_t2} = {{1'b0, cin_a[3:2]} + {1'b0, cin_b[3:2]} + c_out_t1, sum_out_t1};  
    end         

    always @(posedge clk) begin      
            {c_out_t3, sum_out_t3} = {{1'b0, cin_a[5:4]} + {1'b0, cin_b[5:4]} + c_out_t2, sum_out_t2};
    end         

    always @(posedge clk) begin      
           {c_out, sum_out} = {{1'b0, cin_a[7:6]} + {1'b0, cin_b[7:6]} + c_out_t3, sum_out_t3};   
    end

endmodule


可是在ISE12.3 下实际时序分析的结果:采用4级流水线比不采用流水线的延时更大:
非流水线方式: Timing constraint: TS_clk = PERIOD TIMEGRP "clk" 10 ns HIGH 50%;   0 paths analyzed, 0 endpoints analyzed, 0 failing endpoints   0 timing errors detected. (0 component switching limit errors)   Minimum period is   1.366ns.

4级流水线方式: Timing constraint: TS_clk = PERIOD TIMEGRP "clk" 10 ns HIGH 50%;   10 paths analyzed, 10 endpoints analyzed, 0 failing endpoints   0 timing errors detected. (0 setup errors, 0 hold errors, 0 component switching limit errors)   Minimum period is   3.422ns.  


采用流水线之后延时更大,意味着系统最高频率更小,工作速度反而降低了,那流水线技术的意义究竟何在?

发表于 2017-9-28 09:59:14 | 显示全部楼层
你这样写实际上还是一级流水,想变成两级流水的话需要用非阻塞赋值,(输入需要稳定两个时钟周期),即一次运算需要两个时钟周期
 楼主| 发表于 2017-9-29 16:45:43 | 显示全部楼层



但是这个计算分流水的话必须用阻塞赋值,否则时序不对
发表于 2017-9-29 20:51:24 | 显示全部楼层
thx,谢谢分享
发表于 2017-9-29 21:41:06 | 显示全部楼层
用流水线你要进行打拍,还有,时序逻辑最好用非阻塞幅值
 楼主| 发表于 2017-9-30 00:13:48 | 显示全部楼层


用流水线你要进行打拍,还有,时序逻辑最好用非阻塞幅值
黑桃ACE 发表于 2017-9-29 21:41



打拍?
是这样操作么:

原程序:
z <= a + b + c + d;
打拍:
z1 <= a + b ;
z2 <= c + d ;
z <= z1 + z2;

可是ISE时序分析的结果是打拍后延时更大:
(1)z1 <= a + b + c + d;   
Timing constraint:
TS_clk = PERIOD TIMEGRP "clk" 2 ns HIGH 50%;
  0 paths analyzed, 0 endpoints analyzed, 0 failing endpoints   0 timing errors detected. (0 component switching limit errors)   Minimum period is   1.316ns. (2)z1 <= a + b ;z2 <= c + d ;
z <= z1 + z2;

Timing constraint:  TS_clk = PERIOD TIMEGRP "clk" 2 ns HIGH 50%;
  55 paths analyzed, 20 endpoints analyzed, 19 failing endpoints   19 timing errors detected. (19 setup errors, 0 hold errors, 0 component switching limit errors)   Minimum period is   3.832ns.
是我理解有误么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-29 22:18 , Processed in 0.031610 second(s), 6 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表