OpenCores
URL https://opencores.org/ocsvn/versatile_library/versatile_library/trunk

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [versatile_library_altera.v] - Diff between revs 42 and 43

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 42 Rev 43
Line 608... Line 608...
output [width-1:0] dout;
output [width-1:0] dout;
vl_mux_andor
vl_mux_andor
    # ( .width(width), .nr_of_ports(nr_of_ports))
    # ( .width(width), .nr_of_ports(nr_of_ports))
    mux0( .a({a5,a4,a3,a2,a1,a0}), .sel(sel), .dout(dout));
    mux0( .a({a5,a4,a3,a2,a1,a0}), .sel(sel), .dout(dout));
endmodule
endmodule
 
module vl_parity_generate (data, parity);
 
parameter word_size = 32;
 
parameter chunk_size = 8;
 
parameter parity_type = 1'b0; // 0 - even, 1 - odd parity
 
input [word_size-1:0] data;
 
output reg [word_size/chunk_size-1:0] parity;
 
integer i,j;
 
always @ (data)
 
for (i=0;i<word_size/chunk_size;i=i+1) begin
 
    parity[i] = parity_type;
 
    for (j=0;j<chunk_size;j=j+1) begin
 
        parity[i] = data[i+j] ^ parity[i];
 
    end
 
end
 
endmodule
 
module vl_parity_check( data, parity, parity_error);
 
parameter word_size = 32;
 
parameter chunk_size = 8;
 
parameter parity_type = 1'b0; // 0 - even, 1 - odd parity
 
input [word_size-1:0] data;
 
input [word_size/chunk_size-1:0] parity;
 
output parity_error;
 
reg [chunk_size-1:0] error_flag;
 
integer i,j;
 
always @ (data or parity)
 
for (i=0;i<word_size/chunk_size;i=i+1) begin
 
    error_flag[i] = parity[i] ^ parity_type;
 
    for (j=0;j<chunk_size;j=j+1) begin
 
        error_flag[i] = data[i+j] ^ error_flag[i];
 
    end
 
end
 
assign parity_error = |error_flag;
 
endmodule
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  Versatile counter                                           ////
////  Versatile counter                                           ////
////                                                              ////
////                                                              ////
////  Description                                                 ////
////  Description                                                 ////

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.