- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Im using a EPM3064ATC CPLD. My design has 8 switches and two leds. If a button is pressed, then a led should be on. I already tested different variants of code but had no sucess. Attached my code:
module TestSwitch (clk, Switch, Led);
input clk;
input Switch;
output Led;
assign Led = (Switch != 0 ); // switch led on if a button is pressed
assign Led = (Switch | Switch); // same
end
I already tested alll switches by the command:
assign Led = Switch;
This design works well with my hardware. So the pin assignment should be ok. I also tried another version with a Block diagram / schematics file using an or8. Same effect. Thank you for your help! Andreas
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is really weird.. try to register the switch and check at each posedge clk (it should work even w/o registering)
Maybe your led or your button is broken? Try to use signal tap and see if those signals are right, also double check your pin assignment- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello aprado
Thank you for your help. It isreally frustrating ans as you say weird:) I also tested with registering but no success:
module TestSwitch (clk, Switch, Led); input clk; input Switch; output Led;
reg Keys;
@always @(Switch) Keys = Switch;
assign Led = (Keys | Keys); // does not work assign Led = Keys; // that works end
Both Leds and all keys are ok as i can control the leds by every key using statement e.g.: assign Led[1] = Switch[1]; assign Led[1] = Switch[2]; assign Led[1] = Switch[3]; ... It seems that signal tap is not supported for this device. Friendly regards Andreas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try to do like this
input switch;
input clk;
output reg led;
always@(posedge clk)
begin
if(switch)
led <= 1;
else led <=0;
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also check the logic levels your switches/leds are using. Often switches have pullups and pulls the signal to GND when pressed. The led could also be connected between VCC and the FPGA output - i.e. ligth when the output is 0. If this is the case you would see the behaviour you describe since you have implemented two "or" functions. Negating all inputs and outputs gives and "and" function instead. Easily tested by pushing all switches - your leds should ligth then.
Regards, Ove Brynestad- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Solved, thank you very much for your fast help:):)!!!
Ovs' hint helped!!!!!! Switches and Leds are acitve low. Andreas Now, it's time for a coffe
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page