Этот пример подсвечивает использование 'Несинхронизированного' режима синхронизации, когда вы генерируете компонент SystemC™/TLM из модели Simulink с помощью цели tlmgenerator или в Simulink Coder или в Embedded Coder™.
В моделях Simulink® перемещением данных между источниками и приемниками управляют частоты дискретизации сигнала и централизованный решатель синхронизации. В моделях SystemC/TLM взаимодействиями между приемниками данных и источниками управляют ядро симуляции SystemC и усовершенствования времени через SC_THREADs, совместно дающий к управлению другому потоку через wait вызовы.
Для несинхронизированных симуляций SystemC/TLM модель игнорирует аннотируемые задержки коммуникационных интерфейсов и обработки. В таких моделях цель только, чтобы иметь симуляцию, которая дает к правильным результатам путем гарантирования, что инициаторы и цели могут успешно синхронизировать перемещение данных. Нет никакой попытки оценить производительность развернутой системы. Никакое время симуляции не должно протекать, в то время как в несинхронизированной симуляции, потому что синхронизация является полностью базирующимся событием.
Для этого примера мы используем модель Simulink КИХ-фильтра как основание генерации SystemC/TLM.
Продукты, требуемые запускать эту демонстрацию:
MATLAB
Simulink
Simulink Coder
HDL Verifier
SystemC 2.3.1 (включает библиотеку TLM),
Для верификации кода сделайте и совместимый компилятор GNU, gcc, в вашем пути на Linux® или Визуальном компиляторе Studio® в вашем пути на Windows®
Примечание: пример включает процедуру сборки генерации кода. Simulink не разрешает вам создавать программы в области установки MATLAB. При необходимости превратитесь в рабочую директорию, которая не находится в области установки MATLAB до запуска никакой сборки.
Откройте несинхронизированную модель испытательного стенда TLM, или в окне команды MATLAB выполнитесь:
>> openTlmgDemoModel('uttb')Следующая модель открывается в Simulink.

В окне модели, в меню Simulation выбирают Model Configuration Parameters... В диалоговом окне Configuration Parameters выберите представление TLM Generator и вкладку TLM Testbench и рассмотрите настройки испытательного стенда как показано в следующем изображении. Установите многословный флажок сообщения испытательного стенда, чтобы видеть полный журнал взаимодействия инициатора/цели в симуляции SystemC/TLM. Поскольку это будет тысячами линий, при желании отменяют выбор опции, чтобы получить краткий журнал симуляции SystemC/TLM.

В окне модели щелкните правой кнопкой по блоку DualFilter и выберите C/C ++ Code> Generate Code для этой Подсистемы в контекстном меню, чтобы запустить компонент TLM и генерацию испытательного стенда. Или можно выполнить следующую команду в окне команды MATLAB:
>> buildTlmgDemoModel('uttb')Генерация завершается, когда следующее сообщение появляется в окне команды MATLAB:
### Starting Simulink Coder build procedure for model: DualFilter ### Successful completion of Simulink Coder build procedure for model: DualFilter
Откройте сгенерированный исходный код испытательного стенда в веб-браузере MATLAB путем нажатия на 'DualFilter_uttb_tlm_tb.cpp' в сгенерированном отчете или в редакторе MATLAB:
Спецификация, 'Не синхронизируя' результаты в испытательном стенде, дающем компоненту TLM команду запускаться в несинхронизированном режиме посредством специального интерфейса конфигурирования, mw_backdoorcfg_IF. Как код указывает, выбор синхронизации режима является динамическим и может быть изменен в ходе симуляции. Поскольку этим выбором является просто построение симуляции, он не запрограммирован посредством "парадной двери" транзакция TLM.
Кроме того, как код указывает, испытательный стенд должен установить локальный объект помощника с правильным режимом синхронизации для того, чтобы гарантировать, что его инициатор распараллеливает, используют соответствующую синхронизацию в вызовах транзакции TLM.

Реализация несинхронизированного класса синхронизации, mw_syncuntimed_tb, в mw_support_tb.cpp файл показывает детали различных вызовов синхронизации, используемых потоками инициатора и транзакциями TLM. Как ранее утверждено, вызовы используют, ожидает SC_ZERO_TIME, и никаким задержкам не позволяют накопиться.

