fpga4fun.com Forum Index fpga4fun.com
where FPGAs are fun
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

need help on verilog syntax

 
Post new topic   Reply to topic    fpga4fun.com Forum Index -> Verilog HDL
View previous topic :: View next topic  
Author Message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Sat Jun 19, 2010 9:09 pm    Post subject: need help on verilog syntax Reply with quote

Hi all,

How can I convert this piece of verilog description:
Code:

always @(posedge clk) if (&addr) run <= 1'b0; else if (start) run <= 1'b1;


to VHDL:

Code:

process (clk):
begin
  if (rising_edge(clk)) then
    if (????) then
      run <= '0';
    elsif (start = '1') then
      run <= '1';
    end if;
  end if;
end process;


The problem lies in the following expression:
(&addr)

Can someone help me to convert this expression?

Thank you in advance

Thoma
Back to top
View user's profile Send private message
tkbits



Joined: 02 Aug 2004
Posts: 114

PostPosted: Sat Jun 26, 2010 4:51 am    Post subject: Reply with quote

If addr is a bit vector, &addr ANDs all the bits.

I found this site:

http://www.sutherland-hdl.com/online_verilog_ref_guide/vlog_ref_top.html

If addr is 8 bits, use:

if addr = "11111111" then ...

If not, adjust the number of ones in the constant.
Back to top
View user's profile Send private message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Sat Jun 26, 2010 6:35 am    Post subject: Reply with quote

Hi tkbits,

Thanks for your help

So, as addr is a std_logic_vector(5 downto 0), it should be compared to "111111".

Code:
process (clk):
begin
  if (rising_edge(clk)) then
    if (addr = "111111") then
      run <= '0';
    elsif (start = '1') then
      run <= '1';
    end if;
  end if;
end process;


Thoma
Back to top
View user's profile Send private message
fredra



Joined: 28 Jul 2010
Posts: 5

PostPosted: Wed Jul 28, 2010 3:25 am    Post subject: need help in verilog Reply with quote

how i can write this verilog line in vhdl?

CRC <= CRCinit ? ~0 : ({CRC[30:0],1'b0} ^ ({32{CRCinput}} & 32'h04C11DB7));
Back to top
View user's profile Send private message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Wed Jul 28, 2010 5:24 pm    Post subject: Reply with quote

Hi fredra,

I would say:

if (CRCinit = 1) then
CRC <= x"FFFFFFFF"
else
CRC <= (CRC(30 downto 0) & '0') xor (CRCinput and x"04C11DB7");
end if;

if it is used in a process.

Thoma
Back to top
View user's profile Send private message
fredra



Joined: 28 Jul 2010
Posts: 5

PostPosted: Wed Jul 28, 2010 8:48 pm    Post subject: thank you Reply with quote

thank you i will try it
Back to top
View user's profile Send private message
fredra



Joined: 28 Jul 2010
Posts: 5

PostPosted: Wed Jul 28, 2010 9:06 pm    Post subject: Reply with quote

i try it and still have problem with

{32{CRCinput}}
because this one is 32 bit
and we have to xor it with 32'h04C11DB7
Back to top
View user's profile Send private message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Thu Jul 29, 2010 4:54 am    Post subject: Reply with quote

Fredra,

Could you provide the signal definition for CRCinput?

Thoma
Back to top
View user's profile Send private message
fredra



Joined: 28 Jul 2010
Posts: 5

PostPosted: Thu Jul 29, 2010 11:40 am    Post subject: Reply with quote

hello Thoma HAUC
i took this from fpga4fun and i'm trying to do it in vhdl

// generate the CRC32
reg [31:0] CRC;
reg CRCflush; always @(posedge clk20) if(CRCflush) CRCflush <= SendingPacket; else if(readram) CRCflush <= (rdaddress==7'h44);
reg CRCinit; always @(posedge clk20) if(readram) CRCinit <= (rdaddress==7);

wire CRCinput = CRCflush ? 0 : (ShiftData[0] ^ CRC[31]);

always @(posedge clk20) if(ShiftCount[0]) CRC <= CRCinit ? ~0 : ({CRC[30:0],1'b0} ^ ({32{CRCinput}} & 32'h04C11DB7));
Back to top
View user's profile Send private message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Thu Jul 29, 2010 7:56 pm    Post subject: Reply with quote

Fredra,

You can try this.

if (CRCinit = 1) then
CRC <= x"FFFFFFFF"
else
CRC <= (CRC(30 downto 0) & '0') xor ((x"0000000" & "000" & CRCinput) and x"04C11DB7");
end if;

Thoma
Back to top
View user's profile Send private message
fredra



Joined: 28 Jul 2010
Posts: 5

PostPosted: Fri Jul 30, 2010 11:25 pm    Post subject: Reply with quote

hello Thoma HAUC
if you don't mind i'm trying to convert this one to vhdl :

parameter IPsource_1 = 192;
parameter IPsource_2 = 168;
parameter IPsource_3 = 0;
parameter IPsource_4 = 44;

// "IP destination" - put the IP of the PC you want to send to
parameter IPdestination_1 = 192;
parameter IPdestination_2 = 168;
parameter IPdestination_3 = 0;
parameter IPdestination_4 = 2;

// "Physical Address" - put the address of the PC you want to send to
parameter PhysicalAddress_1 = 8'h00;
parameter PhysicalAddress_2 = 8'h07;
parameter PhysicalAddress_3 = 8'h95;
parameter PhysicalAddress_4 = 8'h0B;
parameter PhysicalAddress_5 = 8'hFB;
parameter PhysicalAddress_6 = 8'hAF;

parameter IPchecksum1 = 32'h0000C53F + (IPsource_1<<Cool+IPsource_2+(IPsource_3<<Cool+IPsource_4+
(IPdestination_1<<Cool+IPdestination_2+(IPdestination_3<<Cool+(IPdestination_4);
parameter IPchecksum2 = ((IPchecksum1&32'h0000FFFF)+(IPchecksum1>>16));
parameter IPchecksum3 = ~((IPchecksum2&32'h0000FFFF)+(IPchecksum2>>16));

thank you for your time
Back to top
View user's profile Send private message
Thoma HAUC



Joined: 26 Aug 2004
Posts: 50
Location: Near Paris, France

PostPosted: Sun Aug 01, 2010 6:33 pm    Post subject: Reply with quote

Hi Fredra,

I can take time to check your VHDL but has not enough time to convert all your Verilog.

Thoma
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    fpga4fun.com Forum Index -> Verilog HDL All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group