I'm studying verilog and trying to apply the concepts in my fpga. It supossed to work in this way : When Switch 1 is on, all red leds turn on. When Switch 2 is on, all green leds turn on. When Switch 3 is on, all leds turn on. The problem is when I put it in my fpga switch . Could someone tell me why? Here's my code :
module LED (
input CLOCK_50,
input [17:0] SW,
output reg [17:0] LEDR,
output reg [9:0] LEDG
);
always@(posedge(CLOCK_50))
begin
case(SW[0])
0:
LEDR = 0;
1:
LEDR = ~LEDR;
endcase
case(SW[1])
0:
LEDG = 0;
1:
LEDG = ~LEDG;
endcase
case(SW[2])
0:
begin
LEDR = 0;
LEDG = 0;
end
1:
begin
LEDR = ~LEDR;
LEDG = ~LEDG;
end
endcase
end
endmodule
<=) instead of blocking assignments (=) when assigning values in edge-triggeredalwaysblocks.LEDR = ~LEDR;will result with blinking diodes (with frequency equals to clock frequency)~LEDRin each posedge clk you toggle the value. Then the led is 50% on and 50% off and you only can see low intensity because our eyes can see htis fecuency