从 makefile 生成 VHDL 条件

发布于 2024-08-20 13:57:47 字数 936 浏览 3 评论 0原文

我有一个 vhdl 设计,需要适应不同的变体。 如果能够从 makefile 生成配置那就太好了。用于生成一个项目的 makefile 已准备就绪并可以运行。

我想避免不同的项目有不同的非常相似的文件。 这些项目之间的唯一区别是某处有几行,其中一个包含一堆另一个不需要的 vhdl 文件(和组件)。

例如,我想避免有两个不同的顶级 vhd 文件。相反,我想在顶部文件中使用条件,以便包含(或不包含)其他 vhdl 文件和组件,具体取决于项目。

您对如何执行此操作有什么建议吗?

我尝试使用外部预编译器(gcc)但无法使其工作。此外,我真的不想强迫其他开发人员安装 gcc,或者无法在 Xilinx IDE 中使用 vhdl 文件。


编辑:添加示例

我有两个产品 A 和 B。我想对这两个产品使用相同的文件,并使用条件排除产品 B 的某些部件,生成不同硬件部件的配置,当然还有其他事情。

我想从命令行生成配置: 制作product_A制作product_B

如果我将 generates 放入 vhdl 中以根据目标包含/排除代码,则 xst 需要知道正在构建什么目标。问题是如何将当前目标从 makefile 传递到 xst。

在使用 gcc 编译 C 代码时,我将放入源代码:

#if defined(product_B)
    ...
#elsif defined(product_A)
    ...
#endif

,然后在 makefile 中设置定义:

product_A: source.c
    gcc -Dproduct_A source.c

product_B: source.c
    gcc -Dproduct_B source.c

I have a vhdl design that needs adapting to different variants.
It would be nice to be able to generate the configurations from a makefile. The makefile for the generation of one project is ready and working.

I want to avoid having different very similar files for different projects.
The only differences between the projects are a couple of rows somewhere, and that one of them includes a bunch of vhdl files (and components) that the other one does not need.

I want to avoid having two different top level vhd files, for example. Instead I want to use conditionals inside the top file in order to include (or not) the other vhdl files and components, depending on project.

Do you have any suggestion as to how to do this?

I have tried to use an external pre-compiler (gcc's) but could not make it work. Furthermore I don't really want to force other developers to install gcc, or the vhdl files not to be usable from within the Xilinx IDE.


Edit: Adding an example

I have two products, A and B. I want to use the same files for both products, with conditionals to exclude some parts for product B, generate the configurations for different HW parts, and surely other things.

I want to generate the configs from the command line with:
make product_A, and make product_B.

If I put generates in my vhdl to include/exclude code depending on the target, then xst needs to know what target is being built. The question is about how to pass the current target from the makefile to xst.

In C code compiling with gcc, I'd put in the source code:

#if defined(product_B)
    ...
#elsif defined(product_A)
    ...
#endif

, then set the define in the makefile:

product_A: source.c
    gcc -Dproduct_A source.c

product_B: source.c
    gcc -Dproduct_B source.c

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑忘罢 2024-08-27 13:57:47

您是否考虑过使用 vhdl GENERATE 语句并将其包装在您想要配置的逻辑周围。

name : FOR N IN 1 TO 8 GENERATE

  concurrent statements here

END GENERATE name;

然后,如果您将一些配置泛型添加到顶级文件中,您可以控制生成的运行方式。

编辑

您可以使用 XST 中的命令行设置 GENERICS:

-generics {name=value name=value}

仅从 9.1 开始添加对此的支持。

Have you considered using the vhdl GENERATE statement and wrapping it around the logic you want to be configurable.

name : FOR N IN 1 TO 8 GENERATE

  concurrent statements here

END GENERATE name;

Then if you add some configuration generics to the top level file you can control how the generates run.

EDIT

You can set GENERICS from the command line in XST using:

-generics {name=value name=value}

Support for this was only added from 9.1 onwards.

左岸枫 2024-08-27 13:57:47

这里有几个选项:

  1. 尽量不要使用不同的文件,而是在一个文件中实现所有不同的版本。 这是迄今为止最强大的方法。 VHDL 有一些有用的构造可以帮助您完成此任务:泛型、生成 语句、包、配置等。
  2. 使用外部宏预处理器来获得 VHDL 文件“模板”。一些强化的 Unixoid 使用古老的 m4 工具。我会采取不同的路径,使用成熟的编程语言(例如 Python)和一些模板库。然后,您可以轻松地将这些模板生成的真实 VHDL 文件合并到您的 makefile 中。

无论如何,首先尝试使用选项(1)。差异可能没有你想象的那么糟糕。

You have a couple of options here:

  1. Try not to have different files, but implement all the different versions in a single one. This is by far the most robust approach. VHDL has some useful constructs to help you with this: generics, generate statements, packages, configurations and so on.
  2. Use an external macro pre-processor to have VHDL file "templates". Some hardened Unixoids use the venerable m4 tool. I would take a different path and use a full-fledged programming language like Python with some templating library. Then, you can easily incorporate the generation of real VHDL files from these templates in your makefiles.

By all means, try going with option (1) first. The differences may not be as bad as you think.

习惯成性 2024-08-27 13:57:47

生成是做到这一点的方法 - 无论是否编译某些内容,您都需要一个 if 生成:

product_a_gen: if product_a='1' generate
    -- some code in here
end generate product_a_gen;
product_b_gen: if product_b='1' generate
    -- some code in here
end generate product_b_gen;

VHDL2008 添加了生成扩展,因此您可以拥有 caseelse 部分。 Doulos 有一个关于此的应用说明

请注意 XST 和传递泛型,它们在支持的类型上受到限制。

Generate is the way to do it - to have something compiled in or not, you need an if generate:

product_a_gen: if product_a='1' generate
    -- some code in here
end generate product_a_gen;
product_b_gen: if product_b='1' generate
    -- some code in here
end generate product_b_gen;

VHDL2008 adds extensions to generate, so you can have case and else parts. Doulos have an appnote on this.

Take care with XST and passing in generics, they are limited on which types are supported.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文