Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] problem with code of hamming encoder and decoder

Status
Not open for further replies.

pooja_khubbar

Newbie level 6
Joined
Nov 25, 2010
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,389
--encoder
parameter n=11,k=7;
output [n-1:0] out;
input [k-1:0] in;
input reset;
reg [n-1:0] out;
integer i,j;
always @(in or reset)
begin
if(reset)
out = 0;
else
begin
i=0; j=0;
while((i<n) || (j<k))
begin
while(i==0 || i==1 || i==3 || i==7)
begin
out = 0;
i=i+1;
end
out = in[j];
i=i+1;
j=j+1;
end
if(^(out & 11?b101_0101_0101))
out[0] = ~out[0];
if(^(out & 11?b110_0110_0110))
out[1] = ~out[1];
if(^(out & 11?b000_0111_1000))
out[3] = ~out[3];
if(^(out & 11?b111_1000_0000))
out[7] = ~out[7];
end
end
endmodule


--decoder


parameter n=11,k=7;
output [k-1:0] out;
input [n-1:0] in;
input reset;
reg [k-1:0] out;
reg r1,r2,r4,r8;
reg [3:0] r;
reg [n-1:0] IN;
integer i,j;
always @(in or reset)
begin
if(reset)
out=0;
else
begin
r1 = ^(in & 11?b101_0101_0101);
r2 = ^(in & 11?b110_0110_0110);
r4 = ^(in & 11?b000_0111_1000);
r8 = ^(in & 11?b111_1000_0000);
r = {r8,r4,r2,r1};
IN = in;
IN[r-1] = ~IN[r-1];
i=0; j=0;
while((i<n) || (j<k))
begin
while(i==0 || i==1 || i==3 || i==7)
i=i+1;
out[j]=IN;
i=i+1;
j=j+1;
end
end
end
endmodule


am getting error while executing these codes but not able to point out mistakes..plz help
 

blooz

Advanced Member level 2
Joined
Dec 29, 2010
Messages
561
Helped
121
Reputation
242
Reaction score
116
Trophy points
1,343
Location
India
Activity points
4,989
Code:
			  //encoder	
			  module encode(out,in,reset);
parameter n=11,k=7;
output [n-1:0] out;
input [k-1:0] in;
input reset;
reg [n-1:0] out;
integer i,j;
always @(in or reset)
begin
if(reset)
out = 0;
else
begin
i=0; j=0;
while((i<n) || (j<k))
begin
while(i==0 || i==1 || i==3 || i==7)
begin
out[i] = 0;
i=i+1;
end
out[i] = in[j];
i=i+1;
j=j+1;
end
if(^(out & 11'b101_0101_0101))
out[0] = ~out[0];
if(^(out & 11'b110_0110_0110))
out[1] = ~out[1];
if(^(out & 11'b000_0111_1000))
out[3] = ~out[3];
if(^(out & 11'b111_1000_0000))
out[7] = ~out[7];
end
end
endmodule


//decoder
  module decoder(out,in,reset);

parameter n=11,k=7;
output [k-1:0] out;
input [n-1:0] in;
input reset;
reg [k-1:0] out;
reg r1,r2,r4,r8;
reg [3:0] r;
reg [n-1:0] IN;
integer i,j;
always @(in or reset)
begin
if(reset)
out=0;
else
begin
r1 = ^(in & 11'b101_0101_0101);
r2 = ^(in & 11'b110_0110_0110);
r4 = ^(in & 11'b000_0111_1000);
r8 = ^(in & 11'b111_1000_0000);
r = {r8,r4,r2,r1};
IN = in;
IN[r-1] = ~IN[r-1];
i=0; j=0;
while((i<n) || (j<k))
begin
while(i==0 || i==1 || i==3 || i==7)
i=i+1;
out[j]=IN[i];
i=i+1;
j=j+1;
end
end
end
endmodule


is this what you expected ?...
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top