-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgramCounter.v
More file actions
49 lines (41 loc) · 1.39 KB
/
ProgramCounter.v
File metadata and controls
49 lines (41 loc) · 1.39 KB
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
45
46
47
48
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// ECE369A - Computer Architecture
// Laboratory 1
// Module - pc_register.v
// Description - 32-Bit program counter (PC) register.
//
// INPUTS:-
// Address: 32-Bit address input port.
// Reset: 1-Bit input control signal.
// Clk: 1-Bit input clock signal.
//
// OUTPUTS:-
// PCResult: 32-Bit registered output port.
//
// FUNCTIONALITY:-
// Design a program counter register that holds the current address of the
// instruction memory. This module should be updated at the positive edge of
// the clock. The contents of a register default to unknown values or 'X' upon
// instantiation in your module. Hence, please add a synchronous 'Reset'
// signal to your PC register to enable global reset of your datapath to point
// to the first instruction in your instruction memory (i.e., the first address
// location, 0x00000000H).
////////////////////////////////////////////////////////////////////////////////
module ProgramCounter(PC_Write, Address, Reset, Clk, PCResult);
input [31:0] Address;
input Reset, Clk, PC_Write;
output reg [31:0] PCResult;
initial begin
PCResult <= 32'h000000;
end
always @(posedge Clk) begin
if(Reset)
PCResult <= 32'h000000;
else if(PC_Write)begin
PCResult = Address - 4;
end
else
PCResult = Address;
end
endmodule