emacs verilog-mode方式实现verilog实例化集成

2024-06-16 08:48

本文主要是介绍emacs verilog-mode方式实现verilog实例化集成,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 背景介绍
  • AUTOINST和AUTOWIRE的应用
  • 推荐使用方法
  • auto_template命令总结
    • [],中括号,里面没内容。表示auto_inst时,会显示[3:0]类似内容
    • @,常用于相同module,多次实例化情况。我不常用。这里仅是提一下有这种功能。下面第一段,表示auto_template有一个可选变量,支持正则表达式;如果没有正则表达,@符号就会默认匹配实例化名称里的 **数字字符串** 【可以理解为是第一个 **[0-9]+** 正则表达式字符串】。另外,下面instname表示的是module名称,而非实例化名称,应该是原文手误。
    • Regexp Templates。auto_template里的正则表达式,可以定制化例化的连接信号名称。
    • Lisp Templates。因为是emacs,脚本叫Lisp语言。其实就是有一套成熟脚本,方便实现auto_template里的常见功能。
    • Ignoring Hookup。即忽略自动化连线名称。不想使用autowire或者auto_template等自动连线方式。
  • 教程里的简单操作,也贴一下

背景介绍

emacs默认自带verilog-mode插件,不仅仅支持语法高亮、代码段自动补全等功能,核心应用还有/*AUTOXXX*/
IC顶层集成,最常见的工作就是实例化和端口线网的连接。可以利用/*AUTOINST*//*AUTOWIRE*/节省很多工作量,减少出错可能性。

AUTOINST和AUTOWIRE的应用

下面是示例。用到的技巧包括:

  1. ctrl+c ctrl+a是把/*AUTOINST*/等关键词展开;得到实例化等代码段。连续操作,可以更新。
  2. ctrl+c ctrl+k是把/*AUTOINST*/等关键词收起;
  3. AUTOWIRE,是把output变量进行wire类型声明。理论上verilog,只需要对output设置wire类型定义即可,输入必然来自某一个输出信号。
  4. AUTOINST,默认的线网连接名称与端口名称相同;如对此有要求,可以利用AUTO_TEMPLATE。
  5. 实例化代码和设计代码可以不放在一个文件里,利用verilog-library-files变量设置。
  6. 另外就是tab缩进和指定列,输出autoinst内容。后面有图形,利用几个变量设置。
  7. 下图有几个emac --batch命令,是为了不打开emac编辑器,脚本操作autoinst等命令的。

推荐使用方法

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

auto_template命令总结

参考官网:https://www.veripool.org/verilog-mode/help/#verilog-auto-inst

[],中括号,里面没内容。表示auto_inst时,会显示[3:0]类似内容

For example:/* InstModule AUTO_TEMPLATE (.ptl_bus        (ptl_busnew[]),);*/InstModule ms2m (/*AUTOINST*/);Typing M-x verilog-auto will make this into:InstModule ms2m (/*AUTOINST*/// Outputs.NotInTemplate      (NotInTemplate),.ptl_bus            (ptl_busnew[3:0]),....

@,常用于相同module,多次实例化情况。我不常用。这里仅是提一下有这种功能。下面第一段,表示auto_template有一个可选变量,支持正则表达式;如果没有正则表达,@符号就会默认匹配实例化名称里的 数字字符串 【可以理解为是第一个 [0-9]+ 正则表达式字符串】。另外,下面instname表示的是module名称,而非实例化名称,应该是原文手误。

  • 下面这段sig2里。注释:第1个@"xxx"表示把xxx当做lisp脚本命令执行,第2个@表示实例化名字里匹配到的第一组数字字符串。
/* InstName AUTO_TEMPLATE <optional "REGEXP"> (.sig1   (sigx[@]),.sig2   (sigy[@"(% (+ 1 @) 4)"]),);*/
For example:/* InstModule AUTO_TEMPLATE (.ptl_mapvalidx          (ptl_mapvalid[@]),.ptl_mapvalidp1x        (ptl_mapvalid[@"(% (+ 1 @) 4)"]), );*/InstModule ms2m (/*AUTOINST*/);Typing M-x verilog-auto will make this into:InstModule ms2m (/*AUTOINST*/// Outputs.ptl_mapvalidx              (ptl_mapvalid[2]),.ptl_mapvalidp1x            (ptl_mapvalid[3]));
Note the @ character was replaced with the 2 from "ms2m".Alternatively, using a regular expression for @:/* InstModule AUTO_TEMPLATE "_\([a-z]+\)" (.ptl_mapvalidx          (@_ptl_mapvalid),.ptl_mapvalidp1x        (ptl_mapvalid_@),);*/InstModule ms2_FOO (/*AUTOINST*/);InstModule ms2_BAR (/*AUTOINST*/);Typing M-x verilog-auto will make this into:InstModule ms2_FOO (/*AUTOINST*/// Outputs.ptl_mapvalidx              (FOO_ptl_mapvalid),.ptl_mapvalidp1x            (ptl_mapvalid_FOO));InstModule ms2_BAR (/*AUTOINST*/// Outputs.ptl_mapvalidx              (BAR_ptl_mapvalid),.ptl_mapvalidp1x            (ptl_mapvalid_BAR));

Regexp Templates。auto_template里的正则表达式,可以定制化例化的连接信号名称。

  • 下面一段举例不太好看,pci_reqxx_l,注意后缀是下划线L,不是下划线数字1
  • \1,和\\(xxxxx\\),配合在一起,表示匹配一个正则表达式组1。方便把匹配到的内容,复制到例化信号线名称定义里。
Regexp Templates:A template entry of the form.pci_req\([0-9]+\)_l      (pci_req_jtag_[\1]),
will apply an Emacs style regular expression search for any port beginning in pci_req followed by numbers and ending in _l and connecting that to the pci_req_jtag_[] net, with the bus subscript coming from what matches inside the first set of \( \). Thus pci_req2_l becomes pci_req_jtag_[2].
Since \([0-9]+\) is so common and ugly to read, a @ in the port name does the same thing. (Note a @ in the connection/replacement text is completely different -- still use \1 there!) Thus this is the same as the above template:.pci_req@_l         (pci_req_jtag_[\1]),
Here's another example to remove the _l, useful when naming conventions specify _ alone to mean active low. Note the use of [] to keep the bus subscript:.\(.*\)_l         (\1_[]),

Lisp Templates。因为是emacs,脚本叫Lisp语言。其实就是有一套成熟脚本,方便实现auto_template里的常见功能。

  • 如果在连接线中找到语法 @“(…)”,则引号中的表达式将被计算为Lisp表达式,其中@将被实例化编号替换 。上面的MAPVALIDP1X示例将@+1模4放入括号中。用前导反斜杠(\“…\”)引用表达式中的所有双引号;或者,如果Lisp模板也是regexp模板,则反斜杠引号(\\“…\\”)
        vl-name        Name portion of the input/output port.端口名称vl-bits        Bus bits portion of the input/output port (`[2:0]').一位数组vl-mbits       Multidimensional array bits for port (`[2:0][3:0]').二维数组vl-width       Width of the input/output port (`3' for [2:0]).端口信号的位宽May be a (...) expression if bits isn't a constant.vl-dir         Direction of the pin input/output/inout/interface.端口的方向vl-memory      The unpacked array part of the I/O port (`[5:0]').vl-modport     The modport, if an interface with a modport.vl-cell-type   Module name/type of the cell (`InstModule').module模块名称vl-cell-name   Instance name of the cell (`instName').inst实例化名称

Ignoring Hookup。即忽略自动化连线名称。不想使用autowire或者auto_template等自动连线方式。

  • 没实践过。感觉还是把不期望自动化的连线信号,写在/*autoinst*/之前,更简单直观,而且容易debug。
.pci_req_l  (pci_req_not_to_wire),  //AUTONOHOOKUP

教程里的简单操作,也贴一下

下面有两段代码,第一段代码,按键ctrl+c ctrl+a之后,会自动生成第二段代码。
==================================
module noc(output        z1,output        z2,output [31:0] z3,input         a1,input         a2,input [31:0]  a3);
endmodule
module noc1(output        z1,output        z2,output [31:0] z3,output        a1,output        a2,output [31:0] a3);
endmodule
module a;/*AUTOWIRE*/noc u_noc(/*AUTOINST*/);
endmodule
module a;/*AUTOWIRE*/noc1 u_noc1(/*AUTOINST*/);
endmodule
module a;/*AUTOWIRE*//* noc AUTO_TEMPLATE(.z1 (output1),.z2 (output2),.z3 (output3),.a3 (input3),);*/noc u_noc(/*AUTOINST*/);
endmodule===========================================================
module noc(output        z1,output        z2,output [31:0] z3,input         a1,input         a2,input [31:0]  a3);
endmodule
module noc1(output        z1,output        z2,output [31:0] z3,output        a1,output        a2,output [31:0] a3);
endmodule
module a;/*AUTOWIRE*/// Beginning of automatic wires (for undeclared instantiated-module outputs)wire                 output1;                // From u_noc of noc.vwire                 output2;                // From u_noc of noc.vwire                 output3;                // From u_noc of noc.v// End of automaticsnoc u_noc(/*AUTOINST*/// Outputs.z1                        (output1),               // Templated.z2                        (output2),               // Templated.z3                        (output3),               // Templated// Inputs.a1                        (a1),.a2                        (a2),.a3                        (input3));                // Templated
endmodule
module a;/*AUTOWIRE*/// Beginning of automatic wires (for undeclared instantiated-module outputs)wire                 a1;                     // From u_noc1 of noc1.vwire                 a2;                     // From u_noc1 of noc1.vwire [31:0]          a3;                     // From u_noc1 of noc1.vwire                 z1;                     // From u_noc1 of noc1.vwire                 z2;                     // From u_noc1 of noc1.vwire [31:0]          z3;                     // From u_noc1 of noc1.v// End of automaticsnoc1 u_noc1(/*AUTOINST*/// Outputs.z1                      (z1),.z2                      (z2),.z3                      (z3[31:0]),.a1                      (a1),.a2                      (a2),.a3                      (a3[31:0]));
endmodule
module a;/*AUTOWIRE*/// Beginning of automatic wires (for undeclared instantiated-module outputs)wire                 output1;                // From u_noc of noc.vwire                 output2;                // From u_noc of noc.vwire                 output3;                // From u_noc of noc.v// End of automatics/* noc AUTO_TEMPLATE(.z1 (output1),.z2 (output2),.z3 (output3),.a3 (input3),);*/noc u_noc(/*AUTOINST*/// Outputs.z1                        (output1),               // Templated.z2                        (output2),               // Templated.z3                        (output3),               // Templated// Inputs.a1                        (a1),.a2                        (a2),.a3                        (input3));                // Templated
endmodule

这篇关于emacs verilog-mode方式实现verilog实例化集成的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1065994

相关文章

springboot集成easypoi导出word换行处理过程

《springboot集成easypoi导出word换行处理过程》SpringBoot集成Easypoi导出Word时,换行符n失效显示为空格,解决方法包括生成段落或替换模板中n为回车,同时需确... 目录项目场景问题描述解决方案第一种:生成段落的方式第二种:替换模板的情况,换行符替换成回车总结项目场景s

SpringBoot集成redisson实现延时队列教程

《SpringBoot集成redisson实现延时队列教程》文章介绍了使用Redisson实现延迟队列的完整步骤,包括依赖导入、Redis配置、工具类封装、业务枚举定义、执行器实现、Bean创建、消费... 目录1、先给项目导入Redisson依赖2、配置redis3、创建 RedissonConfig 配

SpringBoot中@Value注入静态变量方式

《SpringBoot中@Value注入静态变量方式》SpringBoot中静态变量无法直接用@Value注入,需通过setter方法,@Value(${})从属性文件获取值,@Value(#{})用... 目录项目场景解决方案注解说明1、@Value("${}")使用示例2、@Value("#{}"php

SpringBoot分段处理List集合多线程批量插入数据方式

《SpringBoot分段处理List集合多线程批量插入数据方式》文章介绍如何处理大数据量List批量插入数据库的优化方案:通过拆分List并分配独立线程处理,结合Spring线程池与异步方法提升效率... 目录项目场景解决方案1.实体类2.Mapper3.spring容器注入线程池bejsan对象4.创建

Python的Darts库实现时间序列预测

《Python的Darts库实现时间序列预测》Darts一个集统计、机器学习与深度学习模型于一体的Python时间序列预测库,本文主要介绍了Python的Darts库实现时间序列预测,感兴趣的可以了解... 目录目录一、什么是 Darts?二、安装与基本配置安装 Darts导入基础模块三、时间序列数据结构与

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

C#实现千万数据秒级导入的代码

《C#实现千万数据秒级导入的代码》在实际开发中excel导入很常见,现代社会中很容易遇到大数据处理业务,所以本文我就给大家分享一下千万数据秒级导入怎么实现,文中有详细的代码示例供大家参考,需要的朋友可... 目录前言一、数据存储二、处理逻辑优化前代码处理逻辑优化后的代码总结前言在实际开发中excel导入很

SpringBoot+RustFS 实现文件切片极速上传的实例代码

《SpringBoot+RustFS实现文件切片极速上传的实例代码》本文介绍利用SpringBoot和RustFS构建高性能文件切片上传系统,实现大文件秒传、断点续传和分片上传等功能,具有一定的参考... 目录一、为什么选择 RustFS + SpringBoot?二、环境准备与部署2.1 安装 RustF

Nginx部署HTTP/3的实现步骤

《Nginx部署HTTP/3的实现步骤》本文介绍了在Nginx中部署HTTP/3的详细步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学... 目录前提条件第一步:安装必要的依赖库第二步:获取并构建 BoringSSL第三步:获取 Nginx

MyBatis Plus实现时间字段自动填充的完整方案

《MyBatisPlus实现时间字段自动填充的完整方案》在日常开发中,我们经常需要记录数据的创建时间和更新时间,传统的做法是在每次插入或更新操作时手动设置这些时间字段,这种方式不仅繁琐,还容易遗漏,... 目录前言解决目标技术栈实现步骤1. 实体类注解配置2. 创建元数据处理器3. 服务层代码优化填充机制详