Member since Oct 27, 2006, follows 0 people, 0 public groups, 509 public bookmarks (540 total).
More »
Tags
More »
Recent Bookmarks and Annotations
- Code Review中的几个提示 | 酷壳 on 2009-08-21
- Dynamic Programming Tutorial on 2009-08-16
- 关于不同文件比较的算法 - 译言翻译 on 2009-08-16
- 游泳活动精彩记录。。(58楼以后有新的PP。。) - 旅游天下 - ChinaUnix.net on 2009-08-01
- 高并发下epoll接受连接不完整的原因分析 on 2009-04-19
- Linux下的反调试技术 on 2009-04-19
- VIM: usr_toc on 2009-04-04
- 卓越亚马逊: 遥控: 网上购物 on 2009-03-21
-
Strings in Verilog — www.dilloneng.com on 2009-03-17
-
Strings in Verilog
A quick reference on a couple of ways to manipulate strings in Verilog HDL.
Declaration
There is no string data type is Verilog, so use the following to declare a register to hold a string.
reg[n*8:0] string;
Where the maximum length of the string is n characters. It takes 8 bits to store each character.
Usage
string = "Hello World";
$sdisplay("%s", string); // will get "Hello World"Also, normal concatination will work, for the most part. So something like:
string = {"/path/to/file","/","filename",".txt"};
will result in a string useful to pass to $open to open a file.
For anything more advanced, a very good function is
$sformat(string,"%s %d %s",str1,num,str2);
would produce the string with the three varibles concatinated together and spaces in between.
-
- 通信人家园 论坛|中国第一通信社区 - Powered by Discuz! on 2009-02-07
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo