Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logic_0.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  logic_0
3  ---------
4  begin : December 2008
5  copyright : (C) 2008 by Mike Brinson
6  email : mbrin72043@yahoo.co.uk
7  ***************************************************************************/
8 
9 /*
10  * logic_0.cpp - device implementations for logic_0 module
11  *
12  * This is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2, or (at your option)
15  * any later version.
16  *
17  */
18 #include <QtGui>
19 #include "node.h"
20 #include "logic_0.h"
21 
23 {
24  Type = isComponent; // Analogue and digital component.
25  Description = QObject::tr ("logic 0 verilog device");
26 
27  Props.append (new Property ("LEVEL", "0", false,
28  QObject::tr ("logic 0 voltage level")
29  +" ("+QObject::tr ("V")+")"));
30 
31  createSymbol ();
32  tx = x1 + 4;
33  ty = y2 + 4;
34  Model = "logic_0";
35  Name = "S";
36 }
37 
39 {
40  logic_0 * p = new logic_0();
41  p->Props.getFirst()->Value = Props.getFirst()->Value;
42  p->recreate(0);
43  return p;
44 }
45 
46 Element * logic_0::info(QString& Name, char * &BitmapFile, bool getNewOne)
47 {
48  Name = QObject::tr("Logic 0");
49  BitmapFile = (char *) "logic_0";
50 
51  if(getNewOne) return new logic_0();
52  return 0;
53 }
54 
56 {
57  Lines.append(new Line(-10, 0, 0, 0,QPen(Qt::darkGreen,2)));
58  Lines.append(new Line(-20,-10,-10, 0,QPen(Qt::darkGreen,2)));
59  Lines.append(new Line(-20, 10,-10, 0,QPen(Qt::darkGreen,2)));
60  Lines.append(new Line(-35,-10,-20,-10,QPen(Qt::darkGreen,2)));
61  Lines.append(new Line(-35, 10,-20, 10,QPen(Qt::darkGreen,2)));
62  Lines.append(new Line(-35,-10,-35, 10,QPen(Qt::darkGreen,2)));
63 
64  Texts.append(new Text(-30,-12, "0", Qt::darkGreen, 12.0));
65 
66  Ports.append(new Port( 0, 0)); // L0
67 
68  x1 = -39; y1 = -14;
69  x2 = 0; y2 = 14;
70 }
71 
72 QString logic_0::vhdlCode( int )
73 {
74  QString s="";
75 
76  QString LO = Ports.at(0)->Connection->Name;
77 
78  s = "\n " + Name + ":process\n" +
79  " begin\n " +
80  LO + " <= '0';\n" +
81  " end process;\n";
82  return s;
83 }
84 
85 QString logic_0::verilogCode( int )
86 {
87  QString l = "";
88 
89  QString LO = Ports.at(0)->Connection->Name;
90 
91  QString v = "net_reg" + Name + LO;
92 
93  l = "\n // " + Name + " logic 0\n" +
94  " assign " + LO + " = " + v + ";\n" +
95  " reg " + v + " = 0;\n" +
96  " initial\n" +
97  " " + v + " <= 0;\n";
98 
99  return l;
100 }
101 
Q3PtrList< Line > Lines
Definition: component.h:67
int Type
Definition: element.h:152
int y1
Definition: element.h:153
QString verilogCode(int)
Definition: logic_0.cpp:85
int tx
Definition: component.h:78
QString vhdlCode(int)
Definition: logic_0.cpp:72
int y2
Definition: element.h:153
Definition: element.h:72
int x1
Definition: element.h:153
static Element * info(QString &, char *&, bool getNewOne=false)
Definition: logic_0.cpp:46
int ty
Definition: component.h:78
logic_0()
Definition: logic_0.cpp:22
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
void createSymbol()
Definition: logic_0.cpp:55
QString Model
Definition: component.h:80
QString Description
Definition: component.h:81
#define isComponent
Definition: element.h:110
int x2
Definition: element.h:153
virtual void recreate(Schematic *)
Definition: component.h:39
Component * newOne()
Definition: logic_0.cpp:38