From 47baad4fe1c0468f06706f98eaa0738826e03eab Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Mon, 12 Nov 2012 19:36:13 +0100 Subject: [PATCH] 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 --- verilog/lm32/lm32_cpu.v | 2 - verilog/lm32/lm32_dcache.v | 8 ++-- verilog/lm32/lm32_debug.v | 2 - verilog/lm32/lm32_decoder.v | 2 - verilog/lm32/lm32_functions.v | 70 ---------------------------- verilog/lm32/lm32_icache.v | 8 ++-- verilog/lm32/lm32_instruction_unit.v | 20 ++++---- verilog/lm32/lm32_load_store_unit.v | 20 ++++---- verilog/lm32/lm32_top.v | 1 - 9 files changed, 24 insertions(+), 109 deletions(-) delete mode 100644 verilog/lm32/lm32_functions.v 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<