Taomes 发表于 2014-4-17 21:42:32

串并转换

我想把编码器发出的17位串行数据由FPGA转换为并行数据,然后输出给DSP.下面是我写的用Verilog实现串并转换,求大神看看对不对,然后能否指导一下具体怎么应用于FPGA.谢谢
这是我该写的,您看看对不对:

模17计数器:
module counter_mod_17(clock,reset,Q);
input clock; //posedge effective
input reset; // negedge effective
output Q; //17位数据是5位宽的
reg Q;
always@(posedge clock or negedge reset) begin
if(~reset)
Q <= 5'd0;
Ifelse(Q<=16)
Q <= Q + 1;
else
Q<=5'd0;
end
endmodule
串转并模块:
module ser_to_par_17bit(ser_in,clk,rst,out);
input ser_in,clk,rst;
output out;
wire out;
reg par_out;
wire count;
counter_mod_17 f1(.clock(clk),.reset(rst),.Q(count));
always@(posedge clk or negedge rst) begin
if(~rst)
par_out <= 17'b0_0000_0000_0000_0000;
else begin
par_out <= {par_out,ser_in};
end
end
assign out = (count == 16)? par_out : 17'b0_0000_0000_0000_0000;
endmodule

zhiweiqiang33 发表于 2014-4-18 14:59:09

关于串并转换的电路实现与代码案例你在本论坛上边找;文档,代码很多的;

zhiweiqiang33 发表于 2014-4-18 15:01:17

请参考http://www.fpgaw.com/forum.php?mod=viewthread&tid=26968&highlight=%B4%AE%B2%A2%D7%AA%BB%BB
页: [1]
查看完整版本: 串并转换