-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFSTAGE.v
51 lines (42 loc) · 1.06 KB
/
IFSTAGE.v
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
49
50
51
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 22:05:42 01/02/2022
// Design Name:
// Module Name: IFSTAGE
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module IFSTAGE(
input [31:0] PC_Immed,
input PC_sel,
input PC_LdEn,
input Reset,
input Clk,
output [31:0] Instr
);
wire [31:0] PC_out;
wire [31:0] MUX_out;
wire [31:0] PC_next;
wire [31:0] PC_imm;
//Create PC
pc progcount (.Data(MUX_out), .Clk(Clk), .Reset(Reset), .LdEn(PC_LdEn), .Dout(PC_out));
//Create adders
assign PC_next = PC_out + 4;
assign PC_imm = PC_out + 4 + (PC_Immed << 2);
//Create MUX
mux2to1 mux_pc (.D1(PC_next), .D2(PC_imm), .Sel(PC_sel), .Dout(MUX_out));
//Create instruction memory
ROM imem (.clk(Clk), .addr(PC_out[11:2]), .dout(Instr));
endmodule