Altera_Forum
Honored Contributor
16 years agoLED/Debouncing problems
Hello All,
I am trying to test LED/debouncing logic for basic gates. Following is my code module ledtesting ( input clock, input A, input B, output C, output D, output E, output F ); reg [60:0] count; wire slowclock; reg [3:0] debounce1; reg [3:0] debounce2; reg out1; reg out2; assign C = (out1 & out2); assign D = (out1 | out2); assign E = ~(out1 & out2); assign F = ~(out1 | out2); always @ (posedge slowclock) begin debounce1 <= debounce1 << 1; debounce1[0] <= A; out1 <= debounce1 == 4'hf ? 1'b1 : 1'b0; debounce2 <= debounce2 << 1; debounce2[0] <= B; out2 <= debounce2 == 4'hf ? 1'b1 : 1'b0; end always @(posedge clock) count = count + 1'b1; assign slowclock = count[24]; endmodule The problem is that my leds (C, D, E, F) are not functioning correctly. Basically AND, OR logic are switched, NAND, NOR logic are switched. Can anybody tell me what might be the problem. I copied this code from a website, could reset be the problem? The pin assignment is correct, i have checked it about 10-15 times. Thanks a bunch for your help NEO