Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

verilog test code issue

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

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I am reading and I am trying to understand.

    Do you know the reason?

    thanks

    Andre
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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!

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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