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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM