';cnt<="00000000";t<=cnt+1;cm<='0';endif;endif;endif;endprocess;c_out<=cnt;endarc;4、试编写同步模5计数器程序,有进位输出和异步复位端。t5(clk,reset,car,out);inputclk,reset;//reset为异步复位信号outputcar,out;//car为进位信号reg[2:t;//cnt为计数器regcar;wire[2:0]out;t;always@(posedgeclkornegedgereset)beginif(!reset)t<=3'b000;car<=0;t==3'b100)begincar<=3't<=3'b000;t<=cnt+3'b001;car<=3'b000;endendendendmodule5、编写4位串/并转换程序。modules2p(clk,rst_n,sdi,pdo);inputclk;//clocksignalforserialdatainputinputrst_n;//systemresetsignal,negativevalueinputsdi;//serialdatainput,posedgeclocksignalvalue,highsignificancebitinputfirstoutput[3:0]pdo;//paralleldataoutputreg[3:0]pdo;always@(posedgeclk)begin?//resetsignalvalue?if(rst_n==1'b0)?begin pdo<=4'b0000;?end //resetsignalisnotvalue,modulework?else?begin pdo[3:0]<={pdo[2:0],sdi};//shiftregistervalue?endend