Свободно синхронизированная Симуляция SystemC/TLM

Этот пример подсвечивает использование 'Синхронизированного' режима синхронизации, когда вы генерируете компонент SystemC™/TLM из модели Simulink с помощью цели tlmgenerator или для Simulink Coder или для Embedded Coder™.

В моделях Simulink® перемещением данных между источниками и приемниками управляют частоты дискретизации сигнала и централизованный решатель синхронизации. В моделях SystemC/TLM взаимодействиями между приемниками данных и источниками управляют ядро симуляции SystemC и усовершенствования времени через SC_THREADs, совместно приводящий к управлению другому потоку через вызовы wait.

Для синхронизированных симуляций SystemC/TLM модель придерживается аннотируемых задержек коммуникационных интерфейсов и обработки. Для свободно синхронизированных симуляций модель не позволяет потокам "запускаться вперед" вовремя и таким образом, нет никакой идеи "местного времени", которое отличается, чем чувство времени некоторого другого потока. Вместо этого инициаторы сразу синхронизируются с возвращенными задержками от транзакций TLM и обычно выполняют ненулевой синхронизированный, ожидает в порядке выполнить циклы опроса и синхронизацию по требованию. Время симуляции будет совершенствоваться в свободно синхронизированной модели, чтобы отразить коммуникацию, обработку и опрос задержек системы. Цель модели, в дополнение к соответствующей синхронизации перемещения данных как с несинхронизированной системой, состоит в том, чтобы иметь функционально правильную симуляцию с быстрые тактовые стеной времена выполнения. Эта скорость допускает разработку программного обеспечения псевдореального времени на архитектурной модели SystemC/TLM.

Для этого примера мы используем модель Simulink КИХ-фильтра как основание генерации SystemC/TLM.

Продукты, требуемые запускать эту демонстрацию:

  • MATLAB

  • Simulink

  • Simulink Coder

  • HDL Verifier

  • SystemC 2.3.1 (включает библиотеку TLM),

  • Для верификации кода сделайте и совместимый компилятор GNU, gcc, в вашем пути на Linux® или Визуальном компиляторе Studio® в вашем пути на Windows®

Примечание: пример включает процедуру сборки генерации кода. Simulink не разрешает вам создавать программы в области установки MATLAB. При необходимости изменитесь на рабочую директорию, которая не находится в области установки MATLAB до запуска никакой сборки.

1. Откройте предварительно сконфигурированную модель

Откройте TLM, который выполняет свободно синхронизированная модель испытательного стенда или в окне команды MATLAB:

  >> openTlmgDemoModel('lttb')

Следующая модель открывается в Simulink.

2. Рассмотрите целевые параметры конфигурации генератора TLM

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

3. Создайте модель

В окне модели щелкните правой кнопкой по блоку DualFilter и выберите C/C ++ Code> Generate Code для этой Подсистемы в контекстном меню, чтобы запустить компонент TLM и генерацию испытательного стенда. Или можно выполнить следующую команду в окне команды MATLAB:

  >> buildTlmgDemoModel('lttb')

Генерация завершается, когда следующее сообщение появляется в окне команды MATLAB:

### Starting Simulink Coder build procedure for model: DualFilter
### Successful completion of Simulink Coder build procedure for model: DualFilter

4. Откройте сгенерированные файлы

Откройте сгенерированный исходный код испытательного стенда в веб-браузере MATLAB путем нажатия на 'DualFilter_lttb_tlm_tb.cpp' в сгенерированном отчете или в редакторе MATLAB:

5. Рассмотрите сгенерированный код

Спецификация 'С синхронизацией' результатов в испытательном стенде, дающем компоненту TLM команду запускаться в синхронизированном режиме посредством специального интерфейса конфигурирования, mw_backdoorcfg_IF. Как код указывает, выбор синхронизации режима является динамическим и может быть изменен в ходе симуляции. Поскольку этим выбором является просто построение симуляции, он не запрограммирован посредством "парадной двери" транзакция TLM.

