MESSAGE
DATE | 2014-11-30 |
FROM | Ruben Safir
|
SUBJECT | Subject: [LIU Comp Sci] Cache Model in C programming
|
From owner-learn-outgoing-at-mrbrklyn.com Sun Nov 30 22:41:17 2014 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix) id B8FE6161170; Sun, 30 Nov 2014 22:41:17 -0500 (EST) Delivered-To: learn-outgoing-at-mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 28) id A1CEA16118F; Sun, 30 Nov 2014 22:41:17 -0500 (EST) Delivered-To: learn-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by mrbrklyn.com (Postfix) with ESMTP id 8AA33161170 for ; Sun, 30 Nov 2014 22:41:16 -0500 (EST) Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id C920F13F54 for ; Sun, 30 Nov 2014 22:41:14 -0500 (EST) Received: by panix2.panix.com (Postfix, from userid 20529) id 948D633CC4; Sun, 30 Nov 2014 22:41:14 -0500 (EST) Date: Sun, 30 Nov 2014 22:41:14 -0500 From: Ruben Safir To: learn-at-nylxs.com Subject: [LIU Comp Sci] Cache Model in C programming Message-ID: <20141201034114.GA8443-at-panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: owner-learn-at-mrbrklyn.com Precedence: bulk Reply-To: learn-at-mrbrklyn.com
This is the out line in C of the direct memory in the C programming langauge. The trick is, or course, to now fill out the binary reads inside the structures, which is not easy. C is a BYTE centered langauge.
It will take to create masks of the unisigned chars with a bitwise AND mask?
For example, the offset is the last 3 bits so
0000 0000 0000 0111 is a mask for the last 3 bits?
Ruben
/* * ===================================================================================== * * Filename: cach.c * * Description: Memory Caching Model * * Version: 1.0 * Created: 11/30/2014 09:15:53 PM * Revision: none * Compiler: gcc * * Author: Ruben Safir (), ruben-at-mrbrklyn.com * Company: NYLXS * * ===================================================================================== */
#include #include
struct word{ unsigned char byte; };
unsigned char totalmem[65536]; // 2^16
struct line { unsigned char address[2]; struct word block [8]; };
struct line cache[32];
int main ( int argc, char *argv[] ) {
return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
void readIndex(struct line num){ }
void readOffset(struct line num){ }
void readData(struct line num){ }
void readTag(struct line num){ }
|
|