Skip to content

Commit

Permalink
Added verilog-A ideal voltage controlled resistor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard C Crozier committed Feb 13, 2014
1 parent 4b24c29 commit f5961b5
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 7 deletions.
1 change: 1 addition & 0 deletions qucs-core/src/components/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
#include "verilog/comp_2bit.core.h"
#include "verilog/comp_4bit.core.h"
#include "verilog/hpribin4bit.core.h"
#include "verilog/vcresistor.core.h"

#include "ecvs.h"

Expand Down
22 changes: 19 additions & 3 deletions qucs-core/src/components/verilog/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ libverilog_la_SOURCES = HBT_X.analogfunction.cpp HBT_X.core.cpp \
comp_1bit.analogfunction.cpp comp_1bit.core.cpp \
comp_2bit.analogfunction.cpp comp_2bit.core.cpp \
comp_4bit.analogfunction.cpp comp_4bit.core.cpp \
hpribin4bit.analogfunction.cpp hpribin4bit.core.cpp
hpribin4bit.analogfunction.cpp hpribin4bit.core.cpp \
vcresistor.analogfunction.cpp vcresistor.core.cpp

noinst_HEADERS = HBT_X.analogfunction.h HBT_X.defs.h HBT_X.core.h \
hicumL2V2p1.analogfunction.h hicumL2V2p1.defs.h hicumL2V2p1.core.h \
Expand Down Expand Up @@ -133,7 +134,8 @@ noinst_HEADERS = HBT_X.analogfunction.h HBT_X.defs.h HBT_X.core.h \
comp_1bit.analogfunction.h comp_1bit.defs.h comp_1bit.core.h \
comp_2bit.analogfunction.h comp_2bit.defs.h comp_2bit.core.h \
comp_4bit.analogfunction.h comp_4bit.defs.h comp_4bit.core.h \
hpribin4bit.analogfunction.h hpribin4bit.defs.h hpribin4bit.core.h
hpribin4bit.analogfunction.h hpribin4bit.defs.h hpribin4bit.core.h \
vcresistor.analogfunction.h vcresistor.defs.h vcresistor.core.h

VERILOG_FILES = constants.vams disciplines.vams \
fbh_hbt-2_2a.va hicumL2V2p11.va mod_amp.va hicumL2V2p22.va log_amp.va \
Expand All @@ -145,7 +147,8 @@ VERILOG_FILES = constants.vams disciplines.vams \
mux2to1.va mux4to1.va mux8to1.va DLS_nto1.va DLS_1ton.va andor4x2.va \
andor4x3.va andor4x4.va dmux2to4.va dmux3to8.va dmux4to16.va ha1b.va \
fa1b.va fa2b.va pad2bit.va pad3bit.va pad4bit.va binarytogrey4bit.va \
greytobinary4bit.va comp_1bit.va comp_2bit.va comp_4bit.va hpribin4bit.va
greytobinary4bit.va comp_1bit.va comp_2bit.va comp_4bit.va hpribin4bit.va \
vcresistor.va

VERILOGDIGITAL_FILES =

Expand Down Expand Up @@ -834,6 +837,19 @@ nigbt.gui.cpp: qucsVersion.xml qucsMODULEgui.xml
nigbt.gui.cpp: nigbt.va
$(ADMSXML) $< -e $(srcdir)/qucsVersion.xml -e $(srcdir)/qucsMODULEgui.xml

vcresistor.analogfunction.cpp: analogfunction.xml
vcresistor.analogfunction.cpp: vcresistor.va
$(ADMSXML) $< -e $(srcdir)/analogfunction.xml
vcresistor.core.cpp: vcresistor.defs.h qucsVersion.xml qucsMODULEcore.xml
vcresistor.core.cpp: vcresistor.va
$(ADMSXML) $< -e $(srcdir)/qucsVersion.xml -e $(srcdir)/qucsMODULEcore.xml
vcresistor.defs.h: qucsVersion.xml qucsMODULEdefs.xml
vcresistor.defs.h: vcresistor.va
$(ADMSXML) $< -e $(srcdir)/qucsVersion.xml -e $(srcdir)/qucsMODULEdefs.xml
vcresistor.gui.cpp: qucsVersion.xml qucsMODULEgui.xml
vcresistor.gui.cpp: vcresistor.va
$(ADMSXML) $< -e $(srcdir)/qucsVersion.xml -e $(srcdir)/qucsMODULEgui.xml

