Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21602 Discussions

verilog test code issue

Altera_Forum
Honored Contributor II
1,458 Views

file://localhost/C:/Documents%20and%20Settings/aabelian/Desktop/altera_sim.JPG Hi to all, 

 

This is my first post. sorry if any thing I am doing wrong. 

I am new to verilog but I am long time C user. I tried my first code today. 

Using simulator I see delay on output side and clk pulse doesn't work. 

I am having hard time to understand what am I doing wrong. 

any help will appreciate. 

 

thanks 

 

Andre 

 

module led_test(sw1,led1,clk); 

input sw1; 

output led1; 

output clk; 

 

reg led1,led2,clk; 

 

//  

initial 

begin 

led1 <= 0; 

end 

 

 

 

always@(sw1 ) 

begin 

# 500 clk = ~clk; 

end  

 

 

 

always@(sw1 ) 

begin 

 

if(sw1 == 1) 

led1 <= 1; 

else  

led1 <= 0; 

 

end 

 

endmodule
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
732 Views

No,i suggest you try to understand what verilog is really created for.If you want to create a verilog file for synthesis,do not use initial or such sentence.If you want to write a testbench,refer to the books,and you'll see how you should implement this.

0 Kudos
Altera_Forum
Honored Contributor II
732 Views

I am reading and I am trying to understand.  

Do you know the reason? 

 

thanks 

 

Andre
0 Kudos
Altera_Forum
Honored Contributor II
732 Views

sorry to say you don't understand the difference between code for synthesis and code for testbench,so don't try to write one before you really understand!

0 Kudos
Altera_Forum
Honored Contributor II
732 Views

This is your second replay with crap. Stop replaying I do not need your feedback. 

 

thanks
0 Kudos
Altera_Forum
Honored Contributor II
732 Views

OK,crap,you don't even want to refer to a book,I promise no one will reply to your question!

0 Kudos
Altera_Forum
Honored Contributor II
732 Views

Look, 

 

sorry I was in bad mood. do not want to help? that's fine. 

I can't wait to see how much do you know about HDL and I will 

remind you one day when you ask a question? 

 

thanks
0 Kudos
Reply