2004-10-04 03:10:51 +02:00
|
|
|
#ifndef __memory_H // -*- c++ -*-
|
2001-05-01 03:09:39 +02:00
|
|
|
#define __memory_H
|
|
|
|
|
/*
|
2010-12-14 02:42:48 +01:00
|
|
|
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
|
2001-05-01 03:09:39 +02:00
|
|
|
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "pointers.h"
|
|
|
|
|
#include "functor.h"
|
|
|
|
|
|
2001-05-09 01:59:33 +02:00
|
|
|
/*
|
|
|
|
|
** vvp_memory_t is a memory
|
|
|
|
|
** vvp_memory_bits_t are bits in a memory
|
|
|
|
|
** vvp_memory_index_t is a memory index range definition
|
|
|
|
|
*/
|
2001-05-01 03:09:39 +02:00
|
|
|
typedef struct vvp_memory_s *vvp_memory_t;
|
|
|
|
|
typedef unsigned char *vvp_memory_bits_t;
|
|
|
|
|
typedef struct vvp_memory_index_s *vvp_memory_index_t;
|
|
|
|
|
|
2006-02-19 17:57:31 +01:00
|
|
|
// moved from memory.cc for callback function visibility
|
|
|
|
|
typedef struct vvp_memory_port_s *vvp_memory_port_t;
|
|
|
|
|
|
|
|
|
|
// moved here from memory.cc for callback function visibility
|
|
|
|
|
struct vvp_memory_s
|
|
|
|
|
{
|
|
|
|
|
char *name; // VPI scope.name
|
|
|
|
|
|
|
|
|
|
// Address port properties:
|
|
|
|
|
unsigned size; // total number of data words
|
|
|
|
|
unsigned a_idxs; // number of address indices
|
|
|
|
|
vvp_memory_index_t a_idx; // vector of address indices
|
|
|
|
|
|
|
|
|
|
// Data port properties:
|
|
|
|
|
unsigned width; // number of data bits
|
|
|
|
|
unsigned fwidth; // number of bytes (4bits) per data word
|
|
|
|
|
int msb, lsb; // Most/Least Significant data bit (VPI)
|
|
|
|
|
|
|
|
|
|
vvp_memory_bits_t bits; // Array of bits
|
2011-03-04 23:11:28 +01:00
|
|
|
vvp_memory_port_t addr_root; // Port list root;
|
|
|
|
|
|
2006-02-19 17:57:31 +01:00
|
|
|
// callbacks
|
|
|
|
|
struct __vpiCallback*cb; // callback list for this vpiMemory
|
|
|
|
|
};
|
|
|
|
|
|
2001-05-01 03:09:39 +02:00
|
|
|
void memory_new(vvp_memory_t mem, char *name, int lsb, int msb,
|
|
|
|
|
unsigned idxs, long *idx);
|
2001-10-31 05:27:46 +01:00
|
|
|
vvp_ipoint_t memory_port_new(vvp_memory_t mem,
|
|
|
|
|
unsigned nbits, unsigned bitoff,
|
|
|
|
|
unsigned naddr, bool writable);
|
2001-06-15 05:28:30 +02:00
|
|
|
|
2001-05-01 03:09:39 +02:00
|
|
|
void memory_init_nibble(vvp_memory_t mem, unsigned idx, unsigned char val);
|
|
|
|
|
|
|
|
|
|
void memory_set(vvp_memory_t mem, unsigned idx, unsigned char val);
|
|
|
|
|
unsigned memory_get(vvp_memory_t mem, unsigned idx);
|
2004-10-04 03:10:51 +02:00
|
|
|
void schedule_memory(vvp_memory_t mem, unsigned idx,
|
2001-05-01 03:09:39 +02:00
|
|
|
unsigned char val, unsigned delay);
|
|
|
|
|
|
2001-05-09 01:59:33 +02:00
|
|
|
unsigned memory_size(vvp_memory_t mem);
|
|
|
|
|
char *memory_name(vvp_memory_t mem);
|
2001-05-01 03:09:39 +02:00
|
|
|
unsigned memory_data_width(vvp_memory_t mem);
|
2001-05-09 01:59:33 +02:00
|
|
|
unsigned memory_root(vvp_memory_t mem, unsigned ix = 0);
|
2002-01-31 05:28:17 +01:00
|
|
|
unsigned memory_left_range(vvp_memory_t mem, unsigned ix = 0);
|
|
|
|
|
unsigned memory_right_range(vvp_memory_t mem, unsigned ix = 0);
|
|
|
|
|
unsigned memory_word_left_range(vvp_memory_t mem);
|
|
|
|
|
unsigned memory_word_right_range(vvp_memory_t mem);
|
2001-05-01 03:09:39 +02:00
|
|
|
|
2001-05-09 01:59:33 +02:00
|
|
|
/*
|
|
|
|
|
** Access to the memory symbol table.
|
|
|
|
|
*/
|
2001-05-01 03:09:39 +02:00
|
|
|
vvp_memory_t memory_find(char *label);
|
|
|
|
|
vvp_memory_t memory_create(char *label);
|
|
|
|
|
|
|
|
|
|
#endif
|