VHDL switch model

  • Permalink
  • submit to reddit
  • Email
  • Follow


I was considering what it will take to implement a bi-directional
switch in VHDL and found this by Peter Ashenden.  The method is pretty
much what I had thought of, but it does have one problem where a high
impedance on either side of the switch will not be conveyed to the
other once the bus has been set to a 1 or 0 state.  In essence, this
is not really a switch, but rather a bus keeper.

  function weaken ( value : in std_logic ) return std_logic is
    type lookup_array is array (std_logic) of std_logic;
    constant lookup_weaker_value : lookup_array
      := ('U'=>'U', 'X'=>'W', '0'=>'L', '1'=>'H', 'Z'=>'Z',
          'L'=>'L', 'H'=>'H', 'W'=>'W', '-'=>'-');
  begin
    return lookup_weaker_value(value);
  end function weaken;

Then we define the switch model along the following lines:

  process (x, y, switch_on) is
  begin
    if switch_on then
      x <= weaken(y) after 250 ps;
      y <= weaken(x) after 250 ps;
    else
      x <= 'Z' after 250 ps;
      y <= 'Z' after 250 ps;
    end if;
  end process;

It occurred to me that the model could take advantage of the delay
spec and allow the "uncertainty" in delay of real devices to introduce
a difference in timing which could allow a Z to stabilize.

  process (x, y, switch_on) is
    variable old_x, old_y : std_logic;
  begin
    if switch_on then
      if (x = old_x) then
        x <= 'Z', weaken(y) after 250 ps;
      else
        x <= 'Z';
      end if;
      old_x := x;
      if (x = 'Z') then
      elsif (y = old_y) then
        y <= 'Z', weaken(x) after 250 ps;
      else
        y <= 'Z';
      end if;
      old_y := y;
    else
      x <= 'Z';
      y <= 'Z';
    end if;
  end process;

By assigning a Z with no delay and assigning everything else with an
initial Z and a delay, I believe there will be an initial glitch and a
final state of Z when neither bus is driven.  Since the behavior in
the propagation delay time is essentially an undefined state, I don't
think the intermediate Z state is any real problem.

I haven't simulated this.  Any idea if I am off base here?

Rick
0
Reply rickman 5/27/2008 8:37:00 PM

See related articles to this posting

On May 27, 4:37=A0pm, rickman <gnu...@gmail.com> wrote:
> I was considering what it will take to implement a bi-directional
> switch in VHDL and found this by Peter Ashenden. =A0The method is pretty
> much what I had thought of,
>
> I haven't simulated this. =A0Any idea if I am off base here?
>

Another example you might want to look at is Ben Cohen's zero ohm
resistor model.

http://www.google.com/search?hl=3Den&rlz=3D1G1GGLQ_ENUS278&q=3D%22Ben+Cohen%=
22+Zohm0_ea.vhd

KJ
0
Reply KJ 5/28/2008 11:55:07 AM


On May 28, 7:55 am, KJ <kkjenni...@sbcglobal.net> wrote:
> On May 27, 4:37 pm, rickman <gnu...@gmail.com> wrote:
>
> > I was considering what it will take to implement a bi-directional
> > switch in VHDL and found this by Peter Ashenden.  The method is pretty
> > much what I had thought of,
>
> > I haven't simulated this.  Any idea if I am off base here?
>
> Another example you might want to look at is Ben Cohen's zero ohm
> resistor model.
>
> http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS278&q=%22Ben+Cohen...
>
> KJ

Yes, that is perfect.  I had the right idea, but using the after
clause did not quite cut it.  The assignment needs to be repeated
*after* the delta wait.

Thanks,

Rick
0
Reply rickman 5/28/2008 1:38:38 PM

On May 28, 7:55 am, KJ <kkjenni...@sbcglobal.net> wrote:
> On May 27, 4:37 pm, rickman <gnu...@gmail.com> wrote:
>
> > I was considering what it will take to implement a bi-directional
> > switch in VHDL and found this by Peter Ashenden.  The method is pretty
> > much what I had thought of,
>
> > I haven't simulated this.  Any idea if I am off base here?
>
> Another example you might want to look at is Ben Cohen's zero ohm
> resistor model.
>
> http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS278&q=%22Ben+Cohen...
>
> KJ

I may have replied too soon.  I'm not sure his resistor even works.
If A and B have different values, the model will drive each bus with a
'Z' initially.  Then after a delta delay each bus will be driven with
the state of the other.  This will put an 'X' on each bus.  This
triggers the process again and the model drives a 'Z' again.  Now the
value of the bus returns to the values driven by the A and B drivers
and the process repeats.  It looks to me like it will infinite loop
oscillating, just advancing delta times and never advance in real
time.

