~arcachofo/simulide/1.1.0

« back to all changes in this revision

Viewing changes to src/gui/circuitwidget/components/logic/i2cram.h

  • Committer: arcachofo
  • Date: 2021-01-01 14:23:42 UTC
  • Revision ID: arcachofo@simulide.com-20210101142342-ozfljnll44g5lbl3
Initial Commit 0.5.15-RC3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2018 by santiago González                               *
 
3
 *   santigoro@gmail.com                                                   *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 3 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.  *
 
17
 *                                                                         *
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef I2CRAM_H
 
21
#define I2CRAM_H
 
22
 
 
23
#include "e-i2c.h"
 
24
#include "itemlibrary.h"
 
25
#include "logiccomponent.h"
 
26
#include "memdata.h"
 
27
 
 
28
class MAINMODULE_EXPORT I2CRam : public LogicComponent, public eI2C, public MemData
 
29
{
 
30
    Q_OBJECT
 
31
    Q_PROPERTY( quint64 Propagation_Delay_ns  READ propDelay   WRITE setPropDelay   DESIGNABLE true USER true )
 
32
    Q_PROPERTY( QVector<int> Mem  READ mem        WRITE setMem )
 
33
    Q_PROPERTY( int  Control_Code READ cCode      WRITE setCcode      DESIGNABLE true USER true )
 
34
    Q_PROPERTY( int  Size_bytes   READ rSize      WRITE setRSize      DESIGNABLE true USER true )
 
35
    Q_PROPERTY( bool Persistent   READ persistent WRITE setPersistent DESIGNABLE true USER true )
 
36
 
 
37
    public:
 
38
        I2CRam( QObject* parent, QString type, QString id );
 
39
        ~I2CRam();
 
40
 
 
41
        static Component* construct( QObject* parent, QString type, QString id );
 
42
        static LibraryItem* libraryItem();
 
43
        
 
44
        void setMem( QVector<int> m );
 
45
        QVector<int> mem();
 
46
 
 
47
        int cCode();
 
48
        void setCcode( int code );
 
49
        
 
50
        int rSize();
 
51
        void setRSize( int size );
 
52
 
 
53
        bool persistent();
 
54
        void setPersistent( bool p );
 
55
        
 
56
        virtual void stamp() override;
 
57
        virtual void initialize() override;
 
58
        virtual void voltChanged() override;
 
59
 
 
60
        virtual void startWrite();
 
61
        virtual void writeByte();
 
62
        virtual void readByte();
 
63
 
 
64
    public slots:
 
65
        void loadData();
 
66
        void saveData();
 
67
        virtual void contextMenu( QGraphicsSceneContextMenuEvent* event, QMenu* menu );
 
68
 
 
69
    protected:
 
70
        virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* event );
 
71
 
 
72
    private:
 
73
        QVector<int> m_ram;
 
74
        int m_size;
 
75
        int m_addrPtr;
 
76
        int m_cCode;
 
77
        int m_phase;
 
78
 
 
79
        bool m_persistent;
 
80
};
 
81
 
 
82
#endif
 
83