Sun, 04 Apr 2010 20:40:03 +0100
add lm32 source
1 // =============================================================================
2 // COPYRIGHT NOTICE
3 // Copyright 2006 (c) Lattice Semiconductor Corporation
4 // ALL RIGHTS RESERVED
5 // This confidential and proprietary software may be used only as authorised by
6 // a licensing agreement from Lattice Semiconductor Corporation.
7 // The entire notice above must be reproduced on all authorized copies and
8 // copies may only be made to the extent permitted by a licensing agreement from
9 // Lattice Semiconductor Corporation.
10 //
11 // Lattice Semiconductor Corporation TEL : 1-800-Lattice (USA and Canada)
12 // 5555 NE Moore Court 408-826-6000 (other locations)
13 // Hillsboro, OR 97124 web : http://www.latticesemi.com/
14 // U.S.A email: techsupport@latticesemi.com
15 // =============================================================================/
16 // FILE DETAILS
17 // Project : LatticeMico32
18 // File : lm32_addsub.v
19 // Title : PMI adder/subtractor.
20 // Version : 6.1.17
21 // : Initial Release
22 // Version : 7.0SP2, 3.0
23 // : No Change
24 // Version : 3.1
25 // : No Change
26 // =============================================================================
28 `include "lm32_include.v"
30 /////////////////////////////////////////////////////
31 // Module interface
32 /////////////////////////////////////////////////////
34 module lm32_addsub (
35 // ----- Inputs -------
36 DataA,
37 DataB,
38 Cin,
39 Add_Sub,
40 // ----- Outputs -------
41 Result,
42 Cout
43 );
45 /////////////////////////////////////////////////////
46 // Inputs
47 /////////////////////////////////////////////////////
49 input [31:0] DataA;
50 input [31:0] DataB;
51 input Cin;
52 input Add_Sub;
54 /////////////////////////////////////////////////////
55 // Outputs
56 /////////////////////////////////////////////////////
58 output [31:0] Result;
59 wire [31:0] Result;
60 output Cout;
61 wire Cout;
63 /////////////////////////////////////////////////////
64 // Instantiations
65 /////////////////////////////////////////////////////
67 generate
68 if (`LATTICE_FAMILY == "SC" || `LATTICE_FAMILY == "SCM") begin
69 wire [32:0] tmp_addResult = DataA + DataB + Cin;
70 wire [32:0] tmp_subResult = DataA - DataB - !Cin;
72 assign Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0];
73 assign Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32];
74 end else begin
75 pmi_addsub #(// ----- Parameters -------
76 .pmi_data_width (32),
77 .pmi_result_width (32),
78 .pmi_sign ("off"),
79 .pmi_family (`LATTICE_FAMILY),
80 .module_type ("pmi_addsub"))
81 addsub (// ----- Inputs -------
82 .DataA (DataA),
83 .DataB (DataB),
84 .Cin (Cin),
85 .Add_Sub (Add_Sub),
86 // ----- Outputs -------
87 .Result (Result),
88 .Cout (Cout),
89 .Overflow ());
90 end
91 endgenerate
93 endmodule