Modelica.Electrical.Digital.Examples.Utilities

Utility components used by package Examples

Information


This package contains utility components used by package Examples.

Package Content

NameDescription
Modelica.Electrical.Digital.Examples.Utilities.MUX4 MUX4 4 to 1 Bit Multiplexer
Modelica.Electrical.Digital.Examples.Utilities.RS RS Unclocked RS FlipFlop
Modelica.Electrical.Digital.Examples.Utilities.RSFF RSFF Unclocked RS FlipFlop
Modelica.Electrical.Digital.Examples.Utilities.DFF DFF D FlipFlop
Modelica.Electrical.Digital.Examples.Utilities.JKFF JKFF JK FlipFlop
Modelica.Electrical.Digital.Examples.Utilities.HalfAdder HalfAdder half adder
Modelica.Electrical.Digital.Examples.Utilities.FullAdder FullAdder adding circuit for binary numbers with input carry bit
Modelica.Electrical.Digital.Examples.Utilities.Adder Adder Generic N Bit Adder
Modelica.Electrical.Digital.Examples.Utilities.Counter3 Counter3 3 Bit Counter
Modelica.Electrical.Digital.Examples.Utilities.Counter Counter Generic N Bit Counter


Modelica.Electrical.Digital.Examples.Utilities.MUX4 Modelica.Electrical.Digital.Examples.Utilities.MUX4

4 to 1 Bit Multiplexer

Modelica.Electrical.Digital.Examples.Utilities.MUX4

Information


Parameters

TypeNameDefaultDescription
TimedelayTime0.001delay time [s]
Logicq0L.'0'initial value

Connectors

TypeNameDescription
input DigitalInputd0 
input DigitalInputd1 
input DigitalInputd2 
input DigitalInputd3 
input DigitalInputa0 
input DigitalInputa1 
output DigitalOutputd 

Modelica definition

model MUX4 "4 to 1 Bit Multiplexer"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;

  parameter Modelica.SIunits.Time delayTime=0.001 "delay time";
  parameter D.Interfaces.Logic q0=L.'0' "initial value";
    D.Interfaces.DigitalInput d0;
    D.Interfaces.DigitalInput d1;
    D.Interfaces.DigitalInput d2;
    D.Interfaces.DigitalInput d3;
    D.Interfaces.DigitalInput a0;
    D.Interfaces.DigitalInput a1;
    D.Interfaces.DigitalOutput d;
    D.Basic.Or Or1(n=4);
    D.Basic.And And1(n=3);
    D.Basic.And And2(n=3);
    D.Basic.And And3(n=3);
    D.Basic.And And4(n=3);
    D.Basic.Not Not1;
    D.Basic.Not Not2;
equation 
    connect(a0, Not1.x);
    connect(a1, Not2.x);
    connect(d0, And1.x[2]);
    connect(d1, And2.x[2]);
    connect(d2, And3.x[2]);
    connect(d3, And4.x[2]);
    connect(And4.y, Or1.x[1]);
    connect(And3.y, Or1.x[2]);
    connect(And2.y, Or1.x[3]);
    connect(And1.y, Or1.x[4]);
    connect(Or1.y, d);
    connect(Not1.y, And1.x[3]);
    connect(Not1.y, And3.x[3]);
    connect(Not2.y, And1.x[1]);
    connect(Not2.y, And2.x[1]);
    connect(a0, And4.x[3]);
    connect(a0, And2.x[3]);
    connect(a1, And4.x[1]);
    connect(a1, And3.x[1]);
end MUX4;

Modelica.Electrical.Digital.Examples.Utilities.RS Modelica.Electrical.Digital.Examples.Utilities.RS

Unclocked RS FlipFlop

Modelica.Electrical.Digital.Examples.Utilities.RS

Information


Parameters

TypeNameDefaultDescription
TimedelayTime0delay time [s]
Logicq0L.'U'initial value of output

Connectors

TypeNameDescription
input DigitalInputs 
input DigitalInputr 
output DigitalOutputq 
output DigitalOutputqn 

Modelica definition

