⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ecc_matrix_64bit.v

📁 本電子檔為 verilog cookbook,包含了通訊,影像,DSP等重要常用之verilog編碼,可作為工程師與初學者的參考手冊
💻 V
📖 第 1 页 / 共 2 页
字号:
// Copyright 2007 Altera Corporation. All rights reserved.  
// Altera products are protected under numerous U.S. and foreign patents, 
// maskwork rights, copyrights and other intellectual property laws.  
//
// This reference design file, and your use thereof, is subject to and governed
// by the terms and conditions of the applicable Altera Reference Design 
// License Agreement (either as signed by you or found at www.altera.com).  By
// using this reference design file, you indicate your acceptance of such terms
// and conditions between you and Altera Corporation.  In the event that you do
// not agree with such terms and conditions, you may not use the reference 
// design file and please promptly destroy any copies you have made.
//
// This reference design file is being provided on an "as-is" basis and as an 
// accommodation and therefore all warranties, representations or guarantees of 
// any kind (whether express, implied or statutory) including, without 
// limitation, warranties of merchantability, non-infringement, or fitness for
// a particular purpose, are specifically disclaimed.  By making this reference
// design file available, Altera expressly does not recommend, suggest or 
// require that this reference design file be used in combination with any 
// other product not provided by Altera.
/////////////////////////////////////////////////////////////////////////////

// baeckler - 08-25-2006 

//////////////////////////////////////////
// 64 bit to 72 bit ECC encoder
//////////////////////////////////////////

module ecc_encode_64bit (d,c);

input [63:0] d;
output [71:0] c;
wire [71:0] c;

  wire [5:0] help_c0;
  xor6 help_c0_0 (help_c0[0],d[0],d[1],d[3],d[4],d[6],d[8]);
  xor6 help_c0_1 (help_c0[1],d[10],d[11],d[13],d[15],d[17],d[19]);
  xor6 help_c0_2 (help_c0[2],d[21],d[23],d[25],d[26],d[28],d[30]);
  xor6 help_c0_3 (help_c0[3],d[32],d[34],d[36],d[38],d[40],d[42]);
  xor6 help_c0_4 (help_c0[4],d[44],d[46],d[48],d[50],d[52],d[54]);
  xor6 help_c0_5 (help_c0[5],d[56],d[57],d[59],d[61],d[63],1'b0);
  assign c[0] = ^help_c0;

  wire [5:0] help_c1;
  xor6 help_c1_0 (help_c1[0],d[0],d[2],d[3],d[5],d[6],d[9]);
  xor6 help_c1_1 (help_c1[1],d[10],d[12],d[13],d[16],d[17],d[20]);
  xor6 help_c1_2 (help_c1[2],d[21],d[24],d[25],d[27],d[28],d[31]);
  xor6 help_c1_3 (help_c1[3],d[32],d[35],d[36],d[39],d[40],d[43]);
  xor6 help_c1_4 (help_c1[4],d[44],d[47],d[48],d[51],d[52],d[55]);
  xor6 help_c1_5 (help_c1[5],d[56],d[58],d[59],d[62],d[63],1'b0);
  assign c[1] = ^help_c1;

  assign c[2] = d[0];
  wire [5:0] help_c3;
  xor6 help_c3_0 (help_c3[0],d[1],d[2],d[3],d[7],d[8],d[9]);
  xor6 help_c3_1 (help_c3[1],d[10],d[14],d[15],d[16],d[17],d[22]);
  xor6 help_c3_2 (help_c3[2],d[23],d[24],d[25],d[29],d[30],d[31]);
  xor6 help_c3_3 (help_c3[3],d[32],d[37],d[38],d[39],d[40],d[45]);
  xor6 help_c3_4 (help_c3[4],d[46],d[47],d[48],d[53],d[54],d[55]);
  xor6 help_c3_5 (help_c3[5],d[56],d[60],d[61],d[62],d[63],1'b0);
  assign c[3] = ^help_c3;

  assign c[4] = d[1];
  assign c[5] = d[2];
  assign c[6] = d[3];
  wire [5:0] help_c7;
  xor6 help_c7_0 (help_c7[0],d[4],d[5],d[6],d[7],d[8],d[9]);
  xor6 help_c7_1 (help_c7[1],d[10],d[18],d[19],d[20],d[21],d[22]);
  xor6 help_c7_2 (help_c7[2],d[23],d[24],d[25],d[33],d[34],d[35]);
  xor6 help_c7_3 (help_c7[3],d[36],d[37],d[38],d[39],d[40],d[49]);
  xor6 help_c7_4 (help_c7[4],d[50],d[51],d[52],d[53],d[54],d[55]);
  assign help_c7[5] = d[56];
  assign c[7] = ^help_c7;

  assign c[8] = d[4];
  assign c[9] = d[5];
  assign c[10] = d[6];
  assign c[11] = d[7];
  assign c[12] = d[8];
  assign c[13] = d[9];
  assign c[14] = d[10];
  wire [5:0] help_c15;
  xor6 help_c15_0 (help_c15[0],d[11],d[12],d[13],d[14],d[15],d[16]);
  xor6 help_c15_1 (help_c15[1],d[17],d[18],d[19],d[20],d[21],d[22]);
  xor6 help_c15_2 (help_c15[2],d[23],d[24],d[25],d[41],d[42],d[43]);
  xor6 help_c15_3 (help_c15[3],d[44],d[45],d[46],d[47],d[48],d[49]);
  xor6 help_c15_4 (help_c15[4],d[50],d[51],d[52],d[53],d[54],d[55]);
  assign help_c15[5] = d[56];
  assign c[15] = ^help_c15;

  assign c[16] = d[11];
  assign c[17] = d[12];
  assign c[18] = d[13];
  assign c[19] = d[14];
  assign c[20] = d[15];
  assign c[21] = d[16];
  assign c[22] = d[17];
  assign c[23] = d[18];
  assign c[24] = d[19];
  assign c[25] = d[20];
  assign c[26] = d[21];
  assign c[27] = d[22];
  assign c[28] = d[23];
  assign c[29] = d[24];
  assign c[30] = d[25];
  wire [5:0] help_c31;
  xor6 help_c31_0 (help_c31[0],d[26],d[27],d[28],d[29],d[30],d[31]);
  xor6 help_c31_1 (help_c31[1],d[32],d[33],d[34],d[35],d[36],d[37]);
  xor6 help_c31_2 (help_c31[2],d[38],d[39],d[40],d[41],d[42],d[43]);
  xor6 help_c31_3 (help_c31[3],d[44],d[45],d[46],d[47],d[48],d[49]);
  xor6 help_c31_4 (help_c31[4],d[50],d[51],d[52],d[53],d[54],d[55]);
  assign help_c31[5] = d[56];
  assign c[31] = ^help_c31;

  assign c[32] = d[26];
  assign c[33] = d[27];
  assign c[34] = d[28];
  assign c[35] = d[29];
  assign c[36] = d[30];
  assign c[37] = d[31];
  assign c[38] = d[32];
  assign c[39] = d[33];
  assign c[40] = d[34];
  assign c[41] = d[35];
  assign c[42] = d[36];
  assign c[43] = d[37];
  assign c[44] = d[38];
  assign c[45] = d[39];
  assign c[46] = d[40];
  assign c[47] = d[41];
  assign c[48] = d[42];
  assign c[49] = d[43];
  assign c[50] = d[44];
  assign c[51] = d[45];
  assign c[52] = d[46];
  assign c[53] = d[47];
  assign c[54] = d[48];
  assign c[55] = d[49];
  assign c[56] = d[50];
  assign c[57] = d[51];
  assign c[58] = d[52];
  assign c[59] = d[53];
  assign c[60] = d[54];
  assign c[61] = d[55];
  assign c[62] = d[56];
  wire [1:0] help_c63;
  xor6 help_c63_0 (help_c63[0],d[57],d[58],d[59],d[60],d[61],d[62]);
  assign help_c63[1] = d[63];
  assign c[63] = ^help_c63;

  assign c[64] = d[57];
  assign c[65] = d[58];
  assign c[66] = d[59];
  assign c[67] = d[60];
  assign c[68] = d[61];
  assign c[69] = d[62];
  assign c[70] = d[63];
  wire [5:0] help_c71;
  xor6 help_c71_0 (help_c71[0],d[0],d[1],d[2],d[4],d[5],d[7]);
  xor6 help_c71_1 (help_c71[1],d[10],d[11],d[12],d[14],d[17],d[18]);
  xor6 help_c71_2 (help_c71[2],d[21],d[23],d[24],d[26],d[27],d[29]);
  xor6 help_c71_3 (help_c71[3],d[32],d[33],d[36],d[38],d[39],d[41]);
  xor6 help_c71_4 (help_c71[4],d[44],d[46],d[47],d[50],d[51],d[53]);
  xor6 help_c71_5 (help_c71[5],d[56],d[57],d[58],d[60],d[63],1'b0);
  assign c[71] = ^help_c71;

endmodule

//////////////////////////////////////////
// compute a syndrome from the code word
//////////////////////////////////////////

module ecc_syndrome_64bit (clk,rst,c,s);

// optional register on the outputs
// of bits 0..6 and back one level in bit 7
parameter REGISTER = 0;

input clk,rst;
input [71:0] c;
output [7:0] s;
reg [7:0] s;

  // 36 terms
  wire [5:0] help_s0;
  xor6 help_s0_0 (help_s0[0],c[0],c[2],c[4],c[6],c[8],c[10]);
  xor6 help_s0_1 (help_s0[1],c[12],c[14],c[16],c[18],c[20],c[22]);
  xor6 help_s0_2 (help_s0[2],c[24],c[26],c[28],c[30],c[32],c[34]);
  xor6 help_s0_3 (help_s0[3],c[36],c[38],c[40],c[42],c[44],c[46]);
  xor6 help_s0_4 (help_s0[4],c[48],c[50],c[52],c[54],c[56],c[58]);
  xor6 help_s0_5 (help_s0[5],c[60],c[62],c[64],c[66],c[68],c[70]);
  generate
    if (REGISTER) begin
      always @(posedge clk or posedge rst) begin
        if (rst) s[0] <= 0;
        else s[0] <= ^help_s0;
      end
    end else begin
      always @(help_s0) begin
        s[0] = ^help_s0;
      end
    end
  endgenerate

  // 36 terms
  wire [5:0] help_s1;
  xor6 help_s1_0 (help_s1[0],c[1],c[2],c[5],c[6],c[9],c[10]);
  xor6 help_s1_1 (help_s1[1],c[13],c[14],c[17],c[18],c[21],c[22]);
  xor6 help_s1_2 (help_s1[2],c[25],c[26],c[29],c[30],c[33],c[34]);
  xor6 help_s1_3 (help_s1[3],c[37],c[38],c[41],c[42],c[45],c[46]);
  xor6 help_s1_4 (help_s1[4],c[49],c[50],c[53],c[54],c[57],c[58]);
  xor6 help_s1_5 (help_s1[5],c[61],c[62],c[65],c[66],c[69],c[70]);
  generate
    if (REGISTER) begin
      always @(posedge clk or posedge rst) begin
        if (rst) s[1] <= 0;
        else s[1] <= ^help_s1;
      end
    end else begin
      always @(help_s1) begin
        s[1] = ^help_s1;
      end
    end
  endgenerate

  // 36 terms
  wire [5:0] help_s2;
  xor6 help_s2_0 (help_s2[0],c[3],c[4],c[5],c[6],c[11],c[12]);
  xor6 help_s2_1 (help_s2[1],c[13],c[14],c[19],c[20],c[21],c[22]);
  xor6 help_s2_2 (help_s2[2],c[27],c[28],c[29],c[30],c[35],c[36]);
  xor6 help_s2_3 (help_s2[3],c[37],c[38],c[43],c[44],c[45],c[46]);
  xor6 help_s2_4 (help_s2[4],c[51],c[52],c[53],c[54],c[59],c[60]);
  xor6 help_s2_5 (help_s2[5],c[61],c[62],c[67],c[68],c[69],c[70]);
  generate
    if (REGISTER) begin
      always @(posedge clk or posedge rst) begin
        if (rst) s[2] <= 0;
        else s[2] <= ^help_s2;
      end
    end else begin
      always @(help_s2) begin
        s[2] = ^help_s2;
      end
    end
  endgenerate

  // 32 terms
  wire [5:0] help_s3;
  xor6 help_s3_0 (help_s3[0],c[7],c[8],c[9],c[10],c[11],c[12]);
  xor6 help_s3_1 (help_s3[1],c[13],c[14],c[23],c[24],c[25],c[26]);
  xor6 help_s3_2 (help_s3[2],c[27],c[28],c[29],c[30],c[39],c[40]);
  xor6 help_s3_3 (help_s3[3],c[41],c[42],c[43],c[44],c[45],c[46]);
  xor6 help_s3_4 (help_s3[4],c[55],c[56],c[57],c[58],c[59],c[60]);
  xor6 help_s3_5 (help_s3[5],c[61],c[62],1'b0,1'b0,1'b0,1'b0);
  generate
    if (REGISTER) begin
      always @(posedge clk or posedge rst) begin
        if (rst) s[3] <= 0;
        else s[3] <= ^help_s3;
      end
    end else begin
      always @(help_s3) begin
        s[3] = ^help_s3;
      end
    end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -