f



VHDL switch model

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
rickman
5/27/2008 8:37:00 PM
comp.lang.vhdl 6415 articles. 2 followers. Post Follow

10 Replies
581 Views

Similar Articles

[PageSpeed] 20

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
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
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
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
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
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
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
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
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
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
Rick
6/1/2008 1:25:01 AM
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 ...

VHDL-2002 vs VHDL-93 vs VHDL-87?
I've looked up google, but I can't seem to find a concise summary about the differences between VHDL 87/93/2002. What are they? And what's the next version of VHDL? Someone wrote: "I've looked up google, but I can't seem to find a concise summary about the differences between VHDL 87/93/2002. What are they?" VHDL93 has many differences from VHDL87, these are mostly additions amongst which are shared variables and directly instantiating a component by using the entity name; and at least one change to filehandling which is not backwards compatible. You may ...

VHDL
hello, please i am looking for someone who can help me to solve my pb. this is my code : Bonjour a tous, je cherche de l'aide pour mon projet sur VHDL: mon testBench ne fonctionne pas correctement je voudrais de l'aide s'il vous plait. voici mes codes: --------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; entity Lane is port ( FPP_CLK_IN : IN std_logic; FPP_FROM_CORE : IN std_logic; DATA_IN : IN std_logic; FPP_SEC_EN : IN std_logic; FPP_TURN_S...

VHDL
can anyone help me and tell me what this program exactly do please? 1 ENTITY EX8 IS 2 GENERIC (n : NATURAL :=4); 3 PORT (clk, rst : IN BIT; 4 in1, in2 : IN BIT_VECTOR (n-1 DOWNTO 0); 5 opt : OUT BIT_VECTOR (n-1 DOWNTO 0)); 6 END EX8; 7 ARCHITECTURE behave OF EX8 IS 8 SIGNAL sopt : BIT_VECTOR (n-1 DOWNTO 0); 9 SIGNAL chng : BIT; 10 BEGIN 11 P0: PROCESS (clk, rst) 12 BEGIN 13 IF rst='1' THEN chng<='0'; 14 ELSIF clk'EVENT AND clk='1' THEN 15 IF sopt=in2 THEN chng<='1'; 16 ELSIF sopt=in1 THEN chng<='0'; 17 END IF...

VHDL
Would it be feasible to implement a VHDL interpreter in Forth (i.e. is VHDL sufficiently clearly defined)? -marcel Marcel Hendrix schrieb: > Would it be feasible to implement a VHDL interpreter in Forth > (i.e. is VHDL sufficiently clearly defined)? > > -marcel > Hmm, your short question is a bit too cryptic for me. At least Google shows a few hits when searching for VERILOG and FORTH. The same is true for VHDL and SIMULATOR. Then we have f.ex. http://www.verilog.net/free.html What were you aiming at? Andreas On 12 May, 20:44, m...@iae.nl (Marcel Hendrix) wrote: &g...

VHDL
Now, I used the state machine to apply to VHDL. In my case, there are two states, S0 and S1. When I press a button, S0 is transit to S1 such that the LED display some of the segments,like segment a,b,c. And press this button again, S1 is back to S0. How can I present in VHDL so that the LED display in segment a,b,c ? Thanks!! Why don't you have a look at a common VHDL book ? There are so many simple examples which show how to describe a state machine ... You could design your state machine on a piece of paper first,=20 later try to describe in VHDL ... Rgds Andr=E9 if you are trying ...

vhdl
i want to know is there any constructs similar to jump with condition to go to start is available in vhdl ...

BPSK on VHDL (warning
Hello, I am writing a BPSK demodulator using VHDL for a Xilinx Vertex2 Pro FPGA. I will be getting IQ data on which I'll do the demodulation. However, the IQ data has varying phase and frequency offsets which need to be corrected before hard decision decoding can be carried out. Has anyone implemented frequency and phase offset removal using VHDL/fixed point algorithms? How can I approach this. Is there somewhere I can find code for this? Thanks and regards, Abhishek If you have some algorithm for these stuff, implement a vhdl code will be easy. People of this list can give lots of h...

VHDL 2002 vs VHDL 1993
Hi, I'm investigating on the opportunity to switch from 93 to 2002... does any one have a link where I may find relevant informations regarding enhancements brought by 2002 ? Thanks, Vincent dude a �crit : > Hi, I'm investigating on the opportunity to switch from 93 to 2002... > does any one have a link where I may find relevant informations > regarding enhancements brought by 2002 ? > Thanks, > Vincent Hi Have a look here: http://groups.google.fr/group/comp.lang.vhdl/browse_thread/thread/3e1571a13ab8431a/9dfbd0a085f36aec?q=2002+93+nicolas&rnum=1#9dfbd0a085f36ae...

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...

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 > >...

Why VHDL?
I'm not looking to start a VHDL vs. Verilog argument, but I was puzzled by Glen's comment in the VHDL group that he learned Verilog first before using VHDL. Am I correct in assuming you used VHDL because a customer required it? I learned VHDL, although not well, then went to work for a comms company who used Verilog. I never went to school for Verilog and never really bought a book. So I don't feel comfortable using it even though I have coded in it. On the other hand, after many years of VHDL, I won't say I've ever gotten "comfortable" with i...

what is VHDL?
WHAT DO YU KNOW ABOUT VHDL?? On 9/6/2014 3:20 PM, aamirsamejo42@gmail.com wrote: > WHAT DO YU KNOW ABOUT VHDL?? I know stuff... -- Rick On 9/6/2014 3:20 PM, aamirsamejo42@gmail.com wrote: > WHAT DO YU KNOW ABOUT VHDL?? > http://lmgtfy.com/?q=what+is+VHDL ...

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. ...

Web resources about - VHDL switch model - comp.lang.vhdl

Switch - Wikipedia, the free encyclopedia
"Toggle button" redirects here. For the GUI widget , see Cycle button . For other uses, see Switch (disambiguation) . Electrical switches. Top, ...

Switch - Wikipedia, the free encyclopedia
Electrical switches. Top, left to right: circuit breaker, mercury switch , wafer switch, DIP switch , surface mount switch, reed switch . Bottom, ...

How quickly can you switch colors? Find out in Swap Ball
... completely black. It may sound easy, however, your mission is to do all of this while the ball is bouncing off of the shapes walls which switch ...

Lawyers squabble after GM ignition-switch trial debacle
Filed under: Government/Legal , GM Days after a bellwether lawsuit over GM ignition switches abruptly ended, there are more troubling signs for ...

GM allowed to tell ignition-switch jury about plaintiff's 'lies'
Stories about government regulation and oversight of the automotive industry, as well as coverage of safety developments and enhancements.

Fintechs — a 'shoal of piranhas' — have forced banks to switch from 'compete to collaborate'
... pay for things are completely different from 20 years ago. But the biggest shift in banking industry during the tech revolution is the switch ...

GM ignition switch trial ends amid claims of fraud
But attorney says the overall litigation involving other plaintiffs will continue

Apple may switch up iPhone charging with wireless tech
As soon as next year, you reportedly might be able to charge an iPhone while it's still in your bag or in your hands.

Enterprises eye a fast switch to Windows 10
Enterprise interest in Windows 10, getting onto it and off Windows 7, is at an unprecedented level, research firm Gartner said today. Although ...

T-Mobile Creates Drinking Game For AT&T Earnings Call, Hopes You Get Drunk Enough To Switch
Earning calls can be a drag, full of heavily massaged numbers and industry jargon meant to make anyone listening fall asleep. To spice things ...

Resources last updated: 2/1/2016 3:45:29 AM