model RS "Unclocked RS FlipFlop"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;
  parameter Modelica.SIunits.Time delayTime=0 "delay time";
  parameter D.Interfaces.Logic q0=L.'U' "initial value of output";
  D.Basic.Nor Nor1;
  D.Basic.Nor Nor2;
  D.Interfaces.DigitalInput s;
  D.Interfaces.DigitalInput r;
  D.Interfaces.DigitalOutput q;
  D.Interfaces.DigitalOutput qn;
  D.Delay.TransportDelay TD1(delayTime=delayTime,y0=q0);
equation 
  connect(s, Nor1.x[2]);
  connect(r, Nor2.x[1]);
  connect(Nor2.y, Nor1.x[1]);
  connect(Nor1.y,qn);
  connect(Nor2.y,q);
  connect(TD1.y, Nor2.x[2]);
  connect(TD1.x, Nor1.y);
end RS;

Modelica.Electrical.Digital.Examples.Utilities.RSFF Modelica.Electrical.Digital.Examples.Utilities.RSFF

Unclocked RS FlipFlop

Modelica.Electrical.Digital.Examples.Utilities.RSFF

Information


Parameters

TypeNameDefaultDescription
TimedelayTime0.01delay time [s]
Logicq0L.'U'initial value

Connectors

TypeNameDescription
input DigitalInputs 
input DigitalInputr 
output DigitalOutputq 
output DigitalOutputqnnot Q
input DigitalInputclk 

Modelica definition

model RSFF "Unclocked RS FlipFlop"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;

  parameter Modelica.SIunits.Time delayTime=0.01 "delay time";
  parameter D.Interfaces.Logic q0=L.'U' "initial value";
  D.Interfaces.DigitalInput s;
  D.Interfaces.DigitalInput r;
  D.Interfaces.DigitalOutput q;
  D.Interfaces.DigitalOutput qn "not Q";
  D.Interfaces.DigitalInput clk;
  D.Examples.Utilities.RS RS1(delayTime=delayTime,q0=q0);
  D.Basic.And And1;
  D.Basic.And And2;
equation 
  connect(And2.y, RS1.r);
  connect(And1.y, RS1.s);
  connect(s, And1.x[2]);
  connect(clk, And1.x[1]);
  connect(clk, And2.x[2]);
  connect(r, And2.x[1]);
  connect(RS1.q,q);
  connect(RS1.qn,qn);
end RSFF;

Modelica.Electrical.Digital.Examples.Utilities.DFF Modelica.Electrical.Digital.Examples.Utilities.DFF

D FlipFlop

Modelica.Electrical.Digital.Examples.Utilities.DFF

Information


Parameters

TypeNameDefaultDescription
TimeTdel0.01delay time [s]
LogicQInitL.'U'initial value

Connectors

TypeNameDescription
input DigitalInputd 
output DigitalOutputq 
output DigitalOutputqnnot Q
input DigitalInputclk 

Modelica definition

model DFF "D FlipFlop"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;

  parameter Modelica.SIunits.Time Tdel=0.01 "delay time";
  parameter Digital.Interfaces.Logic QInit=L.'U' "initial value";
  Digital.Interfaces.DigitalInput d;
  Digital.Interfaces.DigitalOutput q;
  Digital.Interfaces.DigitalOutput qn "not Q";
  Digital.Interfaces.DigitalInput clk;
  D.Examples.Utilities.RSFF RSFF1;
  Digital.Basic.Not Not1;
equation 
  connect(RSFF1.q,q);
  connect(RSFF1.qn,qn);
  connect(Not1.y, RSFF1.r);
  connect(clk, RSFF1.clk);
  connect(d, Not1.x);
  connect(d, RSFF1.s);
end DFF;

Modelica.Electrical.Digital.Examples.Utilities.JKFF Modelica.Electrical.Digital.Examples.Utilities.JKFF

JK FlipFlop

Modelica.Electrical.Digital.Examples.Utilities.JKFF

Information


Parameters

TypeNameDefaultDescription
TimedelayTime0.001delay time [s]
Logicq0L.'0'initial value

Connectors

TypeNameDescription
input DigitalInputj 
output DigitalOutputq 
output DigitalOutputqnnot Q
input DigitalInputclk 
input DigitalInputk 

Modelica definition

