当前位置: 首页> 房产> 政策 > 【credit_based 流控管理-2】

【credit_based 流控管理-2】

时间:2025/7/17 15:04:10来源:https://blog.csdn.net/li_kin/article/details/139154305 浏览次数:0次

credit_based 流控管理-2


上篇文章是简要介绍一下基于credit的流控原理,和实现方法;
本篇序列是应对: when the design can send and return more than one credits at a time.
针对考虑解决:

  • send and return credits > 1 at a time. notes: have the send_units and taken_units port.
  • offer overflow and underflow protection.

code blocks are as belows:
以下代码未经过编译和功能验证,仅供逻辑参考;

//--Auther	:colonel
//--Date	:2024-05-23
//--Function:credit_based for flow control
//			consider for the send and return credits at a time.
//--History	:Description
//--05/22	:Firstly create the file
//module crdt_tracker_multi#(parameter WIDTH = 4
)(input clk,input rst_n,input [WIDTH -1:0] crdt_limit,input send,input [WIDTH -1:0] send_units,input taken,input [WIDTH -1:0] taken_units,output reg has_crdt,output reg[WIDTH -1:0] crdt_left
);reg [WIDTH -1:0] crdt_cnt;
wire[WIDTH :0] nxt_crdt_cnt;//Note: Width changedwire[WIDTH :0] delta;	//minus units:send minus taken
wire overflow;
wire underflow;always@(posedge clk or negedge rst_n) beginif(!rst_n) begincrdt_cnt <= 0;end else beginif(overflow || underflow) begincrdt_cnt <= (overflow) ? crdt_limit:0;end else begincrdt_cnt <= nxt_crdt_cnt;endend
endalways@(*) begindelta = 0;nxt_crdt_cnt = {1'b0,crdt_cnt};if(send && !taken) begindelta = {1'b0,send_units};nxt_crdt_cnt = {1'b0,crdt_cnt} + delta;end else if(!send && taken) begindelta =  {1'b0,taken_units}nxt_crdt_cnt = {1'b0,crdt_cnt} - delta;end else if(send && taken) begindelta = {1'b0,send_units} - {1'b0,taken_units};nxt_crdt_cnt = {1'b0,crdt_cnt} + delta;end else begindelta =  delta;nxt_crdt_cnt = nxt_crdt_cnt;end
end//--underflow and overflow logic
assign underflow = send && (~delta[WIDTH-1] && nxt_crdt_cnt[WIDTH] || (send_units>taken_units)) 
assign overflow = taken && (delta[WIDTH-1] && nxt_crdt_cnt[WIDTH] || (taken_units>send_units)) always@(posedge clk or negedge rst_n) beginif(!rst_n) beginhas_crdt <= 1'b0;crdt_left<= crdt_limit;end else beginif(nxt_crdt_cnt < crdt_limit) beginhas_crdt <= 1'b1;crdt_left<= crdt_limit - nxt_crdt_cnt;end else beginhas_crdt <= 1'b0;crdt_left<= 0;endend
endendmodule

Reference:

关键字:【credit_based 流控管理-2】

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: