My Project  0.0.16
QUCS Mapping
 All Classes Namespaces 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 
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(QPen::darkGreen,2)));
59  Lines.append(new Line(-20,-10,-10, 0,QPen(QPen::darkGreen,2)));
60  Lines.append(new Line(-20, 10,-10, 0,QPen(QPen::darkGreen,2)));
61  Lines.append(new Line(-35,-10,-20,-10,QPen(QPen::darkGreen,2)));
62  Lines.append(new Line(-35, 10,-20, 10,QPen(QPen::darkGreen,2)));
63  Lines.append(new Line(-35,-10,-35, 10,QPen(QPen::darkGreen,2)));
64 
65  Texts.append(new Text(-30,-12, "1", QPen::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