Help - Search - Members - Calendar
Full Version: Error occured while flattening model Modelica.Electrical.Digital.Examples.HalfAdder
Modelica Forum > Modelica > Modelica
opentom
Hi everybody,

i have problems with runing an example-model "halfadder" which is provided via the package:
Modelica.Electrical.Digital.Examples.HalfAdder

Following the code-snipets:

C:\...\OpenModelica-1.4.0\OpenModelica1.4.0\ModelicaLibrary\Modelica\Electrical\Digital.mo
...
package Digital
"Library for digital electrical components based on the VHDL standard with 9-valued logic and conversion to 2-,3-,4-valued logic"
...
model HalfAdder "adding circuit for binary numbers without input carry bit"
import Modelica.Electrical.Digital;
...
end HalfAdder;

-----

OpenModelica 1.4.0
Copyright 2002-2006, PELAB, Linkoping University

To get help on using OMShell and OpenModelica, type "help()" and press enter.

>> loadModel(Modelica)
true

>> loadModel(Modelica.Electrical.Digital.Examples.HalfAdder)
true

>> list(Modelica.Electrical.Digital.Examples.HalfAdder)
"model HalfAdder "adding circuit for binary numbers without input carry bit"
import Modelica.Electrical.Digital;
annotation(Documentation(info="<HTML>
<P>
This example demonstrates an adding circuit for binary numbers, which internally realizes the interconnection to
And and to Xor in the final sum.
<br>
<br>
1 + 0 = 1<br>
0 + 1 = 1<br>
1 + 1 = 10<br>
0 + 0 = 0
<br>
<br>
<b>a</b> + <b>b</b> = <b>s</b>
<br>(The carry of this adding is <b>c</b>.)
<br>
<br>and
<br>
<br>
<b>a</b> * <b>b</b> = <b>s</b>
<br> (It is an interconnection to And.)
<br>
<br>
<b>a</b> * <b>b</b> + <b>a</b> * <b>b</b> = <b>a</b> Xor <b>b</b> = <b>c</b>
<br>(It is an interconnection to Xor.)
<br>
<br>
<pre> <b>a</b> <b>b</b> <b>c</b> <b>s</b> <b>t</b></pre>

<pre> 1 0 1 0 1</pre>
<pre> 0 1 1 0 2</pre>
<pre> 1 1 0 1 3</pre>
<pre> 0 0 0 0 4</pre>

<br>
<br>
<b>t</b> is the pick-up instant of the next bit(s) in the simulation.
The simulation stop time should be 5 seconds.
</P>
</HTML>
"),Coordsys(extent=[-100,-100;100,100],grid=[2,2],component=[20,20]),Icon(Rectangle(extent=[-88,100;90,-100],style(color=0,rgbc

olor={0,0,0},thickness=2,fillColor=51,rgbfillColor={255,255,170})),Line(points=[
40,54;40,60;-40,60;10,0;-40,-60;40,-60;40,-52],style(

color=0,rgbcolor={0,0,0},fillPattern=1))),Diagram,Window(x=0.2,y=0.06,width=0.62,height=0.69),experiment(StopTime=5),experime

ntSetupOutput);
Sources.Table a(t={1,2,3,4},x={4,3,4,3},y0=3) annotation(extent=[-80,18;-60,38]);
Sources.Table b(x={4,3},t={2,4},y0=3) annotation(extent=[-80,-38;-60,-18]);
Digital.Examples.Utilities.HalfAdder Adder(delayTime=0.3) annotation(extent=[-40,-40;40,40]);
Digital.Converters.LogicToReal s annotation(extent=[60,18;80,38]);
Digital.Converters.LogicToReal c annotation(extent=[60,-38;80,-18]);

