OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [PATLPP/] [checksum/] [checksum.v] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
// CHECKSUM - a checksum unit for the PATLPP processor
2
//
3
 
4
`timescale 1ns / 100ps
5
 
6
module checksum
7
(
8
        input           wire                            clk,
9
        input           wire                            rst,
10
 
11
        input           wire    [15:0]   data_in,
12
        input           wire                            checksum_add,
13
        input           wire                            checksum_clear,
14
 
15
        output  wire                            checksum_check,
16
        output  wire    [15:0]   checksum_out
17
);
18
 
19
wire    [16:0]   wide_res;
20
reg     [15:0]   result;
21
 
22
assign wide_res = result + data_in; // compute the addition w/carry
23
assign checksum_out = ~result; // compute the 1's compliment
24
assign checksum_check = (result == 0);
25
 
26
always @(posedge clk)
27
begin
28
        if (rst)
29
        begin
30
                result <= 0;
31
        end
32
        else if (checksum_clear)
33
        begin
34
                result <= 0;
35
        end
36
        else if (checksum_add)
37
        begin
38
                result <= wide_res[15:0] + { 15'd0, wide_res[16] }; // add carry to result
39
        end
40
end
41
 
42
endmodule

powered by: WebSVN 2.1.0

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