简体   繁体   English

在Emacs中的Verilog文件中嵌入Python代码

[英]Embed Python code in Verilog file in Emacs

I am working on a project whereby I need to embed Python within a Verilog file. 我正在一个项目中,需要将Python嵌入Verilog文件中。 The Python isn't really intended for execution in the normal sense as it will be read by a secondary tool. Python并不是真正意义上的正常执行,因为它将由辅助工具读取。 The Python will be written blocks that have some fixed demarcation (such as #+BEGIN_SRC, in org-babel). Python将被编写为具有固定边界的块(例如,org-babel中的#+ BEGIN_SRC)。

module name ();

#+BEGIN_SRC python
def my_function ():
    ...
#+END_SRC

always @(posedge clk)
    ...
endmodule

Within Emacs this causes havoc, although Python-mode and Verilog-mode work fine, when combining both in the same file things quickly break-down as one would expect. 在Emacs内部,这会造成严重破坏,尽管Python模式和Verilog模式可以很好地工作,但是当将两者合并到同一文件中时,它们会像人们期望的那样迅速崩溃。 Indentation is hopelessly broken as is syntax-highlighting. 缩进无可避免地被破坏,语法突出显示也是如此。 I understand this is a very weird thing to do, and I understand that there will almost certainly never been any real need to do this under normal circumstances, however for this particular case it is necessary. 我知道这是一件很奇怪的事情,而且我知道在正常情况下几乎肯定没有任何真正的需要,但是对于这种特殊情况是有必要的。

My question: is there anyway within Emacs to specify multiple major modes within the same file. 我的问题:Emacs中是否始终可以在同一文件中指定多个主要模式。 For example, is there some way that I can write a file using Verilog-mode as my major mode, but use Python-mode within the predefined blocks that are then ignored in the reset of the file. 例如,有某种方法可以使用Verilog模式作为主要模式来写文件,但可以在预定义的块中使用Python模式,然后在重置文件时将其忽略。

There are a number of possibilities listed here: 这里列出了多种可能性:

http://emacswiki.org/emacs/MultipleModes http://emacswiki.org/emacs/MultipleModes

I've used multi-mode with latex and haskell, and it works OK. 我在乳胶和Haskell中使用了多模式,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM