~arcachofo/simulide/1.1.0

« back to all changes in this revision

Viewing changes to src/gui/circuitwidget/components/logic/bcdto7s.cpp

  • 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
#include "bcdto7s.h"
 
21
#include "simulator.h"
 
22
#include "pin.h"
 
23
 
 
24
Component* BcdTo7S::construct( QObject* parent, QString type, QString id )
 
25
{
 
26
        return new BcdTo7S( parent, type, id );
 
27
}
 
28
 
 
29
LibraryItem* BcdTo7S::libraryItem()
 
30
{
 
31
    return new LibraryItem(
 
32
        tr( "Bcd To 7S." ),
 
33
        tr( "Logic/Converters" ),
 
34
        "2to3g.png",
 
35
        "BcdTo7S",
 
36
        BcdTo7S::construct );
 
37
}
 
38
 
 
39
BcdTo7S::BcdTo7S( QObject* parent, QString type, QString id )
 
40
       : LogicComponent( parent, type, id )
 
41
       , eBcdTo7S( id )
 
42
{
 
43
    m_width  = 4;
 
44
    m_height = 8;
 
45
 
 
46
    QStringList pinList;
 
47
 
 
48
    pinList // Inputs:
 
49
            
 
50
            << "IL03 S0"
 
51
            << "IL04 S1"
 
52
            << "IL05 S2"
 
53
            << "IL06 S3"
 
54
 
 
55
            << "IU01OE "
 
56
            
 
57
            // Outputs:
 
58
            << "OR01a  "
 
59
            << "OR02b  "
 
60
            << "OR03c  "
 
61
            << "OR04d "
 
62
            << "OR05e  "
 
63
            << "OR06f  "
 
64
            << "OR07g "
 
65
            ;
 
66
    init( pinList );
 
67
 
 
68
    eLogicDevice::createOutEnablePin( m_inPin[4] );    // IOutput Enable
 
69
 
 
70
    for( int i=0; i<4; i++ )
 
71
        eLogicDevice::createInput( m_inPin[i] );
 
72
        
 
73
    for( int i=0; i<7; i++ )
 
74
    {
 
75
        eLogicDevice::createOutput( m_outPin[i] );
 
76
    }
 
77
}
 
78
BcdTo7S::~BcdTo7S(){}
 
79
 
 
80
void BcdTo7S::stamp()
 
81
{
 
82
    eBcdTo7S::stamp();
 
83
 
 
84
    uint8_t value = m_values[0];
 
85
    for( int i=0; i<7; ++i ) setOut( i, value & (1<<i) );
 
86
}
 
87
 
 
88
#include "moc_bcdto7s.cpp"