OpenCores
URL https://opencores.org/ocsvn/light52/light52/trunk

Subversion Repositories light52

[/] [light52/] [trunk/] [tools/] [b51/] [src/] [b51_mcu.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 ja_rd
/**
2
    @file b51_mcu.h
3
    @brief MCU model -- core peripherals.
4
*/
5
 
6
#ifndef S51_PERIPHERALS_H_INCLUDED
7
#define S51_PERIPHERALS_H_INCLUDED
8
 
9
#include <stdint.h>
10
#include <stdbool.h>
11
 
12
#define MAX_XCODE_SIZE              (64 * 1024)
13
#define MAX_XDATA_SIZE              (64 * 1024)
14
 
15
#define NUM_IRQS (5)
16
 
17
 
18
/** SFRs for this implementation of the MCU. */
19
/* FIXME remove unused stock SFRs */
20
typedef struct mcu51_sfr_s {
21
    uint8_t p0;
22
    uint8_t p1;
23
    uint8_t p2;
24
    uint8_t p3;
25
    uint8_t pcon;
26
    uint8_t sbuf;
27
    uint8_t scon;
28
    uint8_t tcon;
29
    uint8_t th0;
30
    uint8_t th1;
31
    uint8_t tl0;
32
    uint8_t tl1;
33
    uint8_t tmod;
34
} mcu51_sfr_t;
35
 
36
/**
37
    MCU model.
38
    In its present state, this is neither a MCS51 model nor a light52.
39
    Consider this a dummy.
40
*/
41
typedef struct mcu51_s {
42
    uint8_t xcode[MAX_XCODE_SIZE];      /**< XCODE memory image */
43
    uint8_t xdata[MAX_XDATA_SIZE];      /**< XDATA memory image */
44
 
45
    mcu51_sfr_t sfr;                    /**< MCU (peripheral) SFRs */
46
    uint32_t irq_countdown[NUM_IRQS];   /**< Dummy IRQ simulators */
47
} mcu51_t;
48
 
49
/*-- Public functions --------------------------------------------------------*/
50
 
51
/**
52
    Initialize MCU model.
53
    This does NOT perform a reset on the simulated HW.
54
    Call this once before calling any other function in this API.
55
 
56
    @arg mcu MCU model.
57
*/
58
extern void mcu_init(mcu51_t *mcu);
59
 
60
/**
61
    Reset simulated hardware.
62
 
63
    @arg mcu MCU model.
64
*/
65
extern void mcu_reset(mcu51_t *mcu);
66
 
67
/**
68
    Write data to SFR and simulate side effects if any.
69
 
70
    @arg mcu MCU model.
71
    @arg dir Address of SFR.
72
    @arg value Data written to SFR.
73
*/
74
extern uint16_t mcu_set_sfr(mcu51_t *mcu, uint8_t dir, uint8_t value);
75
 
76
/**
77
    Read from SFR.
78
 
79
    @arg mcu MCU model.
80
    @arg dir SFR address.
81
    @return Value of SFR or undefined value for unimplemented SFRs.
82
*/
83
extern uint16_t mcu_get_sfr(mcu51_t *mcu, uint8_t dir);
84
 
85
/**
86
    Simulates a given number of clock cycles in the peripheral hardware.
87
    Call this at the end of every simulated instruction to keep the peripheral
88
    HW state in sync with the CPU state.
89
 
90
    @arg mcu MCU model.
91
    @arg states Number of clock cycles o simulate.
92
*/
93
extern void mcu_update(mcu51_t *mcu, uint32_t states);
94
 
95
#endif // S51_PERIPHERALS_H_INCLUDED

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.