-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathforDatapath.v
executable file
·136 lines (126 loc) · 2.42 KB
/
forDatapath.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:11:29 06/08/2015
// Design Name: Datapath
// Module Name: C:/Users/Apple/Desktop/Project3/project3.1/forDatapath.v
// Project Name: project3
// Target Device:
// Tool versions:
// Description:
//
// Verilog Test Fixture created by ISE for module: Datapath
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
module forDatapath;
// Inputs
reg clk;
reg reset;
reg [1:0] PCSource;
reg lorD;
reg [2:0] ALU_Control;
reg ALUSrcA;
reg RegWrite;
reg [1:0] RegDst;
reg IRWrite;
reg [31:0] Data_in;
reg [1:0] MemtoReg;
reg MIO_ready;
reg [1:0] ALUSrcB;
reg PCWrite;
reg PCWriteCond;
reg Branch;
reg S;
// Outputs
wire [31:0] PC_Current;
wire [31:0] M_addr;
wire [31:0] Data_out;
wire overflow;
wire zero;
wire [31:0] inst;
// Instantiate the Unit Under Test (UUT)
Datapath uut (
.clk(clk),
.rst(reset),
.PCSource(PCSource),
.lorD(lorD),
.ALU_Control(ALU_Control),
.ALUSrcA(ALUSrcA),
.RegWrite(RegWrite),
.RegDst(RegDst),
.IRWrite(IRWrite),
.Data_in(Data_in),
.MemtoReg(MemtoReg),
.MIO_ready(MIO_ready),
.ALUSrcB(ALUSrcB),
.PCWrite(PCWrite),
.PCWriteCond(PCWriteCond),
.Branch(Branch),
.S(S),
.PC_Current(PC_Current),
.M_addr(M_addr),
.Data_out(Data_out),
.overflow(overflow),
.zero(zero),
.inst(inst)
);
initial begin
// Initialize Inputs
clk = 0;
reset = 0;
PCSource = 0;
lorD = 0;
ALU_Control = 0;
ALUSrcA = 0;
RegWrite = 0;
RegDst = 0;
IRWrite = 0;
Data_in = 0;
MemtoReg = 0;
MIO_ready = 0;
ALUSrcB = 0;
PCWrite = 0;
PCWriteCond = 0;
Branch = 0;
S = 0;
// Wait 100 ns for global reset to finish
#100;
reset=1;
#100;
reset=0;
#100;
Data_in=32'b00100000000010011111111111111111;
//addi $t1,$zero,-1; //$t1=ffffffff;
#100;
clk=1;
#100;
IRWrite = 1'b1;
PCWrite = 1'b1;
ALUSrcB=2'b10;
lorD = 1'b1;
ALUSrcA=1;
clk = 0;
#100;
clk=1;
#100;
ALU_Control=3'b010;
clk = 0;
#100;
clk=1;
#100;
clk = 0;
#100;
clk=1;
#100;
clk = 0;
// Add stimulus here
end
endmodule