My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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 
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(QPen::darkBlue,2)));
30  Lines.append(new Line(-20, 20, 20, 20,QPen(QPen::darkBlue,2)));
31  Lines.append(new Line(-20,-20,-20, 20,QPen(QPen::darkBlue,2)));
32  Lines.append(new Line( 20,-20, 20, 20,QPen(QPen::darkBlue,2)));
33 
34  Lines.append(new Line(-30,-10,-20,-10,QPen(QPen::darkBlue,2)));
35  Lines.append(new Line(-30, 10,-20, 10,QPen(QPen::darkBlue,2)));
36  Lines.append(new Line( 30,-10, 20,-10,QPen(QPen::darkBlue,2)));
37  Lines.append(new Line( 30, 10, 20, 10,QPen(QPen::darkBlue,2)));
38 
39  Texts.append(new Text(-18,-21, "R", QPen::darkBlue, 12.0));
40  Texts.append(new Text(-18, -1, "S", QPen::darkBlue, 12.0));
41  Texts.append(new Text( 6,-21, "Q", QPen::darkBlue, 12.0));
42  Texts.append(new Text( 6, -1, "Q", QPen::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 }