如何在带有ghdl的Mac上编译并运行VHDL程序? [英] How do I compile and run a VHDL program on Mac with ghdl?

查看:215
本文介绍了如何在带有ghdl的Mac上编译并运行VHDL程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚编写了一个简单的VHDL程序.我将文件另存为.vhd文件.然后我用

i just wrote a simple VHDL program. I saved the file as a .vhd file. Then I compiled it with

ghdl -a test.vhd

,然后使用

ghdl -e test

最后尝试使用

ghdl -r test

发生的事情是,我现在有一个可见的work-obj93.cf文件和另外两个以某种方式不可见的文件,即....

What happened is that I now have a work-obj93.cf file that is visible and two other files, namely .. and . that are somehow invisible.

有人可以告诉我如何在Mac上测试vhdl程序吗?也许与GTKWave结合使用.

Can someone tell how exactly I can test a vhdl program on my Mac? Maybe in in combination with GTKWave.

推荐答案

正如他们所说的,这是一个很大的问题!

That as they say is a big ask!

可以在 ghdl中获得在Intel处理器上运行的ghdl版本的OS X,版本为10.5、10.6、10.7和10.8. .free.fr (可以从用于Mac的GHDL中下载OS X ).它是mcode版本(例如Windows上的版本),这意味着它不会生成目标代码或VHDL模型的独立可执行文件,从而导致您无法将异物(子程序)绑定到该模型.

There's a version of ghdl for OS X running on Intel processors for versions 10.5, 10.6,10.7 and 10.8 available from ghdl.free.fr (can be downloaded at GHDL for Mac OS X). It's the mcode version (like on Windows), which means it doesn't produce object codes or a standalone executable of a VHDL model with the consequence you can't bind foreign objects (subprograms) to the model.

详细模型仅在运行时存在于内存中,并且-e elaborate命令是多余的,除了工作库.cf文件中的条目外.在ghdl的mcode版本中,-r run命令也会详细说明.您将看到的只是工作目录的work-obj93.cf文件和预分析库的任何.cf文件,默认情况下,这些文件将显示在/usr/local/ghdl/libraries中,该可执行文件位于usr/local/ghdl/libraries中./usr/local/bin链接到/usr/local/ghdl/translate/ghdldrv/ghdl_mcode,而/usr/local/ghdl是由ghdl_mcode版本的编译产生的精简树.

The elaborated model only exists in memory at run time and the -e elaborate command is superfluous other than an entry in the working library .cf file. In an mcode version of ghdl the -r run command also elaborates. All you are going to see is the work-obj93.cf file for the working directory and any .cf files for pre-analyzed libraries, by default these will show up in /usr/local/ghdl/libraries, the executable ghdl found in /usr/local/bin links to /usr/local/ghdl/translate/ghdldrv/ghdl_mcode, and /usr/local/ghdl is a stripped down tree resulting from the compilation of the ghdl_mcode version.

此版本衍生自svn129(遵循ghdl-0.29版本),并且包含i386二进制文件.

This version is derived from svn129 (following the ghdl-0.29 release), and contains an i386 binary.

ghdl的文档位于/usr/local/ghdl/doc/中,其中有ghdl手册页链接到其他地方,ghdl.html和ghdl.texi是ghdl手册,没有链接到其他地方.在ghdl.html中,您可以搜索每次出现的"Windows",以找到对mcode版本的引用.出于疏忽大意,我不认为要修改ghdl手册,以便在Windows出现的任何地方都包括mcode一词,并发布经过修改的手册.

The documentation for ghdl is found in /usr/local/ghdl/doc/, there's the ghdl man page which is linked elsewhere, ghdl.html and ghdl.texi which are the ghdl manual and not linked elsewhere. In ghdl.html you could search for every occurrence of 'Windows' to find reference to the mcode version. As an oversight I didn't think to amend the ghdl manual to include the word mcode wherever Windows appeared and release modified manual.

