<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://ift.wiki.uib.no/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cto070</id>
	<title>ift - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://ift.wiki.uib.no/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Cto070"/>
	<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/Special:Contributions/Cto070"/>
	<updated>2026-05-26T11:51:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1979</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1979"/>
		<updated>2013-10-22T12:50:15Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
 &lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied below. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.   &lt;br /&gt;
&lt;br /&gt;
 quietly set ACTELLIBNAME SmartFusion2&lt;br /&gt;
 quietly set PROJECT_DIR &amp;quot;C:/Microsemi/Projects/APB_custom_peripheral&amp;quot;&lt;br /&gt;
 source &amp;quot;${PROJECT_DIR}/simulation/CompileDssBfm.tcl&amp;quot;;source &amp;quot;${PROJECT_DIR}/simulation/bfmtovec_compile.tcl&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 if {[file exists presynth/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library presynth already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib presynth&lt;br /&gt;
 }&lt;br /&gt;
 vmap presynth presynth&lt;br /&gt;
 vmap SmartFusion2 &amp;quot;C:/Microsemi/Libero_v11.1/Designer/lib/modelsim/precompiled/vhdl/SmartFusion2&amp;quot;&lt;br /&gt;
 if {[file exists COREAPB3_LIB/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library COREAPB3_LIB already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib COREAPB3_LIB&lt;br /&gt;
 }&lt;br /&gt;
 vmap COREAPB3_LIB &amp;quot;COREAPB3_LIB&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral_MSS/APB_custom_peripheral_MSS.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/dcs_interface_pkg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/apb_to_dcs.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/mtest.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/DCS_test.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/FCCC_0/APB_custom_peripheral_FCCC_0_FCCC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/OSC_0/APB_custom_peripheral_OSC_0_OSC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_muxptob3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_iaddr_reg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/components.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/APB_custom_peripheral.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/testbench.vhd&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vsim -L SmartFusion2 -L presynth -L COREAPB3_LIB  -t 1fs presynth.testbench&lt;br /&gt;
 &lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PREADY \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSLVERR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE_PLL_LOCK \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_F2M \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PADDR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PENABLE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSEL \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PRDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWRITE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_M2F&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/penable \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/psel \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwrite \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/paddr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/prdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pslverr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/clk \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_n \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_from_siu \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/global_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/rcu_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/fec_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pready \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/siu_bg&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/siu_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/wr_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/rd_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/address \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/myram&lt;br /&gt;
 run 150 us&lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file supplied below. Name it Fabric_top.pdc. &lt;br /&gt;
 &lt;br /&gt;
 # Microsemi I/O Physical Design Constraints file&lt;br /&gt;
 # Auto Generated User I/O Constraints file&lt;br /&gt;
 &lt;br /&gt;
 # Version: v11.1 11.1.0.14&lt;br /&gt;
 # Family: SmartFusion2 , Die: M2S050T_ES , Package: 896 FBGA&lt;br /&gt;
 # Date generated: Fri Sep 20 10:03:27 2013 &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O Bank Settings&lt;br /&gt;
 # &lt;br /&gt;
 set_iobank Bank0 -vcci 1.80 -fixed yes&lt;br /&gt;
 set_iobank Bank1 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank2 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank3 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank4 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank8 -vcci 3.30 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # Unlocked I/O Bank Settings&lt;br /&gt;
 # The I/O Bank Settings can be locked by directly editing this file&lt;br /&gt;
 # or by making changes in the I/O Attribute Editor&lt;br /&gt;
 # &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O settings&lt;br /&gt;
 # &lt;br /&gt;
 set_io MMUART_0_RXD -pinname L23 -fixed yes&lt;br /&gt;
 set_io MMUART_0_TXD -pinname H27 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io MSS_RESET_N_F2M  \&lt;br /&gt;
     -pinname F30        \&lt;br /&gt;
     -fixed yes          \&lt;br /&gt;
     -RES_PULL Up        \&lt;br /&gt;
     -DIRECTION INPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io GPIO_0_M2F            \&lt;br /&gt;
     -pinname G30       \&lt;br /&gt;
     -fixed yes         \&lt;br /&gt;
     -DIRECTION OUTPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The file is imported by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the  following: &lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;drivers/mss_uart/mss_uart.h&amp;quot; &lt;br /&gt;
 #include &amp;quot;drivers/mss_gpio/mss_gpio.h&amp;quot; &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Initialize registers to read/write&lt;br /&gt;
 #define APB_TO_DCS_0                    0x50000000U&lt;br /&gt;
 #define MEM1 		(*(volatile int32_t *) 0x50000000)&lt;br /&gt;
 #define MEM2 		(*(volatile int32_t *) 0x50000004)&lt;br /&gt;
 #define MEM3 		(*(volatile int32_t *) 0x50000008)&lt;br /&gt;
 #define MEM4 		(*(volatile int32_t *) 0x5000000C)&lt;br /&gt;
 #define MEM5 		(*(volatile int32_t *) 0x50000010)&lt;br /&gt;
 #define MEM6 		(*(volatile int32_t *) 0x50000014)&lt;br /&gt;
 #define MEM7 		(*(volatile int32_t *) 0x50000018)&lt;br /&gt;
 #define MEM8 		(*(volatile int32_t *) 0x5000001C)&lt;br /&gt;
 &lt;br /&gt;
 //Define a constant delay value&lt;br /&gt;
 #define DELAY_LOAD_VALUE	0x00080000     			//about half a second&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 /*&lt;br /&gt;
 * Initialize MSS GPIOs.&lt;br /&gt;
 */&lt;br /&gt;
 MSS_GPIO_init();&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Configure MSS GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_config( MSS_GPIO_0 , MSS_GPIO_OUTPUT_MODE );&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Set initial state of GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_set_output(MSS_GPIO_0,0);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Using UART 0&lt;br /&gt;
 mss_uart_instance_t * const gp_my_uart = &amp;amp;g_mss_uart0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Using one delay to write and one delay to read&lt;br /&gt;
  */&lt;br /&gt;
 volatile int32_t delay_count_1 = 0;&lt;br /&gt;
 volatile int32_t delay_count_2 = 0;&lt;br /&gt;
 delay_count_1 = DELAY_LOAD_VALUE/2;&lt;br /&gt;
 delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variable to read value from memory to set led&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t led;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Incrementing value to be written to memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t i = 0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variables to hold values read from memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t m1,m2,m3,m4,m5,m6,m7,m8;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * data to be sent on UART, holding chopped memory data&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t data[4];&lt;br /&gt;
 &lt;br /&gt;
     /*--------------------------------------------------------------------------&lt;br /&gt;
      * Initialize and configure UART.&lt;br /&gt;
      */&lt;br /&gt;
     MSS_UART_init(gp_my_uart,&lt;br /&gt;
                   MSS_UART_57600_BAUD,&lt;br /&gt;
                   MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);&lt;br /&gt;
 &lt;br /&gt;
     MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r*******************Hello World*********************\n\r&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 	//Always&lt;br /&gt;
 	while( 1 )&lt;br /&gt;
 	{&lt;br /&gt;
 		-- delay_count_1;&lt;br /&gt;
 		-- delay_count_2;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Updating memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_1 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_1 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			MEM1 = i;&lt;br /&gt;
 			MEM2 = i+1;&lt;br /&gt;
 			MEM3 = i+2;&lt;br /&gt;
 			MEM4 = i+3;&lt;br /&gt;
 			MEM5 = i+4;&lt;br /&gt;
 			MEM6 = i+5;&lt;br /&gt;
 			MEM7 = i+6;&lt;br /&gt;
 			MEM8 = i+7;&lt;br /&gt;
 &lt;br /&gt;
 		}&lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Reading memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_2 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			m1 = MEM1;&lt;br /&gt;
 			if(m1 != i) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 1 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
  			 * Chopping data from memory, sending it to UART.&lt;br /&gt;
 			 * Reading hex/binary values from console&lt;br /&gt;
 			 */&lt;br /&gt;
 		    data[3] = m1;&lt;br /&gt;
 		    data[2] = m1 &amp;gt;&amp;gt;8;&lt;br /&gt;
 		    data[1] = m1 &amp;gt;&amp;gt;16;&lt;br /&gt;
 		    data[0] = m1 &amp;gt;&amp;gt;24;&lt;br /&gt;
 		    MSS_UART_polled_tx(gp_my_uart, data, sizeof(data));&lt;br /&gt;
 &lt;br /&gt;
 			m2 = MEM2;&lt;br /&gt;
 			if(m2 != i+1) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 2 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m3 = MEM3; &lt;br /&gt;
 			if(m3 != i+2) { &lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 3 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m4 = MEM4;&lt;br /&gt;
 			if(m4 != i+3) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 4 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m5 = MEM5;&lt;br /&gt;
 			if(m5 != i+4) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 5 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m6 = MEM6;&lt;br /&gt;
 			if(m6 != i+5) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 6 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m7 = MEM7;&lt;br /&gt;
 			if(m7 != i+6) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 7 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m8 = MEM8;&lt;br /&gt;
 			if(m8 != i+7) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 8 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
 			 * Read last bit of current value of m1 and set GPIO (led) according to the bit value&lt;br /&gt;
 			 * Bit should toggle for every read cycle&lt;br /&gt;
 			 */&lt;br /&gt;
 			led = m1 &amp;amp; 0x00000001;&lt;br /&gt;
 			MSS_GPIO_set_output(MSS_GPIO_0,led);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 			++i;&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The application will write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=VHDL files=&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1978</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1978"/>
		<updated>2013-10-22T11:21:22Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
 &lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied below. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.   &lt;br /&gt;
&lt;br /&gt;
 quietly set ACTELLIBNAME SmartFusion2&lt;br /&gt;
 quietly set PROJECT_DIR &amp;quot;C:/Microsemi/Projects/APB_custom_peripheral&amp;quot;&lt;br /&gt;
 source &amp;quot;${PROJECT_DIR}/simulation/CompileDssBfm.tcl&amp;quot;;source &amp;quot;${PROJECT_DIR}/simulation/bfmtovec_compile.tcl&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 if {[file exists presynth/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library presynth already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib presynth&lt;br /&gt;
 }&lt;br /&gt;
 vmap presynth presynth&lt;br /&gt;
 vmap SmartFusion2 &amp;quot;C:/Microsemi/Libero_v11.1/Designer/lib/modelsim/precompiled/vhdl/SmartFusion2&amp;quot;&lt;br /&gt;
 if {[file exists COREAPB3_LIB/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library COREAPB3_LIB already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib COREAPB3_LIB&lt;br /&gt;
 }&lt;br /&gt;
 vmap COREAPB3_LIB &amp;quot;COREAPB3_LIB&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral_MSS/APB_custom_peripheral_MSS.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/dcs_interface_pkg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/apb_to_dcs.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/mtest.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/DCS_test.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/FCCC_0/APB_custom_peripheral_FCCC_0_FCCC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/OSC_0/APB_custom_peripheral_OSC_0_OSC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_muxptob3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_iaddr_reg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/components.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/APB_custom_peripheral.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/testbench.vhd&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vsim -L SmartFusion2 -L presynth -L COREAPB3_LIB  -t 1fs presynth.testbench&lt;br /&gt;
 &lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PREADY \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSLVERR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE_PLL_LOCK \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_F2M \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PADDR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PENABLE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSEL \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PRDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWRITE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_M2F&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/penable \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/psel \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwrite \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/paddr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/prdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pslverr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/clk \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_n \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_from_siu \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/global_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/rcu_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/fec_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pready \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/siu_bg&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/siu_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/wr_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/rd_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/address \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/myram&lt;br /&gt;
 run 150 us&lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file supplied below. Name it Fabric_top.io. &lt;br /&gt;
 &lt;br /&gt;
 # Microsemi I/O Physical Design Constraints file&lt;br /&gt;
 # Auto Generated User I/O Constraints file&lt;br /&gt;
 &lt;br /&gt;
 # Version: v11.1 11.1.0.14&lt;br /&gt;
 # Family: SmartFusion2 , Die: M2S050T_ES , Package: 896 FBGA&lt;br /&gt;
 # Date generated: Fri Sep 20 10:03:27 2013 &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O Bank Settings&lt;br /&gt;
 # &lt;br /&gt;
 set_iobank Bank0 -vcci 1.80 -fixed yes&lt;br /&gt;
 set_iobank Bank1 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank2 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank3 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank4 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank8 -vcci 3.30 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # Unlocked I/O Bank Settings&lt;br /&gt;
 # The I/O Bank Settings can be locked by directly editing this file&lt;br /&gt;
 # or by making changes in the I/O Attribute Editor&lt;br /&gt;
 # &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O settings&lt;br /&gt;
 # &lt;br /&gt;
 set_io MMUART_0_RXD -pinname L23 -fixed yes&lt;br /&gt;
 set_io MMUART_0_TXD -pinname H27 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io MSS_RESET_N_F2M  \&lt;br /&gt;
     -pinname F30        \&lt;br /&gt;
     -fixed yes          \&lt;br /&gt;
     -RES_PULL Up        \&lt;br /&gt;
     -DIRECTION INPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io GPIO_0_M2F            \&lt;br /&gt;
     -pinname G30       \&lt;br /&gt;
     -fixed yes         \&lt;br /&gt;
     -DIRECTION OUTPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The file is imported by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the  following: &lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;drivers/mss_uart/mss_uart.h&amp;quot; &lt;br /&gt;
 #include &amp;quot;drivers/mss_gpio/mss_gpio.h&amp;quot; &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Initialize registers to read/write&lt;br /&gt;
 #define APB_TO_DCS_0                    0x50000000U&lt;br /&gt;
 #define MEM1 		(*(volatile int32_t *) 0x50000000)&lt;br /&gt;
 #define MEM2 		(*(volatile int32_t *) 0x50000004)&lt;br /&gt;
 #define MEM3 		(*(volatile int32_t *) 0x50000008)&lt;br /&gt;
 #define MEM4 		(*(volatile int32_t *) 0x5000000C)&lt;br /&gt;
 #define MEM5 		(*(volatile int32_t *) 0x50000010)&lt;br /&gt;
 #define MEM6 		(*(volatile int32_t *) 0x50000014)&lt;br /&gt;
 #define MEM7 		(*(volatile int32_t *) 0x50000018)&lt;br /&gt;
 #define MEM8 		(*(volatile int32_t *) 0x5000001C)&lt;br /&gt;
 &lt;br /&gt;
 //Define a constant delay value&lt;br /&gt;
 #define DELAY_LOAD_VALUE	0x00080000     			//about half a second&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 /*&lt;br /&gt;
 * Initialize MSS GPIOs.&lt;br /&gt;
 */&lt;br /&gt;
 MSS_GPIO_init();&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Configure MSS GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_config( MSS_GPIO_0 , MSS_GPIO_OUTPUT_MODE );&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Set initial state of GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_set_output(MSS_GPIO_0,0);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Using UART 0&lt;br /&gt;
 mss_uart_instance_t * const gp_my_uart = &amp;amp;g_mss_uart0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Using one delay to write and one delay to read&lt;br /&gt;
  */&lt;br /&gt;
 volatile int32_t delay_count_1 = 0;&lt;br /&gt;
 volatile int32_t delay_count_2 = 0;&lt;br /&gt;
 delay_count_1 = DELAY_LOAD_VALUE/2;&lt;br /&gt;
 delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variable to read value from memory to set led&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t led;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Incrementing value to be written to memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t i = 0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variables to hold values read from memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t m1,m2,m3,m4,m5,m6,m7,m8;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * data to be sent on UART, holding chopped memory data&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t data[4];&lt;br /&gt;
 &lt;br /&gt;
     /*--------------------------------------------------------------------------&lt;br /&gt;
      * Initialize and configure UART.&lt;br /&gt;
      */&lt;br /&gt;
     MSS_UART_init(gp_my_uart,&lt;br /&gt;
                   MSS_UART_57600_BAUD,&lt;br /&gt;
                   MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);&lt;br /&gt;
 &lt;br /&gt;
     MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r*******************Hello World*********************\n\r&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 	//Always&lt;br /&gt;
 	while( 1 )&lt;br /&gt;
 	{&lt;br /&gt;
 		-- delay_count_1;&lt;br /&gt;
 		-- delay_count_2;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Updating memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_1 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_1 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			MEM1 = i;&lt;br /&gt;
 			MEM2 = i+1;&lt;br /&gt;
 			MEM3 = i+2;&lt;br /&gt;
 			MEM4 = i+3;&lt;br /&gt;
 			MEM5 = i+4;&lt;br /&gt;
 			MEM6 = i+5;&lt;br /&gt;
 			MEM7 = i+6;&lt;br /&gt;
 			MEM8 = i+7;&lt;br /&gt;
 &lt;br /&gt;
 		}&lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Reading memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_2 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			m1 = MEM1;&lt;br /&gt;
 			if(m1 != i) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 1 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
  			 * Chopping data from memory, sending it to UART.&lt;br /&gt;
 			 * Reading hex/binary values from console&lt;br /&gt;
 			 */&lt;br /&gt;
 		    data[3] = m1;&lt;br /&gt;
 		    data[2] = m1 &amp;gt;&amp;gt;8;&lt;br /&gt;
 		    data[1] = m1 &amp;gt;&amp;gt;16;&lt;br /&gt;
 		    data[0] = m1 &amp;gt;&amp;gt;24;&lt;br /&gt;
 		    MSS_UART_polled_tx(gp_my_uart, data, sizeof(data));&lt;br /&gt;
 &lt;br /&gt;
 			m2 = MEM2;&lt;br /&gt;
 			if(m2 != i+1) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 2 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m3 = MEM3; &lt;br /&gt;
 			if(m3 != i+2) { &lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 3 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m4 = MEM4;&lt;br /&gt;
 			if(m4 != i+3) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 4 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m5 = MEM5;&lt;br /&gt;
 			if(m5 != i+4) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 5 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m6 = MEM6;&lt;br /&gt;
 			if(m6 != i+5) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 6 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m7 = MEM7;&lt;br /&gt;
 			if(m7 != i+6) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 7 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m8 = MEM8;&lt;br /&gt;
 			if(m8 != i+7) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 8 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
 			 * Read last bit of current value of m1 and set GPIO (led) according to the bit value&lt;br /&gt;
 			 * Bit should toggle for every read cycle&lt;br /&gt;
 			 */&lt;br /&gt;
 			led = m1 &amp;amp; 0x00000001;&lt;br /&gt;
 			MSS_GPIO_set_output(MSS_GPIO_0,led);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 			++i;&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The application will write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=VHDL files=&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1964</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1964"/>
		<updated>2013-09-30T09:32:32Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
 &lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied below. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.   &lt;br /&gt;
&lt;br /&gt;
 quietly set ACTELLIBNAME SmartFusion2&lt;br /&gt;
 quietly set PROJECT_DIR &amp;quot;C:/Microsemi/Projects/APB_custom_peripheral&amp;quot;&lt;br /&gt;
 source &amp;quot;${PROJECT_DIR}/simulation/CompileDssBfm.tcl&amp;quot;;source &amp;quot;${PROJECT_DIR}/simulation/bfmtovec_compile.tcl&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 if {[file exists presynth/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library presynth already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib presynth&lt;br /&gt;
 }&lt;br /&gt;
 vmap presynth presynth&lt;br /&gt;
 vmap SmartFusion2 &amp;quot;C:/Microsemi/Libero_v11.1/Designer/lib/modelsim/precompiled/vhdl/SmartFusion2&amp;quot;&lt;br /&gt;
 if {[file exists COREAPB3_LIB/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library COREAPB3_LIB already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib COREAPB3_LIB&lt;br /&gt;
 }&lt;br /&gt;
 vmap COREAPB3_LIB &amp;quot;COREAPB3_LIB&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral_MSS/APB_custom_peripheral_MSS.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/dcs_interface_pkg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/apb_to_dcs.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/mtest.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/DCS_test.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/FCCC_0/APB_custom_peripheral_FCCC_0_FCCC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/OSC_0/APB_custom_peripheral_OSC_0_OSC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_muxptob3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_iaddr_reg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/components.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/APB_custom_peripheral.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/testbench.vhd&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vsim -L SmartFusion2 -L presynth -L COREAPB3_LIB  -t 1fs presynth.testbench&lt;br /&gt;
 &lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PREADY \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSLVERR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE_PLL_LOCK \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_F2M \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PADDR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PENABLE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSEL \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PRDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWRITE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_M2F&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/penable \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/psel \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwrite \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/paddr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/prdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pslverr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/clk \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_n \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_from_siu \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/global_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/rcu_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/fec_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pready \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/siu_bg&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/siu_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/wr_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/rd_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/address \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/myram&lt;br /&gt;
 run 150 us&lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file supplied below. Name it Fabric_top.io. &lt;br /&gt;
 &lt;br /&gt;
 # Microsemi I/O Physical Design Constraints file&lt;br /&gt;
 # Auto Generated User I/O Constraints file&lt;br /&gt;
 &lt;br /&gt;
 # Version: v11.1 11.1.0.14&lt;br /&gt;
 # Family: SmartFusion2 , Die: M2S050T_ES , Package: 896 FBGA&lt;br /&gt;
 # Date generated: Fri Sep 20 10:03:27 2013 &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O Bank Settings&lt;br /&gt;
 # &lt;br /&gt;
 set_iobank Bank0 -vcci 1.80 -fixed yes&lt;br /&gt;
 set_iobank Bank1 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank2 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank3 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank4 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank8 -vcci 3.30 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # Unlocked I/O Bank Settings&lt;br /&gt;
 # The I/O Bank Settings can be locked by directly editing this file&lt;br /&gt;
 # or by making changes in the I/O Attribute Editor&lt;br /&gt;
 # &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O settings&lt;br /&gt;
 # &lt;br /&gt;
 set_io MMUART_0_RXD -pinname L23 -fixed yes&lt;br /&gt;
 set_io MMUART_0_TXD -pinname H27 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io MSS_RESET_N_F2M  \&lt;br /&gt;
     -pinname F30        \&lt;br /&gt;
     -fixed yes          \&lt;br /&gt;
     -RES_PULL Up        \&lt;br /&gt;
     -DIRECTION INPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io GPIO_0_M2F            \&lt;br /&gt;
     -pinname G30       \&lt;br /&gt;
     -fixed yes         \&lt;br /&gt;
     -DIRECTION OUTPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The file is imported by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the  following: &lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;drivers/mss_uart/mss_uart.h&amp;quot; &lt;br /&gt;
 #include &amp;quot;drivers/mss_gpio/mss_gpio.h&amp;quot; &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Initialize registers to read/write&lt;br /&gt;
 #define APB_TO_DCS_0                    0x50000000U&lt;br /&gt;
 #define MEM1 		(*(volatile int32_t *) 0x50000000)&lt;br /&gt;
 #define MEM2 		(*(volatile int32_t *) 0x50000004)&lt;br /&gt;
 #define MEM3 		(*(volatile int32_t *) 0x50000008)&lt;br /&gt;
 #define MEM4 		(*(volatile int32_t *) 0x5000000C)&lt;br /&gt;
 #define MEM5 		(*(volatile int32_t *) 0x50000010)&lt;br /&gt;
 #define MEM6 		(*(volatile int32_t *) 0x50000014)&lt;br /&gt;
 #define MEM7 		(*(volatile int32_t *) 0x50000018)&lt;br /&gt;
 #define MEM8 		(*(volatile int32_t *) 0x5000001C)&lt;br /&gt;
 &lt;br /&gt;
 //Define a constant delay value&lt;br /&gt;
 #define DELAY_LOAD_VALUE	0x00080000     			//about half a second&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 /*&lt;br /&gt;
 * Initialize MSS GPIOs.&lt;br /&gt;
 */&lt;br /&gt;
 MSS_GPIO_init();&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Configure MSS GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_config( MSS_GPIO_0 , MSS_GPIO_OUTPUT_MODE );&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Set initial state of GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_set_output(MSS_GPIO_0,0);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Using UART 0&lt;br /&gt;
 mss_uart_instance_t * const gp_my_uart = &amp;amp;g_mss_uart0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Using one delay to write and one delay to read&lt;br /&gt;
  */&lt;br /&gt;
 volatile int32_t delay_count_1 = 0;&lt;br /&gt;
 volatile int32_t delay_count_2 = 0;&lt;br /&gt;
 delay_count_1 = DELAY_LOAD_VALUE/2;&lt;br /&gt;
 delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variable to read value from memory to set led&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t led;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Incrementing value to be written to memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t i = 0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variables to hold values read from memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t m1,m2,m3,m4,m5,m6,m7,m8;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * data to be sent on UART, holding chopped memory data&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t data[4];&lt;br /&gt;
 &lt;br /&gt;
     /*--------------------------------------------------------------------------&lt;br /&gt;
      * Initialize and configure UART.&lt;br /&gt;
      */&lt;br /&gt;
     MSS_UART_init(gp_my_uart,&lt;br /&gt;
                   MSS_UART_57600_BAUD,&lt;br /&gt;
                   MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);&lt;br /&gt;
 &lt;br /&gt;
     MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r*******************Hello World*********************\n\r&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 	//Always&lt;br /&gt;
 	while( 1 )&lt;br /&gt;
 	{&lt;br /&gt;
 		-- delay_count_1;&lt;br /&gt;
 		-- delay_count_2;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Updating memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_1 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_1 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			MEM1 = i;&lt;br /&gt;
 			MEM2 = i+1;&lt;br /&gt;
 			MEM3 = i+2;&lt;br /&gt;
 			MEM4 = i+3;&lt;br /&gt;
 			MEM5 = i+4;&lt;br /&gt;
 			MEM6 = i+5;&lt;br /&gt;
 			MEM7 = i+6;&lt;br /&gt;
 			MEM8 = i+7;&lt;br /&gt;
 &lt;br /&gt;
 		}&lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Reading memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_2 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			m1 = MEM1;&lt;br /&gt;
 			if(m1 != i) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 1 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
  			 * Chopping data from memory, sending it to UART.&lt;br /&gt;
 			 * Reading hex/binary values from console&lt;br /&gt;
 			 */&lt;br /&gt;
 		    data[3] = m1;&lt;br /&gt;
 		    data[2] = m1 &amp;gt;&amp;gt;8;&lt;br /&gt;
 		    data[1] = m1 &amp;gt;&amp;gt;16;&lt;br /&gt;
 		    data[0] = m1 &amp;gt;&amp;gt;24;&lt;br /&gt;
 		    MSS_UART_polled_tx(gp_my_uart, data, sizeof(data));&lt;br /&gt;
 &lt;br /&gt;
 			m2 = MEM2;&lt;br /&gt;
 			if(m2 != i+1) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 2 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m3 = MEM3; &lt;br /&gt;
 			if(m3 != i+2) { &lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 3 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m4 = MEM4;&lt;br /&gt;
 			if(m4 != i+3) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 4 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m5 = MEM5;&lt;br /&gt;
 			if(m5 != i+4) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 5 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m6 = MEM6;&lt;br /&gt;
 			if(m6 != i+5) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 6 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m7 = MEM7;&lt;br /&gt;
 			if(m7 != i+6) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 7 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m8 = MEM8;&lt;br /&gt;
 			if(m8 != i+7) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 8 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
 			 * Read last bit of current value of m1 and set GPIO (led) according to the bit value&lt;br /&gt;
 			 * Bit should toggle for every read cycle&lt;br /&gt;
 			 */&lt;br /&gt;
 			led = m1 &amp;amp; 0x00000001;&lt;br /&gt;
 			MSS_GPIO_set_output(MSS_GPIO_0,led);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 			++i;&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The application will write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=VHDL files=&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1963</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1963"/>
		<updated>2013-09-30T09:30:19Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
 &lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied below. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.   &lt;br /&gt;
&lt;br /&gt;
 quietly set ACTELLIBNAME SmartFusion2&lt;br /&gt;
 quietly set PROJECT_DIR &amp;quot;C:/Microsemi/Projects/APB_custom_peripheral&amp;quot;&lt;br /&gt;
 source &amp;quot;${PROJECT_DIR}/simulation/CompileDssBfm.tcl&amp;quot;;source &amp;quot;${PROJECT_DIR}/simulation/bfmtovec_compile.tcl&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 if {[file exists presynth/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library presynth already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib presynth&lt;br /&gt;
 }&lt;br /&gt;
 vmap presynth presynth&lt;br /&gt;
 vmap SmartFusion2 &amp;quot;C:/Microsemi/Libero_v11.1/Designer/lib/modelsim/precompiled/vhdl/SmartFusion2&amp;quot;&lt;br /&gt;
 if {[file exists COREAPB3_LIB/_info]} {&lt;br /&gt;
    echo &amp;quot;INFO: Simulation library COREAPB3_LIB already exists&amp;quot;&lt;br /&gt;
 } else {&lt;br /&gt;
    vlib COREAPB3_LIB&lt;br /&gt;
 }&lt;br /&gt;
 vmap COREAPB3_LIB &amp;quot;COREAPB3_LIB&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral_MSS/APB_custom_peripheral_MSS.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/dcs_interface_pkg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/apb_to_dcs.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/mtest.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/hdl/DCS_test.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/FCCC_0/APB_custom_peripheral_FCCC_0_FCCC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/OSC_0/APB_custom_peripheral_OSC_0_OSC.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_muxptob3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3_iaddr_reg.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/coreapb3.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work COREAPB3_LIB &amp;quot;${PROJECT_DIR}/component/Actel/DirectCore/CoreAPB3/4.0.100/rtl/vhdl/core_obfuscated/components.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/APB_custom_peripheral.vhd&amp;quot;&lt;br /&gt;
 vcom -93 -explicit  -work presynth &amp;quot;${PROJECT_DIR}/component/work/APB_custom_peripheral/testbench.vhd&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 vsim -L SmartFusion2 -L presynth -L COREAPB3_LIB  -t 1fs presynth.testbench&lt;br /&gt;
 &lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PREADY \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSLVERR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MCCC_CLK_BASE_PLL_LOCK \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_F2M \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PADDR \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PENABLE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PSEL \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PRDATA \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/FIC_0_APB_M_PWRITE \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/APB_custom_peripheral_MSS_0/MSS_RESET_N_M2F&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/penable \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/psel \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwrite \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/paddr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pwdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/prdata \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pslverr \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/clk \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_n \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/reset_from_siu \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/global_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/rcu_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/fec_reset \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/pready \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/apb_to_dcs_0/siu_bg&lt;br /&gt;
 add wave  \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/we_dcs \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBadd \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_busBdata_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bi \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/dcs_br \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/siu_bg \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/wr_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/rd_en \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/address \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_in \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/data_out \&lt;br /&gt;
 sim:/testbench/APB_custom_peripheral_0/DCS_test_0/mtest_map/myram&lt;br /&gt;
 run 150 us&lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file supplied below. Name it Fabric_top.io. &lt;br /&gt;
 &lt;br /&gt;
 # Microsemi I/O Physical Design Constraints file&lt;br /&gt;
 # Auto Generated User I/O Constraints file&lt;br /&gt;
 &lt;br /&gt;
 # Version: v11.1 11.1.0.14&lt;br /&gt;
 # Family: SmartFusion2 , Die: M2S050T_ES , Package: 896 FBGA&lt;br /&gt;
 # Date generated: Fri Sep 20 10:03:27 2013 &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O Bank Settings&lt;br /&gt;
 # &lt;br /&gt;
 set_iobank Bank0 -vcci 1.80 -fixed yes&lt;br /&gt;
 set_iobank Bank1 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank2 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank3 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank4 -vcci 3.30 -fixed yes&lt;br /&gt;
 set_iobank Bank8 -vcci 3.30 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # Unlocked I/O Bank Settings&lt;br /&gt;
 # The I/O Bank Settings can be locked by directly editing this file&lt;br /&gt;
 # or by making changes in the I/O Attribute Editor&lt;br /&gt;
 # &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # &lt;br /&gt;
 # User Locked I/O settings&lt;br /&gt;
 # &lt;br /&gt;
 set_io MMUART_0_RXD -pinname L23 -fixed yes&lt;br /&gt;
 set_io MMUART_0_TXD -pinname H27 -fixed yes&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io MSS_RESET_N_F2M  \&lt;br /&gt;
     -pinname F30        \&lt;br /&gt;
     -fixed yes          \&lt;br /&gt;
     -RES_PULL Up        \&lt;br /&gt;
     -DIRECTION INPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 set_io GPIO_0_M2F            \&lt;br /&gt;
     -pinname G30       \&lt;br /&gt;
     -fixed yes         \&lt;br /&gt;
     -DIRECTION OUTPUT&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The file is imported by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the  following: &lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 #include &amp;quot;drivers/mss_uart/mss_uart.h&amp;quot; &lt;br /&gt;
 #include &amp;quot;drivers/mss_gpio/mss_gpio.h&amp;quot; &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Initialize registers to read/write&lt;br /&gt;
 #define APB_TO_DCS_0                    0x50000000U&lt;br /&gt;
 #define MEM1 		(*(volatile int32_t *) 0x50000000)&lt;br /&gt;
 #define MEM2 		(*(volatile int32_t *) 0x50000004)&lt;br /&gt;
 #define MEM3 		(*(volatile int32_t *) 0x50000008)&lt;br /&gt;
 #define MEM4 		(*(volatile int32_t *) 0x5000000C)&lt;br /&gt;
 #define MEM5 		(*(volatile int32_t *) 0x50000010)&lt;br /&gt;
 #define MEM6 		(*(volatile int32_t *) 0x50000014)&lt;br /&gt;
 #define MEM7 		(*(volatile int32_t *) 0x50000018)&lt;br /&gt;
 #define MEM8 		(*(volatile int32_t *) 0x5000001C)&lt;br /&gt;
 &lt;br /&gt;
 //Define a constant delay value&lt;br /&gt;
 #define DELAY_LOAD_VALUE	0x00080000     			//about half a second&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
 /*&lt;br /&gt;
 * Initialize MSS GPIOs.&lt;br /&gt;
 */&lt;br /&gt;
 MSS_GPIO_init();&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Configure MSS GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_config( MSS_GPIO_0 , MSS_GPIO_OUTPUT_MODE );&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Set initial state of GPIO pin&lt;br /&gt;
  */&lt;br /&gt;
 MSS_GPIO_set_output(MSS_GPIO_0,0);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 //Using UART 0&lt;br /&gt;
 mss_uart_instance_t * const gp_my_uart = &amp;amp;g_mss_uart0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Using one delay to write and one delay to read&lt;br /&gt;
  */&lt;br /&gt;
 volatile int32_t delay_count_1 = 0;&lt;br /&gt;
 volatile int32_t delay_count_2 = 0;&lt;br /&gt;
 delay_count_1 = DELAY_LOAD_VALUE/2;&lt;br /&gt;
 delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variable to read value from memory to set led&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t led;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Incrementing value to be written to memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t i = 0;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * Variables to hold values read from memory&lt;br /&gt;
  */&lt;br /&gt;
 int32_t m1,m2,m3,m4,m5,m6,m7,m8;&lt;br /&gt;
 &lt;br /&gt;
 /*&lt;br /&gt;
  * data to be sent on UART, holding chopped memory data&lt;br /&gt;
  */&lt;br /&gt;
 uint8_t data[4];&lt;br /&gt;
 &lt;br /&gt;
     /*--------------------------------------------------------------------------&lt;br /&gt;
      * Initialize and configure UART.&lt;br /&gt;
      */&lt;br /&gt;
     MSS_UART_init(gp_my_uart,&lt;br /&gt;
                   MSS_UART_57600_BAUD,&lt;br /&gt;
                   MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);&lt;br /&gt;
 &lt;br /&gt;
     MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r*******************Hello World*********************\n\r&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
 	//Always&lt;br /&gt;
 	while( 1 )&lt;br /&gt;
 	{&lt;br /&gt;
 		-- delay_count_1;&lt;br /&gt;
 		-- delay_count_2;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Updating memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_1 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_1 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			MEM1 = i;&lt;br /&gt;
 			MEM2 = i+1;&lt;br /&gt;
 			MEM3 = i+2;&lt;br /&gt;
 			MEM4 = i+3;&lt;br /&gt;
 			MEM5 = i+4;&lt;br /&gt;
 			MEM6 = i+5;&lt;br /&gt;
 			MEM7 = i+6;&lt;br /&gt;
 			MEM8 = i+7;&lt;br /&gt;
 &lt;br /&gt;
 		}&lt;br /&gt;
 		/*&lt;br /&gt;
 		 * Reading memory values&lt;br /&gt;
 		 */&lt;br /&gt;
 		if (delay_count_2 &amp;lt;= 0)&lt;br /&gt;
 		{&lt;br /&gt;
 			delay_count_2 = DELAY_LOAD_VALUE;&lt;br /&gt;
 			m1 = MEM1;&lt;br /&gt;
 			if(m1 != i) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 1 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
  			 * Chopping data from memory, sending it to UART.&lt;br /&gt;
 			 * Reading hex/binary values from console&lt;br /&gt;
 			 */&lt;br /&gt;
 		    data[3] = m1;&lt;br /&gt;
 		    data[2] = m1 &amp;gt;&amp;gt;8;&lt;br /&gt;
 		    data[1] = m1 &amp;gt;&amp;gt;16;&lt;br /&gt;
 		    data[0] = m1 &amp;gt;&amp;gt;24;&lt;br /&gt;
 		    MSS_UART_polled_tx(gp_my_uart, data, sizeof(data));&lt;br /&gt;
 &lt;br /&gt;
 			m2 = MEM2;&lt;br /&gt;
 			if(m2 != i+1) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 2 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m3 = MEM3; &lt;br /&gt;
 			if(m3 != i+2) { &lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 3 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m4 = MEM4;&lt;br /&gt;
 			if(m4 != i+3) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 4 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m5 = MEM5;&lt;br /&gt;
 			if(m5 != i+4) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 5 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m6 = MEM6;&lt;br /&gt;
 			if(m6 != i+5) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 6 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m7 = MEM7;&lt;br /&gt;
 			if(m7 != i+6) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 7 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 			m8 = MEM8;&lt;br /&gt;
 			if(m8 != i+7) {&lt;br /&gt;
 				 MSS_UART_polled_tx_string(gp_my_uart,(const uint8_t*) &amp;quot;\n\r**** Data read on memory location 8 is different from expected! *****\n\r&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 &lt;br /&gt;
 			/*&lt;br /&gt;
 			 * Read last bit of current value of m1 and set GPIO (led) according to the bit value&lt;br /&gt;
 			 * Bit should toggle for every read cycle&lt;br /&gt;
 			 */&lt;br /&gt;
 			led = m1 &amp;amp; 0x00000001;&lt;br /&gt;
 			MSS_GPIO_set_output(MSS_GPIO_0,led);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 			++i;&lt;br /&gt;
 		}&lt;br /&gt;
 &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The application will write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1962</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1962"/>
		<updated>2013-09-30T09:14:13Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
 &lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1961</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1961"/>
		<updated>2013-09-30T09:13:38Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files which are included at the bottom of the page. Save the files with the names specified in the text. The files can be included by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
 &lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). Copy the following to  the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 # Enter your BFM commands in this file. &lt;br /&gt;
 #&lt;br /&gt;
 # Syntax: &lt;br /&gt;
 # ------- &lt;br /&gt;
 #&lt;br /&gt;
 # memmap    resource_name base_address;&lt;br /&gt;
 #&lt;br /&gt;
 # write     width resource_name byte_offset data;&lt;br /&gt;
 # read      width resource_name byte_offset;&lt;br /&gt;
 # readcheck width resource_name byte_offset data;&lt;br /&gt;
 #&lt;br /&gt;
 #===========================================================&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;subsystem.bfm&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 procedure user_main;&lt;br /&gt;
 &lt;br /&gt;
 # perform subsystem initialization routine&lt;br /&gt;
 #  call subsystem_init;  &lt;br /&gt;
 &lt;br /&gt;
 # add your BFM commands below: &lt;br /&gt;
&lt;br /&gt;
 memmap apb_to_dcs_0 0x50000000;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 write w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 write w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 write w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x0 0x12345678;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x4 0xBEEFFACE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x8 0xABCDEF12;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0xC 0x44556622;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 write w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 write w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 write w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 write w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 readcheck w apb_to_dcs_0 0x10 0x98765432;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x14 0xABBABABE;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x18 0x12345ABC;&lt;br /&gt;
 readcheck w apb_to_dcs_0 0x1C 0xDEADBEEF;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1960</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1960"/>
		<updated>2013-09-30T09:02:10Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : APB_to_DCS&lt;br /&gt;
 -- Project    : RCU2&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : apb_to_dcs.vhd&lt;br /&gt;
 -- Last edited by   : Christian Torgersen&lt;br /&gt;
 -- Last update      : 30.09.2013 - 09:26&lt;br /&gt;
 -- Current Revision : 1.0&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Mapping between AMBA APB and DCS bus.  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway&lt;br /&gt;
 -- This file has been written by Christian Torgersen&lt;br /&gt;
 -- Christian.torgersen@student.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 library work;&lt;br /&gt;
 use work.dcs_interface_pkg.all;&lt;br /&gt;
 &lt;br /&gt;
 entity apb_to_dcs is&lt;br /&gt;
 port(&lt;br /&gt;
 	--APB input control signals&lt;br /&gt;
 	penable				: in		std_logic;						-- APB enable signal. Asserted high on second pulse&lt;br /&gt;
 	psel				: in		std_logic;						-- APB slave select from master&lt;br /&gt;
 	pwrite				: in		std_logic;						-- APB direction setting&lt;br /&gt;
 	&lt;br /&gt;
 	--APB input and addr&lt;br /&gt;
 	paddr				: in		std_logic_vector(31 downto 0);	-- APB address&lt;br /&gt;
 	pwdata				: in		std_logic_vector(31 downto 0);	-- APB write data&lt;br /&gt;
 	&lt;br /&gt;
 	--APB output signals&lt;br /&gt;
 	prdata				: out	std_logic_vector(31 downto 0);	-- APB read data&lt;br /&gt;
 	pready				: out	std_logic;						-- APB hold signal, for read/write more than 2 cycles&lt;br /&gt;
 	pslverr				: out	std_logic;						-- APB slave error signal&lt;br /&gt;
 &lt;br /&gt;
     clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
     reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
     reset_from_siu      : in    std_logic;                     -- asynch reset from SIU, positive polarity &lt;br /&gt;
 	&lt;br /&gt;
 	--internal resets&lt;br /&gt;
 	global_reset        : out   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : out   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : out   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 	&lt;br /&gt;
 	--DCS bus signals&lt;br /&gt;
 	we_dcs              : out   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : out   std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out   std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : out   std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : in    std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : out   std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : in    std_logic                      -- siu bus grant from arbiter&lt;br /&gt;
 	);&lt;br /&gt;
 end apb_to_dcs; &lt;br /&gt;
 &lt;br /&gt;
 architecture arc of apb_to_dcs is&lt;br /&gt;
 &lt;br /&gt;
 --signal declarations&lt;br /&gt;
 	type   state is (s_idle, s_wait_for_grant, s_grant, s_error);&lt;br /&gt;
 	signal current_state, next_state : state;&lt;br /&gt;
 	&lt;br /&gt;
 --	signal resetting        : std_logic; -- high when the resetting addresses are received, only used by dcs_addr&lt;br /&gt;
 	signal timeout			:std_logic;&lt;br /&gt;
 	signal timeout_cnt		:std_logic_vector(6 downto 0);&lt;br /&gt;
 	signal timeout_cnt_en	:std_logic;&lt;br /&gt;
 	signal we_dcs_i			:std_logic;	&lt;br /&gt;
 	&lt;br /&gt;
 begin&lt;br /&gt;
 	&lt;br /&gt;
 --combinatorics&lt;br /&gt;
 timeout		&amp;lt;= timeout_cnt(6);&lt;br /&gt;
 &lt;br /&gt;
 we_dcs				&amp;lt;= we_dcs_i;&lt;br /&gt;
 dcs_br				&amp;lt;= &#039;1&#039; when (psel = &#039;1&#039;and (next_state = s_wait_for_grant or next_state = s_grant)) else &#039;0&#039;;&lt;br /&gt;
  &lt;br /&gt;
 dcs_busBadd			&amp;lt;= paddr(15 downto 0);										--linking between APB and      dcs addresses&lt;br /&gt;
 dcs_busBdata_out	&amp;lt;= pwdata when (pwrite=&#039;1&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);				-- APB to DCS data	&lt;br /&gt;
 prdata				&amp;lt;= dcs_busBdata_in when (pwrite =&#039;0&#039; and dcs_bg= &#039;1&#039;) else (others =&amp;gt; &#039;0&#039;);		-- DCS to APB data &lt;br /&gt;
 &lt;br /&gt;
 -- purpose: timeout counter for transaction&lt;br /&gt;
 p_timeout_cnt: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     if (timeout_cnt_en = &#039;1&#039;) then&lt;br /&gt;
 	    timeout_cnt &amp;lt;= timeout_cnt + 1;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    timeout_cnt &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 	  end if;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_timeout_cnt;&lt;br /&gt;
 &lt;br /&gt;
 -- purpose: state machine driver&lt;br /&gt;
 p_state_driver: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     current_state &amp;lt;= s_idle;&lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     current_state &amp;lt;= next_state;&lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_state_driver;	&lt;br /&gt;
 &lt;br /&gt;
 --purpose: set next state	&lt;br /&gt;
 p_next_state: process(current_state, dcs_bg, timeout, psel, penable)		&lt;br /&gt;
 begin&lt;br /&gt;
   case current_state is&lt;br /&gt;
     when s_idle =&amp;gt;&lt;br /&gt;
 	  if (dcs_bg = &#039;1&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then		-- giving two cycle read/write possibility&lt;br /&gt;
 		next_state &amp;lt;= s_grant;&lt;br /&gt;
       elsif (dcs_bg = &#039;0&#039; and psel = &#039;1&#039; and penable = &#039;0&#039;) then	--Three or more cycle read/write&lt;br /&gt;
 	    next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
 	  else&lt;br /&gt;
 	    next_state &amp;lt;= s_idle;&lt;br /&gt;
 	  end if;&lt;br /&gt;
   &lt;br /&gt;
     when s_wait_for_grant =&amp;gt; &lt;br /&gt;
       if (dcs_bg = &#039;1&#039;) then &lt;br /&gt;
   	    next_state &amp;lt;= s_grant;&lt;br /&gt;
 	    elsif (timeout = &#039;1&#039;) then&lt;br /&gt;
 	      next_state &amp;lt;= s_error;&lt;br /&gt;
 	    else&lt;br /&gt;
 	      next_state &amp;lt;= s_wait_for_grant;&lt;br /&gt;
       end if;&lt;br /&gt;
   &lt;br /&gt;
     when  s_grant =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
    &lt;br /&gt;
     when s_error =&amp;gt;&lt;br /&gt;
       next_state &amp;lt;= s_idle;&lt;br /&gt;
     &lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	  next_state &amp;lt;= s_idle;&lt;br /&gt;
   end case;&lt;br /&gt;
 end process p_next_state;	&lt;br /&gt;
 	&lt;br /&gt;
 -- purpose: set outputs of module and internal signals&lt;br /&gt;
 p_output: process(clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
     timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	we_dcs_i        &amp;lt;= &#039;0&#039;;     &lt;br /&gt;
 	pslverr			&amp;lt;= &#039;0&#039;;&lt;br /&gt;
  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     	--defaults&lt;br /&gt;
 	case current_state is&lt;br /&gt;
     when s_idle =&amp;gt; &lt;br /&gt;
  		pslverr &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;0&#039;;    &lt;br /&gt;
 &lt;br /&gt;
      when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 	  	    &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
       	we_dcs_i        &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	  	pready			&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 	    	  &lt;br /&gt;
 	when s_error =&amp;gt; &lt;br /&gt;
 		pslverr &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready	&amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		timeout_cnt_en &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	    --defaults&lt;br /&gt;
     end case;&lt;br /&gt;
 &lt;br /&gt;
   	case next_state is&lt;br /&gt;
 	when s_idle =&amp;gt;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_wait_for_grant =&amp;gt;&lt;br /&gt;
 		timeout_cnt_en  &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 &lt;br /&gt;
 	when s_grant =&amp;gt;&lt;br /&gt;
     		timeout_cnt_en  &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		pready &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		we_dcs_i &amp;lt;= pwrite;&lt;br /&gt;
 	when others =&amp;gt;&lt;br /&gt;
 	end case;&lt;br /&gt;
   end if ;&lt;br /&gt;
 end process p_output;	 &lt;br /&gt;
 &lt;br /&gt;
 --purpose: resets&lt;br /&gt;
 p_reset : process(clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
   if (reset_n = &#039;0&#039;) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;1&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;1&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;1&#039;; &lt;br /&gt;
   elsif rising_edge(clk) then&lt;br /&gt;
     global_reset    &amp;lt;= &#039;0&#039;; 		-- send reset when the circuit is being globally reseted by the reset line&lt;br /&gt;
     rcu_reset       &amp;lt;= &#039;0&#039;;  &lt;br /&gt;
     fec_reset       &amp;lt;= &#039;0&#039;; &lt;br /&gt;
     if (we_dcs_i = &#039;1&#039;) then&lt;br /&gt;
       case (paddr(15 downto 0)) is&lt;br /&gt;
         when c_global_reset =&amp;gt;&lt;br /&gt;
           global_reset &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_rcu_reset =&amp;gt;&lt;br /&gt;
           rcu_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when c_fec_reset =&amp;gt;&lt;br /&gt;
           fec_reset    &amp;lt;= &#039;1&#039;;&lt;br /&gt;
         when others =&amp;gt;&lt;br /&gt;
           -- do nothing&lt;br /&gt;
       end case;&lt;br /&gt;
     end if;      &lt;br /&gt;
   end if;&lt;br /&gt;
 end process p_reset; &lt;br /&gt;
 &lt;br /&gt;
 --Purpose: Set up bus interrupt&lt;br /&gt;
 p_bus_int: process (clk, reset_n, reset_from_siu)&lt;br /&gt;
 begin&lt;br /&gt;
 	if( reset_n = &#039;0&#039; or reset_from_siu = &#039;1&#039;) then&lt;br /&gt;
 		dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 	elsif (rising_edge(clk)) then&lt;br /&gt;
 		if(siu_bg = &#039;0&#039; or dcs_bg = &#039;1&#039;) then		--do not interrupt if we have grant&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 		elsif (paddr (15 downto 0) = c_arbiter_irq) then&lt;br /&gt;
 			dcs_bi &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 end process p_bus_int;&lt;br /&gt;
 	&lt;br /&gt;
 end architecture arc;&lt;br /&gt;
&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Title      : DCS interface Package&lt;br /&gt;
 -- Project    : RCU DCS interface&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- File             : $RCSfile: dcs_interface_pkg.vhd,v $&lt;br /&gt;
 -- Last edited by   : $Author: alme $&lt;br /&gt;
 -- Last update      : $Date: 2008/02/15 12:23:43 $&lt;br /&gt;
 -- Current Revision : $Revision: 1.4 $&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Description      : Constant and function library for RCU Trigger Receiver&lt;br /&gt;
 --                    design  &lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 -- Revision History : &lt;br /&gt;
 -- http://portal1.ift.uib.no/cgi-bin/viewcvs.cgi/vhdlcvs/rcu_cpld/&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 --&lt;br /&gt;
 -- This file is property of and copyright by the Instrumentation and &lt;br /&gt;
 -- Electronics Section, Dep. of Physics and Technology&lt;br /&gt;
 -- University of Bergen, Norway, 2005&lt;br /&gt;
 -- This file has been written by Johan Alme&lt;br /&gt;
 -- Johan.Alme@ift.uib.no&lt;br /&gt;
 --&lt;br /&gt;
 -- Permission to use, copy, modify and distribute this firmware and its  &lt;br /&gt;
 -- documentation strictly for non-commercial purposes is hereby granted  &lt;br /&gt;
 -- without fee, provided that the above copyright notice appears in all  &lt;br /&gt;
 -- copies and that both the copyright notice and this permission notice  &lt;br /&gt;
 -- appear in the supporting documentation. The authors make no claims    &lt;br /&gt;
 -- about the suitability of this software for any purpose. It is         &lt;br /&gt;
 -- provided &amp;quot;as is&amp;quot; without express or implied warranty.                 &lt;br /&gt;
 --&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library ieee;&lt;br /&gt;
 use ieee.std_logic_1164.all;&lt;br /&gt;
 use ieee.std_logic_unsigned.all;&lt;br /&gt;
 &lt;br /&gt;
 package dcs_interface_pkg is&lt;br /&gt;
  &lt;br /&gt;
  -- address information (this should be moved to a global adress mapping definition file.)&lt;br /&gt;
   -- memory spaces.&lt;br /&gt;
   -- Safety module address. Always ack these.&lt;br /&gt;
   constant c_MSM_space          : std_logic_vector(3 downto 0):=X&amp;quot;8&amp;quot;;&lt;br /&gt;
   -- Actel space should NEVER be acked&lt;br /&gt;
   constant c_Actel_space        : std_logic_vector(3 downto 0):=X&amp;quot;B&amp;quot;;&lt;br /&gt;
   -- treat as normal except for the subadresses 0xA00 and 0xA01 that should not be acked.&lt;br /&gt;
   constant c_trigger_space      : std_logic_vector(3 downto 0):=X&amp;quot;4&amp;quot;; &lt;br /&gt;
   -- sub adresses&lt;br /&gt;
   -- belongs to trigger space. The two addresses are defined on the DCS board and should not be acked. &lt;br /&gt;
   constant c_dcsSetBunchReset   : std_logic_vector(11 downto 0):= X&amp;quot;A00&amp;quot;;&lt;br /&gt;
   constant c_dcsSetEventReset   : std_logic_vector(11 downto 0):= X&amp;quot;A01&amp;quot;;&lt;br /&gt;
   &lt;br /&gt;
   constant c_global_reset       : std_logic_vector(15 downto 0):= X&amp;quot;5300&amp;quot;;&lt;br /&gt;
   constant c_fec_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5301&amp;quot;;&lt;br /&gt;
   constant c_rcu_reset          : std_logic_vector(15 downto 0):= X&amp;quot;5302&amp;quot;;&lt;br /&gt;
   constant c_arbiter_irq        : std_logic_vector(15 downto 0):= X&amp;quot;5310&amp;quot;; -- interrupts SIU grant&lt;br /&gt;
   constant c_grant              : std_logic_vector(15 downto 0):= X&amp;quot;5311&amp;quot;; -- grant information given&lt;br /&gt;
   &lt;br /&gt;
   --Constant defining mem mapped mode on which the interface should be active&lt;br /&gt;
   constant c_memMappedMode0      : std_logic_vector(1 downto 0) := &amp;quot;00&amp;quot;;&lt;br /&gt;
   constant c_memMappedMode1      : std_logic_vector(1 downto 0) := &amp;quot;11&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
 end package dcs_interface_pkg; &lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: University of Bergen&lt;br /&gt;
 --&lt;br /&gt;
 -- File: DCS_test.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- Component used to test functionality of apb_to_dcs bridge&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: Christian Torgersen&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 &lt;br /&gt;
 entity DCS_test is&lt;br /&gt;
 port (&lt;br /&gt;
 	clk                 : in    std_logic;                     -- global clock (40 MHz)&lt;br /&gt;
 	reset_n             : in    std_logic;                     -- asynch reset, negative polarity&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
 	global_reset        : in   std_logic;                     -- global reset, positive polarity&lt;br /&gt;
     rcu_reset           : in   std_logic;                     -- reset for RCU Xilinx fw,  positive polarity&lt;br /&gt;
     fec_reset           : in   std_logic;                     -- reset for FEC, positive polarity&lt;br /&gt;
 &lt;br /&gt;
 	we_dcs              : in   std_logic;                     -- write enable to the internal modules&lt;br /&gt;
 	dcs_busBadd         : in    std_logic_vector(15 downto 0); -- address passed through&lt;br /&gt;
 	dcs_busBdata_in     : in    std_logic_vector(31 downto 0); -- data from internal modules to DCS&lt;br /&gt;
 	dcs_busBdata_out    : out    std_logic_vector(31 downto 0); -- data to internal modules from DCS&lt;br /&gt;
 	dcs_bi              : in    std_logic;                     -- interrupt in case DCS needs bus&lt;br /&gt;
 	dcs_bg              : out   std_logic;                     -- dcs bus grant from arbiter&lt;br /&gt;
     dcs_br              : in    std_logic;	                   -- dcs bus request to arbiter&lt;br /&gt;
     siu_bg              : out    std_logic                      -- siu bus grant from arbiter &lt;br /&gt;
 &lt;br /&gt;
 );&lt;br /&gt;
 end DCS_test;&lt;br /&gt;
 architecture arch of DCS_test is&lt;br /&gt;
    -- signal, component etc. declarations&lt;br /&gt;
 signal		data_outs :std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 signal		wr_enable, rd_enable : std_logic;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 component mtest&lt;br /&gt;
 port(&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end component;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
 &lt;br /&gt;
 mtest_map: mtest port map(&lt;br /&gt;
 	clk 		=&amp;gt; clk, &lt;br /&gt;
 	nreset		=&amp;gt; reset_n, &lt;br /&gt;
 	wr_en 		=&amp;gt; wr_enable,&lt;br /&gt;
 	rd_en		=&amp;gt; rd_enable,&lt;br /&gt;
 	address		=&amp;gt; dcs_busBadd(7 downto 0),&lt;br /&gt;
 	data_in		=&amp;gt; dcs_busBdata_in, &lt;br /&gt;
 	data_out	=&amp;gt; dcs_busBdata_out &lt;br /&gt;
 ); &lt;br /&gt;
 &lt;br /&gt;
 --dcs_busBdata_out &amp;lt;= data_outs;&lt;br /&gt;
 siu_bg &amp;lt;= &#039;0&#039;;&lt;br /&gt;
 rd_enable &amp;lt;= not(we_dcs);&lt;br /&gt;
 wr_enable &amp;lt;= we_dcs;&lt;br /&gt;
 &lt;br /&gt;
 -- to be used if checking two cycle read/write:&lt;br /&gt;
 --dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 &lt;br /&gt;
 --	Used to test arbitration and wait states:&lt;br /&gt;
 p_arbitration: process (clk, reset_n)&lt;br /&gt;
 begin&lt;br /&gt;
 	if reset_n = &#039;0&#039; then&lt;br /&gt;
 		dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		data_outs &amp;lt;= (others =&amp;gt; &#039;0&#039;);&lt;br /&gt;
 		&lt;br /&gt;
 	elsif rising_edge(clk) then&lt;br /&gt;
 		if (dcs_br = &#039;1&#039;) then&lt;br /&gt;
 			dcs_bg &amp;lt;= &#039;1&#039;;&lt;br /&gt;
 		else&lt;br /&gt;
 			dcs_bg&amp;lt;= &#039;0&#039;;&lt;br /&gt;
 			&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end if;&lt;br /&gt;
 &lt;br /&gt;
 end process p_arbitration;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 -- Company: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- File: mtest.vhd&lt;br /&gt;
 -- File history:&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --      &amp;lt;Revision number&amp;gt;: &amp;lt;Date&amp;gt;: &amp;lt;Comments&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Description: &lt;br /&gt;
 --&lt;br /&gt;
 -- &amp;lt;Description here&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 -- Targeted device: &amp;lt;Family::SmartFusion2&amp;gt; &amp;lt;Die::M2S050T_ES&amp;gt; &amp;lt;Package::896 FBGA&amp;gt;&lt;br /&gt;
 -- Author: &amp;lt;Name&amp;gt;&lt;br /&gt;
 --&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
 library IEEE;&lt;br /&gt;
 &lt;br /&gt;
 use IEEE.std_logic_1164.all;&lt;br /&gt;
 use ieee.numeric_std.all;&lt;br /&gt;
 &lt;br /&gt;
 entity mtest is&lt;br /&gt;
 port (&lt;br /&gt;
 		clk      : IN std_logic;&lt;br /&gt;
 		nreset   : IN std_logic;&lt;br /&gt;
 		wr_en    : IN std_logic;&lt;br /&gt;
 		rd_en	 : IN std_logic;&lt;br /&gt;
 		address  : IN std_logic_vector(7 DOWNTO 0);&lt;br /&gt;
 		data_in  : IN std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 		data_out : OUT std_logic_vector(31 DOWNTO 0)&lt;br /&gt;
 );&lt;br /&gt;
 end mtest;&lt;br /&gt;
 architecture arch of mtest is&lt;br /&gt;
 -- signal, component etc. declarations&lt;br /&gt;
 type memory IS ARRAY (0 TO 31) of std_logic_vector(31 DOWNTO 0);&lt;br /&gt;
 --type memory IS ARRAY (31 DOWNTO 0) of std_logic_vector;&lt;br /&gt;
 signal myram: memory;&lt;br /&gt;
 --attribute ram_init_file: STRING;&lt;br /&gt;
 --attribute ram_init_file OF myram: SIGNAL IS &amp;quot;ram_contents.mif&amp;quot;;&lt;br /&gt;
 begin&lt;br /&gt;
 	-- generation of data_out&lt;br /&gt;
 	process(clk,nreset)&lt;br /&gt;
 	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 	    elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				data_out &amp;lt;= x&amp;quot;0000_0000&amp;quot;;&lt;br /&gt;
 --			elsif(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 			if(rd_en=&#039;1&#039;) then		&lt;br /&gt;
 				data_out &amp;lt;= myram(to_integer(unsigned(address)));&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process; &lt;br /&gt;
 	-- writing data to memory&lt;br /&gt;
  	process(clk,nreset)&lt;br /&gt;
  	begin&lt;br /&gt;
 		if (nreset=&#039;0&#039;) then&lt;br /&gt;
 			myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 		elsif (clk&#039;EVENT AND clk=&#039;1&#039;) then&lt;br /&gt;
 --			if (nreset=&#039;0&#039;) then&lt;br /&gt;
 --				myram(to_integer(unsigned(address))) &amp;lt;= x&amp;quot;DEAD_BEEF&amp;quot;;&lt;br /&gt;
 --			elsif(wr_en=&#039;1&#039;) then&lt;br /&gt;
 			if (wr_en=&#039;1&#039;) then&lt;br /&gt;
 				myram(to_integer(unsigned(address))) &amp;lt;= data_in;&lt;br /&gt;
 			end if;&lt;br /&gt;
 		end if;&lt;br /&gt;
 	end process;&lt;br /&gt;
 end arch;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1959</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1959"/>
		<updated>2013-09-30T08:24:50Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1958</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1958"/>
		<updated>2013-09-30T07:56:07Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. &amp;lt;br&amp;gt;[[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals.&amp;lt;br&amp;gt; [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below&amp;lt;br&amp;gt; [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:SmartDesign_finished.jpg&amp;diff=1957</id>
		<title>File:SmartDesign finished.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:SmartDesign_finished.jpg&amp;diff=1957"/>
		<updated>2013-09-30T06:47:32Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1954</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1954"/>
		<updated>2013-09-30T06:40:04Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import all the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1953</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1953"/>
		<updated>2013-09-28T09:42:01Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1952</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1952"/>
		<updated>2013-09-28T09:02:22Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. Name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1951</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1951"/>
		<updated>2013-09-28T09:01:46Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Microsemi. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1950</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1950"/>
		<updated>2013-09-28T09:01:12Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1949</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1949"/>
		<updated>2013-09-28T09:00:20Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to implement and test a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1948</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1948"/>
		<updated>2013-09-28T08:59:39Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause the LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1947</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1947"/>
		<updated>2013-09-28T08:21:52Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|500 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause this LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1946</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1946"/>
		<updated>2013-09-28T08:19:14Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|400 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;.&amp;lt;br&amp;gt; [[File:Module_bus_interface.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg|700 px]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039; which will start ModelSim.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Presynth_transcript.jpg|400 px]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause this LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Debug_configuration.jpg|600 px]]&amp;lt;br&amp;gt;[[File:Debugging.jpg|600px]]&amp;lt;br&amp;gt;[[File:Debug_binary_count.jpg|600px]]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1945</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1945"/>
		<updated>2013-09-28T08:10:57Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg|500 px]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg|600 px]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg|200 px]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg|400px]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg|400 px]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: &amp;lt;br&amp;gt;[[File:MSS_finished.jpg|600 px]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg|400 px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg|400 px]][[File:CCC_core.jpg|400 px]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;. [[File:Module_bus_interface.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039;.&lt;br /&gt;
[[File:Presynth_transcript.jpg]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause this LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &lt;br /&gt;
[[File:Debug_configuration.jpg]][[File:Debugging.jpg]][[File:Debug_binary_count.jpg]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Modified_MSS.jpg&amp;diff=1944</id>
		<title>File:Modified MSS.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Modified_MSS.jpg&amp;diff=1944"/>
		<updated>2013-09-28T07:52:44Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Debug_binary_count.jpg&amp;diff=1943</id>
		<title>File:Debug binary count.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Debug_binary_count.jpg&amp;diff=1943"/>
		<updated>2013-09-27T13:34:20Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Debugging.jpg&amp;diff=1942</id>
		<title>File:Debugging.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Debugging.jpg&amp;diff=1942"/>
		<updated>2013-09-27T13:34:03Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Debug_configuration.jpg&amp;diff=1941</id>
		<title>File:Debug configuration.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Debug_configuration.jpg&amp;diff=1941"/>
		<updated>2013-09-27T13:33:45Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Presynth_wave.jpg&amp;diff=1940</id>
		<title>File:Presynth wave.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Presynth_wave.jpg&amp;diff=1940"/>
		<updated>2013-09-27T13:33:26Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Presynth_transcript.jpg&amp;diff=1939</id>
		<title>File:Presynth transcript.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Presynth_transcript.jpg&amp;diff=1939"/>
		<updated>2013-09-27T13:33:08Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Module_bus_interface.jpg&amp;diff=1937</id>
		<title>File:Module bus interface.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Module_bus_interface.jpg&amp;diff=1937"/>
		<updated>2013-09-27T13:32:11Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:CCC_core.jpg&amp;diff=1936</id>
		<title>File:CCC core.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:CCC_core.jpg&amp;diff=1936"/>
		<updated>2013-09-27T13:31:45Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:Chip_osc.jpg&amp;diff=1935</id>
		<title>File:Chip osc.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:Chip_osc.jpg&amp;diff=1935"/>
		<updated>2013-09-27T13:31:26Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:CoreAPB3_config.jpg&amp;diff=1934</id>
		<title>File:CoreAPB3 config.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:CoreAPB3_config.jpg&amp;diff=1934"/>
		<updated>2013-09-27T13:31:03Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:MSS_finished.jpg&amp;diff=1933</id>
		<title>File:MSS finished.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:MSS_finished.jpg&amp;diff=1933"/>
		<updated>2013-09-27T13:30:39Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:MMUART.jpg&amp;diff=1932</id>
		<title>File:MMUART.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:MMUART.jpg&amp;diff=1932"/>
		<updated>2013-09-27T13:30:19Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:FIC0.jpg&amp;diff=1931</id>
		<title>File:FIC0.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:FIC0.jpg&amp;diff=1931"/>
		<updated>2013-09-27T13:30:00Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:MSS_reset.jpg&amp;diff=1930</id>
		<title>File:MSS reset.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:MSS_reset.jpg&amp;diff=1930"/>
		<updated>2013-09-27T13:29:42Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:MSS_CCC.jpg&amp;diff=1929</id>
		<title>File:MSS CCC.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:MSS_CCC.jpg&amp;diff=1929"/>
		<updated>2013-09-27T13:29:25Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=File:New_project.jpg&amp;diff=1928</id>
		<title>File:New project.jpg</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=File:New_project.jpg&amp;diff=1928"/>
		<updated>2013-09-27T13:13:42Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1925</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1925"/>
		<updated>2013-09-27T12:42:18Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: [[File:MSS_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg]][[File:CCC_core.jpg]]&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;. [[File:Module_bus_interface.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039;.&lt;br /&gt;
[[File:Presynth_transcript.jpg]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause this LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;br /&gt;
&lt;br /&gt;
Build Debug Application by pressing &#039;&#039;Debug Configurations&#039;&#039; and then choose &#039;&#039;Microsemi Cortex M3 Target&#039;&#039;. Press &#039;&#039;Apply&#039;&#039;, build debug target and launch debug target. &lt;br /&gt;
[[File:Debug_configuration.jpg]][[File:Debugging.jpg]][[File:Debug_binary_count.jpg]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1924</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1924"/>
		<updated>2013-09-27T12:16:13Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: [[File:MSS_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg]][[File:CCC_core.jpg]]&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;. [[File:Module_bus_interface.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
To simulate the functionality of the abp_to_dcs module, normal APB bus functionality from the MSS should be used. To do this, you can add a .bfm file (Bus Functional Model). In the supplied files there is a file called User.bfm. Copy the content of this file to the User.bfm in your project, located under &#039;&#039;Files&#039;&#039; and &#039;&#039;simulation&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Next, go to &#039;&#039;Project&#039;&#039; and then &#039;&#039;Project Settings&#039;&#039;. Choose &#039;&#039;DO File&#039;&#039; under &#039;&#039;Simulation Options&#039;&#039;. You can use the run.do file supplied in the .zip. If you want to use automatic .do file and add signals yourself you can use standard settings, but be sure to change simulation time to 150 us. The system has got some initialization time, which takes around 120 us with this setup, before the bus signals start to change.  &lt;br /&gt;
&lt;br /&gt;
Double click on &#039;&#039;Simulate&#039;&#039; in Design Flow under &#039;&#039;Verify Pre-Synthesized Design&#039;&#039;.&lt;br /&gt;
[[File:Presynth_transcript.jpg]]&amp;lt;br&amp;gt;[[File:Presynth_wave.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Constraints, Synthesize and Place&amp;amp;Route=&lt;br /&gt;
&lt;br /&gt;
Go to &#039;&#039;Project&#039;&#039;, &#039;&#039;Project Settings&#039;&#039;, &#039;&#039;Device I/O Settings&#039;&#039; and set &#039;&#039;Default I/O Technology&#039;&#039; to &#039;&#039;LVCMOS 3.3V&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Import the Physical Design Constraint file, Fabric_top.io, by clicking &#039;&#039;File&#039;&#039;, &#039;&#039;Import&#039;&#039;, &#039;&#039;I/O Constraints (PDC) Files&#039;&#039;. Once this is included, scroll in &#039;&#039;Design Flow&#039;&#039; to &#039;&#039;Place and Route&#039;&#039; and right click. Select &#039;&#039;Configure Options&#039;&#039; and uncheck &#039;&#039;Timing Driven&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now you can click on the &amp;quot;Play&amp;quot; button, Generate Programming Data. This process will take some time. If all succeeds, you should be able to program your FPGA. Program it by connecting power and FlashPro Programmer and click on &#039;&#039;Run Programming Action&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Create Test Software=&lt;br /&gt;
&lt;br /&gt;
To write test application software, scroll to the bottom of the Design Flow and click &#039;&#039;Write Application Code&#039;&#039;. This will open SoftConsole from Microsemi. You can replace the main.c with the main.c supplied in the .zip file. The application will then write data to RAM and then read it. A LED is linked to the LSB of the read data, which cause this LED to blink. Data read on first memory location is written to the UART, and can be observed with a serial terminal program. Note that serial data sent on the UART is counting binary, and ASCII format is not implemented. The UART also sends out a message on the UART if the read data is different from expected.&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1923</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1923"/>
		<updated>2013-09-26T13:29:00Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: [[File:MSS_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg]][[File:CCC_core.jpg]]&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;. [[File:Module_bus_interface.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Right click on &#039;&#039;reset_from_siu&#039;&#039; and choose &#039;&#039;Tie Low&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
Generate component by clicking &#039;&#039;SmartDesign&#039;&#039; and &#039;&#039;Generate Component&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
=Pre-synthesized Simulation=&lt;br /&gt;
&lt;br /&gt;
Use run.do supplied and user.bfm&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1922</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1922"/>
		<updated>2013-09-26T12:53:42Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;. Use system tools &#039;&#039;SmartFusion2 Microcontroller Subsystem (MSS)&#039;&#039;. [[File:New_project.jpg]]&lt;br /&gt;
&lt;br /&gt;
=Modify MSS=&lt;br /&gt;
&lt;br /&gt;
Double click on the MSS component to modify it. A new window will open. Enable/Disable peripherals until your MSS looks like the image below. &amp;lt;br&amp;gt;&lt;br /&gt;
Tip: click &#039;&#039;View &amp;gt; Maximize Work Area&#039;&#039; or &#039;&#039;CTRL+W&#039;&#039; to expand the working area while enabling and disabling the MSS peripherals. [[File:Modified_MSS.jpg]]&lt;br /&gt;
&lt;br /&gt;
Click on the configuration button for the enabled peripherals, and configure them like the following images&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:MSS_CCC.jpg]]&amp;lt;br&amp;gt; MSS CCC&amp;lt;br&amp;gt;[[File:MSS_reset.jpg]]&amp;lt;br&amp;gt; Reset Controller&amp;lt;br&amp;gt;[[File:FIC0.jpg]]&amp;lt;br&amp;gt; FIC 0&amp;lt;br&amp;gt;[[File:MMUART.jpg]]&amp;lt;br&amp;gt; MMUART 0&lt;br /&gt;
&lt;br /&gt;
Your MSS should now look like this: [[File:MSS_finished.jpg]]&lt;br /&gt;
&lt;br /&gt;
=SmartDesign=&lt;br /&gt;
&lt;br /&gt;
Close the MSS configuration window. On the SmartDesign canvas, right click on the MSS component and &#039;&#039;Update instance(s) with Latest Component&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
From &#039;&#039;Catalog&#039;&#039; add the following components:&lt;br /&gt;
&#039;&#039;&#039;CoreAPB3&#039;&#039;&#039; from &#039;&#039;Bus Interfaces&#039;&#039;, &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:CoreAPB3_config.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Chip Oscillators&#039;&#039;&#039; and &#039;&#039;&#039;Clock Conditioning Circuitry&#039;&#039;&#039; from &#039;&#039;Clock &amp;amp; Management&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Chip_osc.jpg]][[File:CCC_core.jpg]]&lt;br /&gt;
&lt;br /&gt;
Now, Import the vhdl files [[Media:APB_DCS_files.zip]] by clicking &#039;&#039;File&#039;&#039;,  &#039;&#039;Import&#039;&#039;, &#039;&#039;HDL Source Files&#039;&#039;. These files can now be found under &#039;&#039;hdl&#039;&#039; in the &#039;&#039;Files&#039;&#039; tab and in &#039;&#039;Design Hierarchy&#039;&#039;. In &#039;&#039;Design Hierarchy&#039;&#039; right click on &#039;&#039;DCS_test&#039;&#039;, choose &#039;&#039;Create Core from HDL&#039;&#039;. Answer &#039;&#039;No&#039;&#039; to question about adding bus interfaces to core. Right click on &#039;&#039;apb_to_dcs&#039;&#039; and choose &#039;&#039;Create Core from HDL&#039;&#039;. Choose &#039;&#039;Yes&#039;&#039; on question about adding bus interfaces to core. Choose &#039;&#039;Add/Edit bus interfaces...&#039;&#039;. In next window, click &#039;&#039;Add Bus Interface...&#039;&#039;, choose &#039;&#039;APB, AMBA, AMBA2, slave&#039;&#039;. Connect &#039;&#039;PSELx&#039;&#039; to &#039;&#039;psel&#039;&#039;. [[File:Module_bus_interface.jpg]]&lt;br /&gt;
&lt;br /&gt;
Add the modules you made to the SmartDesign. In design canvas, right click and choose &#039;&#039;Auto Connect&#039;&#039; followed by &#039;&#039;Auto Arrange Instances&#039;&#039;. Right click on &#039;&#039;MSS_RESET_N_F2M&#039;&#039; and &#039;&#039;GPIO_FABRIC&#039;&#039; and select &#039;&#039;Promote to Top Level&#039;&#039;. Connect the unconnected wires. The result should look something like the image below [[File:SmartDesign_finished.jpg]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1920</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1920"/>
		<updated>2013-09-24T12:29:30Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used and that you are using the SmartFusion2 starter kit from Actel. &lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project &#039;&#039;APB_custom_peripheral&#039;&#039;.[[File:New_project.jpg]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1919</id>
		<title>SmartFusion2- AMBA APB, Custom Peripheral</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=SmartFusion2-_AMBA_APB,_Custom_Peripheral&amp;diff=1919"/>
		<updated>2013-09-24T12:14:54Z</updated>

		<summary type="html">&lt;p&gt;Cto070: Created page with &amp;quot;=Intro=  This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how to create a custom AMBA APB (Advanced Peripheral Bus) module. The tutorial will create a SmartFusion2 MSS (Microcontroller Subsystem) with APB bus interface. The custom module will be connected to the APB bus to map from APB bus to a DCS bus. Connected to the DCS part there will be a test module, which you can write and read from. The MSS will also have a GPIO module connected to a LED and serial a UART peripheral.&lt;br /&gt;
&lt;br /&gt;
=Before you start=&lt;br /&gt;
&lt;br /&gt;
Make sure you have installed Libero and have a valid license, as described in [[SmartFusion2]]. This tutorial assumes Libero v11.1 is used.&lt;br /&gt;
&lt;br /&gt;
=Create new project=&lt;br /&gt;
&lt;br /&gt;
Start Libero SoC v11.1. Press &#039;&#039;Project&#039;&#039; and &#039;&#039;New Project&#039;&#039;. You can name your project&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
	<entry>
		<id>http://ift.wiki.uib.no/index.php?title=Microelectronics_group&amp;diff=1918</id>
		<title>Microelectronics group</title>
		<link rel="alternate" type="text/html" href="http://ift.wiki.uib.no/index.php?title=Microelectronics_group&amp;diff=1918"/>
		<updated>2013-09-24T09:14:45Z</updated>

		<summary type="html">&lt;p&gt;Cto070: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Mikroelektronikk ==&lt;br /&gt;
&lt;br /&gt;
Dokumentasjon for Mentor Graphics IC-programvaren finnes i katalogen /prog/mentor/icflow_2008_1/2008.1_rhelx86linux/icflow_home/shared/pdfdocs eller ../htmldocs/ . Bruk &lt;br /&gt;
&lt;br /&gt;
* [[IC studio]] Veiledning til IC-design ved hjelp av IC studio&lt;br /&gt;
&lt;br /&gt;
* [[IC studio - SPICE/Symbol Tutorial]] Relate a SPICE file to a Symbol&lt;br /&gt;
&lt;br /&gt;
* [[IC Station]] Tegne utlegg for integrerte kretser&lt;br /&gt;
&lt;br /&gt;
* [[Expedition PCB]] Komme i gang med kretskortutlegg ved hjelp av Expedition PCB&lt;br /&gt;
&lt;br /&gt;
* [[Modelsim/Questa]] Skrive og simulere VHDL-kode med Mentor Graphics ModelSim&lt;br /&gt;
&lt;br /&gt;
* [[PCI-eksperiment]] Øving med HLT-RORC-prototypekort&lt;br /&gt;
&lt;br /&gt;
* [[Cadence Virtuoso]]&lt;br /&gt;
&lt;br /&gt;
* [[Xilinx]] Øving i bruk av Xilinx Project Studio&lt;br /&gt;
&lt;br /&gt;
* [[FLTK GUI]] Graphical User Interface using FLTK&lt;br /&gt;
&lt;br /&gt;
* [[Tutorials]] Tutorials from the web&lt;br /&gt;
&lt;br /&gt;
* [[ADS]] Getting started with Agilent Advanced Design System&lt;br /&gt;
&lt;br /&gt;
* [[XJTAG]]  Boundary Scan with XJTAG&lt;br /&gt;
&lt;br /&gt;
* [[XJDeveloper]] Innføring i XJDeveloper&lt;br /&gt;
&lt;br /&gt;
* [[PHYS222]] Fagressurser for PHYS222 og PHYS223&lt;br /&gt;
&lt;br /&gt;
* [[PHYS321]] Fagressurser for PHYS321&lt;br /&gt;
&lt;br /&gt;
* [[Teknisk hjelp]] Teknisk hjelp for bruk av DAK-programvare&lt;br /&gt;
&lt;br /&gt;
* [[BGA lodding]] bruk av Martin 09.6 XL BGA lodding maskin (intern)&lt;br /&gt;
&lt;br /&gt;
* [[SmartFusion2]] Oppsett og design med SF2&lt;br /&gt;
&lt;br /&gt;
* [[SmartFusion2- AMBA APB, Custom Peripheral]] Making a custom peripheral for the AMBA APB bus&lt;br /&gt;
&lt;br /&gt;
[[Category:Mikroelektronikk]]&lt;/div&gt;</summary>
		<author><name>Cto070</name></author>
	</entry>
</feed>