mirror of
https://github.com/mist64/perfect6502.git
synced 2025-04-07 15:42:05 +00:00
cleanups
This commit is contained in:
parent
76d798db79
commit
0269c1bdf1
@ -31,12 +31,6 @@
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Global Data Types
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
/* the smallest types to fit the numbers */
|
||||
typedef uint16_t transnum_t;
|
||||
typedef uint16_t count_t;
|
||||
@ -44,11 +38,11 @@ typedef uint16_t count_t;
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Bitmap Data Structures and Algorithms
|
||||
* Main State Data Structure
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
#if 0 /* on 64 bit CPUs */
|
||||
#if 0 /* faster on 64 bit CPUs */
|
||||
typedef unsigned long long bitmap_t;
|
||||
#define BITMAP_SHIFT 6
|
||||
#define BITMAP_MASK 63
|
||||
@ -60,35 +54,6 @@ typedef unsigned int bitmap_t;
|
||||
#define ONE 1
|
||||
#endif
|
||||
|
||||
#define WORDS_FOR_BITS(a) (a/(sizeof(bitmap_t) * 8)+1)
|
||||
|
||||
static inline void
|
||||
bitmap_clear(bitmap_t *bitmap, count_t count)
|
||||
{
|
||||
bzero(bitmap, WORDS_FOR_BITS(count)*sizeof(bitmap_t));
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_bitmap(bitmap_t *bitmap, int index, BOOL state)
|
||||
{
|
||||
if (state)
|
||||
bitmap[index>>BITMAP_SHIFT] |= ONE << (index & BITMAP_MASK);
|
||||
else
|
||||
bitmap[index>>BITMAP_SHIFT] &= ~(ONE << (index & BITMAP_MASK));
|
||||
}
|
||||
|
||||
static inline BOOL
|
||||
get_bitmap(bitmap_t *bitmap, int index)
|
||||
{
|
||||
return (bitmap[index>>BITMAP_SHIFT] >> (index & BITMAP_MASK)) & 1;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Main State Data Structure
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
/* list of nodes that need to be recalculated */
|
||||
typedef struct {
|
||||
nodenum_t *list;
|
||||
@ -144,13 +109,48 @@ typedef struct {
|
||||
} group_contains_value;
|
||||
} state_t;
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Main Header Include
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
#define INCLUDED_FROM_NETLIST_SIM_C
|
||||
#include "netlist_sim.h"
|
||||
#undef INCLUDED_FROM_NETLIST_SIM_C
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Data Structures for Nodes
|
||||
* Algorithms for Bitmaps
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
#define WORDS_FOR_BITS(a) (a / (sizeof(bitmap_t) * 8) + 1)
|
||||
|
||||
static inline void
|
||||
bitmap_clear(bitmap_t *bitmap, count_t count)
|
||||
{
|
||||
bzero(bitmap, WORDS_FOR_BITS(count)*sizeof(bitmap_t));
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_bitmap(bitmap_t *bitmap, int index, BOOL state)
|
||||
{
|
||||
if (state)
|
||||
bitmap[index>>BITMAP_SHIFT] |= ONE << (index & BITMAP_MASK);
|
||||
else
|
||||
bitmap[index>>BITMAP_SHIFT] &= ~(ONE << (index & BITMAP_MASK));
|
||||
}
|
||||
|
||||
static inline BOOL
|
||||
get_bitmap(bitmap_t *bitmap, int index)
|
||||
{
|
||||
return (bitmap[index>>BITMAP_SHIFT] >> (index & BITMAP_MASK)) & 1;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Algorithms for Nodes
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
@ -197,7 +197,7 @@ get_nodes_value(state_t *state, transnum_t t)
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Data Structures and Algorithms for Transistors
|
||||
* Algorithms for Transistors
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
@ -215,7 +215,7 @@ get_transistors_on(state_t *state, transnum_t t)
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Data Structures and Algorithms for Lists
|
||||
* Algorithms for Lists
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
@ -257,7 +257,7 @@ listout_add(state_t *state, nodenum_t i)
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* Data Structures and Algorithms for Groups of Nodes
|
||||
* Algorithms for Groups of Nodes
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
|
@ -135,9 +135,9 @@ static inline void
|
||||
handleMemory(void *state)
|
||||
{
|
||||
if (isNodeHigh(state, rw))
|
||||
writeDataBus(state, mRead(readAddressBus(state)));
|
||||
writeDataBus(state, mRead(readAddressBus(state)));
|
||||
else
|
||||
mWrite(readAddressBus(state), readDataBus(state));
|
||||
mWrite(readAddressBus(state), readDataBus(state));
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
@ -171,9 +171,11 @@ initAndResetChip()
|
||||
nodenum_t nodes = sizeof(netlist_6502_node_is_pullup)/sizeof(*netlist_6502_node_is_pullup);
|
||||
nodenum_t transistors = sizeof(netlist_6502_transdefs)/sizeof(*netlist_6502_transdefs);
|
||||
void *state = setupNodesAndTransistors(netlist_6502_transdefs,
|
||||
netlist_6502_node_is_pullup,
|
||||
nodes,
|
||||
transistors, vss, vcc);
|
||||
netlist_6502_node_is_pullup,
|
||||
nodes,
|
||||
transistors,
|
||||
vss,
|
||||
vcc);
|
||||
|
||||
setNode(state, res, 0);
|
||||
setNode(state, clk0, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user