----------------------------------------------------------------------------- -- Author: Xiaofei Vivien Dong -- Course: ee552 -- Project: CDMA based communication systems ----------------------------------------------------------------------------- -- the musr_despeader decodes the frame data from scrambling. input bit rate -- 25/4MHz, output 25/32Mhz bps. ----------------------------------------------------------------------------- -- Total logic cells used: 15/1152 ( 1%) -- -- in transmitter, the bit '1' is mapped to x"0f", '0' is mapped to x"f0"; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library work; use work.CDMA_pkg.all; entity musr_despreader is generic ( code_width : positive := 8); port ( resetn : in std_logic; clock : in std_logic; -- shiftin_en shiftin_en : in std_logic; dataout_en : in std_logic; bitin : in std_logic; error_detected: out std_logic; bitout : out std_logic); end musr_despreader; architecture despreading of musr_despreader is signal framedata : std_logic_vector(7 downto 0); constant scramble_code : std_logic_vector(7 downto 0) := x"0f"; constant not_scramble_code : std_logic_vector(7 downto 0) := x"f0"; signal data : std_logic; begin -- despreader collect8bit : s2preg generic map ( width => code_width) port map ( resetn => resetn, clock => clock, enable => shiftin_en, bitin => bitin, frameout => framedata); with framedata select data <= '1' when scramble_code, '0' when others; with framedata select error_detected <= '0' when scramble_code, '0' when not_scramble_code, '1' when others; -- comparing: process -- begin -- if framedata = scramble_code then -- data <= '1'; -- error_detected <= '0'; -- elsif framedata = not_scramble_code then -- data <= '0'; -- error_detected <= '0'; -- else -- error_detected <= '1'; -- end if; -- end process; latchout : dff_en port map ( resetn => resetn, clock => clock, enable => dataout_en, d => data, q => bitout); end despreading;