<commit_before>/* CIS 314 Big Project, Week 2 Fall 2015
 *
 *  Authors:
 *      <NAME>, <NAME>, and <NAME>
 *
 *  Date:
 *      11/19/2015
 *      
 *  Sources:
 *      CIS 314 on canvas.uoregon.edu
 *      https://www.cs.uoregon.edu/Classes/15F/cis314/
 *      StackOverFlow.com
 *      
 *  Assignment:
 *      Week 1:
 *      Single cycle processor simulation in C: implement (a) a register file, (b) an ALU
 *      (c) control logic, and (d) main memory.
 *
 *      Week 2: (WE ARE HERE!)
 *      Convert the single cycle processor into a pipelined 5-stage processor.
 *
 *      Week 3:
 *      Build a direct-mapped cache structure between the main memory and the 5-stage
 *      processor.
 *  
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>
#include <pthread.h>
#define NUM_THREADS	5

static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static char RegisterFileNames[32][6] = {"$zero", "$at", "$v0", "$v1", "$a0", "$a1", "$a2", "$a3", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", "$t8", "$t9", "$k0", "$k1", "$gp", "$sp", "$fp", "$ra"};
static char RegisterNumberNames[32][4] = {"$0", "$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"};
static char RegistersInUse[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static char RegAccess[2] = {0,0};
static int LOCK = 0;


static int data_memory[1024]; // int values
static char* instructions[1024]; // instructions
static int controlRegisterZ[1024]; // Control RegisterZ

struct cache { // cache for the program
	int is_valid;
	int address_tag;
	int index;
	int cacheLine[16];
};

static char* jump_names[128]; // jump location names and addresses
static int jump_locations[128];<commit_msg>Add Cache array, rename struct to cache_line<commit_after>/* CIS 314 Big Project, Week 2 Fall 2015
 *
 *  Authors:
 *      <NAME>, <NAME>, and <NAME>
 *
 *  Date:
 *      11/19/2015
 *      
 *  Sources:
 *      CIS 314 on canvas.uoregon.edu
 *      https://www.cs.uoregon.edu/Classes/15F/cis314/
 *      StackOverFlow.com
 *      
 *  Assignment:
 *      Week 1:
 *      Single cycle processor simulation in C: implement (a) a register file, (b) an ALU
 *      (c) control logic, and (d) main memory.
 *
 *      Week 2: (WE ARE HERE!)
 *      Convert the single cycle processor into a pipelined 5-stage processor.
 *
 *      Week 3:
 *      Build a direct-mapped cache structure between the main memory and the 5-stage
 *      processor.
 *  
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <limits.h>
#include <pthread.h>
#define NUM_THREADS	5

static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static char RegisterFileNames[32][6] = {"$zero", "$at", "$v0", "$v1", "$a0", "$a1", "$a2", "$a3", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", "$t8", "$t9", "$k0", "$k1", "$gp", "$sp", "$fp", "$ra"};
static char RegisterNumberNames[32][4] = {"$0", "$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"};
static char RegistersInUse[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static char RegAccess[2] = {0,0};
static int LOCK = 0;


static int data_memory[1024]; // int values
static char* instructions[1024]; // instructions
static int controlRegisterZ[1024]; // Control RegisterZ

struct cache_line { // cache for the program
	int is_valid;
	int address_tag;
	int index;
	int cacheLine[16];
};

static struct cache_line cache[16];

static char* jump_names[128]; // jump location names and addresses
static int jump_locations[128];
{'fraction_non_alphanumeric': 0.23763313609467457, 'fraction_numerical': 0.09893491124260355, 'mean_word_length': 3.383817427385892, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '45405', 'n_tokens_mistral': 1939, 'n_tokens_neox': 1654, 'n_words': 565}