vead
Full Member level 5
hello,
I need help to understanding following verilog code for PC
I understand how UP counter work but I don't understand how does PC work with different input ( example jump, branch )
?
I need help to understanding following verilog code for PC
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 module PC(clk , instruction , zero , branch , jump , pc ); input clk ; input[31:0] instruction ; reg[31:0] npc; input zero ; input jump ; input branch ; wire[31:0] pcInc; wire[31:0] Branch1 ; wire[15:0] address; wire[31:0] branchAdd; reg[31:0] mux1; wire select1 ; wire[31:0] jumpAdd ; output [31:0] pc ; reg [31:0] pc ; assign select1 = branch & zero ; assign pcInc = pc + 4 ; assign address = instruction[15:0]; assign Branch1 = {{16{address[15]}},address[15:0]} ; // sign extension assign branchAdd = pcInc + ( branch << 2 ) ; always@( branchAdd or pcInc or select1 ) begin if ( select1 == 1 ) mux1 = branchAdd ; else mux1 = pcInc ; end assign jumpAdd = ( instruction[25:0] << 2 ); always@ ( jump or jumpAdd or mux1 ) begin if ( jump == 1 ) npc = jumpAdd ; else npc = mux1; end always @(posedge clk ) pc <= npc;
I understand how UP counter work but I don't understand how does PC work with different input ( example jump, branch )
?