OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [doc/] [src/] [tex/] [simulation.tex] - Diff between revs 210 and 221

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 210 Rev 221
Line 9... Line 9...
    In short, the simulation test bench is meant to run any of the code samples
    In short, the simulation test bench is meant to run any of the code samples
    provided in directory /src, under a controlled environment, while logging
    provided in directory /src, under a controlled environment, while logging
    the cpu state to a text log file.\\
    the cpu state to a text log file.\\
 
 
    This log file can then be compared to a log file generated by a software
    This log file can then be compared to a log file generated by a software
    simulator for the same code sample (see section 5.1). The software
    simulator for the same code sample (see section \ref{sw_simulator}). The software
    simulator is the 'golden model' against which the cpu is tested, so any
    simulator is the 'golden model' against which the cpu is tested, so any
    difference between both log files means trouble.\\
    difference between both log files means trouble.\\
 
 
    This method is far easier than building a fully automated test bench, and
    This method is far easier than building a fully automated test bench, and
    much more convenient and reliable than a visual inspection of the simulation
    much more convenient and reliable than a visual inspection of the simulation
    state.\\
    state.\\
 
 
    In addition to the main log file, there is a console log file to which all
    In addition to the main log file, there is a console log file to which all
    data written to the UART is logged (see section~\ref{uart_logging}).\\
    data written to the UART is logged (see section~\ref{uart_logging}).\\
 
 
    There are a few simulation test bench templates in the /src directory, which
 
    are used by all the code samples.\\
 
    The only ones actually used are '/src/code\_rom\_template.vhdl' and
 
    '/src/sim\_params\_template.vhdl'. The others
 
    are remnants of previous versions that will be removed ASAP.\\
 
 
 
    The template in file '/src/code\_rom\_template.vhdl' is filled with object
 
    code meant to be run from internal FPGA BRAM. This is how we load bootstrap
 
    code into our FPGA. The resulting file is '/vhdl/demo/code\_rom\_pkg.vhdl'
 
    and is used by both the simulation test bench and the synthesizable MCU.\\
 
 
 
    The template in file '/src/sim\_params\_template.vhdl' is filled with
 
    simulation parameters (such as the simulation length, etc.) and the resulting
 
    file is written as '/vhdl/tb/sim\_params\_pkg.vhdl'. This file is only used
 
    by the simulation test bench.
 
 
 
    All of this template filling is done by a python script (/src/bin2hdl.py)
    The simulation test bench can be found in file '/vhdl/tb/mips\_tb.vhdl'.
    which is invoked from the makefiles and explained in section xxx.\\
    This test bench is meant to be used with all the code samples.
 
 
 
    Each of the code samples configures the simulation test bench with certain
 
    parameters (such as simulation length or memory sizes) and of course each
 
    sample has a different object code to be run. The way to pass these
 
    parameters to the simulation is through a simulation package, in file
 
    '/vhdl/tb/sim\_params\_pkg.vhdl'.
 
 
 
    This file is generated from a template whenever you 'make' each code sample
 
    (see section~\ref{samples}). The package is built using oe of the
 
    provided tools, 'build\_pkg', explained in section ~\ref{build_pkg}.
 
 
 
 
    Note that all code samples share the same vhdl files: you need to run the
    Note that all code samples share the same vhdl files: you need to run the
    makefile target 'sim' for the sample you want to simulate; that will
    makefile target 'sim' for the sample you want to simulate; that will
    overwrite the two files mentioned above. So there's no vhdl file that is
    overwrite the package file mentioned above. So there's no vhdl file that is
    specific to a particular code sample.\\
    specific to a particular code sample.\\
 
 
    The actual test bench entity is at '/vhdl/tb/mips\_tb.vhdl' and is shared
 
    by all the code samples.\\
 
 
 
    While the test benches and sample code are good enough to catch MOST errors
    While the test benches and sample code are good enough to catch MOST errors
    in the full system (i.e. cache included) they don't help with diagnostic;
    in the full system (i.e. cache included) they don't help with diagnostic;
    once you know there's an error, and the approximate address where it's
    once you know there's an error, and the approximate address where it's
    triggered (approximate because of the cache) you have to dig into the
    triggered (approximate because of the cache) you have to dig into the
    simulation waveforms to find it. It's easier than it seems.\\
    simulation waveforms to find it.\\
 
 
\section{Running the Simulation}
\section{Running the Simulation}
\label{running_the_simulation}
\label{running_the_simulation}
 
 
    A simulation script can be found at '/sim/mips\_tb.do'. This script will
    A simulation script can be found at '/sim/mips\_tb.do'. This script will
Line 64... Line 57...
    All the code samples are run with the same script.\\
    All the code samples are run with the same script.\\
 
 
    The test bench files mentioned in the previous section are automatically
    The test bench files mentioned in the previous section are automatically
    generated for each of the sample programs. This is automatically done by the
    generated for each of the sample programs. This is automatically done by the
    sample code makefile,
    sample code makefile,
    assuming you have a MIPS cross-toolchain in your computer (see section~\ref{code_samples}).\\
    assuming you have a MIPS cross-toolchain in your computer (see section~\ref{samples}).\\
 
 
    For convenience, a pre-generated mips\_tb.vhdl is included so you can launch
    For convenience, a pre-generated file 'sim\_params\_pkg.vhdl' is included
    a simulation without having to install toolchains, etc. The code is that
    so you can launch a simulation without having to install toolchains, etc.
    of the 'hello world' sample.\\
    The code is that of the 'hello world' sample.\\
 
 
    I guess that if you are interested in this sort of stuff then you probably
    I guess that if you are interested in this sort of stuff then you probably
    know more about Modelsim than I do. Yet, here's a step-by-step guide to
    know more about Modelsim than I do. Yet, here's a step-by-step guide to
    simulating the 'hello world' sample:
    simulating the 'hello world' sample:
 
 
\begin{enumerate}
\begin{enumerate}
    \item Run 'make hello\_sim' from directory '/src/hello'.
    \item Run 'make hello\_sim' from directory '/src/hello'.
        This will compile the program sources, build the necessary binary object
        This will compile the program sources, build the necessary binary object
        files and then create the two package files mentioned above.\\
        files and then create the package file mentioned above.\\
        Read the makefile and comments in the python script '/src/bin2hdl.py'
        Read the makefile and comments in the python script '/src/bin2hdl.py'
        for details.\\
        for details.\\
 
 
        ALTERNATIVELY, if you don't have a toolchain you can just skip this
        ALTERNATIVELY, if you don't have a toolchain you can just skip this
        step and use the default vhdl files provided, which are those of the
        step and use the default vhdl files provided, which are those of the
Line 136... Line 129...
    This means that for example a long chain of NOPs, or MOVEs that don't change
    This means that for example a long chain of NOPs, or MOVEs that don't change
    register values, will not be seen in the log file. This is on purpose.\\
    register values, will not be seen in the log file. This is on purpose.\\
 
 
    Events are logged with the address of the instruction that triggered
    Events are logged with the address of the instruction that triggered
    the change. This holds true even for load instructions.\\
    the change. This holds true even for load instructions.\\
    Early versions of the project logged the address of the
 
    preceding instruction -- it was confusing and I have fixed it.\\
 
 
 
    The simulation log file is stored by default in modelsim's working directory
    The simulation log file is stored by default in modelsim's working directory
    (see above). I don't provide any automated script to do the comparison, you
    (see above). I don't provide any automated script to do the comparison, you
    should use whatever diff tool you like best.\\
    should use whatever diff tool you like best.\\
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.