Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write and executes C programming code(use code-block ) for adding Jal (jump and link) & Jalr instructions to the Single cycle processor, as i put

Write and executes C programming code(use code-block ) for adding Jal (jump and link) & Jalr instructions to the Single cycle processor, as i put source code down below . these are the Screenshots because i cant put long all code in text.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

> maincode 0 0 C maincode) No Selection 1 #include 2 #include 3 #include 4 5 // Main_Decoder 6 int8_t ImmSrc = @ 7 uint8_t Merwrite = 8; Buint8_t Regwrite = ; 9 uintet ALUDP = @; 10 uint8_t ALUSrc = B; 11 uint8_t ResultSrc = @; 12 13 //PC IO 14 uint32_t PCNext = 0; //IN 15 uint32_t PC = 0; //OUT 16 uint32_t PCPlus 4 = ; B 17 18 //Instr_Memory IO 19 uint32_t Instr_Memory[18] = {BxFFC4A383, 8x08644423, @x8862E233, OxFE420AE3, B, B, , , a, a); 20 uint32_t Instr_Memory_A = @; //IN 21 uint32_t Instr_Memory_RD = @; //OUT 22 23 //Instr_Memory IO 24 uint32_t Instr = ; 25 uint32_t Instr_19_15 = ; 26 //uint32_t Instr_31_20 = 0; 27 uint32_t Instr_11_7 = ; 28 uint32_t Instr_24_20 = @ @; 29 uint32_t Instr_6_0 = 0; 30 31 32 //Register Fille 10 32 uint32_t X[32]; //Registers 34 uint8_t Reg_File_A1 = ; //IN 35 uint8_t Reg_Filc_A2 = ; //IN 36 uint8_t Reg_File_A3 = m; //IN 37 uint32_t Reg_File_RD1 = @; //OUT 38 uint32_t Reg_File_RD2 - //OUT 39 uint32_t Reg_File_WD3 = @; //IN 40 uint8_t Reg_File_Ex3 = @ //IN 41 42 //Extend IO 43 int32_t ImmExt = B; 44 uint32_t PCTarget 45 uint8_t PCSTC 46 uint8_t branch = ; 47 48 // ALU the pa'y **7*** = 0; Line: 1 Col: 1 0 0 i Caincode 0 0 O maincode) No Selection printf("Main_Decoder_Prosses iwinir"); ImnSrc = ; Menwrite = @; Regwrite = 1; ALUOp = 0; ALUSrc = 1; ResultSrc = 1; branche: break; case 35: // sw printf("Main_Decoder_Prosses sw "); ImnSrc 1; Merite 1; Regwrite = @ ALUOp = @: ALUSEO = 1; branch = ; ResultSrc = @; HB 89 90 91 92 93 94 96 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 120 131 132 133 134 135 break; case 51: //R-type printf("Main_Decoder_Prosses R-type "); ImSrc = 0; Menwrite - Regwrite = 1; ALUOp = 2; ALUSRC = ; branch = ; ResultSrc = @; break; case 99: // beq printf("Main_Decoder_Prosses beqnr"); ImSrc = 2; Meninrite = @; Regwrite = ; ALUOp = 1; ALUSrc = ; branch = 1; ResultSrc = @ break; default: ImSrc = ; Menwrite = @; Regwrite = ; Line: 1 Col: 1 C maincode 0 0 C maincode) No Selection 129 ResultSrc = @: 130 131 break; 132 default: 133 Im Src = 0; 134 Netwrite = @ 135 Regwrite = @ 136 ALUOP = @ 137 ALUSEO = 0; 138 branch = 0; 139 Resultsrc = @; 140 141 142 143 printf("Main_Decoder_Prosses ImmSrc = %d \/", ImSrc); 144 printf("Main_Decoder_Prosses Menwrite = %d ", Menwrite); 145 printf("Nain_Decoder_Prosses RegWrite = %d ", Regwrite); 146 printf("Main_Decoder_Prosses ALUDP = %d ", ALUOp); 147 printf("Main_Decoder_Prosses ALUSTC = %d ", ALUSTC); 148 printf("Main_Docoder Prosses ResultSrc = %d ", ResultSrc); 149 printf("Main_Decoder_Prosses branch = %d ", branch); 150 151 } 152 163 void Extend Prosses (void) 154 ( 156 printf(" Extend_Prosses ***** "); 156 uint32_t Data = @; 157 uint32_t Data_11 = Get_Bits(Instr,7,7); //a label can only be part of a statement and a 158 //declaration is not a statement 159 uint32_t Data_4_1 = Get_Bits(Instr,11,8); 160 uint32_t Data_10_5 = Get_Bits(Instr, 30,25); 161 uint32_t Data_12 - Get_Bits(Instr, 31, 31); 162 163 164 switch(ImmSrc) 165 { 166 case @: 167 Data = Get_Bits(Instr, 31, 20); 168 break; 169 case 1: 170 Data = Get_Bits(Instr, 31, 24); 171 Data Data maincode 00.62.40 0 0 O maincode 00.52.40 ) No Selection case 2: printf("ALU_Decoder_PrOSSOS ALVOP 2 "); switchl_funct3) { case : printf("ALU_Decoder_Prosses _funct3 = @ln "); switch(_op_5_funct7_5) { case : case 1: case 2: break; case 3: break; default: break; } case 2: printf("ALU_Decoder_Prosses funct3 = 2 "); 218 219 220 221 222 223 224 226 226 227 228 229 230 231 232 233 234 236 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 267 258 259 260 261 262 263 264 265 break; case 6: printf("ALU_Decoder_Prosses _funct3 = 6 "); ALUControl2 = 3; break; case 7: printf("_Decoder_Prosses _funct3 = 7 "); = r" J.J. Hell olunda dy ditul break; default: printf("ALU_Decoder_Prosses _funct3 = ERROR "); break; } break; default: printf("ALU_Decoder_Prosses ERROR "); break; printf("ALU_Decoder_ProssBS ALUControl2 = %d ", ALUControl2); Line: 1 Col: 1 maincode 00.62.40 0 0 C maincode 00.52.40 ) No Selection 260 break; 261 } 262 263 printf("ALU_Decoder_Prosses ALUControl2 = %d \I", ALUControl2); 264 265 266 267 268 int main() 269 270 // 271 printf("RISC-V RV321 SOFT CORE "); 272 Print_Instr_Memory(); 273 274 printf("Clean Register File "); 275 for (uint32_t i = B; i C maincode 00.62.40 0 0 C maincode 00.52.40 ) No Selection ALU_Decoder_Prosses(); Register_File_Prosses(); Extend_Prosses(); PCTarget - ImmExt + PC; printf("#$#************PCTarget: @xxax ",PCTarget); if(ALUSIC == ) { srl = Reg_File_RD2; } else{ srB = InmExt; SIA = Reg_File_RD1; //ALUControl2 = ; ALU_Prosses(); 305 306 307 308 309 310 311 312 313 314 315 316 313 318 319 320 321 322 323 324 325 226 327 32A 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 = %d ", PCSrc); PCSrc = zero & branch; printf("#*********PCSTC //--- Data_Memory_A = ALUResult; Data_Memory_WD - Rog_File_RD2;// Data_Memory_WE = MemWrite; Data_Mentory_Prosses(); if(ResultSrc == %) { Reg_File_WD3 = ALUResult; } else{ Reg_File_WD3 - Data_Memory_RD; } //Reg_File_ND3 = Data_Memory_RD; Reg_File_EWS = Regwrite; //--- PCPlus4 = PC + 4; if(PCSrc == 1) { Line: 1 Col: 1 maincode 00.62.40 0 0 C maincode 00.52.40 ) No Selection 350 PCPlus4 - PC + 4; 351 if(PCSrc == 1) 352 { 353 PCNext = PCTarget; 354 } 355 else{ 356 PCNext = PCPlus4; 357 } ] 358 printf("##############PCNext: @c88x \I", PCNext); 359 360 361 362 the CLK waiting area 363 364 365 Register_File_CLK(); 366 Data_Menory_CLK(); 367 PC_CLKD); 368 } } 369 return 0; 370 } 371 372 void Print_Instr_Memory(void) 373 374 printf(" Instruction Memory Content: "); 375 for (uint32_t i = 0; i C maincode 00.62.40 C 0 0 C maincode 00.52.40 ) No Selection 396 { 397 printf(" PC_CLK ***** ", Data_Mentory_A); 398 PC = PCNext; 399 printf("PC = @xxBx ", PCNext); 400 } 401 void Register_File_CLK(void) 402 { 403 printf(" \Register_File_CLK ***** ", Reg_File_EN3); 404 printf("Register_File Ew3 = %d \I", Reg_File_EWS); 405 printf("Register_File A3 = %d ", Reg_File_A3); 406 printf("Register_File Wo3 = %d ", Reg_File_wD3); 407 if(Reg_File_EW3==1) 408 { 409 X[Reg_File_A3] = Reg_File_WD3 i 410 Print_Register_File(); 411 } 412} 414 415 void Data_Memory_Prosses(void) ( 416 413 printf(" Data_Memory_Prosses ***** ", Data_Memory_A); 418 printf("Data_Memory A = BxXx ", Data_Memory_A); 419 Data_Memory_RD = Data_Memory[Data_Memory_A); 420 printf("Data_Memory RD = $x*x (%d) ", Data_Memory_RD, Data_Memory_RD); "x x)\, ; 421 } 422 423 424 void ALU_Prosses() 425 { 426 printf(" \IALU_Prosses ***** '); 427 switch( ALUControl2 ) 428 C ( 429 case : 430 ALUResult = SrA + srB; 431 break; 432 case 1: 433 ALUResult = SIA - srB; 434 break; 435 case 3: 436 ALUResult SIA srB; 437 break; 438 default: 439 ALUResult = @; 440 } 441 if(ALUResult == @) 442 443 zero = 1: hilanlara... wewe il modulo ditu adalom el delito delle An Line: 1 Col: 1 > C maincode 00.52.40 0 C maincode 00.52.40 ) No Selection 439 ALUKE SUITE 440 } 441 if(ALUResult == @) 442 { C 443 zero = 1; } 445 else{ 446 zero = 6; J... 448 printf("STA = Oxxx ", SIA) 450 printf("SrB = Bxxx ", SIB); 451 printf("ALUControl2 = @xxx \I", ALUControl2); 452 printf("ALUResult = 8xXx(%d) \1", ALUResult, ALUResult); 453 printf("zero = Bxx ', zero); 454 455 } 456 457 458 void Register_Filc_Prosses (void) 459 { 460 printf(" Register_File_Prosses ***** "); 461 printf("Register_File A1 = Xd ", Instr_19_15); 462 Reg_File_RD1 = X[Instr_19_15); 463 Reg_File_RD2 = X[Instr_24_20]; 464 printf("Register_File R01 = Bxx ", Reg_file_R01); 465 printf("Register_File RD2 = Excx ", Reg_File_RO2); 466 467 Reg_File_A3 = Instr_11_7; 468 printf("Register_File A3 = \d ", Reg_File_43); 469} 470 471 472 473 uint32_t Get_Bits(uint32_t data, uint8_t bi, uint8_t b2) 474 475 uint8_t bc = (b1+1)-62; 476 uint32_t b_mask = B; 477 for (uinta_t i = 0; i >>b2; 482 printf("BITS[Xd:%d] IS = Oxxx ", b1,b2, data); 483 return data; 484 } 485 486 void Instr_Memory_Prosses (void) Line: 1 Col: 1 maincode 00.52.40 0 0 C maincode 00.52.40 ) No Selection 461 printf("Register_File A1 = \d ", Instr_19_15); 462 Reg_File_R01 - X[Instr_19_15); 463 Reg_File_RD2 = X[Instr_24_20]; 464 printf("Register_File RD1 = xx ", Reg_File_R01); 465 printf("Register_File RD2 = xx ", Reg_File_RD2); 466 467 Reg_file_A3 = Instr_11_7; 468 printf("Register_File A3 = \d ", Reg_File_A3); 469} 470 471 472 473 uint32_t Get_Bits(uint32_t data, uint8_t bi, uint8_t b2] 474 475 uint8_t be = (b141)-62; 476 uint32_t b_mask = B; 477 for (uint8_t i = 0; i >>b2; 482 printf("BITS[Xd:%d] IS = Bx%x inkr", b1,b2, data); 483 return data; 484 } 485 486 void Instr_Memory_Prosses (void) 487 { 488 printf(" Instr_Memory_Prosses ***** "); 489 Instr_Memory_A = PC >> 2; 490 Instr_Memory_RD = Instr_Memory[Instr_Memory_A); 491 printf("Instr_Memory_RD @x%8x ", Instr_Menory_RD); 492 } 493 495 496 void Print_Register_File(void) 497 { 498 printf(" \Register_File Content: "); 499 uint32_t A,B,C,D; 500 for (uint32_t I = B; I

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

2. What are the two main functions of the financial system? LOP8

Answered: 1 week ago