equation
connect(b.y,Adder.cool.gif

annotation(points=[-60,-28;-40,- 28],style(color=78,rgbcolor={127,0,127},fillColor=78,rgbfillColor={127,0,127},fi
llPattern=1));
connect(a.y,Adder.a)

annotation(points=[-60,28;- 40,28],style(color=78,rgbcolor={127,0,127},fillColor=78,rgbfillColor={127,0,127}
,fillPattern=1));
connect(Adder.s,s.x[1]) annotation(points=[40,28;65,28],style(color=78,rgbcolor={127,0,127}));
connect(Adder.c,c.x[1]) annotation(points=[40,-28;65,-28],style(color=78,rgbcolor={127,0,127}));
end HalfAdder;

"

>> simulate(Modelica.Electrical.Digital.Examples.HalfAdder)
record
resultFile = "Simulation failed.
"
end record
Error occured while flattening model Modelica.Electrical.Digital.Examples.HalfAdder


Could anybody help me with this (simple ?) problem ?

Thanx in advance,

opentom rolleyes.gif
wagner
Hello opentom,

I got your model running using Dymola. The problem I encountered was the fact that Sources.Table was unknown. By replacing Sources.Table by Modelica.Electrical.Digital.Sources.Table the model simulated succesfully.

Here you find my working version.

CODE

model HalfAdder
  "adding circuit for binary numbers without input carry bit"
import Modelica.Electrical.Digital;
  
annotation(Documentation(info="<HTML>
<P>
This example demonstrates an adding circuit for binary numbers, which internally realizes the interconnection to
And and to Xor in the final sum.
<br>
<br>
1 + 0 = 1<br>
0 + 1 = 1<br>
1 + 1 = 10<br>
0 + 0 = 0
<br>
<br>
<b>a</b> + <b>b</b> = <b>s</b>
<br>(The carry of this adding is <b>c</b>.)
<br>
<br>and
<br>
<br>
<b>a</b> * <b>b</b> = <b>s</b>
<br> (It is an interconnection to And.)
<br>
<br>
<b>a</b> * <b>b</b> + <b>a</b> * <b>b</b> = <b>a</b> Xor <b>b</b> = <b>c</b>
<br>(It is an interconnection to Xor.)
<br>
<br>
<pre> <b>a</b> <b>b</b> <b>c</b> <b>s</b> <b>t</b></pre>

<pre> 1 0 1 0 1</pre>
<pre> 0 1 1 0 2</pre>
<pre> 1 1 0 1 3</pre>
<pre> 0 0 0 0 4</pre>

<br>
<br>
<b>t</b> is the pick-up instant of the next bit(s) in the simulation.
The simulation stop time should be 5 seconds.
</P>
</HTML>
"),Coordsys(extent=[-100,-100;100,100],grid=[2,2],component=[20,20]),Icon(Rectangle(extent=[-88,100;90,-100],style& #40;color=0,rgbcolor={0,0,0},thickness=2,fillColor=51,rgbfillColor={255,255,170}
)),Line(points=[
40,54;40,60;-40,60;10,0;-40,-60;40,-60;40,-52],style(
color=0,rgbcolor={0,0,0},fillPattern=1))),Diagram,Window(x=0.2,y=0.06,width=0.62,height=0.69),experiment(StopTime=5),experimentSetupOutput);
Modelica.Electrical.Digital.Sources.Table a(t={1,2,3,4},x={4,3,4,3},y0=3) annotation(extent=[-80,18;-60,38]);
Modelica.Electrical.Digital.Sources.Table b(x={4,3},t={2,4},y0=3) annotation(extent=[-80,-38;-60,-18]);
Digital.Examples.Utilities.HalfAdder Adder(delayTime=0.3) annotation(extent=[-40,-40;40,40]);
Digital.Converters.LogicToReal s annotation(extent=[60,18;80,38]);
Digital.Converters.LogicToReal c annotation(extent=[60,-38;80,-18]);
  
equation
connect(b.y,Adder.b);
  
annotation(points=[-60,-28;-40,- 28],style& #40;color=78,rgbcolor={127,0,127},fillColor=78,rgbfillColor={127,0,127},fillPatt
ern=1));
connect(a.y,Adder.a)
annotation(points=[-60,28;- 40,28],style(color=78,rgbcolor={127,0,127},fillColor=78,rgbfillColor={127,0,127},
fillPattern=1));
  
connect(Adder.s,s.x[1]) annotation(points=[40,28;65,28],style(color=78,rgbcolor={127,0,127}));
connect(Adder.c,c.x[1]) annotation(points=[40,-28;65,-28],style(color=78,rgbcolor={127,0,127}));
end HalfAdder;


Since I don't have Openmodelica installed on my system I could not test the code with your environment.

Regards

Florian
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.