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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [rtl/] [vlib/] [comlib/] [word2byte.vhd] - Diff between revs 29 and 33

Only display areas with differences | Details | Blame | View Log

Rev 29 Rev 33
-- $Id: word2byte.vhd 649 2015-02-21 21:10:16Z mueller $
-- $Id: word2byte.vhd 649 2015-02-21 21:10:16Z mueller $
--
--
-- Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
-- Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
--
--
-- This program is free software; you may redistribute and/or modify it under
-- This program is free software; you may redistribute and/or modify it under
-- the terms of the GNU General Public License as published by the Free
-- the terms of the GNU General Public License as published by the Free
-- Software Foundation, either version 2, or at your option any later version.
-- Software Foundation, either version 2, or at your option any later version.
--
--
-- This program is distributed in the hope that it will be useful, but
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-- for complete details.
-- for complete details.
--
--
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Module Name:    word2byte - syn
-- Module Name:    word2byte - syn
-- Description:    1 word -> 2 byte stream converter
-- Description:    1 word -> 2 byte stream converter
--
--
-- Dependencies:   -
-- Dependencies:   -
-- Test bench:     -
-- Test bench:     -
-- Target Devices: generic
-- Target Devices: generic
-- Tool versions:  xst 12.1-14.7; ghdl 0.29-0.31
-- Tool versions:  xst 12.1-14.7; ghdl 0.29-0.31
--
--
-- Revision History: 
-- Revision History: 
-- Date         Rev Version  Comment
-- Date         Rev Version  Comment
-- 2011-11-21   432   1.0.1  now numeric_std clean
-- 2011-11-21   432   1.0.1  now numeric_std clean
-- 2011-07-30   400   1.0    Initial version 
-- 2011-07-30   400   1.0    Initial version 
------------------------------------------------------------------------------
------------------------------------------------------------------------------
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std.all;
 
 
use work.slvtypes.all;
use work.slvtypes.all;
 
 
entity word2byte is                     -- 1 word -> 2 byte stream converter
entity word2byte is                     -- 1 word -> 2 byte stream converter
  port (
  port (
    CLK : in slbit;                     -- clock
    CLK : in slbit;                     -- clock
    RESET : in slbit;                   -- reset
    RESET : in slbit;                   -- reset
    DI : in slv16;                      -- input data (word)
    DI : in slv16;                      -- input data (word)
    ENA : in slbit;                     -- write enable
    ENA : in slbit;                     -- write enable
    BUSY : out slbit;                   -- write port hold    
    BUSY : out slbit;                   -- write port hold    
    DO : out slv8;                      -- output data (byte)
    DO : out slv8;                      -- output data (byte)
    VAL : out slbit;                    -- read valid
    VAL : out slbit;                    -- read valid
    HOLD : in slbit;                    -- read hold
    HOLD : in slbit;                    -- read hold
    ODD : out slbit                     -- odd byte pending
    ODD : out slbit                     -- odd byte pending
  );
  );
end word2byte;
end word2byte;
 
 
 
 
architecture syn of word2byte is
architecture syn of word2byte is
 
 
  type state_type is (
  type state_type is (
    s_idle,
    s_idle,
    s_valw,
    s_valw,
    s_valh
    s_valh
  );
  );
 
 
  type regs_type is record
  type regs_type is record
    datl : slv8;                        -- lsb data
    datl : slv8;                        -- lsb data
    dath : slv8;                        -- msb data
    dath : slv8;                        -- msb data
    state : state_type;                 -- state
    state : state_type;                 -- state
  end record regs_type;
  end record regs_type;
 
 
  constant regs_init : regs_type := (
  constant regs_init : regs_type := (
    (others=>'0'),
    (others=>'0'),
    (others=>'0'),
    (others=>'0'),
    s_idle
    s_idle
  );
  );
 
 
  signal R_REGS : regs_type := regs_init;  -- state registers
  signal R_REGS : regs_type := regs_init;  -- state registers
  signal N_REGS : regs_type := regs_init;  -- next value state regs
  signal N_REGS : regs_type := regs_init;  -- next value state regs
 
 
begin
begin
 
 
  proc_regs: process (CLK)
  proc_regs: process (CLK)
  begin
  begin
 
 
    if rising_edge(CLK) then
    if rising_edge(CLK) then
      if RESET = '1' then
      if RESET = '1' then
        R_REGS <= regs_init;
        R_REGS <= regs_init;
      else
      else
        R_REGS <= N_REGS;
        R_REGS <= N_REGS;
      end if;
      end if;
    end if;
    end if;
 
 
  end process proc_regs;
  end process proc_regs;
 
 
  proc_next: process (R_REGS, DI, ENA, HOLD)
  proc_next: process (R_REGS, DI, ENA, HOLD)
 
 
    variable r : regs_type := regs_init;
    variable r : regs_type := regs_init;
    variable n : regs_type := regs_init;
    variable n : regs_type := regs_init;
 
 
    variable ival  : slbit := '0';
    variable ival  : slbit := '0';
    variable ibusy : slbit := '0';
    variable ibusy : slbit := '0';
    variable iodd  : slbit := '0';
    variable iodd  : slbit := '0';
 
 
  begin
  begin
 
 
    r := R_REGS;
    r := R_REGS;
    n := R_REGS;
    n := R_REGS;
 
 
    ival  := '0';
    ival  := '0';
    ibusy := '0';
    ibusy := '0';
    iodd  := '0';
    iodd  := '0';
 
 
    case r.state is
    case r.state is
 
 
      when s_idle =>
      when s_idle =>
        if ENA = '1' then
        if ENA = '1' then
          n.datl := DI( 7 downto 0);
          n.datl := DI( 7 downto 0);
          n.dath := DI(15 downto 8);
          n.dath := DI(15 downto 8);
          n.state := s_valw;
          n.state := s_valw;
        end if;
        end if;
 
 
      when s_valw =>
      when s_valw =>
        ibusy := '1';
        ibusy := '1';
        ival  := '1';
        ival  := '1';
        if HOLD = '0' then
        if HOLD = '0' then
          n.datl := r.dath;
          n.datl := r.dath;
          n.state := s_valh;
          n.state := s_valh;
        end if;
        end if;
 
 
      when s_valh =>
      when s_valh =>
        ival := '1';
        ival := '1';
        iodd := '1';
        iodd := '1';
        if HOLD = '0' then
        if HOLD = '0' then
          if ENA = '1' then
          if ENA = '1' then
            n.datl := DI( 7 downto 0);
            n.datl := DI( 7 downto 0);
            n.dath := DI(15 downto 8);
            n.dath := DI(15 downto 8);
            n.state := s_valw;
            n.state := s_valw;
          else
          else
            n.state := s_idle;
            n.state := s_idle;
          end if;
          end if;
        else
        else
          ibusy := '1';
          ibusy := '1';
        end if;
        end if;
 
 
      when others => null;
      when others => null;
    end case;
    end case;
 
 
    N_REGS <= n;
    N_REGS <= n;
 
 
    DO   <= r.datl;
    DO   <= r.datl;
    VAL  <= ival;
    VAL  <= ival;
    BUSY <= ibusy;
    BUSY <= ibusy;
    ODD  <= iodd;
    ODD  <= iodd;
 
 
  end process proc_next;
  end process proc_next;
 
 
 
 
end syn;
end syn;
 
 

powered by: WebSVN 2.1.0

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