model JKFF "JK FlipFlop"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;

  parameter Modelica.SIunits.Time delayTime=0.001 "delay time";
  parameter D.Interfaces.Logic q0=L.'0' "initial value";
  D.Interfaces.DigitalInput j;
  D.Interfaces.DigitalOutput q;
  D.Interfaces.DigitalOutput qn "not Q";
  D.Interfaces.DigitalInput clk;
  D.Interfaces.DigitalInput k;
    D.Examples.Utilities.RS RS1(delayTime=delayTime,q0=q0);
    D.Examples.Utilities.RS RS2(delayTime=delayTime,q0=q0);
    D.Basic.And And1(n=3);
    D.Basic.And And2(n=3);
    D.Basic.And And3;
    D.Basic.And And4;
    D.Basic.Not Not1;
equation 
    connect(And2.y, RS2.r);
    connect(And1.y, RS2.s);
    connect(clk, And2.x[3]);
    connect(clk, And1.x[1]);
    connect(k, And2.x[2]);
    connect(And4.y, RS1.r);
    connect(And3.y, RS1.s);
    connect(RS2.qn, And4.x[2]);
    connect(RS2.q, And3.x[2]);
    connect(clk, Not1.x);
    connect(Not1.y, And3.x[1]);
    connect(Not1.y, And4.x[1]);
    connect(j, And1.x[2]);
    connect(RS1.q, And2.x[1]);
    connect(RS1.qn, And1.x[3]);
  connect(RS1.qn, q);
  connect(RS1.q, qn);
end JKFF;

Modelica.Electrical.Digital.Examples.Utilities.HalfAdder Modelica.Electrical.Digital.Examples.Utilities.HalfAdder

half adder

Modelica.Electrical.Digital.Examples.Utilities.HalfAdder

Information



Parameters

TypeNameDefaultDescription
RealdelayTime0delay time

Connectors

TypeNameDescription
input DigitalInputb 
output DigitalOutputs 
input DigitalInputa 
output DigitalOutputc 

Modelica definition

model HalfAdder "half adder"
  parameter Real delayTime=0 "delay time";
  Digital.Interfaces.DigitalInput b;
  Digital.Interfaces.DigitalOutput s;
  Digital.Interfaces.DigitalInput a;
  Digital.Interfaces.DigitalOutput c;
  Gates.AndGate AND(tLH=delayTime, tHL=delayTime);
  Gates.XorGate XOR(tLH=delayTime, tHL=delayTime);

equation 
  connect(AND.y, c);
  connect(XOR.y, s);
  connect(b, AND.x[1]);
  connect(b, XOR.x[1]);
  connect(a, XOR.x[2]);
  connect(a, AND.x[2]);
end HalfAdder;

Modelica.Electrical.Digital.Examples.Utilities.FullAdder Modelica.Electrical.Digital.Examples.Utilities.FullAdder

adding circuit for binary numbers with input carry bit

Modelica.Electrical.Digital.Examples.Utilities.FullAdder

Information


  a     b     c in     c out     s

         1     1     1     0
         0     0     0     0
         1     0     0     1
         0     1     0     1
 

Connectors

TypeNameDescription
input DigitalInputa 
input DigitalInputb 
input DigitalInputc_in 
output DigitalOutputs 
output DigitalOutputc_out 

Modelica definition

model FullAdder 
  "adding circuit for binary numbers with input carry bit"

  HalfAdder Adder2(delayTime=0.001);
  HalfAdder Adder1(delayTime=0.001);
  Digital.Interfaces.DigitalInput a;
  Digital.Interfaces.DigitalInput b;
  Digital.Interfaces.DigitalInput c_in;
  Digital.Interfaces.DigitalOutput s;
  Digital.Interfaces.DigitalOutput c_out;
  Basic.Or OR;
equation 

  connect(c_out, OR.y);
  connect(Adder2.c, OR.x[2]);
  connect(Adder2.s, s);
    connect(Adder1.a, a);
    connect(b, Adder1.b);
    connect(Adder1.s, Adder2.a);
    connect(Adder1.c, OR.x[1]);
    connect(c_in, Adder2.b);
end FullAdder;

Modelica.Electrical.Digital.Examples.Utilities.Adder Modelica.Electrical.Digital.Examples.Utilities.Adder

Generic N Bit Adder

