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_functions.v
19 // Title : Common functions
20 // Version : 6.1.17
21 // : Initial Release
22 // Version : 7.0SP2, 3.0
23 // : No Change
24 // Version : 3.5
25 // : Added function to generate log-of-two that rounds-up to
26 // : power-of-two
27 // =============================================================================
29 function integer clogb2;
30 input [31:0] value;
31 begin
32 for (clogb2 = 0; value > 0; clogb2 = clogb2 + 1)
33 value = value >> 1;
34 end
35 endfunction
37 function integer clogb2_v1;
38 input [31:0] value;
39 reg [31:0] i;
40 reg [31:0] temp;
41 begin
42 temp = 0;
43 i = 0;
44 for (i = 0; temp < value; i = i + 1)
45 temp = 1<<i;
46 clogb2_v1 = i-1;
47 end
48 endfunction