source: Documentation/sysgen2opb Reference Design/tex_src/sysgen2opb.tex

Last change on this file was 354, checked in by elliotng, 18 years ago
File size: 38.7 KB
Line 
1\documentclass[titlepage]{WARPdoc}
2\usepackage{graphicx}
3\usepackage{color}
4
5\begin{document}
6
7\title{Platform Support Package: sysgen2opb}
8\author{Elliot Ng}
9\organization{Rice University WARP Project\\ Center for Multimedia Communication\\ \href{http://warp.rice.edu/}{http://warp.rice.edu/}}
10\version{1.3}
11\maketitle
12
13\tableofcontents
14
15
16
17
18
19\section{Introduction}
20sysgen2opb is one of several tools in the Platform Support Package for the Rice University Wireless Open-Access Research Platform (WARP). sysgen2opb is a Matlab script which converts a Xilinx System Generator (Sysgen) model into an OPB-compliant peripheral for use with embedded PowerPCs or other OPB bus masters. The result can be integrated within Xilinx Platform Studio (XPS).\\ \\ The sysgen2opb script replaces each System Generator Gateway In and Gateway Out with a memory mapped I/O register, accessible over the OPB. It also creates the necessary address decode logic and a C header file with the resulting register map. This functionality allows software to write/read data to/from the I/O ports of the synthesized System Generator model.  Alternatively, if an addressable dual-port storage block is used within a Sysgen model, the storage element may be mapped directly into the OPB memory space, obviating the need for a separate address bridge register between the OPB and the storage element.  This functionality, termed the shared memory extension, permits higher throughput when accessing shared storage elements. \\ \\ In summary, there are three ways in which the opb2sysgen script can be utilized.
21
22\begin{enumerate}
23    \item Simple Script - This script simply maps Sysgen gateways into software-accessible registers.  It supports versions 7.1 and 8.1 of Xilinx System Generator.
24    \item Shared Memory Extension Script - This script is identical to the simple script, with an additional shared memory extension. Shared memory support requires the use of dual port RAMs, and may be used only with version 8.1 of Xilinx System Generator.
25    \item Configurable Subsystem Extension Script - This script is identical to the simple script, with an additional configurable subsystem extension. It will take the gateways and registers and store them in a library of configurable subsystems. This script is to be used only with version 8.1 of Xilinx System Generator.
26\end{enumerate}
27
28
29
30
31
32\newpage
33\section{General Design Flow}
34This section briefly describes the design flow for producing an OPB-compliant core from a Sysgen model. It is assumed herein that the reader is familiar with Matlab, Simulink, System Generator, and Xilinx Platform Studio.
35\begin{enumerate}
36    \item Select a directory in which your system generator model will reside.  The complete path name of this working directory must not contain any spaces.
37    \item Build a System Generator model of the peripheral core which will later be converted into your OPB-compliant peripheral.
38    \item Copy the Matlab script file \textit{sysgen2opb.m} and the peripheral model file \\\textit{skeleton\_periph\_model.mdl} to the same directory as the model being converted.
39    \item Execute \textit{sysgen2opb.m} to convert the model.
40    \item Use Sysgen to generate your peripheral core from the converted model.  If you already have an existing XPS project in which the peripheral core will be used, System Generator may be configured to copy the generated core into the project's local user repository.  Otherwise, the generated core may be placed in any other user-specified directory.
41    \item If you do not have an existing XPS project, create one.
42    \item If necessary, copy the newly generated peripheral core into your XPS project's local user repository.
43    \item Add the peripheral core to your XPS project and verify/update the system address map.  In XPS, the address range spanned by the peripheral (from base address to high address) MUST match the address range defined at the time of conversion! If it is necessary to remap the core to a different address range, the core must be regenerated from the original unconverted model.
44    \item Write any user software required to interact with the peripheral core.
45    \item Compile the complete system.
46    \item Download and test the system.
47\end{enumerate}
48
49
50
51
52
53\newpage
54\section{Rules/Requirements}
55\subsection{General Requirements}
56\begin{enumerate}
57    \item The script file sysgen2opb.m and skeleton peripheral model skeleton\_periph\_model.mdl must reside in the same directory as the model to be converted.
58    \item The script requires that at least one Gateway In and one Gateway Out will be converted into memory-mapped registers. For cases in which no Gateway In or no Gateway Out is required, a single dummy instance of the missing gateway must be instantiated.
59    \item The base address must be 32 bits in width.
60    \item The complete path name of the working directory (the one containing the model to be converted) must not contain any spaces.  The directory My Documents, for example, is not valid in the working directory path.
61    \item Any Boolean type connected to a Gateway Out that will be converted to a register must be cast to a UFix1\_0.
62    \item A maximum of 450 combined input and output gateways may be converted to registers.
63    \item All gateways that will become registers must be clocked at the system sample period.
64    \item The path to each output gateway must contain a synchronous element.
65\end{enumerate}
66
67\subsection{Simple Script with Shared Memory Extension}
68    \subsubsection{General Requirements}
69        \begin{enumerate}
70            \item OPB address [19:16] determines whether the lower order 16 address bits (spanning 64 KBytes) access memory mapped registers or shared memory blocks. The first 64 KBytes, starting at the peripheral's base address, are reserved for memory mapped registers. Each subsequent 64 KByte memory region is reserved for an individual shared memory block. Consider, for example, a peripheral with a base address of 0xFF010000. Addresses 0xFF010000 through 0xFF01FFFF access simple memory mapped registers.  Addresses 0xFF02000 \\through 0xFF02FFFF access the first shared memory block. Addresses 0xFF03000 through 0xFF03FFFF access the second shared memory block, and so on.
71            \item The maximum number of shared memory blocks equals (15 - bin2dec(base address [19:16])). If base address is 0xFF000000, one register region and up to 15 shared memories are allowed. If base address is 0xFF010000, one register region and up to 14 shared memories are allowed.  If base address is 0xFF0F0000, only one register region is allowed (no shared memories).
72            \item The shared memory extension is defined to function only with dual-port RAM blocks.
73
74                \begin{figure}[htbp]
75                    \centering
76                    \includegraphics[width=0.10\textwidth]{scriptimages/dpram.pdf}
77                    \caption{Dual Port RAM}
78                    \label{fig:dpram}
79                \end{figure}
80            \item Port "A" of the Dual Port RAM is user-defined
81            \item Port "B" of the Dual Port RAM has additional requirements, described below.
82        \end{enumerate}
83    \subsubsection{DPRAM (Read-Only) Requirements}
84        \begin{enumerate}
85            \item DPRAM Name Prefix: SMRO\_
86            \item Source block for DPRAM addrb input
87           
88            \begin{enumerate}
89                \item Name Prefix: SMROAddr\_
90                \item Block Type: Gateway In
91                \item Output Type: UFix14\_0           
92            \end{enumerate}
93       
94            \item Source block for DPRAM dinb input
95            \begin{enumerate}
96                \item Name Prefix: SMRODataI\_
97                \item Block Type: Xilinx Constant
98                \item Constant Value: 0
99                \item Number of bits: 32
100            \end{enumerate}
101       
102            \item Source block for DPRAM web input
103           
104            \begin{enumerate}
105                \item Name Prefix: SMROWE\_
106                \item Block Type: Xilinx Constant
107                \item Output Type: Boolean
108                \item Constant Value: 0
109            \end{enumerate}
110       
111            \item Destination block for DPRAM B output
112       
113            \begin{itemize}
114                \item Name Prefix: SMRODataO\_
115                \item Block Type: Gateway Out
116            \end{itemize}
117   
118            \item The figure below illustrates a valid implementation of a dual-port RAM whose B port will be mapped into the OPB memory space using the read only shared memory extension.  Note that the A port is user-defined, and that the restrictions described herein apply only to the B port.
119                \begin{figure}[htbp]
120                    \centering
121                    \includegraphics[width=0.60\textwidth]{scriptimages/SMRO_dpram.pdf}
122                    \caption{Sample Read-only Dual Port RAM Model}
123                    \label{fig:SMRO_dpram}
124                \end{figure}
125        \end{enumerate} 
126   
127    \newpage   
128    \subsubsection{DPRAM (Write-Only) Requirements} 
129        \begin{enumerate}
130            \item DPRAM Name Prefix: SMWO\_
131            \item Source block for DPRAM addrb input
132   
133            \begin{enumerate}
134                \item Name Prefix: SMWOAddr\_
135                \item Block Type: Gateway In
136                \item Output Type: UFix14\_0
137            \end{enumerate}
138       
139            \item Source block for DPRAM dinb input
140       
141            \begin{enumerate}
142                \item Name Prefix: SMWODataI\_
143                \item Block Type: Gateway In
144                \item Number of bits: 32
145            \end{enumerate}
146       
147            \item Source block for DPRAM web input
148                       
149            \begin{enumerate}
150                \item Name Prefix: SMWOWE\_
151                \item Block Type: Gateway In
152                \item Output Type: Boolean
153            \end{enumerate}
154       
155        \item The figure below illustrates a valid implementation of a dual-port RAM whose B port will be mapped into the OPB memory space using the write only shared memory extension.  Note that the A port is user-defined, and that the restrictions described herein apply only to the B port.
156
157            \begin{figure}[htbp]
158                \centering
159                \includegraphics[width=0.60\textwidth]{scriptimages/SMWO_dpram.pdf}
160                \caption{Sample Write-only Dual Port RAM Model}
161                \label{fig:SWRO_dpram}
162            \end{figure}
163        \end{enumerate}
164
165\newpage
166\section{Example with Simple Registers}
167
168    \subsection{Overview}
169    This example illustrates a process by which a System Generator model is converted into an OPB-compliant peripheral core.  When the converted core is later imported into a XPS design, the model's input and output gateways are mapped into software-accessible registers on the OPB.  Data is then moved into and out of the core through writes/reads to/from these software-accessible registers.  An option is also provided to specify that specific gateways will not be mapped into registers.  These ''no\_reg'' gateways are mapped into generic I/O ports in the top level of the converted core, permitting direct connection to other cores or to FPGA pins in the system.
170
171    \subsection{Software/System Requirements}
172    This example uses System Generator version 8.1 and Xilinx Platform Studio (XPS) version 8.1.  More detailed requirements, including restrictions on file and directory names, are discussed in the section titled ''Rules/Requirements''.  It is assumed that the reader is familiar enough with MATLAB, Simulink, and System Generator to create simple Simulink models and execute simple MATLAB scripts.
173
174    \subsection{Xilinx Platform Studio - Base System Builder}
175Create XPS project. Use Base System Builder to build the project. For more information on using Base System Builder, please refer to the WARP document ''FPGA Board User IO Reference Design'' section ''Setting up the Project in XPS.''
176
177    \subsection{Matlab/System Generator}
178    \begin{enumerate}
179        \item Run Matlab.
180        \item Open the Simulink Library Browser.
181        \item Expand Xilinx Blockset in the Simulink Library Browser.
182        \item Select File $\rightarrow$ New $\rightarrow$ Model from the menu options at the top of the Simulink Library Browser window.
183        \item In the resulting Simulink model window, select File $\rightarrow$ Save As. Type adder in the file name field. Click save.
184        \item Drag the following blocks from the Simulink Library Browser to the new Simulink Model:
185            \begin{enumerate}
186                \item Simulink/Commonly Used Blocks/Scope
187                \item Simulink/Sources/Counter Free-Running
188                \item Xilinx Blockset/Basic Elements/System Generator
189                \item Xilinx Blockset/Basic Elements/Gateway In
190                \item Xilinx Blockset/Basic Elements/Gateway In  (the name should default to Gateway In1)
191                \item Xilinx Blockset/Basic Elements/Gateway Out
192                \item Xilinx Blockset/Math/AddSub
193            \end{enumerate}
194        \item Double click on the Counter Free-Running block. Set Number of Bits to 6 and Sample time to 1.
195        \item   Double click on the Gateway In block. In the Basic tab, set the Output type to Unsigned, the Number of bits to 6, the Binary point to 0, the Quantization to Round, the Overflow to Saturate, and the Sample period to 1. Press OK. Do the same for Gateway In1.
196        \item Double click on the AddSub block. Under the Basic tab, set Operation to Addition and Latency to 1. Under the Output Type tab, set Precision to Full. Press OK.
197        \item Rename Gateway Out to Sum.
198        \item Double click on the Scope block. Click on Scope parameters (the second button from the left within the toolbar at the top of the Scope display window). Set Number of axes to 3. Click OK. Close the Scope display window. The Scope should now display three input ports.
199        \item Connect the Counter Free-Running block so that it feeds the two input gateways and the top two input ports of the scope.  Connect the output gateway to the bottom input port of the scope. Connect the input and output gateways to the inputs and output of the adder block.  The resulting model should appear as shown below.
200           
201            \begin{figure}[htbp]
202                \centering
203                \includegraphics[width=0.70\textwidth]{scriptimages/sysgen1.pdf}
204                \caption{Example System Generator Model}
205                \label{fig:sysgen1}
206            \end{figure}
207
208        \item From the menu bar at the top of the Simulink model window, select Format $\rightarrow$ Port/Signal Displays. Make sure Sample Time Colors, Port Data Types, and Signal Dimensions are selected.
209        \item From the WARP repository, copy sysgen2opb.m and skeleton\_periph\_model.mdl to the directory in which the System Generator model adder.mdl is located.
210        \item In the Matlab Command Window, execute \textit{sysgen2opb('adder', hex2dec('FF000000'))}.  This script will close the model window and then convert it to an OPB-compliant peripheral with ports mapped to a range of addresses starting at hexadecimal FF000000.  A copy of the original unconverted model will be saved to the file adder\_unconverted\_backup.mdl.
211        \newpage
212        \item Reopen adder.mdl to view the converted model.  Note that several blocks may need to be rearranged for aesthetic reasons.     
213           
214            \begin{figure}[htbp]
215                \centering
216                \includegraphics[width=0.70\textwidth]{scriptimages/sysgen2.pdf}
217                \caption{Converted System Generator Model}
218                \label{fig:sysgen2}
219            \end{figure}
220
221        \item Double click on the System Generator block.  A System Generator properties window for the current model will appear.  In this window, set Compilation to OPB Export Tool.  Set Part to Virtex2p xc2vp70-6ff1517.  Set Synthesis Tool to XST.  Set Hardware Description Language to VHDL.  Set FPGA Clock Period (ns) to 20.
222
223            \begin{figure}[htbp]
224                \centering
225                \includegraphics[width=0.30\textwidth]{scriptimages/sysgen3.pdf}
226                \caption{System Generator Properties}
227                \label{fig:sysgen3}
228            \end{figure}
229
230        \item The Target Directory field specifies the location to which output files from the script will be written.  Using the fefault value of ./netlist results in the creation of a directory named netlist within the same directory containing the adder.mdl model.
231        \item If you have not yet created an XPS project in which the OPB peripheral will be used, simply click Generate to complete the process of creating the core.  In this scenario, a directory named pcore will be created within the Target Directory.  Within this pcore directory, another directory named adder\_opbw will be created.  Later, this directory (adder\_opbw) may be moved or copied into the core repository of an XPS project for use within that project.
232        \item If you do have an existing XPS project, and would like the converted core to be placed within the project's core repository, click Settings at the top right of System Generator Properties window.  Make sure that the Export button is highlighted, then browse for an XPS project file (*.xps).  Once the project file has been selected, click Generate in the System Generator properties window.  A directory named adder\_opbw will be created within the XPS project's local pcore directory, making it available for use within the XPS project.
233       
234        \begin{figure}[htbp]
235            \centering
236            \includegraphics[width=0.50\textwidth]{scriptimages/settings.pdf}
237            \caption{EDK Export Settings dialog and Open dialog}
238        \end{figure}
239
240        \item At this point, your system generator model has been converted to an OPB-compliant peripheral that may be imported into an existing XPS project.
241
242    \end{enumerate}
243
244    \newpage
245    \subsection{Xilinx Platform Studio - Using XPS}
246    \begin{enumerate}           
247            \item This section assumes that the peripheral core directory produced by System Generator already resides within the local user repository of the XPS project that will utilize the peripheral.  If necessary, copy the directory now.
248            \item From the menu options at the top of the XPS main window, click Project $\rightarrow$ Rescan User Repositories.
249           
250            \item Click on the IP Catalog tab. Expand Project Repository. You should see adder\_opbw listed in Project Repository. Right-click on adder\_opbw and select Add IP. There may be a popup window that asks, ''Are you sure you want to add this IP?'' If so, click Yes.
251                \begin{figure}[htbp]
252                    \centering
253                    \includegraphics[width=0.30\textwidth]{ORIGdemo/16.pdf}
254                    \label{fig:16}
255                \end{figure}
256                \newpage
257               
258            \item Click on the System Assembly Tab.
259           
260            \begin{enumerate}
261                \item Select the Bus Interface radio button within Filters. This resulting view illustrates connections between available buses and available peripheral cores.  Click the grayed-out circle located at the intersection of the on-chip peripheral bus (OPB) and peripheral adder\_opbw\_0. This will expand adder\_opbw\_0 to show an underlying SOPB item. Click on the grayed-out circle located at the intersection of OPB and the newly visible SOPB item. This will cause the circle to be filled in, and will result in a connection between the OPB and the peripheral's slave OPB interface. On adder\_opbw\_0 $\rightarrow$ SOPB, you will see that the Bus Connection field lists opb.
262                    \begin{figure}[htbp]
263                        \centering
264                        \includegraphics[width=0.70\textwidth]{ORIGdemo/17.pdf}
265                        \label{fig:17}
266                    \end{figure}
267                \newpage
268
269                \item Select the Ports radio button within Filters. The resulting view illustrates port-to-signal mappings for all peripherals. Expand adder\_opbw\_0. Beneath it, you will find the port name ce. Click within ce port's the Net field. In the resulting drop-down menu, select net\_vcc. This will connect a constant ''1'' to the peripheral's ce input port. Click somewhere else within this window for this connection to take effect.
270                    \begin{figure}[htbp]
271                        \centering
272                        \includegraphics[width=0.70\textwidth]{ORIGdemo/18.pdf}
273                        \label{fig:18}
274                    \end{figure}
275
276                \newpage               
277                \item Select the Addresses radio button within Filters. The resulting view illustrates address mappings for all peripherals. Click within the Base Address field of peripheral \\adder\_opbw\_0. Set the base address to 0xFF000000. Click somewhere else within this window for the change to be accepted.  If, after clicking somewhere else, the base address appears incorrect, simply reenter a base address of 0xFF000000. Again, click somewhare else within the window for the change to take effect. Click on the Lock box for peripheral adder\_opbw\_0. A check mark should appear in the box. Click somewhare else within the window for the change to take effect, then click Generate Addresses.
278                    \begin{figure}[htbp]
279                        \centering
280                        \includegraphics[width=0.70\textwidth]{ORIGdemo/19.pdf}
281                        \label{fig:19}
282                    \end{figure}
283               
284            \end{enumerate}
285           
286            \newpage
287            \item Click on the Applications tab. Right click on Project: TestApp\_Memory and deselect Mark to Initialize Bram. Double-click on Add Software Application Project. Name it TestAdder. Processor should be set to ppc405\_0. Click OK. Right click on Project: TestAdder and select Mark to Initialize BRAM.
288                \begin{figure}[htbp]
289                    \centering
290                    \includegraphics[width=0.40\textwidth]{ORIGdemo/20.pdf}
291                    \label{fig:20}
292                \end{figure}
293           
294               
295            \item Under Project: TestAdder, right-click on Sources. Select Add New File. Create a new folder src. Go to the src folder. Put in the file name TestAdder.c . Click Save.
296                \begin{figure}[htbp]
297                    \centering
298                    \includegraphics[width=0.40\textwidth]{ORIGdemo/21.pdf}
299                    \label{fig:21}
300                \end{figure}
301               
302            \item Under Project: TestAdder, expand Sources. Double-click on the new C file that you have recently created in the previous step. Now there will be a TestAdder tab.
303            \newpage
304           
305            \item Within the text file, type:
306                \begin{figure}[htbp]
307                    \centering
308                    \includegraphics[width=0.90\textwidth]{ORIGdemo/code1.pdf}
309                    \label{fig:code1}
310                \end{figure}
311                       
312            \item Go to the directory where you created and converted the System Generator model. Double click on adder\_gatewayLog.h. This is a file that is generated when you converted the System Generator. This contains all the definitions for the register spaces within the address field. Copy all of the text to your TestAdder.c . Make sure that the copied text is below the library declarations. Here is a sample of what the code should look like now:
313                \begin{figure}[htbp]
314                    \centering
315                    \includegraphics[width=0.90\textwidth]{ORIGdemo/code2.pdf}
316                    \label{fig:code2}
317                \end{figure}
318           
319            \item Below your address definitions, type the following:
320                \begin{figure}[htbp]
321                    \centering
322                    \includegraphics[width=0.90\textwidth]{ORIGdemo/code3.pdf}
323                    \label{fig:code3}
324                \end{figure}
325                \newpage
326
327            \item This is what your code should look like in the end:
328                \begin{figure}[htbp]
329                    \centering
330                    \includegraphics[width=0.90\textwidth]{ORIGdemo/code4.pdf}
331                    \label{fig:code4}
332                \end{figure}
333               
334            \item On the XPS menu, go to: File $\rightarrow$ Save to save the c file.
335           
336            \item On the XPS menu, go to: Hardware $\rightarrow$ Generate Bitstream.
337           
338            \item Click on BRAM INIT on the XPS toolbar (or on the XPS menu, go to: Device Configuration $\rightarrow$ Update Bitstream).
339           
340        \end{enumerate}
341    \subsection{Connecting the WARP Board}
342        Connect the WARP board to the serial port of the computer. Turn on the power. For more information in regards to connecting the WARP board to the computer, please read the section ''Connecting and Powering the WARP FGPA Board'' within the WARP document ''WARP FPGA Board User I/O Reference Design.''
343   
344    \newpage
345    \subsection{Tera Term}
346        \begin{enumerate}
347            \item Open Tera Term Pro. Select Serial. Set the Port to COM1. Press OK.
348                \begin{figure}[htbp]
349                        \centering
350                        \includegraphics[width=0.40\textwidth]{ORIGdemo/23.pdf}
351                        \label{fig:23}
352                \end{figure}
353               
354            \item Go to Setup $\rightarrow$ Serial Port. Verify that the baud rate is 9600. Press OK.
355                \begin{figure}[htbp]
356                        \centering
357                        \includegraphics[width=0.40\textwidth]{ORIGdemo/24.pdf}
358                        \label{fig:24}
359                \end{figure}
360    \end{enumerate}
361       
362    \newpage
363    \subsection{iMPACT}
364        \begin{enumerate}
365            \item Open Xilinx iMPACT.
366            \item Cancel the iMPACT Project dialog prompt.
367            \item Double click on Boundary Scan within the iMPACT modes tab.
368            \item Right-click on the empty project space in the Boundary Scan tab. Select Initialize Chain.
369            \item Click on Bypass for the first prompt.
370            \item On the second prompt, to your directory where you saved your XPS project. Double click on the implementation folder and select download.bit . Click Open.
371                \begin{figure}[htbp]
372                        \centering
373                        \includegraphics[width=0.40\textwidth]{ORIGdemo/25.pdf}
374                        \label{fig:25}
375                \end{figure} 
376            \item Select OK on the resulting prompt.
377                \begin{figure}[htbp]
378                        \centering
379                        \includegraphics[width=0.30\textwidth]{ORIGdemo/26.pdf}
380                        \label{fig:26}
381                \end{figure}
382                \newpage
383            \item Right-click on xc2vp70 download.bit . Select Program.
384                \begin{figure}[htbp]
385                        \centering
386                        \includegraphics[width=0.40\textwidth]{ORIGdemo/27.pdf}
387                        \label{fig:27}
388                \end{figure}
389            \item Click OK on Programming Properties.
390                \begin{figure}[htbp]
391                        \centering
392                        \includegraphics[width=0.40\textwidth]{ORIGdemo/28.pdf}
393                        \label{fig:28}
394                \end{figure}
395            \item After it says Program Succeeded, go back to your tera term window and try different inputs for the program.
396        \end{enumerate} 
397
398
399
400
401
402\newpage
403\section{Example with Read Only Shared Memory Extension}
404
405\subsection{Requirements}
406This example assumes that you already know how to use Simulink/Xilinx System Generator, create a XPS project, add a pcore to the XPS project, edit the different properties of System Assembly within XPS, add a Software Application Project, generate the bitstream for the project, use Tera Term, and use iMPACT. If not please go to ''Example with the Original Script'' in this documentation and go through the demo.
407\\
408\\This example uses System Generator 8.1, XPS 8.1, and the iMPACT Tool associated with Xilinx ISE 8.1i
409
410\subsection{Xilinx Platform Studio - Base System Builder}
411Create XPS project. Use Base System Builder to build the project.
412
413\subsection{Matlab/System Generator}
414\begin{enumerate}
415    \item Open Matlab and Simulink
416    \item Create a new model. Save it as SMROdemo.mdl .
417    \item Add the following blocks and edit their properties:
418        \begin{enumerate}
419            \item Xilinx Blockset/Basic Elements/System Generator
420            \item Simulink/Sources/Constant
421                \begin{enumerate}
422                    \item Name: Constant
423                    \item Constant value: 5
424                    \item Sample time: 1
425                \end{enumerate}
426            \item Simulink/Sources/Counter Free-Running
427                \begin{enumerate}
428                    \item Name: Counter Free-Running
429                    \item Number of Bits: 14
430                    \item Sample time: 1
431                \end{enumerate}
432            \item Xilinx Blockset/Basic Elements/Gateway In
433                \begin{enumerate}
434                    \item Name: Gateway In1
435                    \item Output type: Unsigned
436                    \item Number of bits: 14
437                    \item Binary point: 0
438                \end{enumerate}
439            \item Xilinx Blockset/Basic Elements/Gateway In
440                \begin{enumerate}
441                    \item Name: SMROAddr\_gw
442                    \item Output type: Unsigned
443                    \item Number of bits: 14
444                    \item Binary point: 0
445                \end{enumerate}
446            \item Xilinx Blockset/Basic Elements/Constant
447                \begin{enumerate}
448                    \item Name: Constant1
449                    \item Type: Unsigned
450                    \item Constant value: 0
451                    \item Number of bits: 32
452                    \item BInary point: 0
453                \end{enumerate}
454            \item Xilinx Blockset/Basic Elements/Constant
455                \begin{enumerate}
456                    \item Name: Constant 2
457                    \item Type: Boolean
458                    \item Constant value: 0
459                \end{enumerate}
460            \item Xilinx Blockset/Basic Elements/Constant
461                \begin{enumerate}
462                    \item Name: SMRODataI\_const
463                    \item Type: Unsigned
464                    \item Constant value: 0
465                    \item Number of btis: 32
466                    \item Binary: 0
467                \end{enumerate}
468            \item Xilinx Blockset/Basic Elements/Constant
469                \begin{enumerate}
470                    \item Name: SMROWE\_const
471                    \item Type: Boolean
472                    \item Constant value: 0
473                \end{enumerate}
474            \item Xilinx Blockset/Memory/Dual Port RAM
475                \begin{enumerate}
476                    \item Depth: \verb|2^14|
477                    \item Initial value vector: 1:16384
478                    \item Latency: 1
479                \end{enumerate}
480            \item Xilinx Blockset/Basic Elements/Gateway Out
481                \begin{enumerate}
482                    \item Name: Gateway Out1
483                \end{enumerate}
484            \item Xilinx Blockset/Basic Elements/Gateway Out
485                \begin{enumerate}
486                    \item Name: SMRODataO\_GW
487                \end{enumerate}
488            \item Simulink/Commonly Used Blocks/Scope
489                \begin{enumerate}
490                    \item Name: Scope
491                    \item Number of axes: 2
492                        \\Double click on Scope. Click on Scope parameters (the second button on the Scope toolbar).
493Set Number of aces to 2. Click OK. Exit the scope. Now the Scope should have 2 inputs.
494                \end{enumerate}
495        \end{enumerate}
496    \newpage
497    \item Connect Constant to Gateway In1. Connect Gateway In1 to the addra port of SMRO\_dpram. Connect Constant1 to the dina port of SMRO\_dpram. Connect Constant2 to the wea port of SMRO\_dpram. Connect Counter Free-Running to SMROAddr\_gw. Connect SMROAddr\_gw to addrb. Connect SMRODataI\_const to dinb. Connect SMROWE\_const to web. Connect SMRO\_dpram outport A to Gateway Out1. Connect Gateway Out1 outport to the first inport of Scope. Connect SMRO\_dpram outport B to SMRODataO\_GW. Connect SMRODataO\_GW to second inport of Scope.
498        \begin{figure}[htbp]
499            \centering
500            \includegraphics[width=0.70\textwidth]{SMROdemo/UnconvertedModel.pdf}
501            \caption{Unconverted Model}
502            \label{fig:UnconvertedModelSMRO}
503        \end{figure}
504    \item Run the script:
505      \\sysgen2opb('SMROdemo', hex2dec('FF000000'), 'sm')
506        \begin{figure}[htbp]
507                \centering
508                \includegraphics[width=0.70\textwidth]{SMROdemo/ConvertedModel.pdf}
509                \caption{Converted Model}
510                \label{fig:ConvertedModelSMRO}
511            \end{figure}
512    \item Use System Generator to generate the HDL.
513\end{enumerate}
514
515\subsection{Xilinx Platform Studio}
516\begin{enumerate}
517    \item After creating the project, add the generated pcore to the XPS Project.
518    \item Edit the different properties of System Assembly within XPS.
519    \item Add a Software Application Project. Name the project TestSMROdemo. Create a new C Source file. Name the file ''TestSMROdemo.c''
520    \item After including the necessary libraries and copying the generated .h file \\(SMROdemo\_gatewaySMLog.h), add in the following code:
521        \begin{figure}[htbp]
522            \centering
523            \includegraphics[width=0.90\textwidth]{SMROdemo/code1.pdf}
524            \label{fig:codeSMRO1}
525        \end{figure}
526    \newpage
527    \item This is what the code should look like:
528        \begin{figure}[htbp]
529            \centering
530            \includegraphics[width=0.90\textwidth]{SMROdemo/code2.pdf}
531            \label{fig:codeSMRO2}
532        \end{figure}
533    \item Save the file. Generate the bitstream. Update the bitstream. Put the bitstream onto the board and view the output.
534       
535\end{enumerate}
536
537\newpage
538
539
540
541
542
543\section{Example with Write Only Shared Memory Extension}
544\subsection{Requirements}
545This example assumes that you already know how to use Simulink/Xilinx System Generator, create a XPS project, add a pcore to the XPS project, edit the different properties of System Assembly within XPS, add a Software Application Project, generate the bitstream for the project, use Tera Term, and use iMPACT. If not please go to ''Example with the Original Script'' in this documentation and go through the demo.
546\\
547\\This example uses System Generator 8.1, XPS 8.1, and the iMPACT Tool associated with Xilinx ISE 8.1i
548
549\subsection{Xilinx Platform Studio - Base System Builder}
550Create XPS project. Use Base System Builder to build the project.
551
552\subsection{Matlab/System Generator}
553\begin{enumerate}
554    \item Open Matlab and Simulink
555    \item Create a new model. Save it as SMWOdemo.mdl .
556    \item Add the following blocks and edit their properties:
557    \begin{enumerate}
558        \item Xilinx Blockset/Basic Elements/System Generator
559        \item Xilinx Blockset/Basic Elements/Gateway In
560            \begin{enumerate}
561                \item Name: Gateway In
562                \item Output type: Unsigned
563                \item Number of bits: 14
564                \item Binary point: 0
565                \item Sample period: 1
566            \end{enumerate}
567        \item Xilinx Blockset/Basic Elements/Gateway In
568            \begin{enumerate}
569                \item Name: SMWOAddr\_gwin
570                \item Output type: Unsigned
571                \item Number of bits: 14
572                \item Binary point: 0
573                \item Sample period: 1
574            \end{enumerate}
575        \item Xilinx Blockset/Basic Elements/Gateway In
576            \begin{enumerate}
577                \item Name: SMWODataI\_gwin
578                \item Output type: Unsigned
579                \item Number of bits: 32
580                \item Binary point: 0
581                \item Sample period: 1
582            \end{enumerate}
583        \item Xilinx Blockset/Basic Elements/Gateway In
584            \begin{enumerate}
585                \item Name: SMWOWE\_gwin
586                \item Output type: Boolean
587                \item Sample period: 1
588            \end{enumerate}
589        \item Xilinx Blockset/Basic Elements/Constant
590            \begin{enumerate}
591                \item Name: Constant1
592                \item Type: Unsigned
593                \item Constant value: 0
594                \item Number of bits: 32
595                \item Binary point: 0
596                \item Sample constant: checked
597                \item Sample period: 1
598            \end{enumerate}
599        \item Xilinx Blockset/Basic Elements/Constant
600            \begin{enumerate}
601                \item Name: Constant2
602                \item Type: Boolean
603                \item Constant value: 0
604                \item Sample constant: checked
605                \item Sample period: 1
606            \end{enumerate}
607        \item Xilinx Blockset/Memory/Dual Port RAM
608            \begin{enumerate}
609                \item Name: SMWO\_dpram
610                \item Depth: \verb|2^14|
611                \item Initial value vector: 1:16384
612                \item Latency: 1
613            \end{enumerate}
614        \item Xilinx Blockset/Basic Elements/Gateway Out
615            \begin{enumerate}
616                \item Name: Gateway Out
617            \end{enumerate}
618        \item Simulink/Sources/Counter Free-Running
619            \begin{enumerate}
620                \item Name: Counter Free-Running
621                \item Number of Bits: 14
622                \item Sample time: 1
623            \end{enumerate}
624        \item Simulink/Sources/Constant
625            \begin{enumerate}
626                \item Name: Constant3
627                \item Constant value: 50
628                \item Sample time: inf
629            \end{enumerate}
630        \item Simulink/Sources/Constant
631            \begin{enumerate}
632                \item Name: Constant4
633                \item Constant value: 1000
634                \item Sample time: inf
635            \end{enumerate}
636        \item Simulink/Sources/Constant
637            \begin{enumerate}
638                \item Name: Constant5
639                \item Constant value: 1
640                \item Sample time: inf
641            \end{enumerate}
642        \item Simulink/Commonly Used Blocks/Scope
643            \begin{enumerate}
644                \item Name: Scope
645            \end{enumerate}
646    \end{enumerate}
647   
648    \newpage
649    \item Connect Counter Free-Running to Gateway In. Connect Gateway In to SMWO\_dpram inport addra. Connect Constant1 to SMWO\_dpram inport dina. Connect Constant 2 to \\SMWO\_dpram inport wea. Connect Constant3 to SMWOAddr\_gwin. Connect \\SMWOAddr\_gwin to SMWO\_dpram inport addrb. Connect Constant4 to SMWODataI\_gwin. Connect SMWODataI\_gwin to dinb. Connect Constant5 to SMWOWE\_gwin. Connect SMWOWE\_gwin to SMWO\_dpram inport web. Connect SMWO\_dpram outport to Gateway Out. Connect Gateway Out to Scope.
650    \begin{figure}[htbp]
651            \centering
652            \includegraphics[width=0.70\textwidth]{SMWOdemo/UnconvertedModel.pdf}
653            \caption{Unconverted Model}
654            \label{fig:UnconvertedModelSMWO}
655        \end{figure}
656    \newpage
657    \item Run the script:
658      \\sysgen2opb('SMWOdemo', hex2dec('FF000000'), 'sm')
659        \begin{figure}[htbp]
660                \centering
661                \includegraphics[width=0.70\textwidth]{SMWOdemo/ConvertedModel.pdf}
662                \caption{Converted Model}
663                \label{fig:ConvertedModelSMWO}
664            \end{figure}
665    \item Use System Generator to generate the HDL.
666   
667\end{enumerate}
668
669
670\subsection{Xilinx Platform Studio}
671\begin{enumerate}
672    \item After creating the project, add the generated pcore to the XPS Project.
673    \item Edit the different properties of System Assembly within XPS.
674    \item Add a Software Application Project. Name the project TestSMWOdemo. Create a new C Source file. Name the file ''TestSMWOdemo.c''
675    \newpage
676    \item After including the necessary libraries and copying the generated .h file \\(SMWOdemo\_gatewaySMLog.h), add in the following code:
677        \begin{figure}[htbp]
678            \centering
679            \includegraphics[width=0.90\textwidth]{SMWOdemo/code1.pdf}
680            \label{fig:codeSMWO1}
681        \end{figure}
682    \newpage
683    \item This is what the code should look like:
684        \begin{figure}[htbp]
685            \centering
686            \includegraphics[width=0.90\textwidth]{SMWOdemo/code2.pdf}
687            \label{fig:codeSMWO2}
688        \end{figure}
689    \item Save the file. Generate the bitstream. Update the bitstream. Put the bitstream onto the board and view the output.
690\end{enumerate}
691
692
693
694
695
696\newpage
697\section{Example with Configurable Subsystem Extension}
698
699\begin{enumerate}
700    \item This example is exactly the same as the Example with the Original Script. However, after creating the model, run
701\\\textit{sysgen2opb('adder', hex2dec('FF000000'), 'confsubsys')} in order to run the Configurable Subsystem Extension script. This is the result you should get:
702    \begin{figure}[htbp]
703        \centering
704        \includegraphics[width=0.50\textwidth]{CONFdemo/ConvertedModel.pdf}
705        \label{fig:ConvertedModel}
706    \end{figure}
707
708    \item Now the difference is that there are configurable subsystems instead of registers. For each configurable subsystem, double-click on it. Double click on Configurable Subsystem Manager. Click on the drop-down menu and select the option that has the suffix ''\_reg.'' Click OK. Close the Configurable Subsystem Window. Make sure that you do this for all of the configurable subsystems. This will allow the OPB Export Tool to run since the Configurable Subsystem Manager selected the register option to be used in hardware generation.
709    \begin{figure}[htbp]
710        \centering
711        \includegraphics[width=0.50\textwidth]{CONFdemo/ConfSubsManager.pdf}
712        \label{fig:ConfSubsManager}
713    \end{figure}
714   
715    \newpage
716    \item For each configurable subsystem, right-click on the configurable subsystem. Go to block choice and select the option that has the suffix ''\_gw.'' Now you can simulate the model. Also, you can still run OPB Export Tool since the Configurable Subsystem Manager has the register option selected for hardware generation.
717    \begin{figure}[htbp]
718        \centering
719        \includegraphics[width=0.50\textwidth]{CONFdemo/BlockChoice.pdf}
720        \label{fig:BlockChoice}
721    \end{figure}
722
723\end{enumerate}
724
725
726
727
728
729\newpage
730\section{Sysgen2OPB : Syntax and Usage}
731This section briefly describes the syntax and usage of the sysgen2opb script.
732
733\begin{enumerate}
734    \item The syntax for the script in the Matlab command window is:
735        \\\textit{sysgen2opb('YourModelName', hex2dec('YourBaseAddr'), 'YourSelection', 'YourPrefix')}
736        \begin{enumerate}
737            \item Replace 'YourModelName' with your Simulink/System Generator model's name without the .mdl extension.
738            \item Replace 'YourBaseAddr' with a 32-bit memory address in hexidecimal notation. \\FF100000 is usually a safe choice.
739            \item Replace 'YourSelection' with one of the following:
740                \begin{enumerate}
741                    \item 'orig' which will run the Simple Registers Script
742                    \item 'sm' which will run the Shared Memory Extension Script
743                    \item 'confsubsys' which will run the Configurable Subsystem Extension Script
744                \end{enumerate}
745            \item Replace 'YourPrefix' with a string which will replace the ''no\_reg\_'' prefix attached to unconverted gateways. Use a blank string ('') to simply strip the ''no\_reg\_'' prefix.
746            \item There are two defaults in the script
747                \begin{enumerate}
748                    \item If you want to run the Simple Registers Script with a blank string to strip away the ''no\_reg\_'' prefix, run:
749                            \\sysgen2opb('yourModelName', hex2dec('yourBaseAddress'))
750                   
751                    \item If you want to run one of the scripts with a blank strip to strip away the ''no\_reg\_'' prefix, run:
752                            \\sysgen2opb('yourModelName', hex2dec('yourBaseAddress'), 'yourSelection')
753                \end{enumerate}
754
755    \end{enumerate}
756\end{enumerate}
757
758\end{document}
Note: See TracBrowser for help on using the repository browser.