Commit c63535f0 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana Committed by Tomasz Wlostowski

i2c-bridge: Updated bridge and slave modules

Bridge: Removed "redundant" SIM_WB_TRANSFER state.

Slave: Removed redundant ADDR_CHECK state and moved its code to
the ADDR state.

Also corrected a bug whereby the ack_i pin was not being checked within
the ADDR_ACK state. This was causing the FSM to advance even thogh the
slave was actually NACK-ing.

DOC: Updated documentation for both these modules
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent e848b421
......@@ -14,7 +14,7 @@
id="svg3820"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="New document 5">
sodipodi:docname="fsm-and-scl.svg">
<defs
id="defs3822" />
<sodipodi:namedview
......@@ -24,9 +24,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="530.67784"
inkscape:cy="281.42393"
inkscape:zoom="1.4"
inkscape:cx="600.62433"
inkscape:cy="113.09241"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
......@@ -60,7 +60,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
......@@ -429,16 +429,20 @@
sodipodi:role="line"
x="751.18103"
y="129.42914"
id="tspan4687">- shift out ack_i</tspan><tspan
id="tspan4687">- start sampling</tspan><tspan
sodipodi:role="line"
x="751.18103"
y="141.92914"
id="tspan3160">ack_i</tspan><tspan
sodipodi:role="line"
x="751.18103"
y="154.42914"
id="tspan4573">- set r_done_p_o</tspan></text>
<rect
style="opacity:0.98999999;fill:none;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect4575"
width="88.58268"
height="42.51968"
height="53.14962"
x="747.63776"
y="106.29919" />
<path
......
......@@ -10,11 +10,11 @@
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="784.57941"
height="126.67509"
height="131.76501"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="New document 1">
sodipodi:docname="fsm-diag.svg">
<defs
id="defs4">
<marker
......@@ -39,9 +39,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="368.04522"
inkscape:cy="-56.867786"
inkscape:zoom="1.4"
inkscape:cx="471.24039"
inkscape:cy="-21.174434"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
......@@ -50,7 +50,7 @@
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1855"
inkscape:window-height="1148"
inkscape:window-height="1176"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
......@@ -62,7 +62,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
......@@ -76,7 +76,7 @@
transform="translate(-4.4806012,0)">
<path
transform="matrix(0.52372011,0,0,0.52372011,209.1211,95.152762)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -145,7 +145,7 @@
sodipodi:cy="160.39749"
sodipodi:rx="73.236061"
sodipodi:ry="38.385796"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
transform="matrix(0.52372011,0,0,0.52372011,313.56907,95.152762)" />
<text
xml:space="preserve"
......@@ -174,7 +174,7 @@
id="g4855">
<path
transform="matrix(0.8051458,0,0,0.8051458,380.97903,50.012787)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -185,20 +185,15 @@
<text
sodipodi:linespacing="125%"
id="text4439"
y="174.69424"
y="182.19424"
x="573.12122"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:12px;font-weight:bold;text-align:center;text-anchor:middle"
y="174.69424"
x="573.12122"
id="tspan4441"
sodipodi:role="line">ADDR_CHECK</tspan><tspan
id="tspan4443"
style="font-size:12px;font-weight:bold;text-align:center;text-anchor:middle"
y="189.69424"
y="182.19424"
x="573.12122"
sodipodi:role="line">ADDR_ACK</tspan></text>
sodipodi:role="line">ADDR_CHECK</tspan></text>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#TriangleOutM)"
......@@ -221,7 +216,7 @@
transform="translate(15.892857,0)">
<path
transform="matrix(0.82801985,0,0,0.52372011,517.14825,63.332957)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -300,7 +295,7 @@
sodipodi:cy="160.39749"
sodipodi:rx="73.236061"
sodipodi:ry="38.385796"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
transform="matrix(0.52372011,0,0,0.52372011,305.73802,95.152767)" />
<text
xml:space="preserve"
......@@ -337,7 +332,7 @@
sodipodi:cy="160.39749"
sodipodi:rx="73.236061"
sodipodi:ry="38.385796"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
transform="matrix(0.52372011,0,0,0.52372011,305.73802,95.152767)" />
<text
xml:space="preserve"
......@@ -366,7 +361,7 @@
id="g4933">
<path
transform="matrix(0.52372011,0,0,0.52372011,305.73802,95.152767)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -389,7 +384,7 @@
</g>
</g>
<g
transform="translate(-153.06349,62.857143)"
transform="translate(-112.14285,62.857143)"
id="g4943">
<g
transform="translate(545.35714,-31.81981)"
......@@ -398,7 +393,7 @@
id="g4947">
<path
transform="matrix(0.52372011,0,0,0.52372011,305.73802,95.152767)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -423,13 +418,8 @@
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#TriangleOutM)"
d="m 752.80619,210.19349 25.71428,0"
d="m 752.80619,210.19349 67.63561,0"
id="path4955"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#TriangleOutM)"
d="m 864.02757,210.19349 66.42857,0"
id="path4957"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<g
......@@ -444,7 +434,7 @@
</g>
<path
transform="matrix(0.52372011,0,0,0.52372011,849.70248,126.1901)"
d="m 312.13714,160.39749 c 0,21.19989 -32.7889,38.3858 -73.23606,38.3858 -40.44716,0 -73.23606,-17.18591 -73.23606,-38.3858 0,-21.19989 32.7889,-38.38579 73.23606,-38.38579 40.44716,0 73.23606,17.1859 73.23606,38.38579 z"
d="m 312.13714,160.39749 a 73.236061,38.385796 0 1 1 -146.47212,0 73.236061,38.385796 0 1 1 146.47212,0 z"
sodipodi:ry="38.385796"
sodipodi:rx="73.236061"
sodipodi:cy="160.39749"
......@@ -472,7 +462,7 @@
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#TriangleOutM)"
d="m 793.22229,227.57263 c -11.64123,9.61383 -31.0382,9.24083 -48.73986,0"
d="m 833.81378,224.71549 c -24.49837,21.0424 -68.18106,18.34797 -91.23986,1.96428"
id="path5530"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
......@@ -482,5 +472,10 @@
id="path5716"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#TriangleOutM)"
d="m 904.83415,210.19349 25.71428,0"
id="path3060"
inkscape:connector-curvature="0" />
</g>
</svg>
This diff is collapsed.
......@@ -372,10 +372,11 @@ Figure~\ref{fig:fsm-diag} shows a simplified state transition diagram of the FSM
and Table~\ref{tbl:fsm} lists the states of the FSM and the operations performed in each
state. Across the FSM, shifting of bits into the module is done on the rising edge
of SCL and shifting out is done on the falling edge of SCL. A three-bit counter is
used to count the number of received bits. This bit counter is incremented on the
rising edge of SCL. During read and write cycles, the FSM also changes states on
the SCL falling edge. A summary of the FSM actions with reference to the SCL line
on read and write transfer is shown in Figure~\ref{fig:fsm-and-scl}.
used to count the number of bits that are sent and received by the module. This bit
counter is incremented on the rising edge of SCL. During read and write cycles, the
FSM changes states on the SCL falling edge. A summary of the FSM actions with
reference to the SCL line on read and write transfer is shown in
Figure~\ref{fig:fsm-and-scl}.
\begin{figure}[h]
\centerline{\includegraphics[width=\textwidth]{fig/fsm-diag}}
......@@ -409,8 +410,6 @@ on read and write transfer is shown in Figure~\ref{fig:fsm-and-scl}.
\textit{IDLE} & Default state after reset and the state returned to after
reception of a start and stop condition. \\
\textit{ADDR} & Shift in the address and R/W bit. \\
\textit{ADDR\_CHECK} & Check the address versus \textit{i2c\_addr\_i} and set the \textit{op\_o}
output as per the R/W bit. \\
\textit{ADDR\_ACK} & Send ACK depending on value of \textit{ack\_i} and go to \textit{RD} state
if the R/W bit is high, or to \textit{WR\_LOAD\_TXSR} state if R/W bit is low.
If \textit{ack\_i} is low, go back to \textit{IDLE}. \\
......
This diff is collapsed.
......@@ -67,9 +67,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="266.19801"
inkscape:cy="49.556734"
inkscape:zoom="1.979899"
inkscape:cx="218.37393"
inkscape:cy="-21.765683"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
......@@ -268,15 +268,20 @@
<text
sodipodi:linespacing="125%"
id="text4957"
y="204.5881"
x="431.36719"
y="199.4465"
x="455.09521"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:10px;font-weight:bold;fill:#000000;fill-opacity:1"
y="204.5881"
x="431.36719"
style="font-size:10px;font-weight:bold;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
y="199.4465"
x="455.09521"
id="tspan4959"
sodipodi:role="line">vbcp_wb</tspan></text>
sodipodi:role="line">I2C slave</tspan><tspan
style="font-size:10px;font-weight:bold;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
y="211.9465"
x="455.09521"
sodipodi:role="line"
id="tspan3022">module</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)"
d="m 488.97638,201.96848 14.17323,0"
......
......@@ -10,7 +10,7 @@
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="427.21851"
height="180.70866"
height="164.76381"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
......@@ -25,10 +25,10 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="237.22927"
inkscape:cy="106.71884"
inkscape:cx="230.33819"
inkscape:cy="169.95193"
inkscape:document-units="px"
inkscape:current-layer="g3186"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1855"
inkscape:window-height="1176"
......@@ -51,7 +51,7 @@
units="mm"
spacingx="0.5mm"
spacingy="0.5mm"
originx="-9.5000005mm"
originx="-9.5000004mm"
originy="-241.5mm" />
</sodipodi:namedview>
<metadata
......@@ -70,7 +70,7 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-33.66142,-15.94489)">
transform="translate(-33.66142,-31.88974)">
<path
style="fill:#000000;fill-opacity:0.3;stroke:none"
d="m 66.842366,82.013037 0,79.724413 3.543307,0 0,-67.322838 90.354327,0 0,-12.401575 z"
......@@ -1037,37 +1037,12 @@
id="tspan4111"
sodipodi:role="line">SYSMON_WB_ADR</tspan></text>
</g>
<g
transform="translate(-66.031652,934.80802)"
id="g8006">
<g
id="g3186">
<path
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path7225"
d="m 282.1734,-918.86313 -1e-5,12.40158 60.23622,0 0,70.86613 5.31496,0 0,-70.86613 26.5748,0 0,-12.40158 z"
style="fill:#000000;fill-opacity:0.3;stroke:none" />
<text
sodipodi:linespacing="125%"
id="text4115"
y="-910.00488"
x="283.94504"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px;font-style:italic;font-weight:bold"
y="-910.00488"
x="283.94504"
id="tspan4117"
sodipodi:role="line">SIM_WB_TRANSFER</tspan></text>
</g>
<path
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path3184"
d="m 388.47261,-918.86313 -10e-6,12.40159 44.29134,0 0,70.86613 3.5433,0 0,-70.86613 31.88977,0 0,-12.40159 z"
style="fill:#000000;fill-opacity:0.3;stroke:none" />
</g>
<path
style="fill:#000000;fill-opacity:0.3;stroke:none"
d="m 322.44096,115.15749 -1e-5,-12.40159 44.29134,0 0,-70.866126 3.5433,0 0,70.866126 31.88977,0 0,12.40159 z"
id="path3184"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
<g
transform="translate(-313.58266,-93.897598)"
id="g9413">
......@@ -1094,12 +1069,12 @@
<text
sodipodi:linespacing="125%"
id="text3172"
y="24.803162"
y="111.61418"
x="324.21259"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px;font-style:italic;font-weight:bold"
y="24.803162"
y="111.61418"
x="324.21259"
id="tspan3174"
sodipodi:role="line">SYSMON_RD_WB</tspan></text>
......
......@@ -9,8 +9,8 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="337.11417"
height="183.06703"
width="338.63583"
height="164.87885"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
......@@ -24,11 +24,11 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="205.23085"
inkscape:cy="131.97009"
inkscape:zoom="5.6"
inkscape:cx="231.34573"
inkscape:cy="135.10427"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:current-layer="g4154"
showgrid="true"
inkscape:window-width="1855"
inkscape:window-height="1176"
......@@ -50,8 +50,8 @@
units="mm"
spacingx="0.5mm"
spacingy="0.5mm"
originx="-29.929444mm"
originy="-240.83441mm" />
originx="-29.5mm"
originy="-240.96753mm" />
</sodipodi:namedview>
<metadata
id="metadata7">
......@@ -69,7 +69,7 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-101.21472,920.63478)">
transform="translate(-99.693069,902.91827)">
<path
style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 110.32299,-885.20174 8.85827,0 0,35.43307 -8.85827,0 0,-35.43307 -8.85827,0 0,35.43307 8.85827,0"
......@@ -736,7 +736,7 @@
y="125.78734"
x="347.24408"
height="65.551178"
width="154.13388"
width="155.9055"
id="rect3339"
style="fill:#000000;fill-opacity:0.1;fill-rule:evenodd;stroke:none" />
<text
......@@ -752,27 +752,6 @@
id="tspan4111"
sodipodi:role="line">SYSMON_WB_ADR</tspan></text>
</g>
<g
id="g8006">
<path
style="fill:#000000;fill-opacity:0.3;stroke:none"
d="m 283.94504,-920.63478 -1e-5,14.17323 58.46458,0 0,69.09447 5.31496,0 0,-69.09447 28.34645,0 0,-14.17323 z"
id="path7225"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="330.00803"
y="-910.00488"
id="text4115"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4117"
x="330.00803"
y="-910.00488"
style="font-size:8px;font-style:italic;font-weight:bold;text-align:center;text-anchor:middle">SIM_WB_TRANSFER</tspan></text>
</g>
<g
id="g8201">
<path
......
......@@ -301,10 +301,9 @@ shown in Table~\ref{tbl:cmds}.
\hline
writereg \textit{slot addr val} & Writes the \textit{hex} value \textit{val} to hex address
\textit{addr} of board in slot number \textit{slot} \\
writemregs \textit{slot addr v1 .. v8} & This command is similar to the \textit{writereg}
command, but it allows writing up to eight different values
to the same Wishbone register. The values are given in hexadecimal
format and are separated by spaces \\
writemregs \textit{slot addr v1 .. v8} & Similar to the \textit{writereg} command, but allows writing up to
eight different values to the same Wishbone register. The values
are given in hexadecimal format and are separated by spaces \\
readreg \textit{slot addr} & Returns the value of register at hex address \textit{addr} of
board in slot number \textit{slot} \\
\hline
......@@ -333,7 +332,7 @@ As Figure~\ref{fig:writemregs} shows, the data words are sent in little-endian o
word 0 is sent first, followed by word 1 and so forth, until word 7.
\begin{figure}[h]
\centerline{\includegraphics[scale=.55]{fig/fsm}}
\centerline{\includegraphics[width=\textwidth]{fig/fsm}}
\caption{Main FSM of \textit{wb\_i2c\_bridge} module}
\label{fig:fsm}
\end{figure}
......@@ -341,7 +340,6 @@ word 0 is sent first, followed by word 1 and so forth, until word 7.
%==============================================================================
% SEC: Implem
%==============================================================================
\pagebreak
\section{Implementation}
\label{sec:implem}
......@@ -367,11 +365,7 @@ is writing and the \textit{wb\_i2c\_bridge} is reading.
IDLE & Wait for the \textit{gc\_i2c\_slave} module to receive the I$^2$C
address and go to \textit{WB\_ADR} \\
WB\_ADR & Shift in the two address bytes sent via I$^2$C and go to
\textit{SIM\_WB\_TRANSF} \\
SIM\_WB\_TRANSF & Start a Wishbone read transfer from address received in previous
state and go to \textit{OPER} if Wishbone address exists (Wishbone
\textit{ack} received), or \textit{IDLE} otherwise (Wishbone \textit{err}
received) \\
\textit{OPER} \\
OPER & Check the \textit{op\_o} output of the \textit{gc\_i2c\_slave} module.
If '1', go to \textit{SYSMON\_RD\_WB} state (SysMon is reading from
\textit{wb\_i2c\_bridge}), otherwise continue shifting in bytes (SysMon
......@@ -379,8 +373,10 @@ is writing and the \textit{wb\_i2c\_bridge} is reading.
SYSMON\_WR & Continue reading up to four bytes sent by the SysMon and go to
\textit{SYSMON\_WR\_WB}\\
SYSMON\_WR\_WB & Perform a Wishbone write transfer to the register with the address obtained in
\textit{WB\_ADR} \\
SYSMON\_RD\_WB & Perform a Wishbone read transfer from the address obtained in
\textit{WB\_ADR}. If the transfer is successful, go back to \textit{SYSMON\_WR}
to continue receiving register data (useful for the \textit{writemregs} command
-- see Section~\ref{sec:elma-prot-cmds}) \\
SYSMON\_RD\_WB & Perform a Wishbone read transfer from the address obtained in
\textit{WB\_ADR} and go to \textit{SYSMON\_RD} \\
SYSMON\_RD & Shift out the four bytes of the Wishbone register when the \textit{gc\_i2c\_slave}
module successfully finishes a write \\
......@@ -396,15 +392,10 @@ during reads and writes from the SysMon.
When the SysMon writes (Figure~\ref{fig:sysmon-wr-fsm}), the
\textit{wb\_i2c\_bridge} module waits in the \textit{IDLE} state until
the I$^2$C address is received, then, while in the \textit{WB\_ADR} state,
it shifts in the Wishbone address. A Wishbone simulation transfer is performed
from the received address. The simulation transfer is in fact a read transfer
from the address, but the data received from the register is not used in any way.
The purpose of this transfer is only to see if the received address exists, indicated
by a Wishbone \textit{ack} being received as a result of this transfer. If this
\textit{ack} is received, the first byte is shifted in while in the \textit{OPER}
state, followed by the next three bytes while in the \textit{SYSMON\_WR} state. The
register is written to in the \textit{SYSMON\_WR\_WB} state using a Wishbone write
transfer.
it shifts in the Wishbone address. The first byte of the write transfer is shifted
in while in the \textit{OPER} state, followed by the next three bytes while in the
\textit{SYSMON\_WR} state. The register is written to in the \textit{SYSMON\_WR\_WB}
state using a Wishbone write transfer.
To allow for the \textit{writemregs} command, whereby up to eight registers can be
written with one I$^2$C transfer, the FSM goes back to the \textit{SYSMON\_WR} state
......@@ -413,7 +404,7 @@ if the Wishbone write transfer completed successfully. The FSM will go back into
the SysMon after the \textit{writereg} or \textit{writemregs} has been completed.
\begin{figure}[h]
\centerline{\includegraphics[width=\textwidth]{fig/sysmon-wr-fsm}}
\centerline{\includegraphics[width=.8\textwidth]{fig/sysmon-wr-fsm}}
\caption{FSM states when the SysMon writes to the \textit{wb\_i2c\_bridge}}
\label{fig:sysmon-wr-fsm}
\end{figure}
......@@ -424,15 +415,17 @@ the SysMon after the \textit{writereg} or \textit{writemregs} has been completed
\label{fig:sysmon-rd-fsm}
\end{figure}
When the SysMon reads (Figure~\ref{fig:sysmon-rd-fsm}), the first few
steps are the same as for a write. The address is shifted in and checked in the
Wishbone transfer simulation state. In the case of a SysMon reading from a board,
When the SysMon reads (Figure~\ref{fig:sysmon-rd-fsm}), the address is shifted in
as in the case of a write. In the case of a SysMon reading from a board,
however, the I$^2$C transfer is restarted and the order is reversed (SysMon starts
reading). Thus, while in \textit{OPER}, the FSM detects a high value on \textit{op\_o}
corresponding to an I$^2$C read transfer, and goes into the \textit{SYSMON\_RD\_WB}
state. The value of the register is read while in this state, and sent via I$^2$C
in the \textit{SYSMON\_RD} state.
Note that on an error in any Wishbone transfer, the FSM goes back to the \textit{IDLE}
state, setting the \textit{err\_p\_o} output for one \textit{clk\_i} cycle.
The design also contains an FSM watchdog component, which resets the main FSM
in case of errors in communication. The watchdog timeout value is configured
via the \textit{g\_wdt\_max} generic and can be calculated as outlined in
......@@ -455,9 +448,9 @@ on the Spartan-6 XC6SLX45T are shown in Table~\ref{tbl:synth-res}.
\hline
\multicolumn{1}{c}{\textbf{Resource}} & \textbf{Used} & \textbf{Available} & \textbf{\%} \\
\hline
Slices & 76 & 6822 & 1.1 \\
Slice registers & 172 & 54576 & 0.3 \\
LUTs & 151 & 27288 & 0.6 \\
Slices & 94 & 6822 & 1.3 \\
Slice registers & 168 & 54576 & 0.3 \\
LUTs & 188 & 27288 & 0.6 \\
\hline
\end{tabular}
}
......
......@@ -126,7 +126,6 @@ architecture behav of gc_i2c_slave is
(
IDLE, -- idle
ADDR, -- shift in I2C address bits
ADDR_CHECK, -- check received I2C address
ADDR_ACK, -- ACK/NACK to I2C address
RD, -- shift in byte to read
RD_ACK, -- ACK/NACK to received byte
......@@ -282,7 +281,7 @@ begin
rxsr <= (others => '0');
txsr <= (others => '0');
mst_acked <= '0';
sda_en_o <= '0';
sda_en_o <= '0';
r_done_p_o <= '0';
w_done_p_o <= '0';
addr_good_p_o <= '0';
......@@ -323,31 +322,30 @@ begin
bit_cnt <= bit_cnt + 1;
end if;
--
-- Checking the bit counter is done on the falling edge of SCL
--
-- If 8 bits have been shifted in, the received address is checked
-- and the slave goes in the ADDR_ACK state.
--
-- If the address is not ours, go back to IDLE and set inhibit bits
-- so bytes sent to or received from another slave that happen to
-- coincide to the address of this slave don't get interpreted
-- as accesses to this slave.
--
if (scl_f_edge_p = '1') then
-- If we've shifted in 8 bits, go to ADDR_CHECK
if (bit_cnt = 0) then
state <= ADDR_CHECK;
if (rxsr(7 downto 1) = i2c_addr_i) then
op_o <= rxsr(0);
addr_good_p_o <= '1';
state <= ADDR_ACK;
else
inhibit <= '1';
state <= IDLE;
end if;
end if;
end if;
---------------------------------------------------------------------
-- ADDR_CHECK
---------------------------------------------------------------------
when ADDR_CHECK =>
-- if the address is ours, set the OP output and go to ACK state
if (rxsr(7 downto 1) = i2c_addr_i) then
op_o <= rxsr(0);
addr_good_p_o <= '1';
state <= ADDR_ACK;
-- if the address is not ours, the FSM should be inhibited so a
-- byte sent to another slave doesn't get interpreted as this
-- slave's address
else
inhibit <= '1';
state <= IDLE;
end if;
---------------------------------------------------------------------
-- ADDR_ACK
---------------------------------------------------------------------
......@@ -355,13 +353,18 @@ begin
-- clear addr_good pulse
addr_good_p_o <= '0';
-- send ACK from input and go start reading or writing based on OP
-- send ACK from input, check the ACK on falling edge and go to
-- loading of the TXSR if the OP bit is a write, or read otherwise
sda_en_o <= ack_i;
if (scl_f_edge_p = '1') then
if (rxsr(0) = '0') then
state <= RD;
if (ack_i = '1') then
if (rxsr(0) = '0') then
state <= RD;
else
state <= WR_LOAD_TXSR;
end if;
else
state <= WR_LOAD_TXSR;
state <= IDLE;
end if;
end if;
......
......@@ -114,7 +114,6 @@ architecture behav of wb_i2c_bridge is
(
IDLE, -- idle state
SYSMON_WB_ADR, -- get the WB register address
SIM_WB_TRANSF, -- simulate a WB transfer with the received address
OPER, -- operation to perform on the WB register
SYSMON_RD_WB, -- perform a WB read transfer, for sending word to the SysMon
SYSMON_RD, -- send the word to the SysMon during read transfer
......@@ -274,36 +273,12 @@ begin
when SYSMON_WB_ADR =>
if (slv_r_done_p = '1') then
wb_adr <= wb_adr(7 downto 0) & rx_byte;
slv_ack <= '1';
adr_byte_cnt <= adr_byte_cnt + 1;
if (adr_byte_cnt = 1) then
state <= SIM_WB_TRANSF;
state <= OPER;
end if;
end if;
---------------------------------------------------------------------
-- SIM_WB_TRANSF
---------------------------------------------------------------------
-- Simulate a Wishbone transfer with the received address and go
-- to operation state if we get a WB ACK, or back to idle if we get
-- a WB error. In the latter case, an NACK is sent to the SysMon.
---------------------------------------------------------------------
when SIM_WB_TRANSF =>
wb_cyc <= '1';
wb_stb <= '1';
if (wb_ack = '1') then
slv_ack <= '1';
wb_cyc <= '0';
wb_stb <= '0';
state <= OPER;
elsif (wb_err = '1') then
err_p_o <= '1';
slv_ack <= '0';
wb_cyc <= '0';
wb_stb <= '0';
state <= IDLE;
end if;
---------------------------------------------------------------------
-- OPER
---------------------------------------------------------------------
......@@ -324,11 +299,9 @@ begin
if (slv_r_done_p = '1') then
wb_dat_out <= rx_byte & wb_dat_out(31 downto 8);
dat_byte_cnt <= dat_byte_cnt + 1;
slv_ack <= '1';
state <= SYSMON_WR;
elsif (slv_addr_good_p = '1') and (op = '1') then
slv_ack <= '1';
state <= SYSMON_RD_WB;
state <= SYSMON_RD_WB;
end if;
---------------------------------------------------------------------
......@@ -342,12 +315,9 @@ begin
if (slv_r_done_p = '1') then
wb_dat_out <= rx_byte & wb_dat_out(31 downto 8);
dat_byte_cnt <= dat_byte_cnt + 1;
slv_ack <= '1';
if (dat_byte_cnt = 3) then
state <= SYSMON_WR_WB;
state <= SYSMON_WR_WB;
end if;
-- elsif (slv_sto_p = '1') then
-- state <= IDLE;
end if;
---------------------------------------------------------------------
......@@ -360,11 +330,11 @@ begin
wb_cyc <= '1';
wb_stb <= '1';
wb_we <= '1';
if (wb_ack = '1') then -- or (wb_err = '1') then
if (wb_ack = '1') then
wb_cyc <= '0';
wb_stb <= '0';
wb_we <= '0';
state <= SYSMON_WR; --IDLE;
state <= SYSMON_WR;
elsif (wb_err = '1') then
err_p_o <= '1';
state <= IDLE;
......@@ -402,12 +372,9 @@ begin
if (slv_w_done_p = '1') then
wb_dat_in <= x"00" & wb_dat_in(31 downto 8);
dat_byte_cnt <= dat_byte_cnt + 1;
slv_ack <= '1';
if (dat_byte_cnt = 3) then
state <= IDLE;
end if;
-- elsif (slv_sto_p = '1') then
-- state <= IDLE;
end if;
---------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment