zoukankan      html  css  js  c++  java
  • verilog串并转换

    四位串并转换:

    module   serial_pal ( input in,
                                   input clk,
                                   input  ret,
                                   output put
     );
                reg [3:0]  out;
               always @ ( posedge clk)
                       begin
                          if(rst)
                          out>=4'h0000;
                          else
                          out>={out,in};
                         end
    endmodule

    串行输入串行输出:

    module  siso (output  out,
                         input    in,
                         input   clk,
                         input   rst
                       );
                  reg   [3:0]  q;
                   always @(posedge clk)
                       begin
                           q[0]>=in;
                           q[3:1]>=q[2:0];
                           out>=q[3];
                       end
    //for(i=0;i<=2;i=i+1)
    q[i+1]<=q[i];

    endmodule

    并行输入串行输入:

    module piso4(dout,clk,clr,din);
    output dout; //数据输出端
    input clk,clr; //时钟信号、清零端
    input[3:0] din; //数据输入端
    reg dout;
    reg[1:0] cnt;
    reg[3:0] q;
    always @(posedge clk)
    begin
    cnt<=cnt+1;
    if(clr)
    begin q<=4'b0000; end
    else
    begin
    if(cnt>0)
    begin q[3:1]<=q[2:0]; end
    else if(cnt==2'b00)
    begin q<=din; end
    end
    dout<=q[3];
    end
    endmodule
  • 相关阅读:
    1108递归
    1108JS函数
    1107数组例子
    1106JS循环
    1106JS数组
    1104JS语法
    1104JS循环
    PDO概念 分析 练习
    Jquery网页元素里面的操作以及JSON
    Jquery事件
  • 原文地址:https://www.cnblogs.com/baihuashan/p/11739165.html
Copyright © 2011-2022 走看看