Hardware Reference
In-Depth Information
Figure 14.20
FSM for the SPI FRAM interface.
and rst are from switches). The outputs are the SPI signals ( SSn , SCK , MOSI , and MISO
the last one is in fact an input), connected to the slave, plus ssd1 and ssd2 , which feed
two SSD displays to exhibit the data retrieved from the FRAM. A frequency of 5 MHz
is used for spi_clk (as mentioned, this device can operate at up to 20 MHz). The i gure
also shows how the device was wired.
A detailed FSM for this problem is presented in
i gure 14.20 (employing mode 0).
The data-write sequence is in the upper branch, while the data-read sequence is in the
lower branch. MOSI = x (7
i ) in some of the states is just a symbolic way of saying that
vector x , with eight bits, starting with the MSB, must be transmitted. Note that this
is a category 2 (timed) machine, so the timers (here represented by i and j ) run from
0 to i max and 0 to j max .
In this experiment a total of eight bytes are written into the FRAM, starting at
address zero; note that state wr_data lasts from { i = 0, j = 0} up to { i = 7, j = 7}, hence
transmitting eight bytes, corresponding to x (0)(7:0) up to x (7)(7:0). A test circuit is
also included, which reads all eight bytes from the FRAM and displays them sequen-
tially onto the two SSDs; note the arrow and box associated with state rd_data , inform-
ing that data must be recorded (from the MISO wire) while the FSM is in that state.
The FSM of i gure 14.20 can be implemented with a category 2 or category 3
machine (the former is employed in the VHDL code below). It is also simple enough
to be implemented using the pointer-based technique described in chapter 15 (see
section 15.5).
VHDL Code
A complete VHDL code for the FSM of i gure 14.20 is presented below, following the
template for timed (category 2) machines introduced in chapter 9.
Initially, a function called hex_to_ssd , to convert hexadecimal values into SSD values
(display driver), was built in a separate package (called my_functions ), then called in
the main code (lines 217-218) to make the corresponding conversions.
Search WWH ::




Custom Search