FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-13-2009, 03:19 PM
jay
Guest
 
Posts: n/a
Default An incomplete Mux and Latch?

Hello,

I have an ASIC design using internal tri-state multi-sources buses
like below:
assign tbus = a_en ? a : Hiz;
assign tbus = b_en ? b : Hiz;

When implementing to FPGA, I found I can't strobe the right data from
the bus. After analyze the code, I think it's because the strobe
signal comes later than the enable signals for each source. For a real
tri-state bus, the value can still float on the bus so the ASIC can
work.

For the FPGA, I think I need convert the bus using latch to contain
the value when the enable signal has gone, so I designed the code like
below:
always @(*)
begin
if (a_en)
tbus <= a;
else if (b_en)
tbus <= b;
end

However the circuit doesn't work as I expected, I examined the
synthesis result, looks like my code is translated to a mux and a
latch like below:
assign temp = a_en ? a : b;
always @(*)
if (a_en | b_en)
tbus <= temp;

It seems Verilog doesn't accept an incomplete Mux, so b is set as
default.

Can anyone gives me some advise?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-13-2009, 03:45 PM
Gabor
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 9:19*am, jay <heavenf...@gmail.com> wrote:
> Hello,
>
> I have an ASIC design using internal tri-state multi-sources buses
> like below:
> assign tbus = a_en ? a : Hiz;
> assign tbus = b_en ? b : Hiz;
>
> When implementing to FPGA, I found I can't strobe the right data from
> the bus. After analyze the code, I think it's because the strobe
> signal comes later than the enable signals for each source. For a real
> tri-state bus, the value can still float on the bus so the ASIC can
> work.
>
> For the FPGA, I think I need convert the bus using latch to contain
> the value when the enable signal has gone, so I designed the code like
> below:
> always @(*)
> begin
> * if (a_en)
> * * tbus <= a;
> * else if (b_en)
> * * tbus <= b;
> end
>
> However the circuit doesn't work as I expected, I examined the
> synthesis result, looks like my code is translated to a mux and a
> latch like below:
> assign temp = a_en ? a : b;
> always @(*)
> * if (a_en | b_en)
> * * tbus <= temp;
>
> It seems Verilog doesn't accept an incomplete Mux, so b is set as
> default.
>
> Can anyone gives me some advise?
>
> Thanks


The problem is using a_en as both the mux select and the latch
gate doesn't give any hold time when latching the A input.
You may want to recode it using a S/R latch for the mux select
to meet the hold time after a_en. As you have started to
discover, FPGA's are not great at asynchronous sequential logic.
At least they do contain gated latches, and you should check the
synthesis results to be sure the latch is in use rather than
trying to use LUT's as latch gate elements. Which FPGA family
are you using?

Regards,
Gabor
Reply With Quote
  #3 (permalink)  
Old 11-13-2009, 03:58 PM
johnp
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 6:19*am, jay <heavenf...@gmail.com> wrote:
> Hello,
>
> I have an ASIC design using internal tri-state multi-sources buses
> like below:
> assign tbus = a_en ? a : Hiz;
> assign tbus = b_en ? b : Hiz;
>
> When implementing to FPGA, I found I can't strobe the right data from
> the bus. After analyze the code, I think it's because the strobe
> signal comes later than the enable signals for each source. For a real
> tri-state bus, the value can still float on the bus so the ASIC can
> work.
>
> For the FPGA, I think I need convert the bus using latch to contain
> the value when the enable signal has gone, so I designed the code like
> below:
> always @(*)
> begin
> * if (a_en)
> * * tbus <= a;
> * else if (b_en)
> * * tbus <= b;
> end
>
> However the circuit doesn't work as I expected, I examined the
> synthesis result, looks like my code is translated to a mux and a
> latch like below:
> assign temp = a_en ? a : b;
> always @(*)
> * if (a_en | b_en)
> * * tbus <= temp;
>
> It seems Verilog doesn't accept an incomplete Mux, so b is set as
> default.
>
> Can anyone gives me some advise?
>
> Thanks


What is your setup/hold of the data and the enables? You may need to
code this as
latches followed by a mux and not a mux followed by a latch.

