OpenCores
URL https://opencores.org/ocsvn/modular_oscilloscope/modular_oscilloscope/trunk

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [epp/] [eppwbn_wbn_side.vhd] - Diff between revs 19 and 57

Show entire file | Details | Blame | View Log

Rev 19 Rev 57
Line 1... Line 1...
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--| Modular Oscilloscope
--| Modular Oscilloscope
--| UNSL - Argentine
--| UNSL - Argentine
--|
--|
--| File: eppwbn_wbn_side.vhd
--| File: eppwbn_wbn_side.vhd
--| Version: 0.2
--| Version: 0.5
--| Tested in: Actel APA300
--| Tested in: Actel APA300
 
--| Tested in: Actel A3PE1500
 
--|   Board: RVI Prototype Board + LP Data Conversion Daughter Board
--|-------------------------------------------------------------------------------------------------
--|-------------------------------------------------------------------------------------------------
--| Description:
--| Description:
--|     EPP - Wishbone bridge. 
--|     EPP - Wishbone bridge. 
--|     This module is in the wishbone side (IEEE Std. 1284-2000).
--|     This module is in the wishbone side (IEEE Std. 1284-2000).
--|-------------------------------------------------------------------------------------------------
--|-------------------------------------------------------------------------------------------------
--| File history:
--| File history:
--|     0.01    | nov-2008 | First release
--|     0.01    | nov-2008 | First release
--|   0.1   | jan-2009 | Sinc reset
--|   0.1   | jan-2009 | Sinc reset
--|   0.2   | feb-2009 | Some improvements
--|   0.2   | feb-2009 | Some improvements
 
--|   0.5   | sep-2009 | New design, full sincronous
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--| Copyright ® 2008, Facundo Aguilera.
--| Copyright © 2008, Facundo Aguilera.
--|
--|
--| This VHDL design file is an open design; you can redistribute it and/or
--| This VHDL design file is an open design; you can redistribute it and/or
--| modify it and/or implement it after contacting the author.
--| modify it and/or implement it after contacting the author.
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
 
 
 
 
 
 
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_ARITH.ALL;
 
 
 
 
 
entity eppwbn_wbn_side is
entity eppwbn_wbn_side is
 
--   generic(
 
--     WAIT_DELAY : integer := 4  -- min value: 3
 
--   ); 
port(
port(
 
 
        -- al puerto epp
 
                                              -- Nomenclatura IEEE Std. 1284-2000
 
                                              --  Negotiation/ECP/EPP (Compatibiliy)        
 
        inStrobe: in std_logic;                                                                                 --  HostClk/nWrite 
        inStrobe: in std_logic;                                                                                 --  HostClk/nWrite 
        iData: inout std_logic_vector (7 downto 0); --  AD8..1/AD8..1 (Data1..Data8)
        iData: inout std_logic_vector (7 downto 0); --  AD8..1/AD8..1 (Data1..Data8)
        -- inAck: out std_logic;                                                                                --  PtrClk/PeriphClk/Intr
 
        iBusy: out std_logic;                                                                                   --  PtrBusy/PeriphAck/nWait
        iBusy: out std_logic;                                                                                   --  PtrBusy/PeriphAck/nWait
        -- iPError: out std_logic;                                                                      --  AckData/nAckReverse
 
        -- iSel: out std_logic;                                                                                 --  XFlag (Select)
 
        inAutoFd: in std_logic;                                                                                 --  HostBusy/HostAck/nDStrb
        inAutoFd: in std_logic;                                                                                 --  HostBusy/HostAck/nDStrb
        -- iPeriphLogicH: out std_logic;                                                --  (Periph Logic High)
 
        -- inInit: in std_logic;                                                                                --  nReverseRequest
 
        -- inFault: out std_logic;                                                                      --  nDataAvail/nPeriphRequest
 
        inSelectIn: in std_logic;                                                                       --  1284 Active/nAStrb
        inSelectIn: in std_logic;                                                                       --  1284 Active/nAStrb
        -- iHostLogicH: in std_logic;                                                   --  (Host Logic High)
 
        -- i indica interna en el core y controlada por el bloque de control
 
 
 
        --  a la interface wishbone
 
        RST_I: in std_logic;
        RST_I: in std_logic;
        CLK_I: in std_logic;
        CLK_I: in std_logic;
        DAT_I: in std_logic_vector (7 downto 0);
        DAT_I: in std_logic_vector (7 downto 0);
        DAT_O: out std_logic_vector (7 downto 0);
        DAT_O: out std_logic_vector (7 downto 0);
        ADR_O: out std_logic_vector (7 downto 0);
        ADR_O: out std_logic_vector (7 downto 0);
        CYC_O: out std_logic;
        CYC_O: out std_logic;
        STB_O: out std_logic;
        STB_O: out std_logic;
        ACK_I: in std_logic ;
        ACK_I: in std_logic ;
        WE_O: out std_logic;
        WE_O: out std_logic;
 
 
 
    rst_pp: in std_logic  -- reset from pp
        rst_pp: in std_logic  -- reset desde la interfaz del puerto paralelo
 
);
);
 
 
end eppwbn_wbn_side;
end eppwbn_wbn_side;
 
 
architecture con_registro of eppwbn_wbn_side is
architecture bridge2 of eppwbn_wbn_side is
 
 
 
  type StateType is (
 
      ST_IDLE,
 
      ST_ADDR,
 
      ST_WRITING_D1,
 
      ST_WRITING_D2,
 
      ST_READING_D1,
 
      ST_READING_D2
 
      );
 
  signal next_state, present_state: StateType;
 
 
 
  signal nWrite: std_logic;
 
  signal nWait:  std_logic;
 
  signal nDStrb: std_logic;
 
  signal nAStrb: std_logic;
 
  signal strb_hist: std_logic_vector(4 downto 0);
 
  signal strb_ris: std_logic;
 
  signal strb_fall: std_logic;
 
  signal strb_wb: std_logic;
 
  signal ack_pp: std_logic;
 
 
        signal adr_ack,data_ack: std_logic;
 
        signal adr_reg,data_reg: std_logic_vector (7 downto 0); -- registros internos temporales
        signal adr_reg,data_reg: std_logic_vector (7 downto 0); -- registros internos temporales
        signal pre_STB_O: std_logic; -- registro que maneja a STB_O
  --signal waiting: std_logic_vector(WAIT_DELAY-1 downto 0);
 
 
begin
begin
 
 
        iBusy <= adr_ack or data_ack; -- nWait. Se utiliza para confirmación de lectura/escritura de datos/direcciones
  -- Equal
        WE_O <= not(inStrobe); -- Ambas señales tienen la misma utilidad, habilitan escritura
  nWrite <= inStrobe;
        STB_O <= pre_STB_O ;
  nAStrb <= inSelectIn;
        CYC_O <= pre_STB_O;
  nDStrb <= inAutoFd;
        DAT_O <= data_reg;  -- se utiliza el mismo registro para salida de datos 
  iBusy  <= nWait;
                                                                                        -- a wishbone, lectura y escritura de datos desde epp   
 
 
 
        -- Data R/W
  STB_O <= strb_wb;
        data_strobing: process (inAutoFd, ACK_I, CLK_I, pre_STB_O, RST_I, rst_pp, data_ack,inStrobe,iData)
  CYC_O <= strb_wb;
 
  ADR_O <= adr_reg;
 
  DAT_O <= data_reg;
 
 
 
  -- Thanks fpga4fun
 
  P_strobes: process(nAStrb, nDStrb, CLK_I, strb_hist, RST_I, rst_pp)
        begin
        begin
 
    if CLK_I 'event and CLK_I = '1' then
 
      if RST_I = '1' or rst_pp = '1' then
 
        strb_hist <= (others => '1' );
 
      else
 
        strb_hist <= strb_hist(3 downto 0) & (nAStrb and nDStrb); -- only one is zero at a time
 
      end if;
 
    end if;
 
  end process;
 
  strb_ris  <= '1' when strb_hist(4 downto 1) = "0111" else '0';
 
  strb_fall <= '1' when strb_hist(4 downto 1) = "0000" else '0';
 
 
    if (rst_pp = '1') then  -- Reset de desde interfaz EPP asíncrono
 
      data_reg <= (others => '0');
 
      pre_STB_O <= '0';
 
      data_ack <= '0';
 
 
 
    elsif inAutoFd = '0' and data_ack = '0' and pre_STB_O = '0' then -- Data strobe
  P_next_st: process(strb_ris, strb_fall, ACK_I, nAStrb, nDStrb, nWrite, present_state)
      if (inStrobe = '0') then -- Escritura EPP
  begin
        data_reg <= iData;
 
      end if;
 
      pre_STB_O <= '1';
 
    elsif inAutoFd = '1' and data_ack = '1' then -- iBusy solo se pondrá a cero       
 
      data_ack <= '0';
 
                      -- Se indica el la comprobación de data_ack = '1' para forzar a la herramienta
 
                      -- de síntesis a crear un registro.
 
 
 
    elsif (CLK_I'event and CLK_I = '1')  then
      case present_state is
      if RST_I = '1' then
        when ST_ADDR =>
        data_reg <= (others => '0');
          strb_wb <= '0';
        pre_STB_O <= '0';
          ack_pp <= '1';
        data_ack <= '0';
          WE_O <= '0';
 
          -- >>> --
 
        if strb_ris = '1' then
 
          next_state <= ST_IDLE;
      else
      else
        if (ACK_I = '1' and pre_STB_O = '1') then -- Dato escrito o leído
          next_state <= present_state;
          pre_STB_O <= '0';
 
          data_ack <= '1';
 
          if (inStrobe = '1') then -- Lectura EPP
 
           data_reg <= DAT_I;
 
          end if;
 
        end if;
        end if;
 
 
 
      when ST_WRITING_D1 =>
 
        strb_wb <= '0';
 
        ack_pp <= '1';
 
        WE_O <= '0';
 
        -- >>> --
 
        if strb_ris = '1' then
 
          next_state <= ST_WRITING_D2;
 
        else
 
          next_state <= present_state;
      end if;
      end if;
 
 
 
      when ST_WRITING_D2 =>
 
        strb_wb <= '1';
 
        ack_pp <= '0';
 
        WE_O <= '1';
 
        -- >>> --
 
        if ACK_I = '1' then
 
          next_state <= ST_IDLE;
 
        else
 
          next_state <= present_state;
    end if;
    end if;
 
 
 
      when ST_READING_D1 =>
 
        strb_wb <= '1';
 
        ack_pp <= '0';
 
        WE_O <= '0';
 
        -- >>> --
 
        if strb_ris = '1' then
 
          next_state <= ST_IDLE;
 
        elsif ACK_I = '1' then
 
          next_state <= ST_READING_D2;
 
        else
 
          next_state <= present_state;
 
        end if;
 
 
 
      when ST_READING_D2 =>
 
        strb_wb <= '0';
 
        ack_pp <= '1';
 
        WE_O <= '0';
 
        -- >>> --
 
        if strb_ris = '1' then
 
          next_state <= ST_IDLE;
 
        else
 
          next_state <= present_state;
 
        end if;
 
 
 
      when others =>  -- ST_IDLE
 
        strb_wb <= '0';
 
        ack_pp <= '0';
 
        WE_O <= '0';
 
        -- >>> --
 
        if strb_fall = '1' then
 
          if    nWrite = '0' and nDStrb = '0' then
 
            next_state <= ST_WRITING_D1;
 
          elsif nWrite = '1' and nDStrb = '0' then
 
            next_state <= ST_READING_D1;
 
          elsif nAStrb = '0' then
 
            next_state <= ST_ADDR;
 
          else
 
            next_state <= present_state;
 
          end if;
 
        else
 
          next_state <= present_state;
 
        end if;
 
    end case;
        end process;
        end process;
 
 
 
  P_act_st: process(CLK_I, RST_I, rst_pp, next_state, iData, DAT_I, present_state, nWrite)
 
 
        -- Adr R/W
 
        adr_ack <= not(inSelectIn); -- Autoconfirmación de estado.
 
        adr_strobing: process (inSelectIn, RST_I, rst_pp,inStrobe,iData)
 
        begin
        begin
                if (RST_I = '1' or rst_pp = '1') then
    if (CLK_I'event and CLK_I='1') then
 
      if RST_I = '1' or rst_pp = '1' then
 
        present_state <= ST_IDLE;
 
        data_reg <= (others => '0');
                        adr_reg <= (others => '0');
                        adr_reg <= (others => '0');
                elsif (inSelectIn'event and inSelectIn = '1') then -- Adr strobe
      else
                        if inStrobe = '0' then
        present_state <= next_state;
 
        case present_state is
 
          when ST_ADDR =>
 
            --if next_state = ST_IDLE and nWrite = '0' then
 
            if strb_hist(0) = '0' and nWrite = '0' then
                                adr_reg <= iData;
                                adr_reg <= iData;
                        end if;
                        end if;
 
          when ST_WRITING_D1 =>
 
            --if next_state = ST_WRITING_D2 then
 
            if strb_hist(0) = '0' then
 
              data_reg <= iData;
 
            end if;
 
          when ST_READING_D1 =>
 
            if next_state = ST_READING_D2 then
 
              data_reg <= DAT_I;
 
            end if;
 
          when others =>
 
        end case;
 
      end if;
                end if;
                end if;
        end process;
        end process;
        ADR_O <= adr_reg;
 
 
 
 
  nWait <= ack_pp;
 
 
        -- Puerto bidireccional
  iData <= data_reg when (nWrite = '1' and nDStrb = '0' ) else
        iData <= data_reg when (inStrobe = '1' and data_ack = '1') else
           adr_reg  when (nWrite = '1' and nAStrb = '0' ) else
                         adr_reg when (inStrobe = '1' and adr_ack = '1') else
 
                         (others => 'Z');
                         (others => 'Z');
 
 
 
--   P_delay: process(ack_pp, CLK_I, rst_pp, RST_I, waiting)
 
--   begin
 
--     if CLK_I'event and CLK_I = '1' then
 
--       if rst_pp = '1' or RST_I = '1' then
 
--         waiting <= (others => '0');
 
--       else 
 
--         waiting <= waiting(WAIT_DELAY-2 downto 0) & ack_pp;
 
--       end if;
 
--     end if;
 
--   end process;
 
 
 
 
end con_registro;
 
 No newline at end of file
 No newline at end of file
 
end architecture bridge2;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.