串行(chuan xing)是中文“通用串行總線”的簡稱。英文為USB(Universal Serial Bus)是1995年Microsoft、Compaq、IBM等公司聯合制定的一種新的PC串行通信協議。USB協議出臺后得到各PC廠商、芯片制造商和PC外設廠商的廣泛支持。USB本身也處于不斷的發展和完善中,從當初的0.7、0.8到現在廣泛采用的1.0、1.1,2.0版本以及已經被采用,即將被量產應用的3.0版本
串行數據與并行數據是相對的一對概念。串行數據是指傳輸過程中各數據位按順序進行傳輸的數據,并行數據則是各數據位同時傳送的數據。串行通信是指使用一條數據線,將數據一位一位地依次傳輸,每一位數據占據一個固定的時間長度。其只需要少數幾條線就可以在系統間交換信息,特別使用于計算機與計算機、計算機與外設之間的遠距離通信。
數據并行的含義是計算機內包含一組處理單元(PE),每一個處理單元存儲一個(或多個)數據元素。當機器執行順序程序時,可對應于全部或部分的內部處理單元所存的數據同時操作。
數據級并行依賴于并行處理機,它屬于SIMD系統內的并行。并行處理機的特點是重復設置許多個同樣的處理單元,按照一定的方式相互連接,在統一的控制部件作用下,各自對分配來的數據并行地完成同一指令規定的操作。
控制部件實際上是一臺高性能單處理機,它執行控制指令和只適用于串行處理的操作指令,而把適用于并行處理的指令傳送給所用的處理單元,但僅有那些處于“活動”狀態的處理單元才并行地對各自的數據進行同一操作。為了實現快速有效的數據處理,數據應在各處理單元之間合理分配與存儲,使各處理單元主要對自身存儲器內的數據進行運算。
串行數據轉換并行數據的原理圖
module UART_Receiver(
Serial_in,
istartofpacket,
iendofpacket,
clk,RSTn,
Data_Bus,
datavalid,
oempty,
oendofpacket,
ostartofpacket
);
parameterNum_counter_bits=4;
parameterNum_state_bits=3;
parameterword_deepth_size=7;
parameterdeepth_counter_size=3;
parameteridle=3‘b001;
parameterreceiving=3’b010;
parametersending=3‘b100;
output[word_size-1:0]Data_Bus;
output
oendofpacket,ostartofpacket;
oempty,datavalid,
inputSerial_in;inputclk;inputRSTn;
inputistartofpacket;inputiendofpacket;
reg[word_size-1:0]RCV_datareg[word_deepth_size -1:0];
reg[word_size-1:0]RCV_shftreg;
reg[Num_counter_bits-1:0]bit_count;
reg[deepth_counter_size-1:0] deepth_count1,deepth_count2;
reg[Num_state_bits-1:0]state,next_state;
reginc_bit_counter,clr_bit_counter;
regclr_deepth_counter1;
regclr_deepth_counter2;
regclr_deepth_counter2;regshift,load_datareg;regoutputstart,outputend;regsend_word;
regoendofpacket,ostartofpacket;regoempty;regdatavalid;
reg
[word_size-1:0]
Data_Bus;
clr_deepth_counter1=0;clr_deepth_counter2=0;clr_bit_counter=0;inc_bit_counter=0;shift=0;
load_datareg=0;outputstart = 0;outputend = 0;send_word =0;
next_state
=state;
if(istartofpacket==1)next_state=receiving;shift =1;begin
end
idle:
inc_bit_counter =1;shift = 1;begin
endif(bit_count != word_size-1)
clr_bit_counter =1;load_datareg =1;shift = 1;begin
endif(deepth_count1!=word_deepth_size-1)
load_datareg =1;clr_bit_counter =1;
clr_deepth_counter1 = 1;next_state = sending;begin
end
end
end
send_word = 1;outputstart = 1;begin
end
if(deepth_count2 == 0)
outputend = 1;send_word = 1;
clr_deepth_counter2 =1;next_state = idle;begin
endelse if(deepth_count2 == word_deepth_size-1)
send_word = 1;
else
sending:
next_state=idle;
default:
endcaseend
state《=idle;bit_count《=0;deepth_count1《=0;deepth_count2《=0;RCV_shftreg《=0;ostartofpacket 《= 0;oendofpacket 《= 0;Data_Bus 《= 0;begin
endif(RSTn == 0)
state《=next_state;oempty 《= 0;
bit_count《=0;
if(clr_bit_counter == 1)
bit_count《=bit_count + 1;
else if(inc_bit_counter == 1)
deepth_count1《=0;if(clr_deepth_counter1 == 1)deepth_count1《=deepth_count1 + 1;
else if(load_datareg == 1)
RCV_shftreg《={Serial_in,RCV_shftreg[word_size-1:1]};
if(shift == 1)
begin
else
begin
always @ (posedge clk)
RCV_datareg[deepth_count1] 《=RCV_shftreg;if(load_datareg == 1)
deepth_count2《=0;if(clr_deepth_counter2 == 1)
deepth_count2《=deepth_count2 + 1;else if(send_word == 1)
ostartofpacket 《= 1;if(outputstart ==1)
ostartofpacket 《= 0;
else
oendofpacket 《= 1;if(outputend == 1)
oendofpacket 《= 0;
else
Data_Bus 《= RCV_datareg[deepth_count2];datavalid 《= 1;begin
endif(send_word == 1)
Data_Bus 《= 0;datavalid 《= 0;begin
endelse
end
endendmodule
評論