凡出现"Windows"的地方,应将其读作"Windows或其他mcode版本".

Where ever 'Windows' appears it should be read as 'Windows or other mcode version'.

在ghdl手册中,请参见1.3什么是GHDL?(GHDL的Windows™版本不是基于GCC,而是基于内部代码生成器).还有2.1 hello world程序:

In the ghdl manual see 1.3 What is GHDL?, (The Windows(TM) version of GHDL is not based on GCC but on an internal code generator). Also 2.1 The hello world program:

2.1 The hello world program

为说明VHDL的主要目的,下面是一个受评论的VHDL"Hello world"程序.

To illustrate the large purpose of VHDL, here is a commented VHDL "Hello world" program.

 --  Hello world program.
 use std.textio.all; --  Imports the standard textio package.

 --  Defines a design entity, without any ports.
 entity hello_world is
 end hello_world;

 architecture behaviour of hello_world is
 begin
    process
       variable l : line;
    begin
       write (l, String'("Hello world!"));
       writeline (output, l);
       wait;
    end process;
 end behaviour;

假定此程序包含在文件hello.vhdl中.首先,您必须编译该文件;这被称为用VHDL术语分析设计文件.

Suppose this program is contained in the file hello.vhdl. First, you have to compile the file; this is called analysis of a design file in VHDL terms.

 $ ghdl -a hello.vhdl

此命令创建或更新文件work-obj93.cf,该文件描述了库"work".在GNU/Linux上,此命令生成一个文件hello.o,这是与您的VHDL程序相对应的目标文件.该目标文件不是在Windows上创建的.

This command creates or updates a file work-obj93.cf, which describes the library ‘work’. On GNU/Linux, this command generates a file hello.o, which is the object file corresponding to your VHDL program. The object file is not created on Windows.

然后,您必须构建一个可执行文件.

Then, you have to build an executable file.

 $ ghdl -e hello_world

-e"选项表示详尽. GHDL使用此选项创建代码以完善设计,并在层次结构的顶部放置"hello"实体.

The ‘-e’ option means elaborate. With this option, GHDL creates code in order to elaborate a design, with the ‘hello’ entity at the top of the hierarchy.

在GNU/Linux上,结果是一个名为hello的可执行程序,可以运行:

On GNU/Linux, the result is an executable program called hello which can be run:

 $ ghdl -r hello_world

或直接:

 $ ./hello_world

在Windows上,未创建任何文件.使用以下命令启动仿真:

On Windows, no file is created. The simulation is launched using this command:

 > ghdl -r hello_world

模拟结果出现在屏幕上:

The result of the simulation appears on the screen:

 Hello world!

将hello_world命令的源代码保存到文件hello.vhdl并执行以下命令:

Saving the source code for the hello_world command to the file hello.vhdl and executing the commands:

david_koontz @ Macbook:ghdl -a hello.vhdl

david_koontz@Macbook: ghdl -a hello.vhdl

david_koontz @ Macbook:ghdl -e hello_world

david_koontz@Macbook: ghdl -e hello_world

david_koontz @ Macbook:ghdl -r hello_world

david_koontz@Macbook: ghdl -r hello_world

收益:

世界你好!

在标准输出(终端窗口中的TTY会话)上.

on standard output (the TTY session in your terminal window).

您最终将在当前工作目录中获得一个work-obj93.cf库配置文件,而没有其他输出文件.您还需要了解-r run命令的含义(第3.1.3节),并且在命令行上没有传递可选的辅助单元,VHDL默认使用最新的编译体系结构.

You'll end up with a work-obj93.cf library configuration file in the current working directory and no other output files. You'll also want to understand the implications of the -r run command (section 3.1.3), with no optional secondary unit passed on the command line VHDL defaults to the last compiled architecture.

获得Tony Bybell的 gtkwave

Obtaining Tony Bybell's gtkwave gtkwave.app, the documentation is found in /Applications/gtkwave.app/Contents/Resources/doc, both a source .odt file and a PDF file. (You can select an application in the Applications folder and 'Show Package Contents' to navigate to the doc directory).

ghdl特有一种名为ghw的波形格式,可以使用运行命令选项'--wave = .ghw'进行调用.请参见ghdl手册4.1仿真选项.如果您选择改用VCD,也请参见该目录中的vcd选项.

There's a waveform format unique to ghdl called ghw, which can be invoked with the run command option '--wave=.ghw'. See ghdl manual 4.1 Simulation options. Also see the vcd options in that directory should you choose to use VCD instead.

如果您的测试台提供免费的运行时钟,您还应该使用保护计时器来限制运行时间. VHDL仅在没有更多调度信号更新或执行时间超时时才停止执行.这是一个"--stop-time = 587200ns"的运行命令选项.

You should also limit the run time duration with a guard timer should your test bench provide a free running clock. VHDL will only stop executing when either ther are no more scheduled signal updates or execution time maxes out. This is a run command option along the lines of '--stop-time=587200ns'.

OS X gtkwave.app对扩展名为.ghw和.gtkw的两种文件类型敏感,第一种是ghdl波形转储文件,第二种gtkwave的配置文件带有OS X后缀,可通过单击gtkw来调用gtkwave文件.在gtkwave中设置波形显示后,必须先保存配置文件,然后再保存.请参阅gtkwave手册.可以单击ghw文件,并且gtkwave具有一组用于搜索适用的gtkw文件的规则.

The OS X gtkwave.app is sensitive to two file types with extensions .ghw and .gtkw, the first the ghdl waveform dump file, the second gtkwave's configuration file with an OS X suffix allowing invocation of gtkwave by clicking on the gtkw file. The configuration file has to be saved after setting up your wave form display in gtkwave before it exists. See the gtkwave manual. A ghw file can be clicked on and gtkwave has a set of rules used to search for the applicable gtkw file.

使用ghw文件格式有很多优点.通过单击文件自动调用gtkwave应用程序是一种.另一个是ghdl将所有信号交易保存到其ghw转储文件中.您始终可以在gtkwave中选择更多以显示更多信息.尽管在大型模型中这可能是一个缺点,但是ghw格式允许任何类型或子类型的枚举文字显示.

There are a couple of advantages to using the ghw file format. The automatic invocation of the gtkwave app by clicking on files is one. Another is that ghdl saves all signal transactions to it's ghw dump file. You can always select more in gtkwave to display more information. While this can be a disadvantage in large models the ghw format allows any type or subtype enumeration literal display.

加入 GHDL讨论列表并发布问题是一种吸引人的好方法ghdl的专业知识. (是的,gna.org的证书已过期或无效).托尼·贝尔(Tony Bybell)在gtkwave网页上提供了电子邮件联系人,但由于有薪工作的紧急情况,他的空缺受到限制.

Joining the GHDL discuss list and posting a question is a good way to attract ghdl expertise attention. (And yes the certificate for gna.org is expired or otherwise invalid). Tony Bybell provides an email contact on the gtkwave web page but exigencies of paid employment limit his availability.

举例说明ghdl和gtkwave的使用.

原始张贴者要求提供一些带有命令行值的真实示例. GHDL/GTKWave指南(PDF,234 KB),其中包含示例和使用过的VCD.

The original poster asked for some real examples with command line values. There's a however poor GHDL/GTKWave Tutorial (PDF, 234 KB) that contains an example and used VCD.

我将列出GHDL波形格式版本的命令行:

I'll list the command lines for a GHDL Waveform format version:

david_koontz @ Macbook:ghdl -a CarryRipple.vhd

david_koontz@Macbook: ghdl -a CarryRipple.vhd

david_koontz @ Macbook:ghdl -a CarryRipple_tb.vhd

david_koontz@Macbook: ghdl -a CarryRipple_tb.vhd

david_koontz @ Macbook:ghdl -ecarryRipple_tb

david_koontz@Macbook: ghdl -e carryRipple_tb

david_koontz @ Macbook:ghdl -rcarryRipple_tb --wave = carryRipple_tb.ghw

david_koontz@Macbook: ghdl -r carryRipple_tb --wave=carryRipple_tb.ghw

调用gtkwave.app可以通过单击生成的carryRipple_tb.ghw或使用OS X的打开命令来完成:

invoking gtkwave.app can either be done by clicking on the resulting carryRipple_tb.ghw or by using OS X's open command:

david_koontz @ Macbook:打开-一个gtkwave的carryRipple_tb.ghw

david_koontz@Macbook: open -a gtkwave carryRipple_tb.ghw

Gtkwave的SST窗口(左上)将显示在顶部,单击+框将其展开.对显示的carryripple_tb执行相同的操作.单击一个.在信号窗口中选择a [3:0]并点击插入按钮.重复b.

Gtkwave's SST window (upper left) will display top, expand by clicking the + box. Do the same for the revealed carryripple_tb. Click a. In the signals window select a[3:0] and hit the insert button. Repeat for b.

在SST窗口中选择U0,然后在信号窗口中选择cin,然后单击插入按钮,然后对cout进行相同操作.

In the SST window select U0 and then in the signals window select cin hit the insert button then the same for cout.

在SST窗口中选择s,在信号窗口中选择s [3:0]并点击插入.

In the SST window select s, and in the signals window select s[3:0] and hit insert.

是的,从教程"中获取两个VHDL文件的源是很痛苦的.我没做.

And yes getting the source for the two VHDL files from the 'tutorial' was painful. I didn't do it.

您可能还会注意到在gtkwave显示屏中在60 ns时将"X"分配给Cin,我这样做是为了显示测试台中最后分配的值.

You might also note the assignment of 'X' to Cin at 60 ns in the gtkwave display, I did it to show the last values assigned in the testbench.

我不会说这是一个很好的教程,但是您可以在这里得到报酬.做得更好将是一个更大的要求.

I wouldn't claim it's a good tutorial, but you're getting what you paid for here. Doing better would have been a bigger ask.

测试平台(carryRipple_tb.vhd)提供了在仿真过程中驱动模型(CarryRipple.vhd)的动力.该模型在上一个信号事件之后退出执行,因此无需将停止时间传递给运行命令(例如--stop-time = 587200ns).

The test bench (carryRipple_tb.vhd) provides stimulous to drive the model (CarryRipple.vhd) during simulation. The model quits executing after the last signal event so no stop time need be passed to the run command ( e.g. --stop-time=587200ns).

Youtube上还有五部分GHDL/GTKWave教程,由乍得克西.分辨率不是很好,它是以Linux为中心的.第0部分是关于安装这两个工具的信息.在我的示例中,唯一真正的区别是使用ghw波形格式.大多数浏览器将允许您查看下面以完整尺寸拍摄的gtkwave窗口.

There's also a five part GHDL/GTKWave Tutorial on Youtube by Chad Kersey. The resolution isn't so good and it's Linux centric. Part 0 is about installing the two tools. The only real difference in my example is using the ghw waveform format. Most browsers will allow you to see the gtkwave window shot below at full size.

已添加

added

最近有一个答案,展示了一个带触发器的演示,原始VHDL代码中的错误以及三个可能的修复.它使用配置声明来运行各种固定版本.参见如何以避免在VHDL中简单流程语句的输出出现延迟.

There's a recent answer showing a demonstration with a Toggle Flip Flop, showing an error in the original VHDL code, and three possible fixes. It uses configuration declarations to run the various fixed versions. See how to avoid delay in the output of simple process statement in VHDL.

这篇关于如何在带有ghdl的Mac上编译并运行VHDL程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