Again, a simulation is worth a thousand code reviews.

Rick
0
Reply rickman 5/28/2008 1:44:24 PM

On May 28, 9:44=A0am, rickman <gnu...@gmail.com> wrote:
> On May 28, 7:55 am, KJ <kkjenni...@sbcglobal.net> wrote:
>
> > On May 27, 4:37 pm, rickman <gnu...@gmail.com> wrote:
>
> > > I was considering what it will take to implement a bi-directional
> > > switch in VHDL and found this by Peter Ashenden. =A0The method is pret=
ty
> > > much what I had thought of,
>
> > > I haven't simulated this. =A0Any idea if I am off base here?
>
> > Another example you might want to look at is Ben Cohen's zero ohm
> > resistor model.
>
> >http://www.google.com/search?hl=3Den&rlz=3D1G1GGLQ_ENUS278&q=3D%22Ben+Coh=
en...
>
> > KJ
>
> I may have replied too soon. =A0I'm not sure his resistor even works.
> If A and B have different values, the model will drive each bus with a
> 'Z' initially. =A0Then after a delta delay each bus will be driven with
> the state of the other. =A0This will put an 'X' on each bus. =A0This
> triggers the process again and the model drives a 'Z' again. =A0Now the
> value of the bus returns to the values driven by the A and B drivers
> and the process repeats. =A0It looks to me like it will infinite loop
> oscillating, just advancing delta times and never advance in real
> time.
>
> Again, a simulation is worth a thousand code reviews.
>

I've used Ben's model and it 'works', but only under specific sets of
conditions whether they apply to your case or not I don't know.  I'll
also say that I haven't run across a model for a resistor that works
under all configurations that you would use a resistor in, I'm
guessing that the bi-directional switch that you're working on might
be just as difficult.

Some typical resistor configuration and the problems that might occur:
- Series termination.  Output can't go to 'Z' even for a delta cycle
on any sort of 'clock' signal or the 'rising_edge()' VHDL function
will fail.
- Pullup and down termination (i.e. 220/330 typical).  You need to
ignore the larger valued resistor.
- Differential termination (i.e. 100 ohm across a pair).  You need to
totally ignore the resistor.

As a result I came up with a handful of different resistor models and
used a VHDL configuration to select the appropriate one to use.  The
PCBA model was generated by a CAD system which makes the model very
accurate but then not really directly editable since it would get
overwritten every time the schematic was updated.

Kevin Jennings
0
Reply KJ 5/28/2008 2:22:45 PM

rickman schrieb:

> I was considering what it will take to implement a bi-directional
> switch in VHDL and found this by Peter Ashenden.  The method is pretty
> much what I had thought of, but it does have one problem where a high
> impedance on either side of the switch will not be conveyed to the
> other once the bus has been set to a 1 or 0 state.  In essence, this
> is not really a switch, but rather a bus keeper.


Here is my solution:
<http://www.ralf-hildebrandt.de/publication/transfergate/transfergate.vhd>
<http://www.ralf-hildebrandt.de/publication/transfergate/tbench_transfergate.vhd>

Ralf
0
Reply Ralf 5/28/2008 2:25:44 PM

On May 28, 10:25 am, Ralf Hildebrandt <Ralf-Hildebra...@gmx.de> wrote:
> rickman schrieb:
>
> > I was considering what it will take to implement a bi-directional
> > switch in VHDL and found this by Peter Ashenden.  The method is pretty
> > much what I had thought of, but it does have one problem where a high
> > impedance on either side of the switch will not be conveyed to the
> > other once the bus has been set to a 1 or 0 state.  In essence, this
> > is not really a switch, but rather a bus keeper.
>
> Here is my solution:
> <http://www.ralf-hildebrandt.de/publication/transfergate/transfergate.vhd>
> <http://www.ralf-hildebrandt.de/publication/transfergate/tbench_transf...>
>
> Ralf

I had taken another look at Ben's code and found something I don't
understand.  I see the same thing in your code.  Maybe I have
forgotten something, but I thought a process had to either have a
sensitivity list, contain a loop or it would only be run once.  Both
your code and Ben's have no sensitivity list and no loop.  What am I
missing here?

0
Reply rickman 5/28/2008 4:58:29 PM

