"Szép" kód

A következő kódrészlet (Chisel, Scala DSL) nem szimulálódik:


 val arithresult = Wire(UInt(9.W))
  arithresult := MuxCase(0.U(9.W),
    Array((io.aluIO.arith === AOps.ADD) -> (io.aluIO.op1 +& io.aluIO.op2),
      (io.aluIO.arith === AOps.ADC) -> ((io.aluIO.op1 +& io.aluIO.op2) + fc),
      (io.aluIO.arith === AOps.SBC) -> ((io.aluIO.op1 -& io.aluIO.op2) - fc).asUInt
      ,(io.aluIO.arith === AOps.SUB) -> (io.aluIO.op1 -& io.aluIO.op2 ).asUInt

  ))

A következő meg igen.


 val arithresult = Wire(UInt(9.W))
  arithresult := MuxCase(0.U(9.W),
    Array((io.aluIO.arith === AOps.ADD) -> (io.aluIO.op1 +& io.aluIO.op2),
      (io.aluIO.arith === AOps.ADC) -> ((io.aluIO.op1 +& io.aluIO.op2) + fc),
      (io.aluIO.arith === AOps.SBC) -> ((io.aluIO.op1 -& io.aluIO.op2) - fc).asUInt
      ,(io.aluIO.arith === AOps.SUB) -> (io.aluIO.op1 -& io.aluIO.op2 - 0.U(9.W)).asUInt

  ))

Kind of "elegáns". Már az asUInt-ok sem tetszenek túlzottan.

Hozzászólások

gyerekeknek szoktak ilyen "mi a kulonbseg a ket kep kozott" jetokok lenni :)

Screenshot, kivagod mindket kepet, beteszed GIMPbe egy kepre 2 kulon layerre, es az egyiknel beallitod, hogy kivonodjon (felsore mode: difference). (pont ilyen "keresd meg a kulonbseget" jateknal hasznaltam ezt a modszert)

--
A strange game. The only winning move is not to play. How about a nice game of chess? - Wargames