Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `timescale 1ns / 1ps
- //////////////////////////////////////////////////////////////////////////////////
- // upgineer: Bryan Orabutt
- //
- // Create Date: 18:07:32 12/31/2014
- // Design Name: Prototype 1
- // Module Name: LED_counter1
- // Project Name: LED Cube Project
- // Target Devices: XCSLX9
- // Tool versions: ISE Web Pack 14.7
- // Description: This prototype module uses two counters to continuously blink each LED
- //
- // Dependupcies:
- //
- // Revision:
- // Revision 0.01 - File Created
- // Additional Commupts:
- //
- //////////////////////////////////////////////////////////////////////////////////
- module LED_counter(
- input clk,
- output reg[1:0] level,
- output reg[3:0] column
- );
- reg [3:0] counter1 = 4'b0000;
- reg [1:0] counter2 = 2'b00;
- wire c1_max = (counter1 == 4'b1000); //the number of columns in my cube
- wire c2_max = (counter2 == 2'b10); //the number of levels in my cube
- /* Counter to cycle through each column, powering one cloumn with each count
- * and resetting the count when c1_max is a logic high.
- */
- always @ (posedge clk) begin
- if(c1_max)
- counter1 <= 4'b0;
- else
- counter1 <= counter1 + 1;
- end
- /* Counter to cycle through each level, powering the base pin of a single 2N222
- * which causes one level to be connected to GND. Combining this with the column
- * counter means one level + one column is active at a time, meaning one LED is on.
- */
- always @ (posedge clk) begin
- if(c2_max && c1_max)
- counter2 <= 2'b00;
- else if(c1_max)
- counter2 <= counter2 + 1;
- end
- /* Connect the counter values to the output.
- */
- always @ (posedge clk) begin
- column <= counter1;
- level <= counter2;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement