Professional Documents
Culture Documents
CA Paper
CA Paper
net/publication/359861898
CITATIONS READS
0 839
1 author:
Gaurav Srivastav
Indraprastha Institute of Information Technology
1 PUBLICATION 0 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Gaurav Srivastav on 10 April 2022.
Now the Processor.v file passes the fetched instruction from Implementation of Stall
instruction fetch stage to the decode stage. In the decode stage
the instruction is broken down into different segments Stall logic is required to overcome the data hazard by stalling
according to the requirements of RISC RV321 instruction set the pipeline until the value of the source register used is
architecture. The Decode stage prepares the required updated to its correct value by the previous instruction. For
information like source & destination registers used by the example, if any dependency like RAW hazard comes in
instruction, which operation the instruction is performing & picture so to solve that we require a control logic to freeze the
if any offset is used the offset value along with sign extension stages until the previous stages has finished with required
format for the next stage that is the ALU stage. values
The ALU stage is for performing the arithmetic & logical We have implemented the stall logic by sensing the inflight
operations, it performs the required operation that is register in the pipeline. We are continuously tracking the
mentioned in the instruction & if the instruction is branch register after each stage & if the source register in decode
type then ALU calculates the next value of the program stage is same as any inflight destination register in any stage,
counter taking for the branch. After all of these operations are then we are making the stall signal high & inserting NOP
done ALU sends the output to main file which passes the instructions from fetch stage to flow through the pipeline and
information to the Memory stage. delay the instruction until the dependency is over.
a) AND Operation h) SW
Performs bitwise AND operation on registers rs1 and rs2 and Store 32-bit values from the low bits of register rs2
put the result in rd
31-25 24- 19-15 14-12 11- 6-2 1-0
31-27 26- 24- 19-15 14- 11- 6-2 1-0 20 7
25 20 12 7 Offset Rs2 Rs1 010 rd 01000 11
00000 00 Rs2 Rs1 111 rd 01100 11 [6:0]
i) SLL
b) OR
Perform the logical left shift on the value of register rs1 by the
Performs bitwise OR operation on registers rs1 and rs2 and shift amount held in the lower 5 bit of register rs2
put the result in rd
31-27 26- 24- 19-15 14- 11- 6-2 1-0
31-27 26- 24- 19-15 14- 11- 6-2 1-0 25 20 12 7
25 20 12 7
00000 00 Rs2 Rs1 001 rd 01100 11
00000 00 Rs2 Rs1 110 rd 01100 11
j) SRA
c) ADD
Perform the arithmetic right shift on the value of register rs1
Adds the registers rs1 & rs2 and stores the result in rd by the shift amount held in lower 5 bit of register rs2
31-27 26- 24- 19-15 14- 11- 6-2 1-0 31-27 26- 24- 19-15 14- 11- 6-2 1-0
25 20 12 7 25 20 12 7
00000 00 Rs2 Rs1 000 rd 01100 11 01000 00 Rs2 Rs1 101 rd 01100 11
d) SUB k) MAC
Subtract the register rs1 and rs2 and put the result in rd rd<---rd+(rs1*rs2)
31-27 26- 24- 19-15 14- 11- 6-2 1-0 31-27 26- 24- 19- 14- 11- 6-2 1-0
25 20 12 7 25 20 15 12 7
01000 00 Rs2 Rs1 000 rd 01100 11 00000 00 Rs2 Rs1 000 rd 11111 11
e) ADDI
Add the sign extended 12-bit given offset with register rs1 and
III. SIMULATION & RESULTS
put the result in rd
Input Assembly code with instruction
31-20 19-15 14-12 11-7 6-2 1-0