#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <deque>

#define MEM_SIZE (1<<20)
#define CACHE_SIZE (1<<8)
#define DATA_SIZE (1<<8) 

using namespace std;

int main() {
	// Variables used
	int dir, cmd, op;
	unsigned char dat, wait;

	// Plant the seed
	srand(time(0));

	// Infinit Loop
	while(true){
		// Each command is 32 bits,
		// 19...0 bits for dir,
		// 27...20 bits for data
		// 28 bit indicates operation type 1:read 0:write 
		cmd = rand();
		dir = cmd & 0xFFFFF;
		dat = (cmd & 0xF00000)>>20;
		op = (cmd>>28)&1;
		printf("op=%c on dir(0x%x) data:%d\n","wr"[op],dir,dat);
		wait = getchar();
	}
	return 0;
}
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <deque>

#define MEM_SIZE (1<<20)
#define CACHE_SIZE (1<<8)

using namespace std;

enum{
	read,
	write
};

int main() {
	// Variables used
	int dir, cmd, op;
	unsigned char dat, wait;

	// Memory simulated
	unsigned char rawMemory[MEM_SIZE];
	int cacheDirection[CACHE_SIZE];
	unsigned char cacheData[CACHE_SIZE];

	// To simulate the circular queue
	int front = 0, tail = 0;

	// Initialize the cached Directions
	memset(cacheDirection, -1, sizeof cacheDirection);

	// Plant the seed
	srand(time(0));

	// Infinit Loop
	while(true){
		// Each command is 32 bits,
		cmd = rand();
		// 19...0 bits for dir
		dir = ((cmd)&(0xFFFFF));
		// 27...20 bits for data
		dat = (((cmd)&(0xF00000))>>20);
		// 28 bit indicates operation type 0:read 1:write
		op  = ((cmd>>28)&(1));
		
		//Perform operation according
		if(op == read) {
			
		} else { // write

		}

		wait = getchar();
	}
	return 0;
}
Add memory declaration, and refactor comments
Add memory declaration, and refactor comments

Signed-off-by: Ulises Mendez Martinez <64c66da2351c01d4afecd1591810410a1c01865c@gmail.com>
