1.1 diff -r 000000000000 -r cd0b58aa6f83 lm32_addsub.v 1.2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 +++ b/lm32_addsub.v Sun Apr 04 20:40:03 2010 +0100 1.4 @@ -0,0 +1,93 @@ 1.5 +// ============================================================================= 1.6 +// COPYRIGHT NOTICE 1.7 +// Copyright 2006 (c) Lattice Semiconductor Corporation 1.8 +// ALL RIGHTS RESERVED 1.9 +// This confidential and proprietary software may be used only as authorised by 1.10 +// a licensing agreement from Lattice Semiconductor Corporation. 1.11 +// The entire notice above must be reproduced on all authorized copies and 1.12 +// copies may only be made to the extent permitted by a licensing agreement from 1.13 +// Lattice Semiconductor Corporation. 1.14 +// 1.15 +// Lattice Semiconductor Corporation TEL : 1-800-Lattice (USA and Canada) 1.16 +// 5555 NE Moore Court 408-826-6000 (other locations) 1.17 +// Hillsboro, OR 97124 web : http://www.latticesemi.com/ 1.18 +// U.S.A email: techsupport@latticesemi.com 1.19 +// =============================================================================/ 1.20 +// FILE DETAILS 1.21 +// Project : LatticeMico32 1.22 +// File : lm32_addsub.v 1.23 +// Title : PMI adder/subtractor. 1.24 +// Version : 6.1.17 1.25 +// : Initial Release 1.26 +// Version : 7.0SP2, 3.0 1.27 +// : No Change 1.28 +// Version : 3.1 1.29 +// : No Change 1.30 +// ============================================================================= 1.31 + 1.32 +`include "lm32_include.v" 1.33 + 1.34 +///////////////////////////////////////////////////// 1.35 +// Module interface 1.36 +///////////////////////////////////////////////////// 1.37 + 1.38 +module lm32_addsub ( 1.39 + // ----- Inputs ------- 1.40 + DataA, 1.41 + DataB, 1.42 + Cin, 1.43 + Add_Sub, 1.44 + // ----- Outputs ------- 1.45 + Result, 1.46 + Cout 1.47 + ); 1.48 + 1.49 +///////////////////////////////////////////////////// 1.50 +// Inputs 1.51 +///////////////////////////////////////////////////// 1.52 + 1.53 +input [31:0] DataA; 1.54 +input [31:0] DataB; 1.55 +input Cin; 1.56 +input Add_Sub; 1.57 + 1.58 +///////////////////////////////////////////////////// 1.59 +// Outputs 1.60 +///////////////////////////////////////////////////// 1.61 + 1.62 +output [31:0] Result; 1.63 +wire [31:0] Result; 1.64 +output Cout; 1.65 +wire Cout; 1.66 + 1.67 +///////////////////////////////////////////////////// 1.68 +// Instantiations 1.69 +///////////////////////////////////////////////////// 1.70 + 1.71 + generate 1.72 + if (`LATTICE_FAMILY == "SC" || `LATTICE_FAMILY == "SCM") begin 1.73 + wire [32:0] tmp_addResult = DataA + DataB + Cin; 1.74 + wire [32:0] tmp_subResult = DataA - DataB - !Cin; 1.75 + 1.76 + assign Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0]; 1.77 + assign Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32]; 1.78 + end else begin 1.79 + pmi_addsub #(// ----- Parameters ------- 1.80 + .pmi_data_width (32), 1.81 + .pmi_result_width (32), 1.82 + .pmi_sign ("off"), 1.83 + .pmi_family (`LATTICE_FAMILY), 1.84 + .module_type ("pmi_addsub")) 1.85 + addsub (// ----- Inputs ------- 1.86 + .DataA (DataA), 1.87 + .DataB (DataB), 1.88 + .Cin (Cin), 1.89 + .Add_Sub (Add_Sub), 1.90 + // ----- Outputs ------- 1.91 + .Result (Result), 1.92 + .Cout (Cout), 1.93 + .Overflow ()); 1.94 + end 1.95 + endgenerate 1.96 + 1.97 +endmodule