1. Homepage
  2. Programming
  3. CS230 Computer Organization HomeWork #2 RISC-V Assembly

CS230 Computer Organization HomeWork #2 RISC-V Assembly

Engage in a Conversation
KZOOKalamazooCS230Computer OrganizationRISC-VAssembly

  CourseNana.COM

CS230 Computer Organization CourseNana.COM

HomeWork #2 (Due: 1 week) CourseNana.COM

  CourseNana.COM

Name: 張三                        Student ID: 請寫學號 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

1.      (1 Point) Please convert the following C code into RISC-V assembly code with a minimum number of instructions. When you are using the GPR registers, please use ther ABI names instead of their register numbers. Assume that the scalar values of i, num_eq and N are in registers t0, t1, and a2, respectively. Also, assume that registers a0 and a1 hold the base addresses of the array A, B respectively. The return value will be passed to the Caller by register a0.
Note: you should obey the register usage convention.

CourseNana.COM

int count_eq_elems(int A[], int B[], int N) CourseNana.COM

{ CourseNana.COM

int i, num_eq = 0; CourseNana.COM

for(i=0; i<N; i++) { CourseNana.COM

if(A[i] == B[i]) CourseNana.COM

num_eq++; CourseNana.COM

} CourseNana.COM

return num_eq++; CourseNana.COM

} CourseNana.COM

  CourseNana.COM

Please write your assembly code in Table 1: CourseNana.COM

  CourseNana.COM

Table 1: List of instructions CourseNana.COM

Label CourseNana.COM

Instruction CourseNana.COM

L1: CourseNana.COM

ADD  t0, zero, zero CourseNana.COM

L2: CourseNana.COM

ADD  t1, zero, zero CourseNana.COM

L3: CourseNana.COM

  CourseNana.COM

L4: CourseNana.COM

  CourseNana.COM

L5: CourseNana.COM

  CourseNana.COM

L6: CourseNana.COM

  CourseNana.COM

L7: CourseNana.COM

  CourseNana.COM

L8: CourseNana.COM

  CourseNana.COM

L9: CourseNana.COM

  CourseNana.COM

L10: CourseNana.COM

  CourseNana.COM

L11: CourseNana.COM

  CourseNana.COM

L12: CourseNana.COM

  CourseNana.COM

L13: CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

2.      (2 Points) Table 2 gives the RISC-V binary code and data (both in hexadecimal representation) for a program. Suppose PC=0x00400000 before program execution. CourseNana.COM

  CourseNana.COM

Table 2: Memory Content Before Program Execution CourseNana.COM

Address CourseNana.COM

Memory Content CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

0x00400000 CourseNana.COM

0x0fc10517 CourseNana.COM

0x00050513 CourseNana.COM

0x00800593 CourseNana.COM

0x008000ef CourseNana.COM

0x00008067 CourseNana.COM

0x00450293 CourseNana.COM

0x00259313 CourseNana.COM

0x006503b3 CourseNana.COM

0x00400020 CourseNana.COM

0x0272d863 CourseNana.COM

0x0002a303 CourseNana.COM

0xffc28e13 CourseNana.COM

0x00ae4c63 CourseNana.COM

0x000e2e83 CourseNana.COM

0x01d35863 CourseNana.COM

0x01de2223 CourseNana.COM

0xffce0e13 CourseNana.COM

0x00400040 CourseNana.COM

0xfe0006e3 CourseNana.COM

0x006e2223 CourseNana.COM

0x00428293 CourseNana.COM

0xfc000ae3 CourseNana.COM

0x00000867 CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

0x10010000 CourseNana.COM

0x0000001c CourseNana.COM

0x00000021 CourseNana.COM

0x0000000c CourseNana.COM

0x0000000b CourseNana.COM

0x0000000f CourseNana.COM

0x00000020 CourseNana.COM

0x0000001b CourseNana.COM

0x0000000a CourseNana.COM

0x10010020 CourseNana.COM

0x00000011 CourseNana.COM

0x00000022 CourseNana.COM

0x00000033 CourseNana.COM

0x00000044 CourseNana.COM

0x00000055 CourseNana.COM

0x00000066 CourseNana.COM

0x00000077 CourseNana.COM

0x00000088 CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

  CourseNana.COM

a)      (1 Point) Please translate the RISC-V binary code back into RISC-V assembly code in Table 3. The semantics of the first instruction AUIPC is: x10 = PC + (Imm20 << 12), and here Imm20 = 0x0fc10. CourseNana.COM

  CourseNana.COM

Table 3: Assembly Code of the Program CourseNana.COM

Label CourseNana.COM

Instruction CourseNana.COM

L1: CourseNana.COM