GENERATED_FILES = *.core.* *.analogfunction.* *.gui.* *.defs.* .*.adms .*.xml
else
GENERATED_FILES =
Expand Down
46 changes: 46 additions & 0 deletions qucs-core/src/components/verilog/vcresistor.va
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Qucs resistive potentiometer model:
// This model can be used to construct working lin, log and inverse log
// potentiometers, or other devices with designer specified resistive taper functions.
// All required parameters can be extracted directly from
// manufacturers data sheets.
//
// The structure and theoretical background to the potentiometer
// Verilog-a model are presented in the Qucs potentiometer report.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// Copyright (C), Richard Crozier, richard DOT crozier AT yahoo DOT co DOT uk, February 2013.
//
`include "disciplines.vams"
`include "constants.vams"
//
module vcresistor (C1, C2, P1, P2);
inout P1, P2;
input C1, C2;
electrical C1, C2, P1, P2;

`define attr(txt) (*txt*)
//
parameter real gain = 1 from [1e-6 : inf]
`attr(info="Gain" unit = "Ohm/Volt");

real resistance;

analog begin

// Macromodel
//
// resistance is the voltage across the input ports
resistance = V(C1,C2) * gain;

if (resistance>0.0)
I(P1, P2) <+ V(P1, P2)/resistance ;
else
V(P1, P2) <+ 0.0 ;

end

