仅对英特尔可见 — GUID: mtr1430270886847
Ixiasoft
仅对英特尔可见 — GUID: mtr1430270886847
Ixiasoft
6.1. 循环排程器(Round Robin Scheduler)
循环排程器(round robin scheduler)是一个基本的功能模块。以下实例使用模数运算符来确定下一个客户端的服务。由于模数运算符执行除法运算,因此相对较慢,并且面积效率低下。
Round Robin Scheduler的源代码
module round_robin_modulo (last, requests, next); parameter CLIENTS = 7; parameter LOG2_CLIENTS = 3; // previous client to be serviced input wire [LOG2_CLIENTS -1:0] last; // Client requests:- input wire [CLIENTS -1:0] requests; // Next client to be serviced: - output reg [LOG2_CLIENTS -1:0] next; //Schedule the next client in a round robin fashion, based on the previous always @* begin integer J, K; begin : find_next next = last; // Default to staying with the previous for (J = 1; J < CLIENTS; J=J+1) begin K = (last + J) % CLIENTS; if (requests[K] == 1'b1) begin next = K[0 +: LOG2_CLIENTS]; disable find_next; end end // of the for-loop end // of 'find_next' end endmodule
Retiming Summary报告识别关键链上限制Hyper-Retiming的不足寄存器。链从连接到最后一个输入的寄存器开始,通过使用分频器实现的模数运算符,并继续到连接到下一个输出的寄存器。
上面关键链中的44个单元对应于下面具有10级逻辑的电路图。模数运算符是导致低性能的主要因素。10级逻辑中的7级逻辑是模数运算符实现的一部分。
如图 125所示,Fast Forward编译根据在模块输入上添加两个流水线级,通过逻辑云进行重定时,评估出一个140%的性能提升。此时,关键链是一条短路径/长路径,此链包含模数运算符。
模数运算中的除法器是要求RTL修改的瓶颈。通过除法器的路径存在于关键链中,用于Fast Forward编译中所有步骤。考虑替代的实现来计算下一个要服务的客户端,以避免模数运算符。如果切换到一个将客户端的数量指定为2的幂数的实现,那么决定下一个要服务的客户端就不需要模数运算符。当使用少于2n个客户端来例化模块时,要将未使用的请求输入连接到逻辑0。
Round Robin Scheduler的源代码,通过2n个客户端输入提高了性能
module round_robin_modulo (last, requests, next); parameter LOG2_CLIENTS = 3; parameter CLIENTS = 2**LOG2_CLIENTS; // previous client to be serviced input wire [LOG2_CLIENTS -1:0] last; // Client requests:- input wire [CLIENTS -1:0] requests; // Next client to be serviced: - output reg [LOG2_CLIENTS -1:0] next; //Schedule the next client in a round robin fashion, based on the previous always @(next or last or requests) begin integer J, K; begin : find_next next = last; // Default to staying with the previous for (J = 1; J < CLIENTS; J=J+1) begin K = last + J; if (requests[K[0 +: LOG2_CLIENTS]] == 1'b1) begin next = K[0 +: LOG2_CLIENTS]; disable find_next; end end // of the for-loop end // of 'find_next' end endmodule
即使没有任何Fast Forward优化(Base Performance步骤),与Round Robin Scheduler的源代码中没有性能提升的版本相比,这种循环(round robin)实现的运行频率是其两倍。虽然两个版本中的关键链都只包含两个寄存器,但2n版本的关键链仅包含26个单元,而模数版本中只有44个单元。
关键链中的26个单元对应于下面具有四级逻辑的电路图。
通过在输入端添加三个寄存器级,通过逻辑云进行重定时,Fast Forward Compile将电路性能提升至1 GHz。与模数版本类似,Fast Forward优化后的最终关键链具有短路径/长路径的限制原因,如图 132所示,但性能是模数版本的1.6倍。
移除模式运算符并切换到二次幂实现是一个很小的设计变化,但实现了显著的性能提升。
- 仅可能地对数学运算使用自然二次幂
- 对看似基本的功能探索替代的实现。
在此实例中,改变循环逻辑的实现提供了比添加流水线级更多的性能提升。