Laboratory 4 Design a Muti-bit Counter Background A. Approach I: Design 3-bit counter with and clear T-type flip-flop is shown in Figure 1. A T flip-flop is obtained from a JK flip-flop by tying the J and K inputs together to form the T input. Figure 1 Truth Table Inputs Outputs CLRN (clr) T clock Q 1 1 Toggle 1 0 X No change 0 X X 0 Figure 2 shows BDF design for three-bit counter by using three T-type flip-flops Figure 2
Figure 3 is the simulation result. Check the relation among clock, Q0, Q1, and Q2 (set clr as high, en is high). For your simulation, you should consider clr as high and low, en as high and low, and observe the outputs of Q0, Q1, and Q2. Figure 3 Q 2Q 1Q 0: 000 001 010 011 100 101 110 111 000001 B. Design 3-bit counter with and VHDL design for three-bit counter (Figure 4) with and. three_bit_counter inst Figure 4 Step 1. Start the Quartus II software. Select File New Project Wizard. And create a new project name under the directory C:\temp\your initial \Lab. Assign the project name counter3, assign Cyclone II for the device family, and select the EP2C35F672C6 chip in the Family & device settings, which is the FPGA used on Altera s DE2 board.
Figure 5 Step 2. Open a new VHDL Device Design file (File > New) by highlighting VHDL File. And click OK. Type the VHDL code Step 3. Save the VHDL file (Figure 5) as three_bit_counter.vhd as part of our project under your subfolder. Place a check mark in the space labeled Add file to current project and press Save Step 4. Select File Create/Update Create Symbol Files for Current File (three_bit_counter.bsf symbol) to create a symbol file for the VHDL code entered. A Compilation Report window initially displays Report not available ; however, be patient. A display window should soon appear stating that the Create Symbol File was (or not) successful. Click OK and close the Compilation Report window. Step 5. Open a new Schematic file (File > New) by highlighting Block Diagram/Schematic File. And click OK. Find the symbol file (bsf file you just created for VHDL in Step 4) from Project folder to support your design in BDF view. Insert the symbol and input/output pins three_bit_counter inst OUTPUT Figure 6 Step 6. Before compiling this bdf file, we need to name this bdf file and save it as part of our project under your subfolder. Choose File > Save As and enter File name as counter3. Place a check mark in the space labeled Add file to current project and press Save. Step 7. create a Vector Waveform File (vwf) to simulate a design(bdf) file. Set an end time 30 µs for simulation from Edit and then run simulation based on Figure 3. You may have to expand the size of the
Simulation Waveforms to suit your need and choose View > Fit in Window to see the entire 30µs waveform. Figure 7 is the simulation result. Check the relation among clock,,, count_out[0], count_out[1], count_out[2]. Integrated the decoder with 3-bit counter Step 1. design a decode in vhdl (Figure 8) Figure 7 Figure 8 Step 2. Save the VHDL file as dec7seg.vhd as part of our project under your subfolder. Place a check mark in the space labeled Add file to current project and press Save Step 3. Select File Create/Update Create Symbol Files for Current File (dec7seg.bsf symbol) to create a symbol file for the VHDL code entered.
Step 4. Open a new Schematic file (File > New) by highlighting Block Diagram/Schematic File. And click OK. Find the symbol file (bsf file you created for VHDL) from Project folder to support your design in BDF view. Insert the symbol and input/output pins three_bit_counter dec7seg inst dec[2..0] inst1 display[0..6] OUTPUT display[0..6] Figure 9 Step 5. Before compiling this bdf file, we need to name this bdf file and save it as part of our project under your subfolder. Choose File > Save As and enter File name as counter3. Place a check mark in the space labeled Add file to current project and press Save. Step 6. Compile this integrated design (Figure 9) Step 7. You can make a pin configuration, compile your design, and download your design to FPGA board to test your digital system. Step 8. Use the pushbutton KEY0 as the Clock input, switches SW1 and SW0 as Enable and Reset inputs, and 7-segment displays HEX0 to display the hexadecimal count as your circuit operates. Project: Your Turn to Design 4-bit counter 1. Write a VHDL file or create a BDF file that defines a 4-bit counter by using the structure depicted in bdf (Figure 2) or vhdl(figure 5), and compile the circuit. What is the frequency relation between the clock and four outputs from four T-type flip-flops, respectively? 2. Create a waveform vector and simulate your circuit to verify its correctness of the design of 4-bit counter. 3. Is this counter counting up or counting down? 4. Augment your VHDL file or BDF file to use the pushbutton KEY0 as the Clock input, switches SW1 and SW0 as Enable and Reset inputs, and 7-segment displays HEX0 to display the hexadecimal count as your circuit operates. 5. Make the necessary pin assignments and compile the circuit. 6. Programming FPGA and test your implementation. You may use the following library in your VHDL design entry: LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; your code 8-bit counter design 7. Write a VHDL file or create a BDF file that defines a 8-bit counter by reusing the component of 4-bit counter, and compile the circuit. What is the frequency relation between the clock and all 12 outputs of Q namely Q 0, Q 1, Q 2, Q 3, Q 4, Q 5, Q 6, Q 7? 8. Create a waveform vector and simulate your circuit to verify its correctness of the design of 8-bit counter. 9. Augment your VHDL file to use the pushbutton KEY0 as the Clock input, switches SW1 and SW0 as Enable and Reset inputs, and 7-segment displays HEX2, HEX1, HEX0 (or LCD) to display the hexadecimal count as your circuit operates.
10. Make the necessary pin assignments and compile the circuit. 11. Programming FPGA and test your implementation.