f



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 Questions", Kluwer Academic
-- which discusses guidelines and testbench design issues.
--
-- This source file for the switch model may be used and
-- distributed without restriction provided that this copyright
-- statement is not removed from the file and that any derivative work
-- contains this copyright notice.

-- File name  : switch1.vhd
-- Description: This entity, and architecture provide
--   the definition of a three-port component (A, B, Cab) that models a
--   transfer gate.  If Cab = '1' then A and B act as an ON switch
--   (or zero ohm connection).  Else, if Cab = '0', then A and B are
--   assigned the value of 'Z'.
--
--   The width of the pass-through switch is defined through the
--   generic "width_g".  The pass-through control and operation
--   is defined on a per bit basis (i.e. one process per bit).
--
--=================================================================
-- Design Library: User defined.
-------------------------------------------------
-- Revisions:
--   Date   Author             Revision  Comment
-- 03-31-97 Ben Cohen          Rev A     Creation
--          VhdlCohen@aol.com
-- 09-13-03 Grzegorz Jablonski Rev B     Modified to handle multiple
transactions occuring in delta times
--          gwj@dmcs.p.lodz.pl
-------------------------------------------------------------
library IEEE;
  use IEEE.Std_Logic_1164.all;

-------------------------------------------------------------
-- Entity        : Switch1
-- Purpose       : Provides interface of a component
--               : intended to be placed between signals
--               : to dynamically control faults on signals.
-- Library       : User defined
-------------------------------------------------------------
library IEEE;
  use IEEE.Std_Logic_1164.all;

entity Switch1 is
  generic (Width_g      : Positive := 32);
  port
    (A   : inout Std_Logic_Vector(Width_g - 1 downto 0) := (others => 'Z');
     B   : inout Std_Logic_Vector(Width_g - 1 downto 0) := (others => 'Z');
     Cab : in    Std_Logic_Vector(Width_g - 1 downto 0) := (others => 'Z'));
end Switch1;