"rickman" <gnuarm@gmail.com> wrote in message 
news:b0860289-99bb-4a45-a0cd-87e84935e868@p25g2000hsf.googlegroups.com...
> On May 28, 10:25 am, Ralf Hildebrandt <Ralf-Hildebra...@gmx.de> wrote:
>> rickman schrieb:
>>
>
> I had taken another look at Ben's code and found something I don't
> understand.  I see the same thing in your code.  Maybe I have
> forgotten something, but I thought a process had to either have a
> sensitivity list, contain a loop or it would only be run once.  Both
> your code and Ben's have no sensitivity list and no loop.  What am I
> missing here?
>

A loop is not required.  A process must contain either a sensitivity list or 
a wait statement.  All processes automatically 'restart' when they exit, the 
only wait to have something run once is with an unconditional 'wait;' at 
some point.

KJ 


0
Reply KJ 5/28/2008 8:18:44 PM

On May 28, 4:18 pm, "KJ" <kkjenni...@sbcglobal.net> wrote:
> "rickman" <gnu...@gmail.com> wrote in message
>
> news:b0860289-99bb-4a45-a0cd-87e84935e868@p25g2000hsf.googlegroups.com...
>
> > On May 28, 10:25 am, Ralf Hildebrandt <Ralf-Hildebra...@gmx.de> wrote:
> >> rickman schrieb:
>
> > I had taken another look at Ben's code and found something I don't
> > understand.  I see the same thing in your code.  Maybe I have
> > forgotten something, but I thought a process had to either have a
> > sensitivity list, contain a loop or it would only be run once.  Both
> > your code and Ben's have no sensitivity list and no loop.  What am I
> > missing here?
>
> A loop is not required.  A process must contain either a sensitivity list or
> a wait statement.  All processes automatically 'restart' when they exit, the
> only wait to have something run once is with an unconditional 'wait;' at
> some point.
>
> KJ

Is having this statement at the beginning of the process equivalent to
using a sensitivity list (without the "until" part)?

wait on wireA'transaction, wireB'transaction, sel'transaction until
last/=now;

I am not clear on the purpose of the "until" portion.  It looks to me
like it makes the process continue as soon as the "real" time
increments.  Is that right?  Having this run on every increment of
time seems pretty inefficient.

Does this "glitch" the bus on the delta cycles?  I mean will a
simulator display continuous transitions on these signals because of
the change from driving 'Z' vs. the other bus?

I need to fire up the simulator, but I don't have time right now.  But
then again, I need to use this, so maybe I don't have a choice.

Rick
0
Reply rickman 5/29/2008 12:34:39 AM

rickman schrieb:

> Is having this statement at the beginning of the process equivalent to
> using a sensitivity list (without the "until" part)?

Without the until-part: yes.


> wait on wireA'transaction, wireB'transaction, sel'transaction until
> last/=now;
> 
> I am not clear on the purpose of the "until" portion.  It looks to me
> like it makes the process continue as soon as the "real" time
> increments.  Is that right?  Having this run on every increment of
> time seems pretty inefficient.

The process is stopped as long as the wait-condition is not met. Then it 
is run if last/=now. This makes simulation time acceptable.

I used this transfer gate to model an analog switch matrix outside of 
the ASIC for testbench purpose. The ASIC controls the switches and the 
testbench simulates the behavior of the other components on a PCB (the 
analog switches).

> Does this "glitch" the bus on the delta cycles?  I mean will a
> simulator display continuous transitions on these signals because of
> the change from driving 'Z' vs. the other bus?

Every time the transfer gate "fires" it generates a new event - even if 
the signal value does not change.


Ralf
0
Reply Ralf 5/29/2008 4:17:43 PM

Other examples of switches can be found at www.FreeModelFoundry.com in
the STNDS library.  They too are imperfect but may illustrate another
approach to a problem that VHDL is not good at.

Rick

Ralf Hildebrandt wrote:
> rickman schrieb:
> 
>> I was considering what it will take to implement a bi-directional
>> switch in VHDL and found this by Peter Ashenden.  The method is pretty
>> much what I had thought of, but it does have one problem where a high
>> impedance on either side of the switch will not be conveyed to the
>> other once the bus has been set to a 1 or 0 state.  In essence, this
>> is not really a switch, but rather a bus keeper.
> 
> 
> Here is my solution:
> <http://www.ralf-hildebrandt.de/publication/transfergate/transfergate.vhd>
> <http://www.ralf-hildebrandt.de/publication/transfergate/tbench_transfergate.vhd>
> 
> 
> Ralf
0
Reply Rick 6/1/2008 1:25:01 AM
comp.lang.vhdl 6168 articles. 13 followers. Post

10 Replies
143 Views

Similar Articles

[PageSpeed] 15


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

