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