lm32_addsub.v

Sat, 06 Aug 2011 01:26:56 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Sat, 06 Aug 2011 01:26:56 +0100
changeset 27
d6c693415d59
parent 26
73de224304c1
permissions
-rwxr-xr-x

remove synthesis delay entities to ease merge

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