OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [doc/] [peripheral.html] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sinclairrf
<html>
2
<title>
3
SSBCC -- PERIPHERAL
4
</title>
5
<body>
6
<tt>Copyright 2012, Sinclair, R.F., Inc.</tt><br/>
7
<h1>Table of Contents</h1>
8
  <a href="#introduction">Introduction</a><br/>
9
  <a href="#command">Command</a><br/>
10
  <a href="#cores">9x8&nbsp;Cores</a><br/>
11
  <a href="#new">Creating&nbsp;new&nbsp;Peripherals</a><br/>
12
  <a href="#recommendations">Reccomendations</a><br/>
13
<h1><a name="introduction">Introduction</a></h1>
14
  Within the processor configuration command, the PERIPHERAL configuration is used
15
    to incorporate peripherals such as UARTs, TBD into the micro controller
16
    core.<br/><br/>
17
  This document describes the general format of the peripheral configuration
18
    command, lists peripherals for the 9x8 core, and documents how to add
19
    additional peripherals to the computer compiler.<br/><br/>
20
<h1><a name="command">Command</a></h1>
21
  TODO
22
<h1><a name="cores">9x8&nbsp;Cores</a></h1>
23
  TODO
24
<h1><a name="new">Creating&nbsp;new&nbsp;Peripherals</a></h1>
25
  New peripherals are created using a Python class with the following member
26
    functions:
27
  <h2>__init__(self,config,param_list):</h2>
28
    Where:<br/>
29
    <ul>
30
      <li><tt>config</tt> is the computer compiler configuration state when
31
        the peripheral configuration command is encountered.<br/><br/></li>
32
      <li><tt>param_list</tt> is a list of the space separated parameters on
33
        the peripheral
34
        configuration command following the name of the peripheral.  This list
35
        is used to provide mandatory and optional parameters to the
36
        core.  For example, the <tt>UART_Tx</tt> peripheral requires
37
        information to generate the desired baud rate and allows an optional
38
        name to facilitate distinguishing between multiple instances of the
39
        same peripheral.<br/><br/>
40
        For example, the parameters in the peripheral configuration
41
        command<br/><br/>
42
        <tt>&nbsp;&nbsp;PERIPHERAL&nbsp;name&nbsp;param1&nbsp;\<br/>
43
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param2=options&nbsp;\<br/>
44
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param3="a&nbsp;string"&nbsp;\<br/>
45
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param4=value</tt><br/><br/>
46
        is converted to the space delimited string<br/><br/>
47
        <tt>&nbsp;&nbsp;param1&nbsp;param2=option&nbsp;param3="a&nbsp;string"&nbsp;param4=value</tt><br/><br/>
48
        which is then provided to the <tt>__init__</tt> function as a
49
        <tt>list()</tt> with the following four tuples:<br/><br/>
50
        <tt>&nbsp;&nbsp;('param1',)<br/>
51
          &nbsp;&nbsp;('param2','option',)<br/>
52
          &nbsp;&nbsp;('param3','"a&nbsp;string"',)<br/>
53
          &nbsp;&nbsp;('param4','value',)</tt><br/><br/>
54
        These tuples can then be parsed within the <tt>__init__</tt> function to
55
        intialize the object.<br/>
56
        </li>
57
      </ul>
58
    This function should store instantiation specific information in
59
      <tt>self</tt>.<br/><br/>
60
    Inputs from the FPGA fabric to the micro controller module are added by
61
      appending a tuple describing the input.  The tuple consists of the
62
      following:<br/>
63
      <ol>
64
        <li>signal name</li>
65
        <li>signal width</li>
66
        <li>signal type:  the string <tt>'input'</tt><br/></li>
67
        </ol>
68
    For example, to add an 8-bit input named "<tt>i_new_input</tt>", use the
69
      following statement:<br/><br/>
70
      <tt>&nbsp;&nbsp;config['ios'].append(('i_new_input',8,'input',));</tt><br/><br/>
71
    Outputs from the micro controller to the FPGA fabric are added using the
72
      signal type <tt>'output'</tt>.  For example, to add an 8-bit output
73
      named "<tt>o_new_output</tt>", use the following statement:<br/><br/>
74
      <tt>&nbsp;&nbsp;config['ios'].append(('o_new_output',8,'output',));</tt><br/><br/>
75
    Similarly, to add a 16-bit tri-state input/output signal, use the
76
      followiing statement:<br/><br/>
77
      <tt>&nbsp;&nbsp;config['ios'].append(('io_new_signal',16,'inout',));</tt><br/><br/>
78
    To add a signal or a composite signal output from the micro controller
79
      core to the peripheral two actions are required.  These can be done in
80
      either order, but it may make more sense to maintainers or subsequent
81
      users to do them in the following order:<br/><br/>
82
      <ol>
83
        <li>Add the output port to the micro controller core:<br/><br/>
84
          This consists of adding a tuple to <tt>config['outports']</tt>.  The
85
          first element of this tuple is the name of the outport.  The
86
          subsequent elements of this tuple are tuples describing the
87
          signal(s) associated with the outport.  These tuples have the
88
          following ordered format:<br/><br/>
89
          <ol>
90
            <li>signal name</li>
91
            <li>signal width</li>
92
            <li>signal type:  <tt>'data'</tt> or <tt>'strobe'</tt><br/>
93
              Note:  Signal type <tt>'data'</tt> is used to relay single or
94
              multiple bit data from the micro controller core to the
95
              peripheral.  Signal type <tt>'strobe'</tt> generates a single
96
              bit strobe during the clock cycle immediately following the
97
              <tt>outport</tt> instruction.<br/><br/>
98
              </li>
99
            </ol>
100
        <li>Add these same signals to <tt>config['signals']</tt>, one at a
101
          time using tuples with the following ordered format:<br/><br/>
102
          <ol>
103
            <li>signal name</li>
104
            <li>signal width<br/></li>
105
            </ol>
106
          </li>
107
        </ol>
108
    For example, to add two outputs from the micro controller core to a
109
      multiplier, use the following:<br/><br/>
