// Walsh N=256
// Designed by/ Warrior Group
// 
//
module walsh( clk, reset, sel, wout);
input clk, reset;
input [7:0]sel; //Walsh code select
output wout;//Walsh generator output

reg [7:0] cntreg;//Counter Register
reg [7:0] p ;//Intermediate Register
reg t; // these register are used to pipeline the EXOR section

always @ (negedge reset or posedge clk)
begin
if(!reset) 
begin
cntreg <= 8'b0; // initialize the counter register
// initialize all registers associated with this section.  
p[7:0] <= 8'b0;
t <= 1'b0; 
end
else
begin
cntreg <= cntreg + 8'b1;
p <= cntreg & sel ;
t <= p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4] ^ p[5] ^ p[6] ^ p[7]; 
end
end
// Final process to generate Walsh output
assign wout = t ; 
endmodule
