-
Notifications
You must be signed in to change notification settings - Fork 0
/
risky_risc.v
54 lines (49 loc) · 1.27 KB
/
risky_risc.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
module risky_risc(
input rst, clk,
output reg succ
);
wire [23:0] instrw;
wire [15:0] aluoutxw, aluoutaw;
wire cb, done;
reg [2:0] addr;
reg cin, en;
reg [15:0] aluoutx, aluouta;
reg [23:0] instr;
blk_mem_gen_0 inputX (
.clka(clk), // input wire clka
.ena(en), // input wire ena
.addra(addr), // input wire [2 : 0] addra
.douta(instrw) // output wire [23 : 0] douta
);
s3rb RISC(//input
.opcode(instr[23:20]),
.operand1(instr[19:16]),
.operand2(instr[15:0]),
.rst(rst), .clk(clk),
.cin(cin),
//output
.aluout(aluoutaw),
.cb(cb), .done(done)
);
blk_mem_gen_1 outputX (
.clka(clk), // input wire clka
.ena(en), // input wire ena
.addra(addr), // input wire [2 : 0] addra
.douta(aluoutxw) // output wire [15 : 0] douta
);
always @ (posedge clk) begin
if (rst) begin
addr <= 0;
succ <= 0;
en <= 1;
cin <= 0;
end
else begin
instr <= instrw;
if (done) begin
addr <= addr + 1;
succ <= (aluoutxw == aluoutaw);
end
end
end
endmodule