

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


High-level behavioral model of master controller – updated to utilize I^2 C interface High-level behavioral model of memory – updated to utilize I^2 C interface Structural model connecting controller and memory (this is provided in TOP_CIRCUIT.v) Testbench to verify functionality
Additional ECE 574A Requirements Extend master controller to perform I^2 C write operation after determining num_value, writing back num_value into the last memory location (addr = 31) Extend memory module to handle I^2 C write function
Submit your project using electronic turnin, class_account_name is “ece474a”, assignment_name is “proj3”
You are provided with a 32x8 memory module with inputs clk, en, rw, and addr, and a bi-directional signal data. When en=0, the memory is inactive and outputs “Z” on the data bus. When input en=1 and rw=1, the memory module performs a read operation outputting mem[addr] unto the data bus. When en=1 and rw=0, the memory module performs an write operation storing the value provided on the data bus to location mem[addr].
In addition to the memory module a high-level behavior description of COUNT_VALUE is provided. The COUNT_VALUE circuit has inputs rst, clk, and start, output values en, rw, addr, busy, and num_value, and a bi-directional signal data. When start=1, the master controller accesses each memory location (how to access memory is described above) to determine how many entries in the memory are equal to five. While the master controller is scanning the memory, the busy flag is set high. The busy flag will remain high until the master controller has finished scanning the entire memory and outputs the number of entries equal to five on output num_value. In this implementation the master module has a parallel interface to the memory, meaning the controller can transmit the address on a 5-bit bus and read data values from an 8-bit bus. Figure 1(a) provides a block diagram of ORIG_CIRUCIT which connects the memory to COUNT_VALUE.
You are encouraged to download the sample system and get an idea of how this circuit interfaces to memory. Questions regarding the original design will be answered until March 7th. Why? To ensure everyone at least looks at the code before the project is due. Questions
2
Modify the Verilog code provided (or create your own code) to implement the block diagram shown in Figure 1(b). The updated circuit maintains the same overall functionality, but communicates with the memory over an I^2 C bus. Note that while the functionality will remain the same, the timing will differ. Instead of a parallel interface you will now communicate serially over a 2-bit bus interface. An overview of the I^2 C protocol is provided below. You are welcomed to utilize any of the code provided in the sample system. You will however have to change the interface to the memory and controller. Check the course page for skeletal code outlining how TOP_CIRCUIT, MASTER_CONTROL, and MEM are connected.
Figure 1: Block diagram of (a) original parallel memory access circuit ORIG_CIRCUIT and (b) modified I^2 C memory access circuit TOP_CIRCUIT.
(a) (b)
rst clk start
SDA SCL
Master Control
32 x 8 Memory
I 2 C Bus Interface TOP_CIRCUIT
rst clk start
busy num_value 6
Count_ Value
32 x 8 Memory
ORIG_CIRCUIT
busy num_value
en rw
6
addr data 8
5
ECE 574A Extension: After the MASTER_CONTORL outputs the number of memory entries equal to five on num_value, the MASTER_CONTROL module will then perform the following write operation MEM[31] = num_value. Although MEM[31] contains the number of entries equal to five, do not forget to include this entry when scanning the memory.
I
2 C Bus Interface Overview
The I^2 C bus is a simple bi-directional 2-wire bus. All I^2 C compatible devices incorporate an on-chip interface which enables them to communicate directly with any other I^2 C compatible device connected to the bus. By utilizing the I^2 C bus, we can interface with a multitude of devices without having to create a custom interface with each device. The bus interface is broken up into four main bus conditions: START, STOP, DATA (transmit/receive byte), and ACK (acknowledge).
The I2C bus consists of 2 wires (ground connection is omitted), SDA and SCL. Both the SDA (Serial DAta line) and the SCL (Serial CLock line) are bi-directional. Every device on the bus has its own unique address. Each of these devices can act as a receiver and/or transmitter, depending on the functionality of a given device. While the I^2 C bus can be a multi-master bus, in our example we consider only a single master, the master control module.
To communicate over the bus, the master device sends a START condition. This gets the attention of all peripherals on the bus to listen for incoming data. Next, the master device sends the address of the device (DATA condition) it wants to communicate with, also indicating whether the master device wants to read or write to a peripheral device. All the peripheral devices will read the address and compare this address to its own. If a peripheral determines its address was send, the peripheral will send an acknowledge (ACK condition) on the bus. Once the master device receives the ACK, the master device will start sending or receiving data (DATA condition). When finished, the master device sends the STOP condition on the bus. This condition relinquishes control over the bus (in the case of a multi- master bus) and indicates to other peripherals to potentially expect another transmission to start.
The START condition, shown in Figure 2(a), first sets SCL high. Next a high-to-low transition is performed on SDA. The STOP condition, also shown in Figure 2(a), sets SCL high, and followed by a low-to-high transition on SDA. The START and STOP conditions are always generated by the master device.
Figure 2(b) illustrates the data transfer protocol or DATA condition. The first byte transmitted on the I 2 C bus after the START condition is a 7-bit device address. The device address identifies which peripheral device the master device wants to communicate with. The 8th bit (RW) within the byte also indicates the communication mode, i.e. whether the master device wants to read data (RW=1) from a peripheral device or write data (RW=0) to the peripheral device. Every byte put on the SDA line must be 8-bits long and followed by a 1-bit acknowledge. The number of bytes transmitted is unrestricted. Data is transmitted with the most significant bit (MSB) first. The SCL line is always controlled by the master device. The SDA line can be controlled by either the master device or peripheral device depending on the type of data transfer (read or write) being performed.
Figure 3 illustrates the acknowledge protocol or ACK condition. The SCL pulse during the ACK is controlled by the master device. The ACK on the SDA line is generated by the receiver. For example, if the master device is reading from a peripheral, the master device will pulse the SCL for the ACK and set the SDA low (in some instances no acknowledge is provided – this depends on what the peripheral device expects). Alternatively, if the master device is writing to a peripheral, the master device will pulse the SCL for the ACK, but the peripheral device will set the SDA wire high.
NOTE: SCL is not necessarily equal to the system clock. The purpose of SCL is to simply synchronize the master and peripheral modules, where each pulse of SCL indicates the beginning of a new bit.
Figure 2: (a) START and STOP Conditions and (b) Transfer of data on the I^2 C bus (DATA)
Figure 3: Acknowledge on the I^2 C bus (ACK).
(a) (b)
START condition
STOP condition
S P
SDA
SCL
SDA
SCL
START condition
S P
SDA
SCL
STOP condition
ADDRESS R/W’ ACK DATA ACK
1-7 8 9 1-7 8 9
START condition
S
DATA OUTPUT BY RECEIVER
DATA OUTPUT BY TRANSMITTER
SCL FROM MASTER^1 28
clock pulse for acknowledgement
no acknowledge
acknowledge