Verilog 移位、串行、并口

本文介绍了一种串行到并行及并行到串行的数据转换模块设计,使用Verilog HDL实现。该模块能够根据控制信号进行串并转换,并通过仿真验证其正确性。

//module shift(clk,out,in,res,en,x_out);
//    input clk;//时钟信号端口
//    input res;//高电平复位信号端口
//    input en;
//    input [7:0]in;//8个比特位输入信号端口
//    output reg[7:0]out;//8个比特位输出信号端口
//    output wire[7:0]x_out;//循环移位输出信号端口
//    
////    assign out = in;
//    reg [7:0]x_temp;//用于循环移位赋值
//    
//    always @(posedge clk)begin
//       if(res)begin//高电平复位
//            out<=8'b0;
//        end
//        //移位和赋值
//        else if(en) begin    
////            out<=in;//单一赋值
//            
//            //右移位是把低位拿走。
////            out<={in[0],in[7:1]};//右移一位
//            
//            //左移位是把高位拿走。
//            out<={in[6:0],in[7]};//左移一位
//            x_temp<=in;
//        end
//        //循环移位
//        else begin
////       x_temp<={x_temp[0],x_temp[7:1]};//右循环移位
//            x_temp<={x_temp[6:0],x_temp[7]};//左循环移位
//        end
//    end
//    
//     assign  x_out=x_temp;
//endmodule


//00000000000000000000000000000000000000000000000000000000000000
//串口,并口之间转换
//00000000000000000000000000000000000000000000000000000000000000
module Serial_parallel(clk,re,in,in_s,o_q,sp_en,o_p_q);
    input clk;//时钟信号端口
    input in;//串口输入信号端口
    input [7:0]in_s;//并口输入信号端口
    input sp_en;//高电平串口转并口,低电平并口转串口
    input re;//高电平复位信号端口
    
    output reg[7:0]o_q;//并口输出信号端口
    output reg o_p_q;//串口输出信号端口
    
    reg [7:0]x_temp;
    integer i;
   &nbs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值