uart.v`timescale1ns/100psmoduleuart(dout,data_ready,framing_error,parity_error,rxd,clk16x,rst,rdn,din,tbre,tsre,wrn,sdo);outputtbre;outputtsre;outputsdo;input[7:0]din;inputrst;inputclk16x;inputwrn;inputrxd;inputrdn;output[7:0]dout;outputdata_ready;outputframing_error;outputparity_error;rcvru1(dout,data_ready,framing_error,parity_error,rxd,clk16x,rst,rdn);txmitu2(din,tbre,tsre,rst,clk16x,wrn,sdo);endmodulercvr.v`timescale1ns/1nsmodulercvr(dout,data_ready,framing_error,parity_error,rxd,clk16x,rst,rdn);inputrxd;inputclk16x;inputrst;inputrdn;output[7:0]dout;outputdata_ready;outputframing_error;outputparity_error;regrxd1;regrxd2;regclk1x_enable;reg[3:0]clkdiv;reg[7:0]rsr;reg[7:0]rbr;reg[3:0]no_bits_rcvd;regdata_ready;regparity;regparity_error;regframing_error;wireclk1x;assigndout=!rdn?rbr:8'bz;always@(posedgeclk16xorposedgerst)beginif(rst)beginrxd1=1'b1;rxd2=1'b1;endelsebeginrxd1=rxd;rxd2=rxd1;endendalways@(posedgeclk16xorposedgerst)beginif(rst)clk1x_enable=1'b0;elseif(!rxd1&&rxd2)clk1x_enable=1'b1;elseif(no_bits_rcvd==4'b1100)clk1x_enable=1'b0;endalways@(posedgeclk16xorposedgerstornegedgerdn)beginif(rst)data_ready=1'b0;elseif(!rdn)data_ready=1'b0;elseif(no_bits_rcvd==4'b1011)data_ready=1'b1;endalways@(posedgeclk16xorposedgerst)beginif(rst)clkdiv=4'b0000;elseif(clk1x_enable)clkdiv=clkdiv+1;endassignclk1x=clkdiv[3];always@(posedgeclk1xorposedgerst)if(rst)beginrsr=8'b0;rbr=8'b0;parity=1'b1;framing_error=1'b0;parity_error=1'b0;endelsebeginif(no_bits_rcvd=4'b0001&&no_bits_rcvd=4'b1000)//4'b1001begin/*MSBFirstrsr[0]=rxd2;rsr[7:1]=rsr[6:0];parity=parity^rsr[7];*//*LSBFirst*/rsr[7]=rxd2;rsr[6:0]=rsr[7:1];parity=parity^rsr[0];endelseif(no_bits_rcvd==4'b1001)//4'b1010beginrbr=rsr;endelseif(!parity)parity_error=1'b1;elseif((no_bits_rcvd==4'b1011)&&(rxd2!=1'b1))framing_error=1'b1;elseframing_error=1'b0;endalways@(posedgeclk1xorposedgerstornegedgeclk1x_enable)if(rst)no_bits_rcvd=4'b0000;elseif(!clk1x_enable)no_bits_rcvd=4'b0000;elseno_bits_rcvd=no_bits_rcvd+1;endmoduletxmit.v`timescale1ns/1nsmoduletxmit(din,tbre,tsre,rst,clk16x,wrn,sdo);outputtbre;outputtsre;outputsdo;input[7:0]din;inputrst;inputclk16x;inputwrn;regtbre;regtsre;regclk1x_enable;reg[7:0]tsr;reg[7:0]tbr;regparity;reg[3:0]clkdiv;wireclk1x;regsdo;reg[3:0]no_bits_sent;regwrn1;regwrn2;always@(posedgeclk16xorposedgerst)beginif(rst)beginwrn1=1'b1;wrn2=1'b1;endelsebeginwrn1=wrn;wrn2=wrn1;endendalways@(posedgeclk16xorposedgerst)beginif(rst)begintbre=1'b0;clk1x_enable=1'b0;endelseif(!wrn1&&wrn2)beginclk1x_enable=1'b1;tbre=1'b1;endelseif(no_bits_sent==4'b0010)tbre=1'b1;elseif(no_bits_sent==4'b1101)beginclk1x_enable=1'b0;tbre=1'b0;endendalways@(negedgewrnorposedgerst)beginif(rst)tbr=8'b0;elsetbr=din;endalways@(posedgeclk16xorposedgerst)beginif(rst)clkdiv=4'b0;elseif(clk1x_enable)clkdiv=clkdiv+1;endassignclk1x=clkdiv[3];always@(negedgeclk1xorposedgerst)if(rst)beginsdo=1'b1;tsre=1'b1;parity=1'b1;tsr=8'b0;endelsebeginif(no_bits_sent==4'b0001)begintsr=tbr;tsre=1'b0;endelseif(no_bits_sent==4'b0010)beginsdo=1'b0;endelseif((no_bits_sent=4'b0011)&&(no_bits_sent=4'b1010))begin/*MSBFirsttsr[7:1]=tsr[6:0];tsr[0]=1'b0;sdo=tsr[7];parity=parity^tsr[7];*//*LSBFirst*/tsr[6:0]=tsr[7:1];tsr[7]=1'b0;sdo=tsr[0];parity=parity^tsr[0];endelseif(no_bits_sent==4'b1011)beginsdo=parity;endelseif(no_bits_sent==4'b1100)beginsdo=1'b1;tsre=1'b1;endendalways@(posedgeclk1xorposedgerstornegedgeclk1x_enable)if(rst)no_bits_sent=4'b0000;elseif(!clk1x_enable)no_bits_sent=4'b0000;elseno_bits_sent=no_bits_sent+1;endmodule