Modelica.Electrical.Digital.Examples.Utilities.Adder

Information



Parameters

TypeNameDefaultDescription
Integern2number of single adders

Connectors

TypeNameDescription
input DigitalInputa[n] 
input DigitalInputb[n] 
input DigitalInputc_in 
output DigitalOutputs[n] 
output DigitalOutputc_out 

Modelica definition

model Adder "Generic N Bit Adder"
    import Modelica.Electrical.Digital;
  parameter Integer n=2 "number of single adders";
  Digital.Examples.Utilities.FullAdder Adder[n];
  Digital.Interfaces.DigitalInput a[n];
  Digital.Interfaces.DigitalInput b[n];
  Digital.Interfaces.DigitalInput c_in;
  Digital.Interfaces.DigitalOutput s[n];
  Digital.Interfaces.DigitalOutput c_out;
equation 
  connect(c_in,Adder[1].c_in);
  for i in 1:n loop
    connect(a[i],Adder[i].a);
    connect(b[i],Adder[i].b);
    connect(Adder[i].a,s[i]);
    if i>1 then
      connect(Adder[i-1].c_out,Adder[i].c_in);
    end if;
  end for;
  connect(Adder[n].c_out,c_out);
end Adder;

Modelica.Electrical.Digital.Examples.Utilities.Counter3 Modelica.Electrical.Digital.Examples.Utilities.Counter3

3 Bit Counter

Modelica.Electrical.Digital.Examples.Utilities.Counter3

Information



Connectors

TypeNameDescription
input DigitalInputenable 
output DigitalOutputq2 
input DigitalInputcount 
output DigitalOutputq1 
output DigitalOutputq0 

Modelica definition

model Counter3 "3 Bit Counter"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;
  D.Interfaces.DigitalInput enable;
  D.Interfaces.DigitalOutput q2;
  D.Interfaces.DigitalInput count;
  D.Examples.Utilities.JKFF FF1;
  D.Examples.Utilities.JKFF FF2;
  D.Examples.Utilities.JKFF FF3;
  D.Interfaces.DigitalOutput q1;
  D.Interfaces.DigitalOutput q0;
equation 
  connect(enable, FF1.j);
  connect(enable, FF1.k);
  connect(count, FF1.clk);
  connect(FF1.q, FF2.clk);
  connect(FF2.q, FF3.clk);
  connect(FF2.j, enable);
  connect(FF2.k, FF2.j);
  connect(FF3.k, FF3.j);
  connect(FF3.j, enable);
  connect(FF3.q, q2);
  connect(FF1.q, q0);
  connect(FF2.q, q1);
end Counter3;

Modelica.Electrical.Digital.Examples.Utilities.Counter Modelica.Electrical.Digital.Examples.Utilities.Counter

Generic N Bit Counter

Modelica.Electrical.Digital.Examples.Utilities.Counter

Information



Parameters

TypeNameDefaultDescription
Integern3number of bits
TimedelayTime0.001delay of each JKFF [s]
Logicq0L.'0'initial value

Connectors

TypeNameDescription
input DigitalInputenable 
input DigitalInputcount 
output DigitalOutputq[n] 

Modelica definition

model Counter "Generic N Bit Counter"
    import D = Modelica.Electrical.Digital;
    import L = Modelica.Electrical.Digital.Interfaces.Logic;
  parameter Integer n=3 "number of bits";
  parameter Modelica.SIunits.Time delayTime=0.001 "delay of each JKFF";
  parameter D.Interfaces.Logic q0=L.'0' "initial value";
  D.Interfaces.DigitalInput enable;
  D.Interfaces.DigitalInput count;
  D.Examples.Utilities.JKFF FF[n](each delayTime=delayTime,each q0=q0);
  D.Interfaces.DigitalOutput q[n];
equation 
  connect(enable,FF[1].j);
  connect(enable,FF[1].k);
  connect(count,FF[1].clk);
  connect(FF[1].q,q[1]);
  for i in 2:n loop
    connect(enable,FF[i].j);
    connect(enable,FF[i].k);
    connect(FF[i-1].q,FF[i].clk);
    connect(FF[i].q,q[i]);
  end for;
end Counter;

HTML-documentation generated by Dymola Sun Jan 17 21:10:28 2010.