セットアソシアティブ キャッシュの場合は、Vec[Mem] が便利です。
残念ながら、Chisel は Vec[Mem] コンストラクトをサポートしていません。
val tag_ram2 = Vec.fill(num_ways) {Mem(new TagType(), num_sets , seqRead = true )}
それはそう:
inferred type arguments [Chisel.Mem[cache.TagType]] do not conform to method fill's type parameter bounds [T <: Chisel.Data]
[error] Error occurred in an application involving default arguments.
[error] val tag_ram2 = Vec.fill(num_ways) {Mem(new TagType(), num_sets , seqRead = true )}
[error] ^
[error] /home/asamoilov/work/projects/my-chisel/Cache.scala:139: type mismatch;
[error] found : Chisel.Mem[cache.TagType]
[error] required: T
[error] Error occurred in an application involving default arguments.
[error] val tag_ram2 = Vec.fill(num_ways) {Mem(new TagType(), num_sets , seqRead = true )}
ただし、簡単な回避策は問題なく機能します。
val tag_ram2 = Array.fill(num_ways) {Mem(new TagType(), num_sets , seqRead = true )}
[...]
is (read_tag) {
set_idx := req_idx % UInt(num_sets) // FIXME
for (way_no <- 0 until num_ways) {
tag_read_vec(way_no) := tag_ram2(way_no)(set_idx)
}
controller_state := compare_tag
}
そして、タグを書くため(いくつかの when(...) 句の下での原因の)
for (way_no <- 0 until num_ways) {
when (UInt(way_no) === way_idx) {
printf("writing to way %d set %d tag %x\n", way_idx, set_idx, tag_write.toBits)
tag_ram2(way_no)(set_idx) := tag_write
}
}
提案されたスキームを改善するためのコメント、提案はありますか? ありがとう!