2017-08-12 6 views
-1

Je viens juste de commencer à travailler avec CRC32.So quand je voulais vérifier le code que j'ai écrit et je reçois xxxxxx que les output.I ne suis pas sûr si le code est bon siCRC32 code ne fonctionne pas

module last_time(input [127:0]finalinput,output [31:0]crcout1 
    ,input clk); 


wire [31:0]poly; 
assign poly=32'h04c11db7; 
reg [7:0]lsb; 
reg [3:0]i; 
reg [7:0]ans; 
reg [31:0]nextcrc; 
reg [31:0]newcrc; 
reg [31:0]crcout; 
reg [7:0] lut [255:0]; 

[email protected](posedge clk) 
begin 
crcout=32'hffffffff; 
lsb=finalinput; 

for(i=0;i<16;i=i+1) 
    begin 
    ans=(8'hff^(lsb)); 
    newcrc = lut[ans]; 
    $readmemh("table.txt",lut); // to fill lut 
    nextcrc=(newcrc)^(crcout>>8); 
    lsb=lsb>>8; 
    end 
end 

assign crcout1=nextcrc^32'hffffffff; 
endmodule 
+0

s'il vous plaît, les espaces sont libres, utilisez-les dans l'exemple. – Serge

+0

D'accord, merci de me le faire savoir. – Ashley

+1

Pourquoi échantillonnez-vous 'lut' avant de lui attribuer une valeur? Pourquoi le chargez-vous 16 fois? – Greg

Répondre

0

Le problème était avec l'entrée de la table LUT, il devait s'agir d'un entier et non d'une valeur reg. La taille LUT n'était pas la bonne taille

module bit32(input [31:0]msg,input [31:0]crcinitial,output reg[31:0]tableout,output [23:0]crcshifted, 
output[31:0]newcrc,output reg [7:0]xor1); 
wire [7:0]msglsb; 

assign msglsb=msg; 
wire [7:0]crclsb; 
assign crclsb=crcinitial; 
integer k; 
reg [31:0]lut[0:255]; 

initial 
begin 
assign xor1=(crclsb^msglsb)&8'hff; 
assign k=xor1; 
assign tableout=lut[xor1]; 
$readmemh("table.txt",lut); 
end 

assign crcshifted=crcinitial>>8; 
assign newcrc=(tableout^crcshifted)^32'hffffffff; 
endmodule