system-verilog - 在数组查找中使用数组查找
问题描述
有没有办法使用数组定位器函数作为数组定位器函数的条件?类似于以下内容:
我知道我可以简单地遍历数组,但我希望有一个更简洁的方法
module tb;
typedef struct {
string name;
int id;
} positions_t;
typedef struct {
positions_t positions[];
string unit_name;
} injector_t;
injector_t injectors[$] = '{
'{
unit_name: "unit1",
positions: '{
'{name: "ha", id:0},
'{name: "he", id:0},
'{name: "hi", id:0}
}
}
};
injector_t filtered_injectors[$];
initial begin
// LIKE THIS!
filtered_injectors = injectors.find with (
item.positions.find with (item.name == "hi")
);
$display("filtered list = %p", filtered_injectors);
end
endmodule
解决方案
find
返回一个队列,所以这似乎有效
filtered_injectors = injectors.find with (
item.positions.find with (item.name == "hi") != {}
);
推荐阅读
- elasticsearch - 是否可以在 ElasticSearch 的聚合脚本中访问日期范围值?
- amazon-web-services - 在 S3 上列出文件夹
- c# - 无法解析表达式'...:给定的参数与预期的参数不匹配”
- python-3.x - 如何在pytorch的Unet中使用PNASNet5作为编码器
- javascript - 如何在fullPage.js中将一张图片放在两个屏幕上
- linux - 有人知道如何在终端中使用“¥”符号吗?
- sql - 从同一个表中获取员工姓名和经理姓名的 SQL 查询
- mongodb - MongoDB、Nodejs 路由顺序
- php - PHP form getting submitted without validation
- javascript - 检测 HTML5 画布中显示的两个视频帧之间的差异