-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage_EX.v
54 lines (44 loc) · 1.18 KB
/
stage_EX.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
52
53
54
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2021/11/13 00:20:50
// Design Name:
// Module Name: stage_EX
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module STAGE_EX(
input clk,
input reset_n,
// normal input & output
input [`WORD_SIZE-1:0] PC,
input [`WORD_SIZE-1:0] instruction,
input [`WORD_SIZE-1:0] A,
input [`WORD_SIZE-1:0] B,
output [`WORD_SIZE-1:0] aluOut,
// control input & output
input aluSrcA,
input aluSrcB,
input [5:0] func
);
wire [`WORD_SIZE-1:0] offset_ze = {8'b0, instruction[7:0]};
wire [`WORD_SIZE-1:0] aluA = aluSrcA == 1'b0 ? PC : A;
wire [`WORD_SIZE-1:0] aluB = aluSrcB == 1'b0 ? B : offset_ze ;
ALU alu(
.A(aluA),
.B(aluB),
.C(aluOut),
.OP(func)
);
endmodule