You may not choose the PWM controller for Lab 7.
The PWM controller handles the low-level details of creating a PWM (Pulse Width Modulation) signal. The PWM controller is implemented in pwm.v. PWM generates a digital signal that approximates an analog output, by modulating the digital signal with a specified duty cycle. The analog signal that is generated is the digital high voltage value times the fraction of time the signal is high. For example, a digital signal that is on for 60% of the time will look like a 3V signal.
pwm_command and pwm_response implement the standard I/O protocol. The command parameters are pwm_compare and pwm_period. There are no response parameters.
The PWM controller creates a periodic signal that is high for pwm_high clock ticks out of a total period of pwm_period clock ticks (each clock tick is 10 ns). E.g., to create a signal that with an 80% duty cycle and a period of 100 ns, set pwm_high to 8 and pwm_period to 10.
You will connect the PWM controller to an external device using the General
Purpose I/O (GPIO) pins on the DE2-115 board. top.v uses GPIO
(pin 3 in the figure below) to send the PWM signal. Also note that pin 11
is 5V, pin 29 is 3.3V and pins 12 and 30 are ground.
You can power a servo directly from your board by plugging the black wire into GND (pin 12), and the red wire into 5V (pin 11). You should then connect the yellow wire to your PWM output (GPIO, pin 3). To move this servo, use a period of 20 ms and set the high portion to 0.7-2.3 ms, which corresponds to about 0-180 degrees on these servos.
To use a motor, you'll need to use an H-Bridge, such as the ST L298. To move a motor in one direction, connect GND (pin 12 and pin 30) to the ground pin on your H-Bridge, and connect this to the CSA pin on your H-bridge. Then connect 3.3V (pin 29) to the VLS (Logic Voltage) on your H-Bridge. Connect Out1 and Out2 on your H-Bridge to the 2 different wires of your motor. Connect the VS (Supply Voltage) pin on your H-Bridge to some voltage supply (for small motors, you can just use the 5V (pin 11) supply from the FPGA).
The remaining pins on the H-Bridge are EN, IN1, and IN2. EN dictates whether the H-Bridge allows current to flow, so think of it as an on/off switch. Connect EN to the PWM output (GPIO, pin 3). IN1 and IN2 change the direction of the motor. If they are the same, then the motor will be put into a fast-stop state. While they are different they will go in a certain direction, if you invert them from that position, they will go in the opposite direction. So if you just wanted your motor to move in one direction, you could wire IN1 directly to VLS and IN2 to ground.
ase100 ignores PWM commands, so you will need to use the DE2-115 to test any project that uses PWM.