endmodule
1 change: 1 addition & 0 deletions qucs-core/src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ void module::registerModules (void) {
REGISTER_CIRCUIT (comp_2bit);
REGISTER_CIRCUIT (comp_4bit);
REGISTER_CIRCUIT (hpribin4bit);
REGISTER_CIRCUIT (vcresistor);
REGISTER_CIRCUIT (ecvs);

// analyses
Expand Down
Binary file added qucs/qucs/bitmaps/vcresistor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions qucs/qucs/components/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ libcomponents_a_SOURCES = phaseshifter.cpp gyrator.cpp componentdialog.cpp \
hpribin4bit.cpp msrstub.cpp phototransistor.cpp nigbt.cpp hicumL2V2p24.cpp \
hicumL0V1p2g.cpp hybrid.cpp ctline.cpp tunneldiode.cpp hicumL0V1p3.cpp \
hicumL2V2p31n.cpp bsim3v34nMOS.cpp bsim3v34pMOS.cpp bsim4v30nMOS.cpp \
bsim4v30pMOS.cpp etr_sim.cpp ecvs.cpp
bsim4v30pMOS.cpp etr_sim.cpp ecvs.cpp vcresistor.cpp

nodist_libcomponents_a_SOURCES = $(MOCFILES)

Expand Down Expand Up @@ -90,7 +90,7 @@ noinst_HEADERS = $(MOCHEADERS) resistor.h components.h capacitor.h vccs.h \
comp_2bit.h comp_4bit.h hpribin4bit.h msrstub.h phototransistor.h nigbt.h \
vafile.h hicumL2V2p24.h hicumL0V1p2g.h hybrid.h ctline.h tunneldiode.h \
hicumL0V1p3.h hicumL2V2p31n.h bsim3v34nMOS.h bsim3v34pMOS.h bsim4v30nMOS.h \
bsim4v30pMOS.h etr_sim.h ecvs.h
bsim4v30pMOS.h etr_sim.h ecvs.h vcresistor.h

AM_CPPFLAGS = $(X11_INCLUDES) $(QT_INCLUDES) -I$(top_srcdir)/qucs

Expand Down
1 change: 1 addition & 0 deletions qucs/qucs/components/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
#include "photodiode.h"
#include "phototransistor.h"
#include "nigbt.h"
#include "vcresistor.h"

#include "dff_SR.h"
#include "tff_SR.h"
Expand Down
6 changes: 4 additions & 2 deletions qucs/qucs/components/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ Switch::Switch()
Props.append(new Property("init", "off", false,
QObject::tr("initial state")+" [on, off]"));
Props.append(new Property("time", "1 ms", false,
QObject::tr("time when state changes (semicolon separated list possible)")));
QObject::tr("time when state changes (semicolon separated list possible, even numbered lists are repeated)")));
Props.append(new Property("Ron", "0", false,
QObject::tr("resistance of \"on\" state in ohms")));
Props.append(new Property("Roff", "1e9", false,
Props.append(new Property("Roff", "1e12", false,
QObject::tr("resistance of \"off\" state in ohms")));
Props.append(new Property("Temp", "26.85", false,
QObject::tr("simulation temperature in degree Celsius")));
Props.append(new Property("MaxDuration", "1e-6", false,
QObject::tr("Max possible switch transition time (transition time 1/100 smallest value in 'time', or this number)")));

createSymbol();
tx = x1+4;
Expand Down
90 changes: 90 additions & 0 deletions qucs/qucs/components/vcresistor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/***************************************************************************
vcresistor.cpp - description
-------------------
begin : Feb 13 2014
copyright : (C) 2014 by Richard Crozier
email : richard dot crozier at yahoo dot co dot uk
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "vcresistor.h"


vcresistor::vcresistor()
{
Description = QObject::tr("voltage controlled voltage source");

// The resistor shape
Lines.append(new Line(5, 18, 5, -18, QPen(Qt::darkBlue,2)));
Lines.append(new Line(17, 18, 17, -18, QPen(Qt::darkBlue,2)));
Lines.append(new Line(5, 18, 17, 18, QPen(Qt::darkBlue,2)));
Lines.append(new Line(5, -18, 17, -18, QPen(Qt::darkBlue,2)));

// horizontal lines on top and bottom of left hand side
Lines.append(new Line(-30,-30,-12,-30,QPen(Qt::darkBlue,2)));
Lines.append(new Line(-30, 30,-12, 30,QPen(Qt::darkBlue,2)));
// horizontal lines on top and bottom of right hand side
Lines.append(new Line( 11,-30, 30,-30,QPen(Qt::darkBlue,2)));
Lines.append(new Line( 11, 30, 30, 30,QPen(Qt::darkBlue,2)));
// vertical lines on top and bottom of left hand side
Lines.append(new Line(-12,-30,-12,-23,QPen(Qt::darkBlue,2)));
Lines.append(new Line(-12, 30,-12, 23,QPen(Qt::darkBlue,2)));
// vertical lines on top and bottom of right hand side
Lines.append(new Line( 11,-30, 11,-18,QPen(Qt::darkBlue,2)));
Lines.append(new Line( 11, 30, 11, 18,QPen(Qt::darkBlue,2)));

// downward pointing arrow
Lines.append(new Line(-12,-18,-12, 18,QPen(Qt::darkBlue,1)));
Lines.append(new Line(-12, 18,-17, 9,QPen(Qt::darkBlue,1)));
Lines.append(new Line(-12, 18, -7, 9,QPen(Qt::darkBlue,1)));

Lines.append(new Line(-25,-27, 25,-27,QPen(Qt::darkGray,1)));
Lines.append(new Line( 25,-27, 25, 27,QPen(Qt::darkGray,1)));
Lines.append(new Line( 25, 27,-25, 27,QPen(Qt::darkGray,1)));
Lines.append(new Line(-25, 27,-25,-27,QPen(Qt::darkGray,1)));


Ports.append(new Port(-30,-30));
Ports.append(new Port(-30, 30));
Ports.append(new Port( 30,-30));
Ports.append(new Port( 30, 30));


x1 = -30; y1 = -30;
x2 = 30; y2 = 30;

tx = x1+4;
ty = y2+4;
Model = "vcresistor";
Name = "VCR";

Props.append(new Property("gain", "1", true,
QObject::tr("resistance gain")));
}

vcresistor::~vcresistor()
{
}

Component* vcresistor::newOne()
{
return new vcresistor();
}

Element* vcresistor::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Name = QObject::tr("Voltage Controlled Resistor");
BitmapFile = (char *) "vcresistor";

if(getNewOne) return new vcresistor();
return 0;
}

32 changes: 32 additions & 0 deletions qucs/qucs/components/vcresistor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/***************************************************************************
vcresistor.h - description
-------------------
begin : Feb 13 2014
copyright : (C) 2014 Richard Crozier
email : richard dot crozier at yahoo.co.uk
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef VCRESISTOR_H
#define VCRESISTOR_H

#include "component.h"


class vcresistor : public Component {
public:
vcresistor();
~vcresistor();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
};

#endif
1 change: 1 addition & 0 deletions qucs/qucs/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ void Module::registerModules (void) {
REGISTER_VERILOGA_1 (photodiode);
REGISTER_VERILOGA_1 (phototransistor);
REGISTER_VERILOGA_1 (nigbt);
REGISTER_VERILOGA_1 (vcresistor);

// digital components
REGISTER_DIGITAL_1 (Digi_Source);
Expand Down
1 change: 1 addition & 0 deletions qucs/qucs/qucs.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,6 @@
<file>bitmaps/ysmith.png</file>
<file>bitmaps/etran.png</file>
<file>bitmaps/ecvs.png</file>
<file>bitmaps/vcresistor.png</file>
</qresource>
</RCC>

0 comments on commit f5961b5

Please sign in to comment.