В Configuration Parameters диалоговое окно, войдите в TLM Testbench диалоговое окно параметра конфигурации и нажатие Verify TLM Component кнопка, чтобы запустить сгенерированный испытательный стенд в несинхронизированном режиме синхронизации или в окне команды MATLAB выполняется:
>> verifyTlmgDemoModel('uttb')Это действие будет:
создайте сгенерированный код
запустите Simulink, чтобы получить входной стимул и ожидаемые результаты
преобразуйте данные Simulink в векторы TLM
запустите автономный исполняемый файл испытательного стенда SystemC/TLM
преобразуйте результаты TLM назад в данные Simulink
выполните сравнение данных
сгенерируйте Окно рисунка для любых сигналов, которые имели данные, неправильный выдерживает сравнение
Опция, чтобы сгенерировать многословные сообщения была выбрана в порядке, чтобы видеть, как потоки инициатора испытательного стенда взаимодействуют и синхронизируются с целью. В несинхронизированной симуляции заметьте, как метка времени остается в '0 с', и весь опрос и синхронизированный ожидает, zero-sim-time точки синхронизации.
### Starting component verification
### Checking available compiler.
### Building testbench and TLM component.
### Running Simulink simulation to capture inputs and expected outputs.
### Executing TLM testbench to generate actual outputs.
SystemC 2.3.1-Accellera --- Jun 18 2014 15:36:00
Copyright (c) 1996-2014 by all Contributors,
ALL RIGHTS RESERVED
[ 0 s] (readerThread) ## found input field tlmg_in1 at tlmg_tlminvec fieldnum 0
[ 0 s] (readerThread) ## found input field tlmg_in2 at tlmg_tlminvec fieldnum 1
[ 0 s] (readerThread) ## found output field tlmg_out1 at tlmg_tlminvec fieldnum 2
[ 0 s] (readerThread) ## found output field tlmg_out2 at tlmg_tlminvec fieldnum 3
[ 0 s] (readerThread) ## setup 2 input data fields, 2 output data fields
## STARTING SIMULATION
[ 0 s] (writerThread) ## Start of vectors from MAT file. Will display '.' for every 100 vectors played.
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM write transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## vec 0:
## initialized input dataset
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM write transaction to target component at address 00000000
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## vec 1:
## initialized input dataset
[ 0 s] (readerThread) ## TLM write transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM write transaction to target component at address 00000000
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## vec 2:
## initialized input dataset
[ 0 s] (readerThread) ## syncing to interrupt signal for data ready in output buffer...
[ 0 s] (readerThread) ## ...saw interrupt
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM write transaction to target component at address 00000000
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00012204)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## polling for input and output buffers empty...
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000010
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00012204)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## wrote actual output dataset to MAT file buffer.
[ 0 s] (readerThread) ## initialized expected output dataset
[ 0 s] (readerThread) ## actual output dataset matched expected output dataset
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00012200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00012200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000010
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## wrote actual output dataset to MAT file buffer.
[ 0 s] (readerThread) ## initialized expected output dataset
[ 0 s] (readerThread) ## actual output dataset matched expected output dataset
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00012200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00012200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000010
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (readerThread) ## wrote actual output dataset to MAT file buffer.
[ 0 s] (readerThread) ## initialized expected output dataset
[ 0 s] (readerThread) ## actual output dataset matched expected output dataset
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## syncing to interrupt signal for data ready in output buffer...
[ 0 s] (writerThread) ## ...saw polling return expected value. (bitValue=0x00110000, bitMask=0x00110000, masked csr=0x00110000)
[ 0 s] (writerThread) ## vec 3:
## initialized input dataset
[ 0 s] (writerThread) ## TLM write transaction to target component at address 00000000
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## vec 4:
## initialized input dataset
[ 0 s] (writerThread) ## TLM write transaction to target component at address 00000000
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
<<<<<<<<<<< SNIP >>>>>>>>>>>>>>
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00012200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000010
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (readerThread) ## wrote actual output dataset to MAT file buffer.
[ 0 s] (readerThread) ## end of output vectors in MAT file vectors/tlmg_tlminvec.mat for output number 0
[ 0 s] (readerThread) ## end of output vectors in MAT file vectors/tlmg_tlminvec.mat for output number 1
[ 0 s] (readerThread) ## initialized expected output dataset
[ 0 s] (readerThread) ## actual output dataset matched expected output dataset
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (readerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (readerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (readerThread) ## end of output data...Terminating readerThread
[ 0 s] (readerThread)
#############################################
## END OF VECTORS. PLAYED 501 VECTORS. ##
## DATA MISCOMPARES : 0 ##
## TRANSPORT ERRORS : NO ##
## MAT FILE WRITE ERRORS: NO ##
#############################################
[ 0 s] (readerThread) ## Wrote results MAT file.
[ 0 s] (writerThread) ## ...saw polling return expected value. (bitValue=0x00110000, bitMask=0x00110000, masked csr=0x00110000)
[ 0 s] (writerThread) ## end of input vectors in MAT file vectors/tlmg_tlminvec.mat for input number 0
[ 0 s] (writerThread) ## end of input vectors in MAT file vectors/tlmg_tlminvec.mat for input number 1
[ 0 s] (writerThread) ## waiting for explicit amount of time (time = 0 ns + 0 ns).
[ 0 s] (writerThread) ## polling for input and output buffers empty...
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## ...saw polling return expected value. (bitValue=0x00110000, bitMask=0x00110000, masked csr=0x00110000)
[ 0 s] (writerThread) ## ...saw polling return expected value. (bitValue=0x00110000, bitMask=0x00110000, masked csr=0x00110000)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## TLM read transaction to target component at address 0x000020
[ 0 s] (writerThread) ## (Command/Status reg data value = 0x00112200)
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## syncing to local time offset (delay = 0 ns).
[ 0 s] (writerThread) ## end of data...Terminating initiator thread.
## SIMULATION HAS ENDED
### Comparing expected vs. actual results.
Data successfully compared for signal tlmg_out1.
Data successfully compared for signal tlmg_out2.