-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatapath_fake.sv
65 lines (49 loc) · 1.26 KB
/
datapath_fake.sv
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
module datapath_fake (
input [2:0] num_write0_in,
input [2:0] num_write1_in,
input write0,
input write1,
input [15:0] data_write0_in,
input [15:0] data_write1_in,
//input rst, //Consider this later
input clk
);
regfile_fake REGFILE(
.num_write0_in(num_write0_in),
.num_write1_in(num_write1_in),
.write0(write0),
.write1(write1),
.data_write0_in(data_write0_in),
.data_write1_in(data_write1_in),
.clk(clk)
);
endmodule
module regfile_fake (
input [2:0] num_write0_in,
input [2:0] num_write1_in,
input write0,
input write1,
input [15:0] data_write0_in,
input [15:0] data_write1_in,
//input rst, //Consider this later
input clk
);
reg [15:0] regs [7:0];
wire [15:0] R0,R1,R2,R3,R4,R5,R6,R7;//to be recognized by the autograder
assign R0=regs[0];
assign R1=regs[1];
assign R2=regs[2];
assign R3=regs[3];
assign R4=regs[4];
assign R5=regs[5];
assign R6=regs[6];
assign R7=regs[7];
always @(posedge clk) begin
if (write0) begin
regs[num_write0_in]=data_write0_in;
end
if (write1) begin
regs[num_write1_in]=data_write1_in;
end
end
endmodule