小编N8T*_*TRO的帖子

使用System-Verilog进行串行测试和断言

我有一个verilog模块的串行输出,我想使用system-verilog进行测试。

给定正确的串行输入“ SI”(其值为8'h9A),称为“ SO”的输出将输出类似于8'hC6的输出。

是否有一种无需明确描述每个信号的简单方法来编码/解码串行IO?

例如:

assert property @(posedge clk) $rose(EN) |-> ##[1:3] SI ##1 !SI[*2] ##1 SI[*2] ##1 !SI ##1 SI ##1 !SI
                                             ##[1:3] SO[*2] ##1 !SO[*3] ##1 SO[*2] ##1 !SO;
Run Code Online (Sandbox Code Playgroud)

它看起来像一团混乱,几乎不可读。我非常想写

8'h9A ##[1:3] 8'hC6
Run Code Online (Sandbox Code Playgroud)

但显然这是行不通的。任何建议或示例都将受到欢迎。提前致谢。

testing verification verilog system-verilog system-verilog-assertions

3
推荐指数
1
解决办法
1212
查看次数

如何在R中的data.frame中提取子序列的最后日期?

我用以下数据集挣扎了一段时间:

    id   date       var1 var2     
1   7031 2008-12-01  27  1
2   7031 2009-01-05   6  0
3   7031 2009-02-02   0  3
4   7031 2008-11-01   1  4
5   7500 2009-07-11  30  0
6   7500 2009-10-01   8  0
7   7500 2010-01-01   0  0
8   7041 2009-06-20  26  0
9   7041 2009-08-01   0  0
10  0277 2009-01-01   3  0
Run Code Online (Sandbox Code Playgroud)

我想为每个id输出具有非零变量的最后日期.这些用户的时间序列长度不同.我期望作为输出smth像:

id   last_date
7031 2009-02-02
7500 2009-10-01
7041 2009-06-20
0277 2009-01-01
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激!

r date subset dataframe

2
推荐指数
1
解决办法
227
查看次数

我如何处理ValueError?

我正在使用index()字符串来查找子字符串的出现.

当字符串中不存在子字符串时,我得到:

"ValueError: substring not found".
Run Code Online (Sandbox Code Playgroud)

我希望我的程序能够识别何时发生这种情况,但我不知道如何将其ValueError转化为有用的东西.例如,我如何ValueErrorif声明中使用a ?

python

2
推荐指数
2
解决办法
2950
查看次数

使用循环中的变量转换R数据帧

我试图逐列替换R数据帧中的值.我想,虽然循环数据框的列的定列表和0代替1"是"的价值观和所有其他的值.

我尝试使用transform()和ifelse()函数执行此操作,如下所示:

# List of selected Columns:
ColumnNames = c("Frigori", "Microond" , "Arca", "Aspira")

# Replace Values in dataframe
for(i in 1:length(ColumnNames)){
dataframe <- transform(dataframe, ColumnNames[i] = ifelse(Columnames[i] == "Yes", 1, 0))
}
Run Code Online (Sandbox Code Playgroud)

这段代码工作正常循环外显式的列名,但与阵列,它会给我下面的错误:

Error: unexpected '=' in:
"for(i in 1:length(Appliances)){
dataframe <- transform(dataframe, ColumnNames[i] ="
Run Code Online (Sandbox Code Playgroud)

我不知道这里出了什么问题,但问题必须与变量替换有关.

conditional loops r dataframe

1
推荐指数
1
解决办法
3877
查看次数