简体   繁体   English

CHISEL中的ListLookUp

[英]ListLookUp in CHISEL

I am new to Scala and I have been trying to understand the RISC-V architecture. 我是Scala的新手,我一直在尝试了解RISC-V架构。 I came across this piece of code, which I have been staring at for hours, unable to understand. 我遇到了这段代码,我已经盯着看了好几个小时了,无法理解。

val csignals =                                                                                                   
  ListLookup(io.dat.inst,                                                                                       
                         List(N, BR_N  , OP1_X  ,  OP2_X  , ALU_X   , WB_X   , REN_0, MEN_0, M_X  , MT_X,  CSR.N),
           Array(       /* val  |  BR  |  op1   |   op2     |  ALU    |  wb  | rf   | mem  | mem  | mask |  csr  */
                        /* inst | type |   sel  |    sel    |   fcn   |  sel | wen  |  en  |  wr  | type |  cmd  */
              LW      -> List(Y, BR_N  , OP1_RS1, OP2_IMI , ALU_ADD ,  WB_MEM, REN_1, MEN_1, M_XRD, MT_W,  CSR.N),
              LB      -> List(Y, BR_N  , OP1_RS1, OP2_IMI , ALU_ADD ,  WB_MEM, REN_1, MEN_1, M_XRD, MT_B,  CSR.N),
              LBU     -> List(Y, BR_N  , OP1_RS1, OP2_IMI , ALU_ADD ,  WB_MEM, REN_1, MEN_1, M_XRD, MT_BU, CSR.N),... 
  1. What ListLookUp exactly does here ? ListLookUp到底在这里做什么?
  2. Is the value of 'csignals' Boolean or something else ? 'csignals'的值是布尔型还是其他?

The ListLookUp is roughly equivalent to a switch() statement in software programming, or a casez statement in Verilog RTL. ListLookUp大致等效于软件编程中的switch()语句,或Verilog RTL中的casez语句。

The first argument ( io.dat.inst ) is the signal to match against. 第一个参数( io.dat.inst )是要匹配的信号。

The second argument is the default value if no match occurs. 如果没有匹配项,则第二个参数是默认值。

The third argument is an Array of "key"->"value" tuples. 第三个参数是“键”->“值”元组的数组。 The io.dat.inst is matched against the keys to find a match and the csignals is set to the value part if a match is found. io.dat.inst与键进行匹配以找到匹配项,如果找到匹配项, csignals信号设置为value部分。

So csignals is of a type List() . 因此,csignals的类型为List()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM