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