URL
https://opencores.org/ocsvn/klc32/klc32/trunk
[/] [klc32/] [trunk/] [rtl/] [verilog/] [carry.v] - Blame information for rev 11
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
5 |
robfinch |
/* ============================================================================
|
2 |
|
|
(C) 2005-2007 Robert T Finch
|
3 |
|
|
All rights reserved.
|
4 |
|
|
rob@birdcomputer.ca
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
carry.v
|
8 |
|
|
|
9 |
|
|
Verilog 1995
|
10 |
|
|
|
11 |
|
|
You may use this source code for non-commercial or evaluation purposes,
|
12 |
|
|
provided this copyright statement and disclaimer remains present in the
|
13 |
|
|
file.
|
14 |
|
|
|
15 |
|
|
NO WARRANTY.
|
16 |
|
|
THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER
|
17 |
|
|
EXPRESS OR IMPLIED. The user must assume the entire risk of using the
|
18 |
|
|
Work.
|
19 |
|
|
|
20 |
|
|
IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
|
21 |
|
|
INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO
|
22 |
|
|
THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR.
|
23 |
|
|
|
24 |
|
|
IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK
|
25 |
|
|
IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN
|
26 |
|
|
REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN
|
27 |
|
|
LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU
|
28 |
|
|
AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR
|
29 |
|
|
LOSSES RELATING TO SUCH UNAUTHORIZED USE.
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
This module computes carry for add/subtract given two operands and the
|
33 |
|
|
result. Assuming we don't know what the carry input is and there may
|
34 |
|
|
have been one.
|
35 |
|
|
============================================================================ */
|
36 |
|
|
|
37 |
|
|
module carry(op, a, b, s, c);
|
38 |
|
|
|
39 |
|
|
input op; // 0=add,1=sub
|
40 |
|
|
input a;
|
41 |
|
|
input b;
|
42 |
|
|
input s; // sum
|
43 |
|
|
output c;
|
44 |
|
|
|
45 |
|
|
assign c = op? (~a&b)|(s&~a)|(s&b) : (a&b)|(a&~s)|(b&~s);
|
46 |
|
|
|
47 |
|
|
endmodule
|
48 |
|
|
|
49 |
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.