%% Verify Viterbi Decoder Using HDL Cosimulation
% This example shows how to use HDL Verifier(TM) in conjunction with
% Mentor Graphics ModelSim(R)/QuestaSim(R) or Cadence
% Incisive(R)/Xcelium(R) to verify HDL code for a fixed-point Viterbi
% decoder.

% Copyright 2011-2018 The MathWorks, Inc.

%% Open the Simulink Model
%
% * If you are using Incisive/Xcelium, open the model <matlab:viterbi_incisive viterbi_incisive.slx>. 
% * If you are using ModelSim/QuestaSim, open the model <matlab:viterbi_modelsim viterbi_modelsim.slx>. 
%
open_system('viterbi_modelsim');

%% Launch HDL Simulator
% Before launching the HDL simulator, make sure the executables are on the
% MATLAB(R) system path. Launch the simulator by double-clicking the 
% |Startup Command| block.

%% Run Simulation
% When HDL simulator has finished compiling the VHDL files and loading the
% simulation, the text "Ready for cosimulation ..." is displayed in the HDL
% simulator command window. After you see this text, start Simulink
% simulation from the open model.
%
% When the simulation stops, observe the bit error rate displayed at
% the "BER Display" block. 

%% Rerun Simulation with Different Parameters.
% There are two parameters that control the behavior of this model. The
% first is the frame size and the other is the Es/No used for simulation.
% You can change those parameters in the MATLAB console. For example,
%
%   FrameSize = 10;
%   EsNo      = 5;
%
% Then you can rerun the cosimulation with updated parameters by starting
% the simulation again from the model.

%% Finish Simulation
%
% Close the HDL simulator session.  Then return to Simulink and close 
% the model.
