Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ifu cache update #769

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
28f3f69
adding test file
muhammad3mar Nov 2, 2024
88ba556
initializing files
abdkeb Dec 9, 2024
17994bf
Merge branch 'ifu_cache' of https://github.com/amichai-bd/fpga_mafia …
muhammad3mar Dec 9, 2024
e4dc181
Merge branch 'ifu_cache' of https://github.com/amichai-bd/fpga_mafia …
muhammad3mar Dec 9, 2024
8212f20
initail cach design
Abdullahkeblawi Dec 9, 2024
4e8aca5
Merge branch 'ifu_cache' of https://github.com/amichai-bd/fpga_mafia …
muhammad3mar Dec 11, 2024
a832289
test
muhammad3mar Dec 11, 2024
569bdac
test
muhammad3mar Dec 11, 2024
f9c1583
cache update
abdkeb Dec 11, 2024
48c8557
ifu_cache_tb1
muhammad3mar Dec 11, 2024
dc2464a
comiling module and test bench
abdkeb Dec 11, 2024
85a9ce5
updating file lists
abdkeb Dec 14, 2024
df6f352
remove uneccessary unnecessary dir's and syntax errors
roman012285 Dec 14, 2024
ff8641a
ifu_cache compilation success
abdkeb Dec 14, 2024
2a6c332
Merge branch 'ifu_cache' of https://github.com/amichai-bd/fpga_mafia …
abdkeb Dec 14, 2024
a54ec6c
simulation mini success
Abdullahkeblawi Dec 15, 2024
a596d79
adding the PLRU algorithim to the cache
muhammad3mar Dec 16, 2024
6889e37
fixing LRU cmpilation
Abdullahkeblawi Dec 20, 2024
bbe5ddb
converting cache to always_comb + new tb
abdkeb Dec 21, 2024
f426719
inserting the new cache with with always_comb
abdkeb Dec 21, 2024
f090227
fixing some width issues
abdkeb Dec 21, 2024
7081f51
changing the implementation of the getPLRUIndex
muhammad3mar Dec 24, 2024
4335684
this is the updated files, it was a mistake in the
muhammad3mar Dec 24, 2024
1325bc8
compiation, FFed arrays
abdkeb Dec 24, 2024
c8dfa10
update ifu arrays
abdkeb Dec 26, 2024
cf674b9
running plru tb
muhammad3mar Dec 26, 2024
9fbbb75
submodule problem
muhammad3mar Dec 26, 2024
5624ae6
submodules problem fixed
muhammad3mar Dec 26, 2024
50bfc64
adding debug signals and updating the testbench
muhammad3mar Dec 27, 2024
028dd91
PLRU simple test 1-3 working, 4 not working
abdkeb Dec 27, 2024
39e0560
merge the two submodules into the big module
muhammad3mar Dec 30, 2024
cd54d7a
Initialization the IFU unit interface.
muhammad3mar Jan 2, 2025
630df38
plru testing for cache
Abdullahkeblawi Jan 4, 2025
feea367
plru testing for cache
Abdullahkeblawi Jan 4, 2025
d679136
added Prefetcher and IFU top basic logic, changed interface, changed …
Abdullahkeblawi Jan 13, 2025
5658c23
adding state machine to prefetcher + test bench + adjusting interface…
Abdullahkeblawi Jan 25, 2025
6ef3c25
implementation of IDU and testbench
muhammad3mar Jan 29, 2025
26814d9
fixing ompilation IDu
Abdullahkeblawi Feb 1, 2025
deda30b
updating the IDU testbench to cover more cases
muhammad3mar Feb 1, 2025
d596a2f
initializing mini_core_di
Abdullahkeblawi Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions source/IDU/IDU.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module idu (
input logic [31:0] instr1,
input logic [31:0] instr2,
output logic [31:0] issue_instr1, // Instruction for primary issue
output logic [31:0] issue_instr2 // Instruction for secondary issue
);

// Dependency Flags
logic raw_dependency; // Read-After-Write (RAW)
logic waw_dependency; // Write-After-Write (WAW)
logic branch_instr; // Branch detection
logic mem_access_instr1; // Memory access detection for instr1
logic mem_access_instr2; // Memory access detection for instr2



logic [6:0] opcode1, opcode2; // Opcode fields for instr1 and instr2
logic [4:0] rd1, rs1_1, rs2_1; // Fields for instr1
logic [4:0] rd2, rs1_2, rs2_2; // Fields for instr2

assign opcode1 = instr1[6:0];
assign opcode2 = instr2[6:0];

assign rd1 = instr1[11:7];
assign rs1_1 = instr1[19:15];
assign rs2_1 = instr1[24:20];

assign rd2 = instr2[11:7];
assign rs1_2 = instr2[19:15];
assign rs2_2 = instr2[24:20];


assign raw_dependency = (rs1_2 == rd1) || (rs2_2 == rd1);

