-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriscv.v
89 lines (79 loc) · 2.11 KB
/
riscv.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2024/07/04 17:13:46
// Design Name:
// Module Name: riscv
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module riscv(
input clk,rst,
output [31:0]memwdata,memaddra,pc,dest,//dest为实际预测的目标地址 错误与否
output memreadM,memwriteM,error
);
wire [31:0]instr;
wire [13:0]sigs;
wire [4:0]rdE,rdM,rdW,rs1,rs2,opcodeE;
wire hazard,memreadE,regwriteM,regwriteW;
wire [1:0]forwardA,forwardB;
controller controller(
.instr(instr), //regwrite regsrc memread memwrite pc_rs1_sel branch alusrc alucontrol(4)immsel(3) 共14位
.sigs(sigs)
);
datapath datapath(
.clk(clk),
.rst(rst),
.hazard(hazard),
.sigs(sigs),//regwrite regsrc memread memwrite pc_rs1_sel branch alusrc alucontrol(4)immsel(3) 共14位
.forwardA(forwardA),
.forwardB(forwardB),
.instr(instr),
.rd2M(memwdata),
.npc(pc),
.dest(dest),
.error(error),
.aluoutM(memaddra),
.memreadM(memreadM),
.memwriteM(memwriteM),
.memreadE(memreadE),
.opcodeE(opcodeE),
.regwriteM(regwriteM),
.regwriteW(regwriteW),
.rdE(rdE),
.rdM(rdM),
.rdW(rdW),
.rs1(rs1),
.rs2(rs2)
);
Hazard_detect Hazard_detect(
.opcode(instr[6:2]),
.memread(memreadE),
.rd(rdE),
.rs1(instr[19:15]),
.rs2(instr[24:20]),
.hazard(hazard)
);
Forward_detect Forward_detect(
.opcode(opcodeE),
.rdM(rdM),
.rdW(rdW),
.rs1(rs1),
.rs2(rs2),
.regwriteM(regwriteM),
.regwriteW(regwriteW),
.forwardA(forwardA),
.forwardB(forwardB)
);
endmodule