【正文】
n IF (clk39。event and clk=39。139。) then if clr=39。139。then re_clk=39。139。 count:=11。 elsif count=11 then count:=00。 re_clk=not re_clk。 else count:=count+1。 end if。 end if。 仿真波行如下: 圖 3 8分頻產(chǎn)生程序仿真波行圖 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能:對全局時鐘進(jìn)行不同倍數(shù)的分頻,獲得所需時鐘頻率,本程序是產(chǎn)生 32分頻。 3. 控制時鐘:全局時鐘或前級級聯(lián)引出時鐘。 library ieee。 use 。 use 。 entity decimator32 is port(clr,clk:in bit。 clk32:out bit)。 19 end decimator32。 architecture dec of decimator32 is signal re_clk :bit。 begin process(clk,clr) variable count:std_logic_vector(3 downto 0)。 begin IF (clk39。event and clk=39。139。) then if clr=39。139。then re_clk=39。139。 count:=1111。 elsif count=1111 then count:=0000。 re_clk=not re_clk。 else count:=count+1。 end if。 end if。 clk32=re_clk。 end process。 end dec。 仿真波行如下: 圖 4 32分頻產(chǎn)生 程序仿真波行圖 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能:信息碼延時,與 delaym2 共同完成原信息碼 mess 與輸出 remess 的同步比較 。 3. 控制時鐘:信息碼時鐘( 96分頻) 。 library ieee。 use 。 use 。 entity delaym1 is port(clk:in bit。 clr:in bit。 min:in bit_vector(3 downto 0)。 mout:out bit_vector(3 downto 0))。 end delaym1。 architecture cha of delaym1 is signal tempwal:bit_vector(3 downto 0)。 20 begin process(clk) begin if clr=39。139。 then tempwal=0000。 else if (clk39。event and clk=39。139。) then tempwal=min。 end if。 end if。 mout=tempwal。 end process。 end cha。 仿真波行如下: 圖 5 信息碼延時程序仿真波行圖 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能:信息碼延時,與 delaym1 共同完成原信息碼 mess 與輸出 remess 的同步比較 。 3. 控制時鐘: Walsh 碼時鐘( 24 分頻) 。 library ieee。 use 。 use 。 entity delaym2 is port(clk:in bit。 clr:in bit。 min:in bit_vector(3 downto 0)。 mout:out bit_vector(3 downto 0))。 end delaym2。 architecture cha of delaym2 is signal tempwal:bit_vector(3 downto 0)。 begin process(clk) begin if clr=39。139。 then tempwal=0000。 else if (clk39。event and clk=39。139。) then tempwal=min。 end if。 end if。 21 mout=tempwal。 end process。 end cha。 仿真波行如下: 圖 6 信息碼延時程序仿真波行圖 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能: PN碼延時,補(bǔ)償因并串變換帶來的 延時。 3. 控制時鐘: PN碼時鐘( 3 分頻)。 library ieee。 use 。 use 。 entity delaympn is port(clk:in bit。 clr:in bit。 pnin:in bit。 pnout:out bit)。 end delaympn。 architecture cha of delaympn is signal tempwal1,tempwal2:bit。 begin process(clk) begin if clr=39。139。 then tempwal1=39。039。tempwal2=39。039。 else if (clk39。event and clk=39。139。) then tempwal1=pnin。tempwal2=tempwal1。 end if。 end if。 pnout=tempwal2。 end process。 end cha。 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能: Walsh 碼延時,補(bǔ)償因并串變換帶來的延時。 22 3. 控制時鐘: PN碼時鐘( 3 分頻)。 library ieee。 use 。 use 。 entity delaymwal is port(clk:in bit。 clr:in bit。 walin:in bit_vector(3 downto 0)。 walout:out bit_vector(3 downto 0))。 end delaymwal。 architecture cha of delaymwal is signal tempwal1,tempwal2:bit_vector(3 downto 0)。 begin process(clk) begin if clr=39。139。 then tempwal2=1111。tempwal1=1111。 else if (clk39。event and clk=39。139。) then tempwal1=walin。tempwal2=tempwal1。 end if。 end if。 walout=tempwal2。 end process。 end cha。 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能: Walsh 碼時鐘延時,補(bǔ)償因并串變換帶來的延時 。 3. 控制時鐘: PN碼時鐘( 3 分頻) 。 library ieee。 use 。 use 。 entity delaymwal_clk is port(clk:in bit。 clr:in bit。 wal_clk_in:in bit。 wal_clk_out:out bit)。 end delaymwal_clk。 architecture cha of delaymwal_clk is signal tempwal1,tempwal2:bit。 begin process(clk) begin if clr=39。139。 then tempwal1=39。039。tempwal2=39。039。 23 else if (clk39。event and clk=39。139。) then tempwal1=wal_clk_in。tempwal2=tempwal1。 end if。 end if。 wal_clk_out=tempwal2。 end process。 end cha。 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能:基帶求和。 3. 控制時鐘:全局時鐘。 library ieee。 use 。 use 。 entity plus is port(clk:in bit。 clr:in bit。 mess:in bit_vector(3 downto 0)。 code:out bit_vector(2 downto 0))。 end plus。 architecture add of plus is begin process(clk,clr) begin if clr=39。139。 then code=000。 elsif (clk39。event and clk=39。139。) then if mess=0000 then code=000。 elsif mess=0001 then code=001。 elsif mess=0010 then code=001。 elsif mess=0100 then code=001。 elsif mess=1000 then code=001。 elsif mess=0011 then code=010。 elsif mess=0101 then code=010。 elsif mess=1001 then code=010。 elsif mess=0110 then code=010。 elsif mess=1010 then code=010。 elsif mess=1100 then code=010。 elsif mess=0111 then code=011。 elsif mess=1101 then code=011。 elsif mess=1110 then code=011。 elsif mess=1011 then code=011。 elsif mess=1111 then code=100。 end if。 24 end if。 end process。 end add。 仿真波行如下: 圖 7 基帶求 和程序仿真波行圖 1. CDMA 基帶收發(fā)系統(tǒng) —— 調(diào)制部分( modulator)。 2. 程序功能:并串轉(zhuǎn)換。 3. 控制時鐘:全局時鐘。 library ieee。 use 。 use 。 entity change is port(clk:in bit。 clr:in bit。 pcode:in bit_vector(2 downto 0)。 scode:out bit)。 end change。 architecture cha of change is begin process(clk) variable count,temp:std_logic_vector(1 downto 0):=00。 begin if (clk39。event and clk=39。139。) then if (clr=39。039。 and temp=00) then if count=10 then count:=00。scode=pcode(0)。 else count:=count+39。139。 if count=01 then scode=pcode(2)。 else scode=pcode(1)。 end if。 end if。 else if temp=10 then temp: