From: Michael Walle Date: Mon, 12 Nov 2012 18:36:13 +0000 (+0100) Subject: lm32: replace clogb2 by builtin $clog2 X-Git-Tag: 24jan2021_ls180~3081 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47baad4fe1c0468f06706f98eaa0738826e03eab;p=litex.git lm32: replace clogb2 by builtin $clog2 This function is fixed in ISE since version 14.1 (see AR #44586). If the builtin function is used, the design can be simulated with Icarus Verilog. Signed-off-by: Michael Walle --- diff --git a/verilog/lm32/lm32_cpu.v b/verilog/lm32/lm32_cpu.v index dc5be84c..ee0daf43 100644 --- a/verilog/lm32/lm32_cpu.v +++ b/verilog/lm32/lm32_cpu.v @@ -780,8 +780,6 @@ reg ext_break_r; // Functions ///////////////////////////////////////////////////// -`include "lm32_functions.v" - ///////////////////////////////////////////////////// // Instantiations ///////////////////////////////////////////////////// diff --git a/verilog/lm32/lm32_dcache.v b/verilog/lm32/lm32_dcache.v index 71e4c0bf..7b3799e3 100644 --- a/verilog/lm32/lm32_dcache.v +++ b/verilog/lm32/lm32_dcache.v @@ -112,14 +112,14 @@ parameter bytes_per_line = 16; // Number of bytes per c parameter base_address = 0; // Base address of cachable memory parameter limit = 0; // Limit (highest address) of cachable memory -localparam addr_offset_width = clogb2(bytes_per_line)-1-2; -localparam addr_set_width = clogb2(sets)-1; +localparam addr_offset_width = $clog2(bytes_per_line)-2; +localparam addr_set_width = $clog2(sets); localparam addr_offset_lsb = 2; localparam addr_offset_msb = (addr_offset_lsb+addr_offset_width-1); localparam addr_set_lsb = (addr_offset_msb+1); localparam addr_set_msb = (addr_set_lsb+addr_set_width-1); localparam addr_tag_lsb = (addr_set_msb+1); -localparam addr_tag_msb = clogb2(`CFG_DCACHE_LIMIT-`CFG_DCACHE_BASE_ADDRESS)-1; +localparam addr_tag_msb = $clog2(`CFG_DCACHE_LIMIT-`CFG_DCACHE_BASE_ADDRESS); localparam addr_tag_width = (addr_tag_msb-addr_tag_lsb+1); ///////////////////////////////////////////////////// @@ -200,8 +200,6 @@ genvar i, j; // Functions ///////////////////////////////////////////////////// -`include "lm32_functions.v" - ///////////////////////////////////////////////////// // Instantiations ///////////////////////////////////////////////////// diff --git a/verilog/lm32/lm32_debug.v b/verilog/lm32/lm32_debug.v index 90c8d20b..e7f73cb1 100644 --- a/verilog/lm32/lm32_debug.v +++ b/verilog/lm32/lm32_debug.v @@ -183,8 +183,6 @@ integer state; // State of single-step FSM // Functions ///////////////////////////////////////////////////// -`include "lm32_functions.v" - ///////////////////////////////////////////////////// // Combinational Logic ///////////////////////////////////////////////////// diff --git a/verilog/lm32/lm32_decoder.v b/verilog/lm32/lm32_decoder.v index eebe5c3e..be20c16e 100644 --- a/verilog/lm32/lm32_decoder.v +++ b/verilog/lm32/lm32_decoder.v @@ -333,8 +333,6 @@ wire select_call_immediate; // Whether to select the call im // Functions ///////////////////////////////////////////////////// -`include "lm32_functions.v" - ///////////////////////////////////////////////////// // Combinational logic ///////////////////////////////////////////////////// diff --git a/verilog/lm32/lm32_functions.v b/verilog/lm32/lm32_functions.v deleted file mode 100644 index 1332a6e5..00000000 --- a/verilog/lm32/lm32_functions.v +++ /dev/null @@ -1,70 +0,0 @@ -// ================================================================== -// >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< -// ------------------------------------------------------------------ -// Copyright (c) 2006-2011 by Lattice Semiconductor Corporation -// ALL RIGHTS RESERVED -// ------------------------------------------------------------------ -// -// IMPORTANT: THIS FILE IS AUTO-GENERATED BY THE LATTICEMICO SYSTEM. -// -// Permission: -// -// Lattice Semiconductor grants permission to use this code -// pursuant to the terms of the Lattice Semiconductor Corporation -// Open Source License Agreement. -// -// Disclaimer: -// -// Lattice Semiconductor provides no warranty regarding the use or -// functionality of this code. It is the user's responsibility to -// verify the user's design for consistency and functionality through -// the use of formal verification methods. -// -// -------------------------------------------------------------------- -// -// Lattice Semiconductor Corporation -// 5555 NE Moore Court -// Hillsboro, OR 97214 -// U.S.A -// -// TEL: 1-800-Lattice (USA and Canada) -// 503-286-8001 (other locations) -// -// web: http://www.latticesemi.com/ -// email: techsupport@latticesemi.com -// -// -------------------------------------------------------------------- -// FILE DETAILS -// Project : LatticeMico32 -// File : lm32_functions.v -// Title : Common functions -// Version : 6.1.17 -// : Initial Release -// Version : 7.0SP2, 3.0 -// : No Change -// Version : 3.5 -// : Added function to generate log-of-two that rounds-up to -// : power-of-two -// ============================================================================= - -function integer clogb2; -input [31:0] value; -begin - for (clogb2 = 0; value > 0; clogb2 = clogb2 + 1) - value = value >> 1; -end -endfunction - -function integer clogb2_v1; -input [31:0] value; -reg [31:0] i; -reg [31:0] temp; -begin - temp = 0; - i = 0; - for (i = 0; temp < value; i = i + 1) - temp = 1<