0

In 'Computer Organization and Design' RISC-V version (by Patterson and Hennessy) ebook p1195, it has ALUControl module :

module ALUControl (
    ALUOp,
    FuncCode,
    ALUCtl
);
  input [1:0] ALUOp;
  input [5:0] FuncCode;
  output reg [3:0] ALUCtl;
  always @* // origin book is `always`
    case (FuncCode) //origin book is `ALUOp <=`
      32: ALUCtl <= 2;  // add
      34: ALUCtl <= 6;  // subtract
      36: ALUCtl <= 0;  // and
      37: ALUCtl <= 1;  // or
      39: ALUCtl <= 12;  // nor
      42: ALUCtl <= 7;  // slt
      default: ALUCtl <= 15;  // should not happen
    endcase
endmodule

I understand the ALUCtl encoding from this doc p4. However, what does the Function code(i.e. 32,34 listed above) which is in link p6 mean? (the link Function code encoding is same as the encoding in the book )

zg c
  • 113
  • 1
  • 1
  • 7
  • 1
    The first doc you link to is for RISC V, while the second doc you link to is for MIPS. That has got to be confusing. – Erik Eidt Jun 10 '23 at 14:57
  • Thanks. Maybe I understand the problem. The COD RISC-V may forget to change the code from [MIPS](https://www.d.umn.edu/~gshute/mips/rtype.xhtml) to RISC-V version. In RISC-V, opcode is instruction[6:0], while MIPS is instruction[5:0]. – zg c Jun 11 '23 at 02:05
  • I tried to find the appendix A which includes the above code in [official web](https://www.elsevier.com/books-and-journals/book-companion/9780128122754/advanced-content-and-appendices#Advanced%20Content), but not find (also not find in [MIPS](https://booksite.elsevier.com/9780124077263/appendices.php) version of the book ). This is weird. But the above ebook has the appendix (not knowing the source of appendix A.) – zg c Jun 23 '23 at 14:10
  • 1
    That Verilog module you quote, from the RISC V COD, `ALUControl` FIGURE A.5.15 p1195, is a verbatim copy of the same `ALUControl` FIGURE C.5.16 on C-38 in [Appendix C](https://www.cs.tufts.edu/comp/140/files/Appendix-C.pdf) of the COD Fourth Edition (MIPS). Obviously, they didn't update it for RISC V. There's no func[5:0] instead there's func3 and func7. – Erik Eidt Jun 23 '23 at 16:24
  • Sorry. I made the mistake. The appendix A is in the [printed book](https://bank.engzenon.com/tmp/5e7f7183-219c-4d93-911a-4aaec0feb99b/5dc835ea-b66c-4988-be3f-4d51c0feb99b/Computer_Organization_RiscV_Edition.pdf). The orginal risc-v [book (see p14 of the book online 'Advanced Content')](https://www.elsevier.com/__data/assets/pdf_file/0010/297514/Section-4-13_Advanced.pdf#Section%204.13) says `ALUControl` is 'defined in Figure B.5.16'. However, it is about GPU from the [official web](https://www.elsevier.com/books-and-journals/book-companion/9780128122754#Home). – zg c Jun 24 '23 at 00:39
  • Thanks. After all, I have understanded the problem although the code not corresponds to risc-v. – zg c Jun 24 '23 at 00:41

0 Answers0