Verilog $Scannf 使用小结
2014-06-05 09:07
369 查看
Here is an example:
The IR_CUR can be anything like binary string...
we can change the formate, based on the input parameter, like we can even use :"0b%b".
Here I only wanto get the binary part.
So, the width of IR_CUR should be [(length-2)*8-1:0] =>[95;0];
Onther way :
parameter IR500_CURRENT = "0b00000000000"; parameter CURRENT_MODE = "0b0"; reg [95:0] IR_CUR; reg [7:0] CUR_MOD; reg [20:0] ir_current; reg cur_mode; integer i,j; supply0 GND; supply1 VCC; initial begin IR_CUR= IR500_CURRENT; CUR_MOD = CURRENT_MODE; i=$sscanf(IR_CUR, "%b",ir_current); j=$sscanf(CUR_MOD, "%b",cur_mode); end
The IR_CUR can be anything like binary string...
we can change the formate, based on the input parameter, like we can even use :"0b%b".
Here I only wanto get the binary part.
So, the width of IR_CUR should be [(length-2)*8-1:0] =>[95;0];
Onther way :
function [10:1] str2bin_12 (input [(12+2)*8-1:0] binstr); integer i, j; reg [1:8] ch; begin for (i=12; i>=1; i=i-1) begin for (j=1; j<=8; j=j+1) ch[j] = binstr[i*8-j]; case (ch) "0" : str2bin_12[i] = 1'b0; "1" : str2bin_12[i] = 1'b1; default: str2bin_12[i] = 1'bx; endcase end end endfunction wire [11:0] ir_current = str2bin_12(IR500_CURRENT);
相关文章推荐
- DBGrideh使用小结(一)
- 创建,测试和使用Web服务的小结
- TChart使用经验小结
- vi编辑器的学习使用(小结)
- c#.NET使用小结(1)
- SQL SERVER SQL Agent服务使用技巧小结
- ASP.NET中TreeView控件使用小结
- 水日报表的使用小结
- treeview的使用小结
- XML文档搜索使用小结
- 使用弹出窗口的技巧小结
- Web Services 中 Web Method 的使用小结(一)
- TestDirector安装使用过程小结
- Ant使用小结
- jbuilder8开发环境使用小结
- SQL Server 最佳实践分析器使用小结
- 在JAVA中使用文档对象模型DOM经验小结[转载]
- ASP.NET中TreeView控件使用小结
- C# OleDbCommand 和 OleDbDataReader 使用小结
- 关于使用ODBC+VC操作DBF文件问题小结