Ask Question
19 June, 09:37

The processor needs to compute the next PC after each instruction. Write a verilog module which computes the next PC. Be sure to include the B, and CBZ cases. You may use the output of the "Control" module.

+5
Answers (1)
  1. 19 June, 09:43
    0
    Check the explanation

    Explanation:

    module calculatePC (

    input Rst, / / Reset is asynchronous an active high

    input [15:0] BranchAddress, / / Branch Address

    input Clk, / / Clock of MPU

    input B, / / Branch instruction is Recieved

    input CNZ, / / Compare with Zero and Branch is Recieved

    input ZeroFlag, / / Zero Flag input

    output [19:0] PC / / Program Counter

    );

    reg [19:0] NextPC, PC;

    always "at" (*)

    begin

    if (B = = 1'b1)

    NextPC = BranchAddress;

    else if ((CNZ = = 1'b1) && (ZeroFlag = = 1'b1))

    NextPC = BranchAddress;

    else

    NextPC = NextPC + 20'd4;

    end

    always "at" (posedge Clk or posedge Rst)

    begin

    if (Rst)

    PC < = 20'd0;

    else

    PC < = NextPC;

    end

    endmodule
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The processor needs to compute the next PC after each instruction. Write a verilog module which computes the next PC. Be sure to include ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers