system-verilog - 流式操作符在 PHY 中的串行器上下文中的使用
问题描述
我有基于 RTL 代码中数据宽度的 8:1 序列化器和反序列化器。截至目前,我们正在使用for循环来加载数据路径和从序列化器读取数据路径。我们可以为这个功能使用流式操作符吗?
我是流媒体运营商的新手,所以我不知道如何在这种情况下使用它们。
input [8*DATA_WIDTH-1:0] data_from_user; //WRITE DATA
output [8*DATA_WIDTH-1:0] data_to_user; //READ DATA
output [7:0] data_to_phy_serializer [DATA_WIDTH-1:0];
input [7:0] data_from_phy_deserializer [DATA_WIDTH-1:0];
//WRITE DATA PATH FLOW
always@(posedge clk) begin:WRITE_PATH
for(i = 0 ; i < DATA_WIDTH ; i = i+ 1 )
data_to_phy_serializer[i] = '{
data_from_user[DATA_WIDTH*7 + i],
data_from_user[DATA_WIDTH*6 + i],
data_from_user[DATA_WIDTH*5 + i],
data_from_user[DATA_WIDTH*4 + i],
data_from_user[DATA_WIDTH*3 + i],
data_from_user[DATA_WIDTH*2 + i],
data_from_user[DATA_WIDTH*1 + i],
data_from_user[DATA_WIDTH*0 + i]
} ;
end
//READ DATA PATH FLOW
always@(posedge clk) begin:READ_PATH
for(j= 0 ; j < DATA_WIDTH ; j = j + 1)begin
{
data_to_user[j+DATA_WIDTH*7],
data_to_user[j+DATA_WIDTH*6],
data_to_user[j+DATA_WIDTH*5],
data_to_user[j+DATA_WIDTH*4],
data_to_user[j+DATA_WIDTH*3],
data_to_user[j+DATA_WIDTH*2],
data_to_user[j+DATA_WIDTH*1],
data_to_user[j+DATA_WIDTH*0]
} <= #TCQ data_from_phy_deserializer[j] ;
end
输入将采用 8 个数据字连接的形式,我需要通过从输入数据中相应地拾取这些元素来分别将数据发送到每个数据位的 PHY。
这段代码工作正常,但唯一的疑问是我可以在这种情况下使用流操作符。请不要讲述流式运营商的基础知识,比如打包到解包的转换,反之亦然。我需要为 PHY 流式传输数据。如果我可以在这种情况下使用流式运营商,那将对我有很大帮助。
将 4 位数据宽度的数据路径写入 8:1 串行器的示例代码
//write data for data width of 4
assign [8*4 -1:0] data = {4'hF,4'hE,4'hD,4'hC,4'hB,4'hA,4'h9,4'h8};
//so now data to each data bit serializer will be
//8:1 data for serializers of
// bit-- 3-- 2-- 1-- 0
// 4'b___1___1___1___1
// 4'b___1___1___1___0
// 4'b___1___1___0___1
// 4'b___1___1___0___0
// 4'b___1___0___1___1
// 4'b___1___0___1___0
// 4'b___1___0___0___1
// 4'b___1___0___0___0
// data for serializer of bit 0 is 8'b10101010
// data for serializer of bit 1 is 8'b11001100
// data for serializer of bit 2 is 8'b11110000
// data for serializer of bit 3 is 8'b11111111
assign [7:0] data_to_phy_serializers [3:0] = '{
8'b11111111,
8'b11110000,
8'b11001100,
8'b10101010
};
解决方案
Yes you can use it in both cases.I guess this will work:
data_to_phy_serializer = {>>{data_from_user}};
and
data_to_user <= #TCD {>>{data_from_phy_deserializer}};
I have a small experimental example here which you can play with.
module ab;
logic [3:0][1:0]a;
logic [3:0]b[1:0];
logic [3:0][1:0]c;
initial begin
a = 8'hAB;
b = {>>{a}};
c = {>>{b}};
$displayh(a,b[1],b[0],c);
end
endmodule