-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor.v
More file actions
36 lines (31 loc) · 1.13 KB
/
Copy pathprocessor.v
File metadata and controls
36 lines (31 loc) · 1.13 KB
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
module riscv_pipelined(input clk,input reset,
output [31:0] PC,
input [31:0] Instr,
output MemWrite,
output [31:0] ALUResult,output [31:0] WriteData,
input [31:0] ReadData_from_data_memory);
// Inputs : clk ,reset , Inctruction , Readata_from_data_memeory
// Outputs : Program counrer , memwrite, alu result , writedata(data to be writt// to memory
//Internal signals :
wire ALUSrc;// alu source values are from imm/reg
wire RegWrite; // asssert to write to reg file
wire Jump; // asserted in b type or jal instructions
wire Zero; // used in b type , if the computed alu result is 0 , then asserted
wire [1:0] ResultSrc; // chooses bw slu output/memory or imm
wire ImmSrc; // imm extraction from instructions
wire [2:0] ALUControl; // 3 bit signal gives exacy operation to be done
// Controller
controller c(Instr[6:0] // Opcode
, Instr[14:12] // funct3
, Instr[30] // funct7
, Zero,// asserted if answer is 0
ResultSrc, MemWrite, PCSrc,
ALUSrc, RegWrite, Jump,
ImmSrc, ALUControl);
// data path:
datapath dp(clk, reset, ResultSrc, PCSrc,
ALUSrc, RegWrite,
ImmSrc, ALUControl,
Zero, PC, Instr,
ALUResult, WriteData, ReadData);
endmodule