AUIPC x10, 0x0fc10 CourseNana.COM

L2: CourseNana.COM

  CourseNana.COM

L3: CourseNana.COM

  CourseNana.COM

L4: CourseNana.COM

  CourseNana.COM

L5: CourseNana.COM

  CourseNana.COM

L6: CourseNana.COM

  CourseNana.COM

L7: CourseNana.COM

  CourseNana.COM

L8: CourseNana.COM

  CourseNana.COM

L9: CourseNana.COM

  CourseNana.COM

L10: CourseNana.COM

  CourseNana.COM

L11: CourseNana.COM

  CourseNana.COM

L12: CourseNana.COM

  CourseNana.COM

L13: CourseNana.COM

  CourseNana.COM

L14: CourseNana.COM

  CourseNana.COM

L15: CourseNana.COM

  CourseNana.COM

L16: CourseNana.COM

  CourseNana.COM

L17: CourseNana.COM

  CourseNana.COM

L18: CourseNana.COM

  CourseNana.COM

L19: CourseNana.COM

  CourseNana.COM

L20: CourseNana.COM

  CourseNana.COM

L21: CourseNana.COM

  CourseNana.COM

  CourseNana.COM

b)      (0.5 Point) Please explain the functionality of the program (i.e., what it does), and give the updated data in the memory after the program execution in Table 4. CourseNana.COM

  CourseNana.COM

Table 4: Updated Memory Content After Program Execution CourseNana.COM

Address CourseNana.COM

Memory Content CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

0x10010000 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

0x10010020 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

... CourseNana.COM

  CourseNana.COM

  c)      (0.5 Point) Are there any problem with this program? (Hint: related to issues of register usage convention). CourseNana.COM

   CourseNana.COM

3.      (2 Points) Suppose we want to extend the single-cycle RV32I processor design with the AUIPC instruction (The semantics of the AUIPC is given in Question 2, and its encoding format can be referred to slide 61 in Lecture 4 ppt). CourseNana.COM

a)      (0.5 Point) Do we need to add any new datapath component? If so, please describe the functionality of this new component, and describe its connections with other datapath components. Do we need to change the connections between any datapath components? If so, please describe the changes of connections. CourseNana.COM


CourseNana.COM

b)      (1 Point) Do we need to change the internal logic of any components? If the changed component is the ImmGen, please describe its detailed change by modifying the Excel tables provided together with this homework, and paste the screenshot of the Excel tables in this word document. For other changed component, you can simply describe the name of the component and the reason for changing it, without the need to give its detailed change. CourseNana.COM


CourseNana.COM

  CourseNana.COM

c)      (0.5 Point) Does AUIPC needs additional control signals? If so, please give their names and the datapath components that they control, as well as their usage. Please make change to the Truth Table for the PLA-based control logic by adding an addition table entry for auipc, and fill the values of its columns. If no additional control signal is needed, please just keep the last column empty. CourseNana.COM

  CourseNana.COM


CourseNana.COM

Table 5: Changes to The Truth Table by AUIPC Instruction CourseNana.COM

Inst[31:0] CourseNana.COM

BrEq CourseNana.COM

BrLT CourseNana.COM

PCSel CourseNana.COM

BrUn CourseNana.COM

Op1Sel CourseNana.COM

Op2Sel CourseNana.COM

MemRW CourseNana.COM

RegW CourseNana.COM

WBSel CourseNana.COM

ImmSel CourseNana.COM

ALUctr CourseNana.COM

? CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
KZOO代写,Kalamazoo代写,CS230代写,Computer Organization代写,RISC-V代写,Assembly代写,KZOO代编,Kalamazoo代编,CS230代编,Computer Organization代编,RISC-V代编,Assembly代编,KZOO代考,Kalamazoo代考,CS230代考,Computer Organization代考,RISC-V代考,Assembly代考,KZOOhelp,Kalamazoohelp,CS230help,Computer Organizationhelp,RISC-Vhelp,Assemblyhelp,KZOO作业代写,Kalamazoo作业代写,CS230作业代写,Computer Organization作业代写,RISC-V作业代写,Assembly作业代写,KZOO编程代写,Kalamazoo编程代写,CS230编程代写,Computer Organization编程代写,RISC-V编程代写,Assembly编程代写,KZOOprogramming help,Kalamazooprogramming help,CS230programming help,Computer Organizationprogramming help,RISC-Vprogramming help,Assemblyprogramming help,KZOOassignment help,Kalamazooassignment help,CS230assignment help,Computer Organizationassignment help,RISC-Vassignment help,Assemblyassignment help,KZOOsolution,Kalamazoosolution,CS230solution,Computer Organizationsolution,RISC-Vsolution,Assemblysolution,