Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rs_flipflop.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rs_flipflop.cpp
3  -----------------
4  begin : Fri Jan 06 2006
5  copyright : (C) 2006 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #include <QtGui>
18 #include "rs_flipflop.h"
19 #include "node.h"
20 #include "main.h"
21 
23 {
25  Description = QObject::tr("RS flip flop");
26 
27  Props.append(new Property("t", "0", false, QObject::tr("delay time")));
28 
29  Lines.append(new Line(-20,-20, 20,-20,QPen(Qt::darkBlue,2)));
30  Lines.append(new Line(-20, 20, 20, 20,QPen(Qt::darkBlue,2)));
31  Lines.append(new Line(-20,-20,-20, 20,QPen(Qt::darkBlue,2)));
32  Lines.append(new Line( 20,-20, 20, 20,QPen(Qt::darkBlue,2)));
33 
34  Lines.append(new Line(-30,-10,-20,-10,QPen(Qt::darkBlue,2)));
35  Lines.append(new Line(-30, 10,-20, 10,QPen(Qt::darkBlue,2)));
36  Lines.append(new Line( 30,-10, 20,-10,QPen(Qt::darkBlue,2)));
37  Lines.append(new Line( 30, 10, 20, 10,QPen(Qt::darkBlue,2)));
38 
39  Texts.append(new Text(-18,-21, "R", Qt::darkBlue, 12.0));
40  Texts.append(new Text(-18, -1, "S", Qt::darkBlue, 12.0));
41  Texts.append(new Text( 6,-21, "Q", Qt::darkBlue, 12.0));
42  Texts.append(new Text( 6, -1, "Q", Qt::darkBlue, 12.0));
43  Texts.current()->over=true;
44 
45  Ports.append(new Port(-30,-10)); // R
46  Ports.append(new Port(-30, 10)); // S
47  Ports.append(new Port( 30,-10)); // Q
48  Ports.append(new Port( 30, 10)); // nQ
49 
50  x1 = -30; y1 = -24;
51  x2 = 30; y2 = 24;
52  tx = x1+4;
53  ty = y2+4;
54  Model = "RSFF";
55  Name = "Y";
56 }
57 
58 // -------------------------------------------------------
59 QString RS_FlipFlop::vhdlCode(int NumPorts)
60 {
61  QString s = "";
62  if(NumPorts <= 0) { // no truth table simulation ?
63  QString td = Props.at(0)->Value; // delay time
64  if(!VHDL_Delay(td, Name)) return td; // time has not VHDL format
65  s = td;
66  }
67  s += ";\n";
68 
69  s = " " +
70  Ports.at(2)->Connection->Name + " <= " +
71  Ports.at(0)->Connection->Name + " nor " +
72  Ports.at(3)->Connection->Name + s + " " +
73  Ports.at(3)->Connection->Name + " <= " +
74  Ports.at(1)->Connection->Name + " nor " +
75  Ports.at(2)->Connection->Name + s + '\n';
76  return s;
77 }
78 
79 // -------------------------------------------------------
80 QString RS_FlipFlop::verilogCode(int NumPorts)
81 {
82  QString t = "";
83  if(NumPorts <= 0) { // no truth table simulation ?
84  QString td = Props.at(0)->Value; // delay time
85  if(!Verilog_Delay(td, Name)) return td; // time has not VHDL format
86  t = td;
87  }
88  t += " ";
89 
90  QString l = "";
91 
92  QString s = Ports.at(1)->Connection->Name;
93  QString r = Ports.at(0)->Connection->Name;
94  QString q = Ports.at(2)->Connection->Name;
95  QString b = Ports.at(3)->Connection->Name;
96 
97  l = "\n // " + Name + " RS-flipflop\n" +
98  " assign" + t + q + " = ~(" + r + " | " + b + ");\n" +
99  " assign" + t + b + " = ~(" + s + " | " + q + ");\n\n";
100  return l;
101 }
102 
103 // -------------------------------------------------------
105 {
106  return new RS_FlipFlop();
107 }
108 
109 // -------------------------------------------------------
110 Element* RS_FlipFlop::info(QString& Name, char* &BitmapFile, bool getNewOne)
111 {
112  Name = QObject::tr("RS-FlipFlop");
113  BitmapFile = (char *) "rsflipflop";
114 
115  if(getNewOne) return new RS_FlipFlop();
116  return 0;
117 }
Q3PtrList< Line > Lines
Definition: component.h:67
QString vhdlCode(int)
Definition: rs_flipflop.cpp:59
static Element * info(QString &, char *&, bool getNewOne=false)
int Type
Definition: element.h:152
QString verilogCode(int)
Definition: rs_flipflop.cpp:80
int y1
Definition: element.h:153
bool VHDL_Delay(QString &td, const QString &Name)
Definition: main.cpp:493
int tx
Definition: component.h:78
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
#define isDigitalComponent
Definition: element.h:113
bool Verilog_Delay(QString &td, const QString &Name)
Definition: main.cpp:555
Definitions and declarations for the main application.
int ty
Definition: component.h:78
Q3PtrList< Property > Props
Definition: component.h:72
Definition: element.h:82
Definition: element.h:48
Superclass of all schematic drawing elements.
Definition: element.h:142
Q3PtrList< Port > Ports
Definition: component.h:70
QString Name
Definition: component.h:80
Q3PtrList< Text > Texts
Definition: component.h:71
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
Component * newOne()
int x2
Definition: element.h:153