// Long PN Code generator for a UMTS uplink channel
// 
// Designed by/ Warrior Group
//  (Y)
module pn_code_up(out_data, clk, reset) ;
input clk, reset ;
output out_data ;

reg [24:0] tmp_pn1, tmp_pn2 ;//Internal pn registers
reg a,b ;//Internal feedback from the Xors of pn1 and pn2
reg pn_out ;//Intermediate output register

always @(posedge clk)
begin
if (!reset)
//initialize all registers associated with this section
  begin
  tmp_pn1 <= 25'b1 ;
  tmp_pn2 <= 25'b1 ;
  pn_out <= 1'b0 ;
  a <= 1'b0 ; b <= 1'b0 ;
  end
else
begin
  a <= tmp_pn1[0] ^ tmp_pn1[3] ;
  b <= tmp_pn2[0] ^ tmp_pn2[1] ^ tmp_pn2[2] ^ tmp_pn2[3] ;
  
  tmp_pn1 <= { a, tmp_pn1[24:1] };
  tmp_pn2 <= { b, tmp_pn2[24:1] };
  
  pn_out <= tmp_pn1[0] ^ tmp_pn2[0] ;
end 
end

assign out_data = pn_out ;

endmodule