The process of adding a new behavioral model to
the MCS simulator is outlined in the following steps:
WARNING:
This is not a simple process. Set a bit of time aside.
Before You Begin:
You will need access to the following:
a. MCS simulator source code
b. Structural parser source
code
c. Behavioral Parser
Also Note:
The following instructions tell you how to edit
source files for the MCS simulator
and the Structural Parser in order to add
a new behavioral model to the simulator.
In many cases, you must add new '#define'
statements or lines of code. When in doubt,
just look at what was added for other behavioral
models and use these as examples.
In most cases, you can just replicate what
was done for other models and make the
appropriate name changes. In the cases where
index numbers exist, just add your
new model to the end of the existing list,
and make you index 1 more than the last
element on the list.
1.) Write the behavioral model in Verilog
and save with a *.v extension.
2.) Run the behavioral Parser on your verilog
model, outputting to a file called 'ModelName.out'.
Here, 'ModelName' can just be
the name of your model. This can be accomplished with the
following command:`
parser
< ModelName.v > ModelName.out
3.) Inspect "ModelName.out" and make sure
the behavioral parser has not spit out junk.
You should see some code that
looks like C.
CHANGES TO THE SIMULATOR:
4.) The next step is to update the mcs
simulator with the new model, "ModelName.out".
It will be necessary to update
the following files: 'eval.c', 'topology.h', 'create.c', 'loadcode.h'.
It's best to check out all of
the MCS source files into a working directory.
5) 'eval.c'
add the code from 'ModelName.out'
to the end of the eval.c file.
Helper functions may be added
here as well.
6) 'topology.h'
Add a #define statement towards
the beginning of this file.
Behavioral types start with
integer 150 and proceed from there.
7) 'create.c'
Add an extern declaration for
the procedure as named in eval.c.
Also add a case statement following
"switch ((unsigned char) te_type)"
This begins about halfway through
the file. The case statement is pretty much just a
call to the appropriate eval.c
function.
8) 'loadcode.h'
Add another #define statement
to this file.
Again, find the behavioral code
section and follow the sequence.
9.) Assuming everything has gone well so
far, mcs can now be recompiled.
To do this, just type 'make'
in the working directory.
10.) Congratulations! You now have a new
version of MCS which recognizes your model.
However, you might like to write
a test network file which includes it. This will let you make sure
that it functions correctly
as a behavioral component in the simulator. You will have to write your test
file in verilog, and then use
the Structural Parser to convert it to the *.dee format which MCS understands.
Sadly, this leads to an additional
complication: The Structural Parser will not recognize a reference to your
behavioral component if it is
not mentioned in the Struct_Parser code. So, now you have to add the name of
your behavioral component to
the Structural Parser. Read on to see how this is done:
11.) You will have to edit two files: 'verilog.lex'
and 'verilog.yacc'. At this time of this writing, the
Structural parser being used
is in the '/groups/sim/Tools/Struct_parser/Source.mult_output/' directory.
12.) 'verilog.yacc'
Add a new define statement for
your behavioral component as follows:
#define
ModelName ID_NUMBER
Here, the ID_NUMBER should be
the same as the number that appears to the right of your model
as mentioned in the 'loadcode.h'
file. For example, if your define statement in 'loadcode.h' looks like:
#define
MZ_MATTI_MUX (unsigned char) 10
Then you should add the line,
#define
MATTI_MUX 10
to verilog.yacc.
Also add the name of your model
to the list of token keywords with no type in verilog.yacc.
Just do a search for an existing
model such as "FA" (a full adder) to see where you should add.
13.) 'verilog.lex'
Add the name of your model to
the list of verilog keywords as follows:
"ModelName"
{ return MODELNAME }
Here, "ModelName" on the left
is the name you will use to refer to your behavioral model in the verilog test
file.
MODELNAME in caps on the right
is the token returned to the parser when it sees this.
MODELNAME in caps should appear
the same way in Verilog.yacc.
14.) Now, recompile the Structural parser
with the 'make' command. Assuming you did everything correctly,
you should now be able to write
a verilog test file which refers to you behavioral model by name, run it through
the Structural Parser to convert
it to a *.dee, and run it in the recompiled simulator. To see if your Structural
Parser
recognizes the Verilog test
file (and your behavioral model) correctly, try using the 'decode' utility.
It should show
that you have an unidentified
behavioral element.
15.) You're all done. :)