-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlUnit.v
80 lines (80 loc) · 1.32 KB
/
ControlUnit.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 18:50:52 06/12/2022
// Design Name:
// Module Name: ControlUnit
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module ControlUnit(Opcode,Clk,ALUop,Branch,Regdst,ALUsrc,Regwrite,Memread,Memtoreg,Memwrite
);
input [3:0]Opcode;
input Clk;
output reg Branch;
output reg Regdst;
output reg ALUsrc;
output reg Regwrite;
output reg Memread;
output reg Memtoreg;
output reg Memwrite;
output reg [2:0] ALUop;
always @(Clk)
begin
if(Opcode==0)
begin
Branch=0;
Regdst=1;
ALUsrc=0;
Regwrite=1;
Memread=0;
Memtoreg=0;
Memwrite=0;
ALUop=4;
end
if(Opcode==1)
begin
Branch=1;
Regdst=0;
ALUsrc=0;
Regwrite=0;
Memread=0;
Memtoreg=0;
Memwrite=0;
ALUop=1;
end
if(Opcode==3)
begin
Branch=0;
Regdst=0;
ALUsrc=1;
Regwrite=1;
Memread=1;
Memtoreg=1;
Memwrite=0;
ALUop=2;
end
if(Opcode==11)
begin
Branch=0;
Regdst=0;
ALUsrc=1;
Regwrite=0;
Memread=0;
Memtoreg=0;
Memwrite=1;
ALUop=2;
end
end
endmodule