/*
* Copyright (c) 2009-2023 Tony Bybell.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
/*
* possible disables:
*
* FST_DYNAMIC_ALIAS_DISABLE : dynamic aliases are not processed
* FST_DYNAMIC_ALIAS2_DISABLE : new encoding for dynamic aliases is not generated
* FST_WRITEX_DISABLE : fast write I/O routines are disabled
*
* possible enables:
*
* FST_DEBUG : not for production use, only enable for development
* FST_REMOVE_DUPLICATE_VC : glitch removal (has writer performance impact)
* HAVE_LIBPTHREAD -> FST_WRITER_PARALLEL : enables inclusion of parallel writer code
* FST_DO_MISALIGNED_OPS (defined automatically for x86 and some others) : CPU architecture can handle misaligned loads/stores
* _WAVE_HAVE_JUDY : use Judy arrays instead of Jenkins (undefine if LGPL is not acceptable)
*
*/
#ifndef FST_CONFIG_INCLUDE
# define FST_CONFIG_INCLUDE <config.h>
#endif
#include FST_CONFIG_INCLUDE
#include "fstapi.h"
#include "fastlz.h"
#include "lz4.h"
#include <errno.h>
#ifndef HAVE_LIBPTHREAD
#undef FST_WRITER_PARALLEL
#endif
#ifdef FST_WRITER_PARALLEL
#include <pthread.h>
#endif
#ifdef __MINGW32__
#include <windows.h>
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#elif defined(__GNUC__)
#ifndef __MINGW32__
#ifndef alloca
#define alloca __builtin_alloca
#endif
#else
#include <malloc.h>
#endif
#elif defined(_MSC_VER)
#include <malloc.h>
#define alloca _alloca
#endif
#ifndef PATH_MAX
#define PATH_MAX (4096)
#endif
#if defined(_MSC_VER)
typedef int64_t fst_off_t;
#else
typedef off_t fst_off_t;
#endif
/* note that Judy versus Jenkins requires more experimentation: they are */
/* functionally equivalent though it appears Jenkins is slightly faster. */
/* in addition, Jenkins is not bound by the LGPL. */
#ifdef _WAVE_HAVE_JUDY
#include <Judy.h>
#else
/* should be more than enough for fstWriterSetSourceStem() */
#define FST_PATH_HASHMASK ((1UL << 16) - 1)
typedef const void *Pcvoid_t;
typedef void *Pvoid_t;
typedef void **PPvoid_t;
#define JudyHSIns(a,b,c,d) JenkinsIns((a),(b),(c),(hashmask))
#define JudyHSFreeArray(a,b) JenkinsFree((a),(hashmask))
void JenkinsFree(void *base_i, uint32_t hashmask);
void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint32_t hashmask);
#endif
#ifndef FST_WRITEX_DISABLE
#define FST_WRITEX_MAX (64 * 1024)
#else
#define fstWritex(a,b,c) fstFwrite((b), (c), 1, fv)
#endif
/* these defines have a large impact on writer speed when a model has a */
/* huge number of symbols. as a default, use 128MB and increment when */
/* every 1M signals are defined. */
#define FST_BREAK_SIZE (1UL << 27)
#define FST_BREAK_ADD_SIZE (1UL << 22)
#define FST_BREAK_SIZE_MAX (1UL << 31)
#define FST_ACTIVATE_HUGE_BREAK (1000000)
#define FST_ACTIVATE_HUGE_INC (1000000)
#define FST_WRITER_STR "fstWriter"
#define FST_ID_NAM_SIZ (512)
#define FST_ID_NAM_ATTR_SIZ (65536+4096)
#define FST_DOUBLE_ENDTEST (2.7182818284590452354)
#define FST_HDR_SIM_VERSION_SIZE (128)
#define FST_HDR_DATE_SIZE (119)
#define FST_HDR_FILETYPE_SIZE (1)
#define FST_HDR_TIMEZERO_SIZE (8)
#define FST_GZIO_LEN (32768)
#define FST_HDR_FOURPACK_DUO_SIZE (4*1024*1024)
#if defined(__i386__) || defined(__x86_64__) || defined(_AIX)
#define FST_DO_MISALIGNED_OPS
#endif
#if defined(__APPLE__) && defined(__MACH__)
#define FST_MACOSX
#include <sys/sysctl.h>
#endif
#if defined(FST_MACOSX) || defined(__MINGW32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
#define FST_UNBUFFERED_IO
#endif
#ifdef __GNUC__
/* Boolean expression more often true than false */
#define FST_LIKELY(x) __builtin_expect(!!(x), 1)
/* Boolean expression more often false than true */
#define FST_UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define FST_LIKELY(x) (!!(x))
#define FST_UNLIKELY(x) (!!(x))
#endif
#define FST_APIMESS "FSTAPI | "
/***********************/
/*** ***/
/*** common function ***/
/*** ***/
/***********************/
#ifdef __MINGW32__
#include <io.h>
#ifndef HAVE_FSEEKO
#define ftello _ftelli64
#define fseeko _fseeki64
#endif
#endif
/*
* the recoded "extra" values...
* note that FST_RCV_Q is currently unused and is for future expansion.
* its intended use is as another level of escape such that any arbitrary
* value can be stored as the value: { time_delta, 8 bits, FST_RCV_Q }.
* this is currently not implemented so that the branchless decode is:
* uint32_t shcnt = 2 << (vli & 1); tdelta = vli >> shcnt;
*/
#define FST_RCV_X (1 | (0<<1))
#define FST_RCV_Z (1 | (1<<1))
#define FST_RCV_H (1 | (2<<1))
#define FST_RCV_U (1 | (3<<1))
#define FST_RCV_W (1 | (4<<1))
#define FST_RCV_L (1 | (5<<1))
#define FST_RCV_D (1 | (6<<1))
#define FST_RCV_Q (1 | (7<<1))
#define FST_RCV_STR "xzhuwl-?"
/* 01234567 */
/*
* prevent old file overwrite when currently being read
*/
static FILE *unlink_fopen(const char *nam, const char *mode)
{
unlink(nam);
return(fopen(nam, mode));
}
/*
* system-specific temp file handling
*/
#ifdef __MINGW32__
static FILE* tmpfile_open(char **nam)
{
char *fname = NULL;
TCHAR szTempFileName[MAX_PATH];
TCHAR lpTempPathBuffer[MAX_PATH];
DWORD dwRetVal = 0;
UINT uRetVal = 0;
FILE *fh = NULL;
if(nam) /* cppcheck warning fix: nam is always defined, so this is not needed */
{
dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
if((dwRetVal > MAX_PATH) || (dwRetVal == 0))
{
fprintf(stderr, FST_APIMESS "GetTempPath() failed in " __FILE__ " line %d, exiting.\n", __LINE__);
exit(255);
}
else
{
uRetVal = GetTempFileName(lpTempPathBuffer, TEXT("FSTW"), 0, szTempFileName);
if (uRetVal == 0)
{
fprintf(stderr, FST_APIMESS "GetTempFileName() failed in " __FILE__ " line %d, exiting.\n", __LINE__);
exit(255);
}
else
{
fname = strdup(szTempFileName);
}
}
if(fname)
{
*nam = fname;
fh = unlink_fopen(fname, "w+b");
}
}
return(fh);
}
#else
static FILE* tmpfile_open(char **nam)
{
FILE *f = tmpfile(); /* replace with mkstemp() + fopen(), etc if this is not good enough */
if(nam) { *nam = NULL; }
return(f);
}
#endif
static void tmpfile_close(FILE **f, char **nam)
{
if(f)
{
if(*f) { fclose(*f); *f = NULL; }
}
if(nam)
{
if(*nam)
{
unlink(*nam);
verilog windows环境配置(sublime+verilator+cygwin)
5星 · 超过95%的资源 需积分: 0 80 浏览量
更新于2023-01-12
收藏 16.64MB RAR 举报
在IC设计领域,Verilog是一种广泛使用的硬件描述语言(HDL),用于编写数字电子系统的模型。Windows环境下配置Verilog开发环境通常需要安装一系列工具,包括文本编辑器、编译器和模拟器。在这个配置过程中,Sublime Text是一个流行的代码编辑器,Verilator是开源的Verilog编译器,而Cygwin则为Windows提供类UNIX环境。下面将详细介绍如何在Windows环境下配置这个开发环境。
我们需要下载和安装`Sublime Text Build 3211 x64 Setup.exe`,这是一个高效、跨平台的文本编辑器,具有丰富的代码高亮、自动完成和多行选择等功能,特别适合编程工作。安装过程通常简单直观,只需按照向导指示操作即可。
接下来,安装`apt-cyg-master`,这是一款基于Cygwin的包管理工具,类似于Linux中的APT,用于方便地安装和管理Cygwin的软件包。解压下载的`apt-cyg-master`,然后在命令行中运行`install apt-cyg`脚本,按照提示完成安装。
现在,我们需要安装Cygwin,它是一个在Windows上模拟Linux环境的工具,允许我们在Windows上运行许多Linux命令。运行`setup-x86_64.exe`,在安装过程中确保选择“Devel”类别下的所有必需包,特别是`gcc`, `make`, `git` 和 `bash`等,这些都是编译和管理Verilator所需的。
安装完成后,通过Cygwin终端,我们可以使用`apt-cyg`来安装Verilator。在终端输入`apt-cyg install verilator`,等待安装结束。Verilator是一个开源的Verilog编译器,它可以将Verilog代码转化为C++,然后编译成可执行文件进行仿真。
安装好Verilator后,我们需要配置Sublime Text以支持Verilog。可以利用`Package Control`来安装插件,这是一个Sublime Text的插件管理器。访问`https://packagecontrol.io/installation`获取安装命令,然后在Sublime Text的命令面板中运行这个命令。接着,通过`Package Control: Install Package`命令找到并安装`Verilog/SystemVerilog`插件,该插件提供了语法高亮、代码片段等功能,提高Verilog编程体验。
配置Sublime Text的构建系统。打开`Tools` -> `Build System` -> `New Build System...`,输入以下配置:
```json
{
"cmd": ["bash", "-c", "cd ${file_path} && make"],
"file_regex": "^(.*\\.v):([0-9]+):(?:([0-9]+))?:? (.*)$",
"selector": "source.verilog",
"shell": true
}
```
保存为`Verilog.sublime-build`,这样Sublime Text就能识别Verilog文件并使用`make`命令进行编译和仿真了。
至此,一个基本的Verilog开发环境已经配置完成。在Sublime Text中编写Verilog代码,利用`Verilog/SystemVerilog`插件的辅助功能,然后通过`Ctrl+B`运行构建系统,即可在Cygwin环境中编译和运行Verilog程序。这样的配置为Windows用户提供了便利,使他们能够在熟悉的环境下进行Verilog的设计和验证工作。
丛林法则1943
- 粉丝: 13
- 资源: 1
最新资源
- 毕设和企业适用springboot企业知识管理平台类及在线音乐平台源码+论文+视频.zip
- 毕设和企业适用springboot企业知识管理平台类及智慧社区管理平台源码+论文+视频.zip
- 毕设和企业适用springboot人才招聘类及企业资源规划平台源码+论文+视频.zip
- 毕设和企业适用springboot人才招聘类及社区服务平台源码+论文+视频.zip
- 毕设和企业适用springboot人才招聘类及食品配送管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业资源规划类及AI数据标注平台源码+论文+视频.zip
- 毕设和企业适用springboot企业资源规划类及车载智能管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业资源规划类及大数据实时处理系统源码+论文+视频.zip
- 毕设和企业适用springboot人才招聘类及视频内容管理平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及网络营销平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及物流信息平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及销售管理平台源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及物流追踪系统源码+论文+视频.zip
- 毕设和企业适用springboot汽车管理类及消费品管理平台源码+论文+视频.zip
- 毕设和企业适用springboot企业资源规划类及个性化广告平台源码+论文+视频.zip
- 毕设和企业适用springboot企业资源规划类及教育评价系统源码+论文+视频.zip