assign waw_dependency = (rd1 == rd2) && (rd1 != 5'b0);

// Branch Detection
assign branch_instr = (opcode1 == 7'b1100011);

// Memory Access Detection
assign mem_access_instr1 = (opcode1 == 7'b0000011) || // Load instructions
(opcode1 == 7'b0100011); // Store instructions

assign mem_access_instr2 = (opcode2 == 7'b0000011) || // Load instructions
(opcode2 == 7'b0100011); // Store instructions




always_comb begin
// Default assignments
issue_instr1 = instr1;
issue_instr2 = instr2;

// Ensure memory access in primary issue
if (mem_access_instr2 && mem_access_instr1 == 0) begin
issue_instr1 = instr2;
issue_instr2 = instr1;
end

// Stall the second pipe if there are dependencies, branch, or memory access
if (raw_dependency || waw_dependency || branch_instr || mem_access_instr2) begin
issue_instr2 = 32'b0;
end
end

endmodule
5 changes: 5 additions & 0 deletions source/IDU/IDU_rtl_list.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

+incdir+../../../source/common/

//RTL FIle
../../../source/idu/idu.sv
137 changes: 137 additions & 0 deletions source/ifu/ifu.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
`include "macros.vh"

module ifu
import ifu_pkg::*;
(
// Chip Signals
input logic Clock,
input logic Rst,

// CPU Interface
input logic [ADDR_WIDTH-1:0] cpu_reqAddrIn, // Address requested by the CPU
output logic [ADDR_WIDTH-1:0] cpu_rspAddrOut, // Address of the line in the response to CPU
output logic [LINE_WIDTH-1:0] cpu_rspInsLineOut, // Instruction line in the response to CPU
output logic cpu_rspInsLineValidOut, // Indicates if the response is valid

// Memory Interface
input logic [TAG_WIDTH-1:0] mem_rspTagIn, // Tag of the line provided by memory
input logic [LINE_WIDTH-1:0] mem_rspInsLineIn, // Line data provided by memory
input logic mem_rspInsLineValidIn, // Valid signal for memory response
output logic [ADDR_WIDTH-1:0] mem_reqTagOut, // Indicates if memory is ready for requests
output logic mem_reqTagValidOut // Indicates if a memory request is valid
);


///////////////////
// Logic Defines //
///////////////////
// data insertion
logic insertionOnMiss;
logic insertionOnPrefetch;
logic p_reqSent;

// cache signals
logic [TAG_WIDTH - 1: 0] c_mem_reqTagOut;
logic c_mem_reqTagValidOut;

// prefetcher signals
logic [TAG_WIDTH - 1: 0] p_mem_reqTagOut;
logic p_mem_reqTagValidOut;

// cache <-> prefetcher
logic c2p_rspTagValid;
logic c2p_rspTagStatus;
logic [TAG_WIDTH - 1: 0] c2p_rspTag;
logic p2c_reqTagValid;
logic [TAG_WIDTH - 1: 0] p2c_reqTag;

///////////
// Cache //
///////////
ifu_cache ifu_cache (
.Clock(Clock), // Input
.Rst(Rst), // Input

// Prefetcher Interface
.pref_reqTagValidIn(p2c_reqTag), // Input
.pref_reqTagIn(p2c_reqTagValid), // Input
.pref_rspTagValidOut(c2p_rspTagValid), // Output
.pref_rspTagStatusOut(c2p_rspTagStatus), // Output
.pref_rspTagOut(p2c_reqTag), // Output

// CPU Interface
.cpu_reqAddrIn(cpu_reqAddrIn), // Input
.cpu_rspAddrOut(cpu_rspAddrOut), // Output
.cpu_rspInsLineOut(cpu_rspInsLineOut), // Output
.cpu_rspInsLineValidOut(cpu_rspInsLineValidOut), // Output

// Memory Interface
.mem_rspTagIn(mem_rspTagIn), // Input
.mem_rspInsLineIn(mem_rspInsLineIn), // Input
.mem_rspInsLineValidIn(mem_rspInsLineValidIn), // Input
.mem_reqTagOut(c_mem_reqTagOut), // Output
.mem_reqTagValidOut(c_mem_reqTagValidOut) // Output
);

////////////////
// Prefetcher //
////////////////
ifu_prefetcher ifu_prefetcher (
.Clock(Clock), // Input
.Rst(Rst), // Input

// Cache Interface
.cache_rspTagValidIn(c2p_rspTagValid), // input
.cache_rspTagStatusIn(c2p_rspTagStatus), // input
.cache_rspTagIn(c2p_rspTag), // input
.cache_reqTagValidOut(p2c_reqTagValid), // Output
.cache_reqTagOut(p2c_reqTag), // Output

// IFU signals
.ifu_prefReqSent(p_reqSent), // Input

// CPU Interface
.cpu_reqAddrIn(cpu_reqAddrIn), // Input

// Memory Interface
.mem_rspTagIn(mem_rspTagIn), // input
.mem_rspInsLineValidIn(mem_rspInsLineValidIn), // input
.mem_reqTagOut(p_mem_reqTagOut), // Output
.mem_reqTagValidOut(p_mem_reqTagValidOut) // Output
);


/////////////
// Assigns //
/////////////
assign insertionOnMiss = (c_mem_reqTagValidOut == VALID) && (mem_rspInsLineValidIn == VALID) && (c_mem_reqTagOut == mem_rspTagIn);
assign insertionOnPrefetch = (mem_rspInsLineValidIn == VALID) && (p_mem_reqTagValidOut == !VALID) && !insertionOnMiss;


///////////////////////////
// Always Comb Statement //
///////////////////////////
always_comb begin

if (insertionOnMiss) begin
mem_reqTagOut = c_mem_reqTagOut;
end

if (insertionOnPrefetch) begin
mem_reqTagOut = p_mem_reqTagOut;
p_reqSent = VALID;
end

if (insertionOnMiss || insertionOnPrefetch) begin
mem_reqTagValidOut = VALID;
end

end

///////////////////////////
// Always_FF Statement //
///////////////////////////


endmodule

Loading