2017-08-12 189 views
-1

我剛開始的時候我想檢查我寫的代碼與CRC32.So工作,我得到XXXXXX爲output.I我不知道如果代碼是正確的,雖然CRC32代碼不起作用

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

請,空格是免費的,在例子中使用它們。 – Serge

+0

好的,謝謝你讓我知道。 – Ashley

+1

爲什麼在給它一個值之前抽取'lut'?你爲什麼要加載它16次? – Greg

回答

0

問題在於輸入到LUT,它應該是一個整數而不是reg值。 LUT尺寸不是正確的尺寸

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