lm32_addsub.v

Sun, 06 Mar 2011 19:48:34 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Sun, 06 Mar 2011 19:48:34 +0000
changeset 16
5fb37de64edc
parent 2
a61bb364ae1f
permissions
-rwxr-xr-x

Add JTAG interface for Xilinx Spartan 6 (Michael Walle)

Original-Source: Milkymist mailing list posting, 2010-09-23
Original-Message-Id: <201009232334.04219.michael@walle.cc>
Original-Author: Michael Walle <michael walle.cc>

     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 // Only use Lattice specific constructs when compiling with ispLEVER
    68 `ifdef PLATFORM_LATTICE
    69        generate
    70 	  if (`LATTICE_FAMILY == "SC" || `LATTICE_FAMILY == "SCM") begin
    71 `endif
    72 	     wire [32:0] tmp_addResult = DataA + DataB + Cin;
    73 	     wire [32:0] tmp_subResult = DataA - DataB - !Cin;   
    75 	     assign  Result = (Add_Sub == 1) ? tmp_addResult[31:0] : tmp_subResult[31:0];
    76 	     assign  Cout = (Add_Sub == 1) ? tmp_addResult[32] : !tmp_subResult[32];
    77 `ifdef PLATFORM_LATTICE
    78 	  end else begin
    79 	    pmi_addsub #(// ----- Parameters -------
    80 			 .pmi_data_width     (32),
    81 			 .pmi_result_width   (32),
    82 			 .pmi_sign           ("off"),
    83 			 .pmi_family         (`LATTICE_FAMILY),
    84 			 .module_type        ("pmi_addsub")) 
    85 	      addsub    (// ----- Inputs -------
    86 			 .DataA              (DataA),
    87 			 .DataB              (DataB),
    88 			 .Cin                (Cin),
    89 			 .Add_Sub            (Add_Sub),
    90 			 // ----- Outputs -------
    91 			 .Result             (Result),
    92 			 .Cout               (Cout),
    93 			 .Overflow           ());
    94 	  end
    95        endgenerate 
    96 `endif
    98 endmodule