概述
- 并转串(4bit)
module pal_ser(
input clk,
input rst_n,
input load
input [3:0]din,
output dout);
reg [3:0] databuff;
always @(posedge clk or negedge rst_n)
if(!rst_n) databuff <= 4'b0;
else if(load) databuff <= din;
else databuff <= databuff << 1;
assign dout = databuff[3];
endmodule
- 串转并(4位)
module ser_pal(
input clk,
input rst_n,
input en
input cin,
output cout);
reg [3:0] cout;
always @(posedge clk or negedge rst_n)
if(!rst_n) cout <= 4'b0;
else if(en) cout <= {cout[2:0],cin};
else cout <= cout;
endmodule
用Verilog实现串转并电路,输出信号8bit,同时可选择模式MSB或LSB优先。
module ser_to_pal(
input clk,
input rst_n,
input sel_mode,
input data_in,
output [7:0]data_out
);
reg [7:0]LSB_reg; // 最低位
reg [7:0]MSB_reg; // 最高位
always @(posedge clk or negedge rst_n) begin
if(!rst_n) begin
LSB_reg <= 8'b0;
MSB_reg <= 8'b0; end
else if(sel_mode)
LSB_reg <= {LSB_reg[6:0],data_in};
else
MSB_reg <= {data_in,MSB_reg[7:1]};
end
assign data_out = (sel_mode)?LSB_reg:MSB_reg;
endmodule
最后
以上就是聪明月光为你收集整理的串并转换-串转并+并转串+LSB/MSB串转并的全部内容,希望文章能够帮你解决串并转换-串转并+并转串+LSB/MSB串转并所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复