Advertisement
kekellner

PC_ALU.v

Nov 15th, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module PC_ALU (
  2.     input [6:0] k,
  3.     input [6:0] PC_count,
  4.     input instruction,
  5.     output [6:0] newPC
  6. );
  7.  
  8.     reg [6:0] _newPC, neg_k;
  9.  
  10.     always @(k, PC_count, instruction) begin
  11.  
  12.         if (instruction)  // JMP
  13.             _newPC <= k;
  14.         else begin  // BRBS
  15.             if (k[6]) begin  // negative number
  16.                 neg_k  = ~k + 1;  // Complemento a 2 para revertir el numero
  17.                 _newPC = PC_count - neg_k;
  18.             end else _newPC = PC_count + k;
  19.         end
  20.  
  21.     end
  22.  
  23.     assign newPC = _newPC;
  24. endmodule
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement