Initial import
[litex.git] / verilog / lm32 / lm32_functions.v
1 // ==================================================================
2 // >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<
3 // ------------------------------------------------------------------
4 // Copyright (c) 2006-2011 by Lattice Semiconductor Corporation
5 // ALL RIGHTS RESERVED
6 // ------------------------------------------------------------------
7 //
8 // IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM.
9 //
10 // Permission:
11 //
12 // Lattice Semiconductor grants permission to use this code
13 // pursuant to the terms of the Lattice Semiconductor Corporation
14 // Open Source License Agreement.
15 //
16 // Disclaimer:
17 //
18 // Lattice Semiconductor provides no warranty regarding the use or
19 // functionality of this code. It is the user's responsibility to
20 // verify the user's design for consistency and functionality through
21 // the use of formal verification methods.
22 //
23 // --------------------------------------------------------------------
24 //
25 // Lattice Semiconductor Corporation
26 // 5555 NE Moore Court
27 // Hillsboro, OR 97214
28 // U.S.A
29 //
30 // TEL: 1-800-Lattice (USA and Canada)
31 // 503-286-8001 (other locations)
32 //
33 // web: http://www.latticesemi.com/
34 // email: techsupport@latticesemi.com
35 //
36 // --------------------------------------------------------------------
37 // FILE DETAILS
38 // Project : LatticeMico32
39 // File : lm32_functions.v
40 // Title : Common functions
41 // Version : 6.1.17
42 // : Initial Release
43 // Version : 7.0SP2, 3.0
44 // : No Change
45 // Version : 3.5
46 // : Added function to generate log-of-two that rounds-up to
47 // : power-of-two
48 // =============================================================================
49
50 function integer clogb2;
51 input [31:0] value;
52 begin
53 for (clogb2 = 0; value > 0; clogb2 = clogb2 + 1)
54 value = value >> 1;
55 end
56 endfunction
57
58 function integer clogb2_v1;
59 input [31:0] value;
60 reg [31:0] i;
61 reg [31:0] temp;
62 begin
63 temp = 0;
64 i = 0;
65 for (i = 0; temp < value; i = i + 1)
66 temp = 1<<i;
67 clogb2_v1 = i-1;
68 end
69 endfunction
70