always @(*)
if (a_en | (a & a_hold)
a_hold = a;

always @(*)
if (b_en | (b & b_hold)
b_hold = b;

assign t_bus = a_en ? a_hold : b_hold;

Make sure that the synthesizer infers the latches properly, you may
need to use the simpler:
always @(&)
if (b_en)
b_hold = b;

Adding the extra term in the "if" solves a race condition when the
latch enable is removed and you're
making the latch out of discrete gates. This is probably not needed
since the latch inferred by synthesis
should alreay take care of this.

I hope this helps!

John Providenza
Reply With Quote
  #4 (permalink)  
Old 11-13-2009, 05:00 PM
jay
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 10:45*pm, Gabor <ga...@alacron.com> wrote:
> On Nov 13, 9:19*am, jay <heavenf...@gmail.com> wrote:
>
>
>
> > Hello,

>
> > I have an ASIC design using internal tri-state multi-sources buses
> > like below:
> > assign tbus = a_en ? a : Hiz;
> > assign tbus = b_en ? b : Hiz;

>
> > When implementing to FPGA, I found I can't strobe the right data from
> > the bus. After analyze the code, I think it's because the strobe
> > signal comes later than the enable signals for each source. For a real
> > tri-state bus, the value can still float on the bus so the ASIC can
> > work.

>
> > For the FPGA, I think I need convert the bus using latch to contain
> > the value when the enable signal has gone, so I designed the code like
> > below:
> > always @(*)
> > begin
> > * if (a_en)
> > * * tbus <= a;
> > * else if (b_en)
> > * * tbus <= b;
> > end

>
> > However the circuit doesn't work as I expected, I examined the
> > synthesis result, looks like my code is translated to a mux and a
> > latch like below:
> > assign temp = a_en ? a : b;
> > always @(*)
> > * if (a_en | b_en)
> > * * tbus <= temp;

>
> > It seems Verilog doesn't accept an incomplete Mux, so b is set as
> > default.

>
> > Can anyone gives me some advise?

>
> > Thanks

>
> The problem is using a_en as both the mux select and the latch
> gate doesn't give any hold time when latching the A input.
> You may want to recode it using a S/R latch for the mux select
> to meet the hold time after a_en. *As you have started to
> discover, FPGA's are not great at asynchronous sequential logic.
> At least they do contain gated latches, and you should check the
> synthesis results to be sure the latch is in use rather than
> trying to use LUT's as latch gate elements. *Which FPGA family
> are you using?
>
> Regards,
> Gabor


Good idea, S/R latch should work if I only had two enables, but
there's more in my design. I think I need a state machine.

I'm using spartan-3a, it has d-latch resources, probably no sr-latch.
Reply With Quote
  #5 (permalink)  
Old 11-13-2009, 05:34 PM
jay
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 10:58*pm, johnp <jprovide...@yahoo.com> wrote:
> On Nov 13, 6:19*am, jay <heavenf...@gmail.com> wrote:
>
>
>
> > Hello,

>
> > I have an ASIC design using internal tri-state multi-sources buses
> > like below:
> > assign tbus = a_en ? a : Hiz;
> > assign tbus = b_en ? b : Hiz;

>
> > When implementing to FPGA, I found I can't strobe the right data from
> > the bus. After analyze the code, I think it's because the strobe
> > signal comes later than the enable signals for each source. For a real
> > tri-state bus, the value can still float on the bus so the ASIC can
> > work.

>
> > For the FPGA, I think I need convert the bus using latch to contain
> > the value when the enable signal has gone, so I designed the code like
> > below:
> > always @(*)
> > begin
> > * if (a_en)
> > * * tbus <= a;
> > * else if (b_en)
> > * * tbus <= b;
> > end

>
> > However the circuit doesn't work as I expected, I examined the
> > synthesis result, looks like my code is translated to a mux and a
> > latch like below:
> > assign temp = a_en ? a : b;
> > always @(*)
> > * if (a_en | b_en)
> > * * tbus <= temp;

>
> > It seems Verilog doesn't accept an incomplete Mux, so b is set as
> > default.

>
> > Can anyone gives me some advise?

>
> > Thanks

>
> What is your setup/hold of the data and the enables? *You may need to
> code this as
> latches followed by a mux and not a mux followed by a latch.
>
> always @(*)
> * if (a_en | (a & a_hold)
> * * *a_hold = a;
>
> always @(*)
> * if (b_en | (b & b_hold)
> * * b_hold = b;
>
> assign t_bus = a_en ? a_hold : b_hold;
>
> Make sure that the synthesizer infers the latches properly, you may
> need to use the simpler:
> * always @(&)
> * * *if (b_en)
> * * * * *b_hold = b;
>
> Adding the extra term in the "if" solves a race condition when the
> latch enable is removed and you're
> making the latch out of discrete gates. *This is probably not needed
> since the latch inferred by synthesis
> should alreay take care of this.
>
> I hope this helps!
>
> John Providenza


I haven't seen "always @(&)" before, a new syntax?
Reply With Quote
  #6 (permalink)  
Old 11-13-2009, 05:50 PM
Gabor
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 11:00*am, jay <heavenf...@gmail.com> wrote:
> On Nov 13, 10:45*pm, Gabor <ga...@alacron.com> wrote:
>
>
>
> > On Nov 13, 9:19*am, jay <heavenf...@gmail.com> wrote:

>
> > > Hello,

>
> > > I have an ASIC design using internal tri-state multi-sources buses
> > > like below:
> > > assign tbus = a_en ? a : Hiz;
> > > assign tbus = b_en ? b : Hiz;

>
> > > When implementing to FPGA, I found I can't strobe the right data from
> > > the bus. After analyze the code, I think it's because the strobe
> > > signal comes later than the enable signals for each source. For a real
> > > tri-state bus, the value can still float on the bus so the ASIC can
> > > work.

>
> > > For the FPGA, I think I need convert the bus using latch to contain
> > > the value when the enable signal has gone, so I designed the code like
> > > below:
> > > always @(*)
> > > begin
> > > * if (a_en)
> > > * * tbus <= a;
> > > * else if (b_en)
> > > * * tbus <= b;
> > > end

>
> > > However the circuit doesn't work as I expected, I examined the
> > > synthesis result, looks like my code is translated to a mux and a
> > > latch like below:
> > > assign temp = a_en ? a : b;
> > > always @(*)
> > > * if (a_en | b_en)
> > > * * tbus <= temp;

>
> > > It seems Verilog doesn't accept an incomplete Mux, so b is set as
> > > default.

>
> > > Can anyone gives me some advise?

>
> > > Thanks

>
> > The problem is using a_en as both the mux select and the latch
> > gate doesn't give any hold time when latching the A input.
> > You may want to recode it using a S/R latch for the mux select
> > to meet the hold time after a_en. *As you have started to
> > discover, FPGA's are not great at asynchronous sequential logic.
> > At least they do contain gated latches, and you should check the
> > synthesis results to be sure the latch is in use rather than
> > trying to use LUT's as latch gate elements. *Which FPGA family
> > are you using?

>
> > Regards,
> > Gabor

>
> Good idea, S/R latch should work if I only had two enables, but
> there's more in my design. I think I need a state machine.
>
> I'm using spartan-3a, it has d-latch resources, probably no sr-latch.


Actually there are flip-flops with async preset and clear. If you tie
off the clock and D it becomes an SR latch.

Regards,
Gabor
Reply With Quote
  #7 (permalink)  
Old 11-13-2009, 08:45 PM
johnp
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

On Nov 13, 8:34*am, jay <heavenf...@gmail.com> wrote:
> On Nov 13, 10:58*pm, johnp <jprovide...@yahoo.com> wrote:
>
>
>
> > On Nov 13, 6:19*am, jay <heavenf...@gmail.com> wrote:

>
> > > Hello,

>
> > > I have an ASIC design using internal tri-state multi-sources buses
> > > like below:
> > > assign tbus = a_en ? a : Hiz;
> > > assign tbus = b_en ? b : Hiz;

>
> > > When implementing to FPGA, I found I can't strobe the right data from
> > > the bus. After analyze the code, I think it's because the strobe
> > > signal comes later than the enable signals for each source. For a real
> > > tri-state bus, the value can still float on the bus so the ASIC can
> > > work.

>
> > > For the FPGA, I think I need convert the bus using latch to contain
> > > the value when the enable signal has gone, so I designed the code like
> > > below:
> > > always @(*)
> > > begin
> > > * if (a_en)
> > > * * tbus <= a;
> > > * else if (b_en)
> > > * * tbus <= b;
> > > end

>
> > > However the circuit doesn't work as I expected, I examined the
> > > synthesis result, looks like my code is translated to a mux and a
> > > latch like below:
> > > assign temp = a_en ? a : b;
> > > always @(*)
> > > * if (a_en | b_en)
> > > * * tbus <= temp;

>
> > > It seems Verilog doesn't accept an incomplete Mux, so b is set as
> > > default.

>
> > > Can anyone gives me some advise?

>
> > > Thanks

>
> > What is your setup/hold of the data and the enables? *You may need to
> > code this as
> > latches followed by a mux and not a mux followed by a latch.

>
> > always @(*)
> > * if (a_en | (a & a_hold)
> > * * *a_hold = a;

>
> > always @(*)
> > * if (b_en | (b & b_hold)
> > * * b_hold = b;

>
> > assign t_bus = a_en ? a_hold : b_hold;

>
> > Make sure that the synthesizer infers the latches properly, you may
> > need to use the simpler:
> > * always @(&)
> > * * *if (b_en)
> > * * * * *b_hold = b;

>
> > Adding the extra term in the "if" solves a race condition when the
> > latch enable is removed and you're
> > making the latch out of discrete gates. *This is probably not needed
> > since the latch inferred by synthesis
> > should alreay take care of this.

>
> > I hope this helps!

>
> > John Providenza

>
> I haven't seen "always @(&)" before, a new syntax?


No, a typo. It should have been always @(*)

John P
Reply With Quote
  #8 (permalink)  
Old 11-14-2009, 09:32 AM
maurizio.tranchero
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

When I had to implement tri-state buffers onto FPGAs I've always
used FPGA-specific gates, e.g., "tri" buffers on Altera. I could
suggest you to look at the logic family you are using, probably
they have a solution for your issue.

Regards,
m
Reply With Quote
  #9 (permalink)  
Old 11-14-2009, 04:02 PM
Ralf Hildebrandt
Guest
 
Posts: n/a
Default Re: An incomplete Mux and Latch?

Am 13.11.2009 15:19, schrieb jay:

> always @(*)
> begin
> if (a_en)
> tbus <= a;
> else if (b_en)
> tbus <= b;
> end


This is a muxed latch. The latch-enable and the mux-selector are driven
by the same signal.

> assign temp = a_en ? a : b;
> always @(*)
> if (a_en | b_en)
> tbus <= temp;


You exactly have pointed out the problem with this alternative
description. Nevertheless it does not solve the problem.

To be more precise: Let's say a_en==1'b1 then signal a is selected and
the latch is open. Now with the falling edge of a_en the mux may change
it's output value AND the latch becomes inactive. No one can say witch
one is faster. A hold time violation is the result in simulation and
unpredictable results are the result in hardware.

Don't use muxed latches! Don't do it in ASICS or in FPGAs.
Find a new signal that drives the mux-selector!

Ralf
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xilinx XST 9.2i.01 - still incomplete support for always @* Xilinx User FPGA 3 07-20-2007 05:41 PM
Xilinx XST 9.2i.01 - still incomplete support for always @* Xilinx User Verilog 3 07-20-2007 05:41 PM
Synthesis of 'task' statement with incomplete conditions dmitriym Verilog 10 03-06-2007 01:05 AM
Incomplete Data Analysis Statistica Sinica DSP 0 11-06-2006 04:57 PM
Is it incomplete sensitivity list ? Mohammed A khader VHDL 7 03-03-2005 01:41 AM


All times are GMT +1. The time now is 03:09 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved