Initial import
[litex.git] / verilog / lm32 / lm32_addsub.v
1 // ==================================================================
2 // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
3 // ------------------------------------------------------------------
4 // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation
5 // ALL RIGHTS RESERVED
6 // ------------------------------------------------------------------
7 //
8 // IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM.
9 //
10 // Permission:
11 //
12 // Lattice Semiconductor grants permission to use this code
13 // pursuant to the terms of the Lattice Semiconductor Corporation
14 // Open Source License Agreement.
15 //
16 // Disclaimer:
17 //
18 // Lattice Semiconductor provides no warranty regarding the use or
19 // functionality of this code. It is the user's responsibility to
20 // verify the user's design for consistency and functionality through
21 // the use of formal verification methods.
22 //
23 // --------------------------------------------------------------------
24 //
25 // Lattice Semiconductor Corporation
26 // 5555 NE Moore Court
27 // Hillsboro, OR 97214
28 // U.S.A
29 //
30 // TEL: 1-800-Lattice (USA and Canada)
31 // 503-286-8001 (other locations)
32 //
33 // web: http://www.latticesemi.com/
34 // email: techsupport@latticesemi.com
35 //
36 // --------------------------------------------------------------------
37 // FILE DETAILS
38 // Project : LatticeMico32
39 // File : lm32_addsub.v
40 // Title : PMI adder/subtractor.
41 // Version : 6.1.17
42 // : Initial Release
43 // Version : 7.0SP2, 3.0
44 // : No Change
45 // Version : 3.1
46 // : No Change
47 // =============================================================================
48
49 `include "lm32_include.v"
50
51 /////////////////////////////////////////////////////
52 // Module interface
53 /////////////////////////////////////////////////////
54
55 module lm32_addsub (
56 // ----- Inputs -------
57 DataA,
58 DataB,
59 Cin,
60 Add_Sub,
61 // ----- Outputs -------
62 Result,
63 Cout
64 );
65
66 /////////////////////////////////////////////////////
67 // Inputs
68 /////////////////////////////////////////////////////
69
70 input [31:0] DataA;
71 input [31:0] DataB;
72 input Cin;
73 input Add_Sub;
74
75 /////////////////////////////////////////////////////
76 // Outputs
77 /////////////////////////////////////////////////////
78
79 output [31:0] Result;
80 wire [31:0] Result;
81 output Cout;
82 wire Cout;
83
84 /////////////////////////////////////////////////////
85 // Instantiations
86 /////////////////////////////////////////////////////
87
88 // Modified for Milkymist: removed non-portable instantiated block
89 wire [32:0] tmp_addResult = DataA + DataB + Cin;
90 wire [32:0] tmp_subResult = DataA - DataB - !Cin;
91
92 assign Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0];
93 assign Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32];
94
95 endmodule