mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	More detailed decoding of load/store/branch/jump
This commit is contained in:
		
							parent
							
								
									583b8ed91e
								
							
						
					
					
						commit
						08f1ed8e53
					
				| @ -114,6 +114,8 @@ module controller( | ||||
|   logic        SFenceVmaD;                     // sfence.vma instruction
 | ||||
|   logic        IntDivM;                        // Integer divide instruction
 | ||||
|   logic        IFunctD, RFunctD, MFunctD;      // Detect I, R, and M-type RV32IM/Rv64IM instructions
 | ||||
|   logic        LFunctD, SFunctD, BFunctD;      // Detect load, store, branch instructions
 | ||||
|   logic        JFunctD;                        // detect jalr instruction
 | ||||
| 
 | ||||
|   // Extract fields
 | ||||
|   assign OpD = InstrD[6:0]; | ||||
| @ -135,10 +137,20 @@ module controller( | ||||
|     assign IFunctD     = IShiftD | INoShiftD; | ||||
|     assign RFunctD     = ((Funct3D == 3'b000 | Funct3D == 3'b101) & Funct7b5D) | Funct7ZeroD; | ||||
|     assign MFunctD     = (Funct7D == 7'b0000001) & (`M_SUPPORTED | (`ZMMUL_SUPPORTED & ~Funct3D[2])); // muldiv
 | ||||
|     assign LFunctD     = Funct3D == 3'b000 | Funct3D == 3'b001 | Funct3D == 3'b010 | Funct3D == 3'b100 | Funct3D == 3'b101 |  | ||||
|                          ((`XLEN == 64) & (Funct3D == 3'b011 | Funct3D == 3'b110)); | ||||
|     assign SFunctD     = Funct3D == 3'b000 | Funct3D == 3'b001 | Funct3D == 3'b010 |  | ||||
|                          ((`XLEN == 64) & (Funct3D == 3'b011)); | ||||
|     assign BFunctD     = (Funct3D[2:1] != 2'b01); // legal branches
 | ||||
|     assign JFunctD     = (Funct3D == 3'b000); | ||||
|   end else begin  | ||||
|     assign IFunctD     = 1; // Don't bother to separate out shift decoding
 | ||||
|     assign RFunctD     = ~Funct7D[0]; // Not a multiply
 | ||||
|     assign MFunctD     = Funct7D[0] & (`M_SUPPORTED | (`ZMMUL_SUPPORTED & ~Funct3D[2])); // muldiv
 | ||||
|     assign LFunctD     = 1; // don't bother to check Funct3 for loads
 | ||||
|     assign SFunctD     = 1; // don't bother to check Funct3 for stores
 | ||||
|     assign BFunctD     = 1; // don't bother to check Funct3 for branches
 | ||||
|     assign JFunctD     = 1; // don't bother to check Funct3 for jumps    
 | ||||
|   end | ||||
| 
 | ||||
|   // Main Instruction Decoder
 | ||||
| @ -146,7 +158,10 @@ module controller( | ||||
|     case(OpD) | ||||
|     // RegWrite_ImmSrc_ALUSrc_MemRW_ResultSrc_Branch_ALUOp_Jump_ALUResultSrc_W64_CSRRead_Privileged_Fence_MDU_Atomic_Illegal
 | ||||
|       7'b0000000:     ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Illegal instruction
 | ||||
|       7'b0000011:     ControlsD = `CTRLW'b1_000_01_10_001_0_0_0_0_0_0_0_0_0_00_0; // lw
 | ||||
|       7'b0000011: if (LFunctD)  | ||||
|                       ControlsD = `CTRLW'b1_000_01_10_001_0_0_0_0_0_0_0_0_0_00_0; // loads
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b0000111:     ControlsD = `CTRLW'b0_000_01_10_001_0_0_0_0_0_0_0_0_0_00_1; // flw - only legal if FP supported
 | ||||
|       7'b0001111: if (`ZIFENCEI_SUPPORTED) | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_1_0_00_0; // fence
 | ||||
| @ -161,7 +176,10 @@ module controller( | ||||
|                       ControlsD = `CTRLW'b1_000_01_00_000_0_1_0_0_1_0_0_0_0_00_0; // IW-type ALU for RV64i
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b0100011:     ControlsD = `CTRLW'b0_001_01_01_000_0_0_0_0_0_0_0_0_0_00_0; // sw
 | ||||
|       7'b0100011: if (SFunctD)  | ||||
|                       ControlsD = `CTRLW'b0_001_01_01_000_0_0_0_0_0_0_0_0_0_00_0; // stores
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b0100111:     ControlsD = `CTRLW'b0_001_01_01_000_0_0_0_0_0_0_0_0_0_00_1; // fsw - only legal if FP supported
 | ||||
|       7'b0101111: if (`A_SUPPORTED) begin | ||||
|                     if (InstrD[31:27] == 5'b00010) | ||||
| @ -185,8 +203,14 @@ module controller( | ||||
|                       ControlsD = `CTRLW'b1_000_00_00_011_0_0_0_0_1_0_0_0_1_00_0; // W-type Multiply/Divide
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b1100011:     ControlsD = `CTRLW'b0_010_11_00_000_1_0_0_0_0_0_0_0_0_00_0; // branches
 | ||||
|       7'b1100111:     ControlsD = `CTRLW'b1_000_01_00_000_0_0_1_1_0_0_0_0_0_00_0; // jalr
 | ||||
|       7'b1100011: if (BFunctD)    | ||||
|                       ControlsD = `CTRLW'b0_010_11_00_000_1_0_0_0_0_0_0_0_0_00_0; // branches
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b1100111: if (JFunctD) | ||||
|                       ControlsD = `CTRLW'b1_000_01_00_000_0_0_1_1_0_0_0_0_0_00_0; // jalr
 | ||||
|                   else | ||||
|                       ControlsD = `CTRLW'b0_000_00_00_000_0_0_0_0_0_0_0_0_0_00_1; // Non-implemented instruction
 | ||||
|       7'b1101111:     ControlsD = `CTRLW'b1_011_11_00_000_0_0_1_1_0_0_0_0_0_00_0; // jal
 | ||||
|       7'b1110011: if (`ZICSR_SUPPORTED) begin | ||||
|                    if (Funct3D == 3'b000) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user