110
      <tt>&nbsp;&nbsp;config['outports'].append(('O_MULT_A',<br/>
111
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_mult_a',8,'data'),<br/>
112
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
113
      &nbsp;&nbsp;config['outports'].append(('O_MULT_B',<br/>
114
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_mult_b',8,'data'),<br/>
115
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
116
      &nbsp;&nbsp;config['signals'].append(('s_mult_a',8,));<br/>
117
      &nbsp;&nbsp;config['signals'].append(('s_mult_b',8,));</tt><br/><br/>
118
    As&nbsp;a second example, to add an output from the micro controller core
119
      to the input side of an 8-bit FIFO, use the following.  Here, the signal
120
      <tt>s_fifo_data</tt> will be the data to write to the FIFO and
121
      <tt>s_fifo_wr</tt> will be a strobe that is set high during the clock
122
      cycle immediately following the <tt>outport</tt> instruction.<br/><br/>
123
      <tt>&nbsp;&nbsp;config['outports'].append(('O_FIFO',<br/>
124
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_data',8,'data'),<br/>
125
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_wr',1,'strobe'),<br/>
126
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
127
      &nbsp;&nbsp;config['signals'].append(('s_fifo_data',8,));<br/>
128
      &nbsp;&nbsp;config['signals'].append(('s_fifo_wr',1,));</tt><br/><br/>
129
    Adding a signal or a composite signal from the peripheral to the micro
130
      controller core requires two similar actions:<br/>
131
      <ol>
132
        <li>Add the input port to the micro controller core:<br/><br/>
133
          This consists of adding a tuple to <tt>config['inports']</tt>.  The
134
          first element of this tuple is the name of the inport.  The
135
          subsequent elements of this tuple are tuples describing the
136
          signal(s) associated with the inport.  These tuples have the
137
          following ordered format:<br/><br/>
138
          <ol>
139
            <li>signal name</li>
140
            <li>signal width</li>
141
            <li>signal type:  <tt>'data'</tt>, <tt>'set-reset'</tt>, or
142
              <tt>'strobe'</tt>
143
              Note:  Signal type <tt>'data'</tt> is used to relay single or
144
              multiple bit data from the peripheral to the micro controller
145
              core.  Signal type <tt>'set-reset'</tt> latches the associated
146
              input bit until the signal is read, at which time it is cleared.
147
              Signal type <tt>'strobe'</tt> generates a single bit strobe
148
              during the clock cycle immediately following the
149
              <tt>inport</tt> instruction.<br/>
150
              Note:  The <tt>'set-reset'</tt> signal type is provided as a
151
              signal type for the <tt>INPORT</tt> command and may not be as
152
              useful for peripherals since the peripheral can include the
153
              associated logic required for the latch.<br/><br/>
154
              </li>
155
            </ol>
156
        <li>Add these same signals to <tt>config['signals']</tt>, one at a
157
          time using tuples with the following ordered format:<br/><br/>
158
          <ol>
159
            <li>signal name</li>
160
            <li>signal width<br/></li>
161
            </ol>
162
          </li>
163
        </ol>
164
    For example, to add two inport ports for the MSB and LSB from an 8 by 8 multipler, use the
165
      following:<br/><br/>
166
      <tt>&nbsp;&nbsp;config['inports'].append(('I_MULT_MSB',<br/>
167
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_mult_msb',8,'data'),<br/>
168
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
169
      &nbsp;&nbsp;config['inports'].append(('I_MULT_LSB',<br/>
170
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_mult_lsb',8,'data'),<br/>
171
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
172
      &nbsp;&nbsp;config['signals'].append(('s_mult_msb',8,));<br/>
173
      &nbsp;&nbsp;config['signals'].append(('s_mult_lsb',8,));</tt><br/><br/>
174
    As&nbsp;a second example, to add an input port from a FIFO in the
175
      peripheral to the micro controlller core, use the following:<br/><br/>
176
      <tt>&nbsp;&nbsp;config['inports'].append(('I_FIFO',<br/>
177
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_data',8,'data'),<br/>
178
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_ack',1,'strobe'),<br/>
179
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
180
      &nbsp;&nbsp;config['signals'].append(('s_fifo_data',8,));<br/>
181
      &nbsp;&nbsp;config['signals'].append(('s_fifo_ack',1,));</tt><br/><br/>
182
    As&nbsp;a third example, to add an input port for two status bits from a
183
      FIFO in the peripheral to the micro controlller core, use the
184
      following:<br/><br/>
185
      <tt>&nbsp;&nbsp;config['inports'].append(('I_FIFO_STATUS',<br/>
186
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_full',1,'data'),<br/>
187
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;('s_fifo_empty',1,'data'),<br/>
188
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;));<br/>
189
      &nbsp;&nbsp;config['signals'].append(('s_fifo_full',1,));<br/>
190
      &nbsp;&nbsp;config['signals'].append(('s_fifo_empty',1,));</tt><br/><br/>
191
  <h2>GenAssembly(self,config):</h2>
192
    This is an optional function to generate an assembly file associated with
193
      the peripheral.<br/>
194
    TODO
195
  <h2>GenHDL(self,fp,config):</h2>
196
    This function examines <tt>config['hdl']</tt> to determine the HDL language
197
      for generating the FPGA logic for the peripheral.  The logic is written to
198
      the file handle <tt>fp</tt>.<br/><br/>
199
    Rather than capture all HDL languages in this function, the following type
200
      of structure is recommended:<br/><br/>
201
      <tt>&nbsp;&nbsp;GenHDL(self,fp,config):<br/>
202
      &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;config['hdl']&nbsp;==&nbsp;'Verilog':<br/>
203
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.GenVerilog(fp,config);<br/>
204
      &nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;config['hdl']&nbsp;==&nbsp;'VHDL':<br/>
205
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.GenVHDL(fp,config);<br/>
206
      &nbsp;&nbsp;&nbsp;&nbsp;else:<br/>
207
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise&nbsp;Exception('HDL&nbsp;"%s"&nbsp;not&nbsp;implemented'&nbsp;%&nbsp;config['hdl']);</tt><br/><br/>
208
    For example, to generate the logic for an unsigned 8 by 8 multiplier using
209
      the previous inport, outport, and signal assignments, the Verilog code
210
      could be generated using:<br/><br/>
211
      <tt>&nbsp;&nbsp;GenVerilog(self,fp,config):<br/>
212
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('initial s_mult_msb = 8\'d0;\n');<br/>
213
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('initial s_mult_lsb = 8\'d0;\n');<br/>
214
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('always&nbsp;@&nbsp;(posedge&nbsp;i_clk)\n');<br/>
215
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('&nbsp;&nbsp;if&nbsp;(i_rst) begin\n');<br/>
216
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('&nbsp;&nbsp;&nbsp;&nbsp;s_mult_msb&nbsp;&lt;=&nbsp;8\'d0;\n');<br/>
217
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('&nbsp;&nbsp;&nbsp;&nbsp;s_mult_lsb&nbsp;&lt;=&nbsp;8\'d0;\n');<br/>
218
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('&nbsp;&nbsp;end&nbsp;else\n');<br/>
219
      &nbsp;&nbsp;&nbsp;&nbsp;fp.write('&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;s_mult_msb,&nbsp;s_mult_lsb&nbsp;}&nbsp;&lt;=&nbsp;$unsigned(s_mult_a)&nbsp;*&nbsp;$unsigned(s_mult_b);\n');</tt><br/><br/>
220
    Note:  The results of this multiplication are available two clock cycles
221
      after the <tt>outport</tt> instruction setting the <tt>s_mult_a</tt> or
222
      <tt>s_mult_b</tt> value.  This isn't a problem with the processor as the
223
      <tt>outport</tt> is probably followed by a <tt>drop</tt>
224
      instruction and the <tt>inport</tt> instruction to read either part of the
225
      multiplication has to be preceded by an instruction pushing the port
226
      number onto the data stack.<br/><br/>
227
    Note:  While Python allows the entire logic block to be written using a
228
      single <tt>fp.write("""initial&nbsp;s_...""");</tt> statement, breaking
229
      out the individual statements allows computed signal names to be included
230
      more cleanly and also accomodates conditional inclusion of code.<br/><br/>
231
<h1><a name="recommendations">Recommendations</a></h1>
232
  <h2>help</h2>
233
    The PERIPHERAL configuration command will print the documentation string for
234
    peripherals if the parameter "<tt>help</tt>" is listed.  For example, to get
235
    help for the <tt>monitor_stack</tt> peripheral, insert the peripheral
236
    using:<br/><br/>
237
    <tt>&nbsp;&nbsp;PERIPHERAL&nbsp;monitor_stack&nbsp;help</tt><br/><br/>
238
    This will display the documentation string for the <tt>monitor_stack</tt>
239
    peripheral and then terminate the build.<br/><br/>
240
    If&nbsp;there is no documentation string for the peripheral, the
241
    following message is printed and the build is terminated:<br/><br/>
242
    <tt>&nbsp;&nbsp;No&nbsp;help&nbsp;for&nbsp;periperal&nbsp;XXX&nbsp;is&nbsp;provided</tt><br/><br/>
243
    Note:  The help message displays the name of the peripheral and the source
244
    file.<br/><br/>
245
</body>
246
</html>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.