--------------------------------------------------------------
-- Architecture  : Switch1_a
-- Purpose       : Implements the switch architecture.
--               : This model is optimized for speed by minimizing the
--               : number of transactions by generating one process
--               : for each element of the width for the
--               : mode of interest.
-------------------------------------------------------------
architecture Switch1_a of Switch1 is
  type StdLogic_Table is array(Std_uLogic, Std_uLogic) of Std_uLogic;

  ------------------------------------------------------------------- 
  -- resolution function, from 1164 package body
  ------------------------------------------------------------------- 
  constant Resolution_Table : Stdlogic_Table := (
  --      ---------------------------------------------------------
  --      |  U    X    0    1    Z    W    L    H    -        |   |
  --      ---------------------------------------------------------
          ( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |
          ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |
          ( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ), -- | 0 |
          ( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ), -- | 1 |
          ( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |
          ( 'U', 'X', '0', '1', 'W', 'W', 'W', 'W', 'X' ), -- | W |
          ( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |
          ( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |
          ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' )  -- | - |
      );

  function Resolved ( S : Std_uLogic_Vector ) return Std_uLogic is
      variable Result : Std_uLogic := 'Z';  -- weakest state default
  begin
      -- the test for a single driver is essential otherwise the
      -- loop would return 'X' for a single driver of '-' and that
      -- would conflict with the value of a single driver unresolved
      -- signal.
      if    (S'length = 1) then
        return S(S'low);
      else
          for I in S'range Loop
              Result := Resolution_Table(Result, S(I));
          end loop;
      end if;
      return Result;
   end Resolved;

begin
  Px_Lbl: for I in (Width_g - 1) downto 0 generate
    ABC1_Lbl: process
      variable ThenTime_v : time;
      variable ResolvedValue_v : Std_uLogic;
   variable Cab_v : Std_Logic;
    begin
      wait on A(I)'transaction, B(I)'transaction, Cab(I)'transaction
   until (
              ThenTime_v /= now or Cab(I) /= Cab_v or
              (Cab(I) = '1' and (A(i)/=ResolvedValue_v or
B(i)/=ResolvedValue_v))
   );
      -- Break
      ThenTime_v := now;
      A(I) <= 'Z';
      B(I) <= 'Z';
      wait for 0 ns;
      Cab_v := Cab(I);
      if Cab(I) = '1' then
        -- Make.  Must compute the resolved value
        ResolvedValue_v  := Resolved((A(I), B(I)));
        A(I) <= ResolvedValue_v;
        B(I) <= ResolvedValue_v;

      else
          A(I) <= 'Z';
          B(I) <= 'Z';
      end if;
    end process ABC1_Lbl;
  end generate Px_Lbl;
end Switch1_a;


----------------------------------------------------------------------------
---
--  1 bit switch
----------------------------------------------------------------------------
---
library IEEE;
  use IEEE.Std_Logic_1164.all;

entity Switch1b is
  generic (Width_g      : Positive := 32);
  port
    (A   : inout Std_Logic := 'Z';
     B   : inout Std_Logic := 'Z';
     Cab : in    Std_Logic := 'Z');
end Switch1b;


--------------------------------------------------------------
-- Architecture  : Switch1b_a
-- Purpose       : Implements the switch architecture.
--               : This model is optimized for speed by minimizing the
--               : number of transactions by generating one process
--               : for each element of the width for the
--               : mode of interest.
-------------------------------------------------------------
architecture Switch1b_a of Switch1b is
  type StdLogic_Table is array(Std_uLogic, Std_uLogic) of Std_uLogic;

  ------------------------------------------------------------------- 
  -- resolution function
  ------------------------------------------------------------------- 
  constant Resolution_Table : Stdlogic_Table := (
  --      ---------------------------------------------------------
  --      |  U    X    0    1    Z    W    L    H    -        |   |
  --      ---------------------------------------------------------
          ( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |
          ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X |
          ( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ), -- | 0 |
          ( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ), -- | 1 |
          ( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z |
          ( 'U', 'X', '0', '1', 'W', 'W', 'W', 'W', 'X' ), -- | W |
          ( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L |
          ( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H |
          ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' )  -- | - |
      );

  function Resolved ( S : Std_uLogic_Vector ) return Std_uLogic is
      variable Result : Std_uLogic := 'Z';  -- weakest state default
  begin
      -- the test for a single driver is essential otherwise the
      -- loop would return 'X' for a single driver of '-' and that
      -- would conflict with the value of a single driver unresolved
      -- signal.
      if    (S'length = 1) then
        return S(S'low);
      else
          for I in S'range Loop
              Result := Resolution_Table(Result, S(I));
          end loop;
      end if;
      return Result;
   end Resolved;

begin
    ABC1_Lbl: process
      variable ThenTime_v : time;
      variable ResolvedValue_v : Std_uLogic;
   variable Cab_v : Std_Logic;
    begin
      wait on A'transaction, B'transaction, Cab'transaction
   until (
              ThenTime_v /= now or Cab /= Cab_v or
              (Cab = '1' and (A/=ResolvedValue_v or B/=ResolvedValue_v))
   );
      -- Break
      ThenTime_v := now;
      A <= 'Z';
      B <= 'Z';
      wait for 0 ns;
      Cab_v := Cab;
      if Cab = '1' then
        -- Make.  Must compute the resolved value
        ResolvedValue_v  := Resolved((A, B));
        A <= ResolvedValue_v;
        B <= ResolvedValue_v;

      else
          A <= 'Z';
          B <= 'Z';
      end if;
    end process ABC1_Lbl;
end Switch1b_a;





0
gwj (1)
9/13/2003 10:21:17 AM
comp.lang.vhdl 6414 articles. 2 followers. Post Follow

0 Replies
323 Views

Similar Articles

[PageSpeed] 49

Reply:

Similar Artilces:

VHDL standard question (VHDL 93 chapter 4.3.2.2)
Hi, I have small problems understanding what the 1076-1993 Ch. 4.3.2.2/490 "The type of the actual (after applying the conversion function or type conversion. if present in the actual part) must be the same as the type of the corresponding formal, if the mode of the formal is IN, INOUT, or LINKAGE, and if the actual is not open. Similarly, if the mode of the formal is OUT, INOUT, BUFFER, or LINKAGE, and if the actual is not open, then the type of the formal (after applying the conversion function or type conversion, if present in the formal part) must be the same as the corresponding ac...

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

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 #2
Hey i am pretty green at this VHDL... can someone tell me the error in this code.. : library IEEE; use IEEE.STD_LOGIC_1164.all; use ieee.std_logic_unsigned.all; entity Test is port( b: in std_logic; a: out std_logic_vector(7 downto 0)); end Test; architecture eksempel of Test is signal a_old,a_new : std_logic_vector(7 downto 0); begin test_if:process(b) begin if b='1' then a_new <= a_old + 1; end if; a<=a_new; end process test_if; end eksempel; it was suposed to add 1 to A regards Kasper > can someone tell me the error in this code.. : ...

WHAT IS VHDL? #2
... ...

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
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
i want to know is there any constructs similar to jump with condition to go to start is available in vhdl ...

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

sqrt(a^2 + b^2) in synthesizable VHDL?
How do i calculate sqrt(a^2 + b^2) in synthesizable VHDL? The signals a and b are 32 bit signed fix point numbers (std_logic_vector (31 downto 0)). Marko S schrieb: > How do i calculate sqrt(a^2 + b^2) in synthesizable VHDL? > The signals a and b are 32 bit signed fix point numbers (std_logic_vector > (31 downto 0)). how accurate? how fast? latency? a table with 64 Bits input, 32 Bits output will not fit into an FPGA (but if you need the result with low latency, you might store some precomputed data in an external ram) or you could do something like max(a, b) + 0.5*min(a,b...

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

declaring real numbers (2^15-1) and (-2^15) in vhdl
hi i would like to know how to declare the numbers in vhdl.the numbers are (2^15-1) and (-2^15). when i declare it using the REAL modelsim returns a error saying it is out of range.how to overcome it thanks hari Here an example (no problem for Modelsim) constant rl : real := 2.0**15; (remember the right operand of the power function should be an integer; so do not write 15.0. When you use the IEEE package math_real you have more functions) Egbert Molenkamp "hari" <hari_pro@yahoo.com> wrote in message news:a4a587f1.0404211903.7b799a11@posting.google.com... > hi > i...

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

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

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

Householders win up to $469 off bill in Big SA Energy Switch - AdelaideNow Search Search
A PEOPLE power campaign to force electricity companies to offer discounts has accepted an offer which would save an average four-person household ...

Inside Running: Trainers unhappy with Geelong Racing Club after track switch - HeraldSun Search Search ...
TRAINERS weren’t happy with the decision by the Geelong Racing Club on Sunday morning to switch Monday’s trials from the Geelong track to the ...

Trainers unhappy with track switch
TRAINERS weren’t happy with the decision by the Geelong Racing Club on Sunday morning to switch Monday’s trials from the Geelong track to the ...

NRL clubs to decide future of Sydney's stadiums after Baird policy switch
Sydney's stadium plans are set to be overhauled after six NRL clubs agreed to ask the Baird government for a funding switch.

Waratahs captain David Dennis backs former Raider Reece Robinson in Super Rugby switch
Former Canberra Raiders back shines in first hit-out for Super Rugby province NSW Waratahs.

You may already be able to switch between multiple accounts on Instagram
Instagram has begun rolling out support for switching between multiple accounts — without logging out — in its official iOS app.

Comcast begs Atlanta customers not to switch to Google Fiber
(credit: TheBen91 ) Google Fiber recently went live in apartments and condos in Atlanta, making it the fourth metro area to get Google's gigabit ...

Judge rejects attempt to oust lawyers from GM ignition-switch trials
... denied a motion that sought to oust lead counsel for plaintiffs suing General Motors over deaths and injuries caused by faulty ignition switches. ...

Resources last updated: 2/11/2016 11:22:49 PM