VHDL switch model #2
Dear All, I have modified Ben Cohen's switch model code (http://members.aol.com/vhdlcohen/vhdl/vhdlcode/switch1.vhd) to handle multiple transactions occuring in delta times. Could you please comment on this, are there any problems with the following code? Best regards, GWJ ---------------------------------------------------------------------------- -- Copyright (c) 1997, Ben Cohen. All rights reserved. -- This model can be used in conjunction with the Kluwer Academic book -- "VHDL Coding Styles and Methodologies", ISBN: 0-7923-9598-0 -- "VHDL Amswers to Frequently Asked ...

Looking for a Verilog or VHDL RAM Model(or FIFO) that models RAM Faults.
Dear Gentle Persons, Does anyone know where I could get a Verilog or VHDL RAM Model that models common RAM Faults like Stuck At Faults on the Address, Data Lines, Stuck Ram Cells, Coupling faults Etc? I would also be interested in Verilog or VHDL implementation of a March SS RAM Test, or any March type RAM Test. Robert Posey check in actel's web site. `timescale 1 ns/100 ps // Behavioral description of FIFO with: // active high write enable // active high read enable // active low asynchronous clear // rising edge clock // active high full flag // active low emp...

Switching between two models
Good People: Hi, I have a program that runs two models for different data sets. The first model, that is preferred over second one, does not converge sometimes, because number of cases is less than enough. Instead I switch to the second model that does not have such a problem up to a point (when sample size is very low, the second model does not converge also). When the second model does not converge I do not want to go further. Running these models for different data sets I have hard time in checking each model one by one to see which is good for an especial file. So, my question is: I...

How to model a buffer in VHDL
Hi Im trying to model a buffer in VHDL but am unable to do so... I have a signal A and I want to generate a signal B which is nothing but A delayed by 2 seconds. i.e B <= A after 2 ns; But the above way does not work as I do not see anything on B. When A (widht of A) is high for 1ns , then B is 0 but if I increase the width of A to 3ns then I am able to see B with a delay of 2 ns Please suggest some way This is because of the default ineretial delay of vhdl.To see your required behaviour replace the inertial delay with transport delay. b<= transport a after 20 ns; Thanks, Abila...

Markov Switching Models
How to run Markov Switching Models in SAS Thanks & Regards, Priyanka Hi, Are you refering to markov chains? ------Original Message------ From: priyanka singh Sender: SAS(r) Discussion To: SAS-L@LISTSERV.UGA.EDU ReplyTo: priyanka singh Subject: Markov Switching Models Sent: Jan 22, 2010 7:57 PM How to run Markov Switching Models in SAS Thanks & Regards, Priyanka Sent from my BlackBerry Wireless Handheld -- Regards, Murphy Choy Certified Advanced Programmer for SAS V9 Certified Basic Programmer for SAS V9 for the simplest markov switching ...

modelling a FIFO in VHDL
I am trying to send data via RS 232 to a spartan 3 development board that has external SRAM. I want to send data to the RXD input of the FPGA and have the FPGA send this to the SRAM. This is a simplex transmission from my PC to the FPGA that is listening. Is there any models I can see or use maybe for doing this kind of a UART, FIFO in VHDL ? I assume that you have heard of the google search engine,well I suggest you give that a try because i did and it worked for me. ...

VHDL into a simulink model
Hi all, Does someone know a way for transforming VHDL code into a Simulink model ? I'm familiar with the Simulink HDL coder, but this tool can transform only in the opposite direction ... Tomer Gidony wrote: > Hi all, > > Does someone know a way for transforming VHDL code into a Simulink > model ? > I'm familiar with the Simulink HDL coder, but this tool can transform > only in the opposite direction ... Tomer, The MathWorks offers a product to do exactly what you are looking for. Please see the product page at http://www.mathworks.com/products...

PCI model VHDL
hi all, could someone help me to search a free PCI model (master and target) in VHDL language, compliant with the PCI2.2 specification? thank you in advance. mar. ...

DDR2 VHDL model
Hi, on the following link http://www.samsung.com/products/semiconductor/DDR_DDR2/DDR2SDRAM/Component/= 256Mbit/K4T56083QF/K4T56083QF.htm#ge there are DDR2 memory VHDL simulation models from Samsung available. But the compressed download files only contain .dat files. Are these files suitable for functional simulations ? I have always simulated with "real" vhdl models ... Rgds Andr=E9 ALuPin@web.de wrote: > Hi, > > on the following link > > http://www.samsung.com/products/semiconductor/DDR_DDR2/DDR2SDRAM/Component/256Mbit/K4T56083QF/K4T56083QF.htm#ge > >...