Кроме того, как код указывает, испытательный стенд должен установить локальный объект помощника с правильным режимом синхронизации в порядке гарантировать, что его инициатор распараллеливает, используют соответствующую синхронизацию в вызовах транзакции TLM.

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

6. Проверьте сгенерированный код

В диалоговом окне Configuration Parameters войдите в диалоговое окно параметра конфигурации TLM Testbench и нажмите на кнопку Verify TLM Component, чтобы запустить сгенерированный испытательный стенд в свободно синхронизированном режиме синхронизации, или в окне команды MATLAB выполнитесь:

  >> verifyTlmgDemoModel('lttb')

Это действие будет:

  • создайте сгенерированный код

  • запустите Simulink, чтобы получить входной стимул и ожидаемые результаты

  • преобразуйте данные Simulink в векторы TLM

  • запустите автономный исполняемый файл испытательного стенда SystemC/TLM

  • преобразуйте результаты TLM назад в данные Simulink

  • выполните сравнение данных

  • сгенерируйте Окно рисунка для любых сигналов, которые имели данные, неправильный выдерживает сравнение

7. Рассмотрите журнал выполнения

Опция, чтобы сгенерировать многословные сообщения была выбрана по порядку, чтобы видеть, как потоки инициатора испытательного стенда взаимодействуют и синхронизируются с целью. В свободно синхронизированной симуляции заметьте, как инициаторы сразу синхронизируются с аннотируемой задержкой, возвращенной в транзакции TLM. Кроме того, весь опрос и синхронизированный ожидает, мгновенные, ненулевые sim-разовые точки синхронизации.

### 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 --- Dec  4 2015 16:22:19 
        Copyright (c) 1996-2014 by all Contributors, 
        ALL RIGHTS RESERVED 
[       0 s] (singleInitiatorThread) ## found input field tlmg_in1 at tlmg_tlminvec fieldnum 0 
[       0 s] (singleInitiatorThread) ## found input field tlmg_in2 at tlmg_tlminvec fieldnum 1 
[       0 s] (singleInitiatorThread) ## found output field tlmg_out1 at tlmg_tlminvec fieldnum 2 
[       0 s] (singleInitiatorThread) ## found output field tlmg_out2 at tlmg_tlminvec fieldnum 3 
[       0 s] (singleInitiatorThread) ## setup 2 input data fields, 2 output data fields 
## STARTING SIMULATION 
[       0 s] (singleInitiatorThread) ## Start of vectors from MAT file.  Will display '.' for every 100 vectors played. 
[       0 s] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000020 
[       0 s] (singleInitiatorThread) ##	 (Command/Status reg data value = 0x00112200) 
[       0 s] (singleInitiatorThread) ##	 syncing to local time offset (delay = 5 ns). 
[     10 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 0x000020 
[     10 ns] (singleInitiatorThread) ##	 (Command/Status reg data value = 0x00112200) 
[     10 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[     10 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000020 
[     10 ns] (singleInitiatorThread) ##	 (Command/Status reg data value = 0x00112200) 
[     10 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 5 ns). 
[     20 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 0x000020 
[     20 ns] (singleInitiatorThread) ##	 (Command/Status reg data value = 0x00112200) 
[     20 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[     20 ns] (singleInitiatorThread) ## vec     0: 
##	 initialized input dataset 
[     40 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[     40 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[     40 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    140 ns] (singleInitiatorThread) ##	...saw interrupt 
[    140 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    140 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    160 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    160 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    160 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    160 ns] (singleInitiatorThread) ## vec     1: 
##	 initialized input dataset 
[    180 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    180 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    180 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    280 ns] (singleInitiatorThread) ##	...saw interrupt 
[    280 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    280 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    300 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    300 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    300 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    300 ns] (singleInitiatorThread) ## vec     2: 
##	 initialized input dataset 
[    320 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    320 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    320 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    420 ns] (singleInitiatorThread) ##	...saw interrupt 
[    420 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    420 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    440 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    440 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    440 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    440 ns] (singleInitiatorThread) ## vec     3: 
##	 initialized input dataset 
[    460 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    460 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    460 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    560 ns] (singleInitiatorThread) ##	...saw interrupt 
[    560 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    560 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    580 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    580 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    580 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    580 ns] (singleInitiatorThread) ## vec     4: 
##	 initialized input dataset 
[    600 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    600 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    600 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    700 ns] (singleInitiatorThread) ##	...saw interrupt 
[    700 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    700 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    720 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    720 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    720 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    720 ns] (singleInitiatorThread) ## vec     5: 
##	 initialized input dataset 
[    740 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    740 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    740 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    840 ns] (singleInitiatorThread) ##	...saw interrupt 
[    840 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    840 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[    860 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[    860 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[    860 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[    860 ns] (singleInitiatorThread) ## vec     6: 
##	 initialized input dataset 
[    880 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[    880 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[    880 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[    980 ns] (singleInitiatorThread) ##	...saw interrupt 
[    980 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[    980 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[      1 us] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[      1 us] (singleInitiatorThread) ##	 initialized expected output dataset 
[      1 us] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 


<<<<<<<<<<<  SNIP >>>>>>>>>>>>>>

[  69860 ns] (singleInitiatorThread) ##	...saw interrupt 
[  69860 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[  69860 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[  69880 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[  69880 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[  69880 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[  69880 ns] (singleInitiatorThread) ## vec   499: 
##	 initialized input dataset 
[  69900 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[  69900 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[  69900 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[     70 us] (singleInitiatorThread) ##	...saw interrupt 
[     70 us] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[     70 us] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[  70020 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[  70020 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[  70020 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[  70020 ns] (singleInitiatorThread) ## vec   500: 
##	 initialized input dataset 
[  70020 ns] (singleInitiatorThread) . 
[  70040 ns] (singleInitiatorThread) ##	 TLM write transaction to target component at address 00000000 
[  70040 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[  70040 ns] (singleInitiatorThread) ##	 syncing to interrupt signal for data ready in output buffer... 
[  70140 ns] (singleInitiatorThread) ##	...saw interrupt 
[  70140 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000010 
[  70140 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 20 ns). 
[  70160 ns] (singleInitiatorThread) ##	 wrote actual output dataset to MAT file buffer. 
[  70160 ns] (singleInitiatorThread) ## end of output vectors in MAT file vectors/tlmg_tlminvec.mat for output number 0 
[  70160 ns] (singleInitiatorThread) ## end of output vectors in MAT file vectors/tlmg_tlminvec.mat for output number 1 
[  70160 ns] (singleInitiatorThread) ##	 initialized expected output dataset 
[  70160 ns] (singleInitiatorThread) ##	 actual output dataset matched expected output dataset 
[  70160 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[  70160 ns] (singleInitiatorThread) ##	 TLM read  transaction to target component at address 0x000020 
[  70160 ns] (singleInitiatorThread) ##	 (Command/Status reg data value = 0x00112200) 
[  70160 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 5 ns). 
[  70165 ns] (singleInitiatorThread) ##	 syncing to local time offset (delay = 0 s). 
[  70165 ns] (singleInitiatorThread) ## end of data...Terminating initiator thread. 
[  70165 ns] (singleInitiatorThread)  
############################################# 
## END OF VECTORS. PLAYED   501 VECTORS.   ## 
## DATA MISCOMPARES     :     0            ## 
## DATA MISCOMPARES     :     0            ## 
## TRANSPORT ERRORS     :    NO            ## 
## MAT FILE WRITE ERRORS:    NO            ## 
############################################# 
[  70165 ns] (singleInitiatorThread) ##	 Wrote results MAT file. 
## SIMULATION HAS ENDED 
### Comparing expected vs. actual results.
Data successfully compared for signal tlmg_out1.
Data successfully compared for signal tlmg_out2.
Для просмотра документации необходимо авторизоваться на сайте