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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [rtl/] [vlib/] [comlib/] [byte2word.vhd] - Blame information for rev 40

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 wfjm
-- $Id: byte2word.vhd 432 2011-11-25 20:16:28Z mueller $
2
--
3
-- Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
--
14
------------------------------------------------------------------------------
15
-- Module Name:    byte2word - syn
16
-- Description:    2 byte -> 1 word stream converter
17
--
18
-- Dependencies:   -
19
-- Test bench:     -
20
-- Target Devices: generic
21
-- Tool versions:  xst 12.1; ghdl 0.29
22
--
23
-- Revision History: 
24
-- Date         Rev Version  Comment
25
-- 2011-11-21   432   1.0.1  now numeric_std clean
26
-- 2011-07-30   400   1.0    Initial version 
27
------------------------------------------------------------------------------
28
 
29
library ieee;
30
use ieee.std_logic_1164.all;
31
use ieee.numeric_std.all;
32
 
33
use work.slvtypes.all;
34
 
35
entity byte2word is                     -- 2 byte -> 1 word stream converter
36
  port (
37
    CLK : in slbit;                     -- clock
38
    RESET : in slbit;                   -- reset
39
    DI : in slv8;                       -- input data (byte)
40
    ENA : in slbit;                     -- write enable
41
    BUSY : out slbit;                   -- write port hold    
42
    DO : out slv16;                     -- output data (word)
43
    VAL : out slbit;                    -- read valid
44
    HOLD : in slbit;                    -- read hold
45
    ODD : out slbit                     -- odd byte pending
46
  );
47
end byte2word;
48
 
49
 
50
architecture syn of byte2word is
51
 
52
  type state_type is (
53
    s_idle,
54
    s_vall,
55
    s_valw
56
  );
57
 
58
  type regs_type is record
59
    datl : slv8;                        -- lsb data
60
    dath : slv8;                        -- msb data
61
    state : state_type;                 -- state
62
  end record regs_type;
63
 
64
  constant regs_init : regs_type := (
65
    (others=>'0'),
66
    (others=>'0'),
67
    s_idle
68
  );
69
 
70
  signal R_REGS : regs_type := regs_init;  -- state registers
71
  signal N_REGS : regs_type := regs_init;  -- next value state regs
72
 
73
begin
74
 
75
  proc_regs: process (CLK)
76
  begin
77
 
78
    if rising_edge(CLK) then
79
      if RESET = '1' then
80
        R_REGS <= regs_init;
81
      else
82
        R_REGS <= N_REGS;
83
      end if;
84
    end if;
85
 
86
  end process proc_regs;
87
 
88
  proc_next: process (R_REGS, DI, ENA, HOLD)
89
 
90
    variable r : regs_type := regs_init;
91
    variable n : regs_type := regs_init;
92
 
93
    variable ival  : slbit := '0';
94
    variable ibusy : slbit := '0';
95
    variable iodd  : slbit := '0';
96
 
97
  begin
98
 
99
    r := R_REGS;
100
    n := R_REGS;
101
 
102
    ival  := '0';
103
    ibusy := '0';
104
    iodd  := '0';
105
 
106
    case r.state is
107
 
108
      when s_idle =>
109
        if ENA = '1' then
110
          n.datl := DI;
111
          n.state := s_vall;
112
        end if;
113
 
114
      when s_vall =>
115
        iodd := '1';
116
        if ENA = '1' then
117
          n.dath := DI;
118
          n.state := s_valw;
119
        end if;
120
 
121
      when s_valw =>
122
        ival := '1';
123
        if HOLD = '0' then
124
          if ENA = '1' then
125
            n.datl := DI;
126
            n.state := s_vall;
127
          else
128
            n.state := s_idle;
129
          end if;
130
        else
131
          ibusy := '1';
132
        end if;
133
 
134
      when others => null;
135
    end case;
136
 
137
    N_REGS <= n;
138
 
139
    DO   <= r.dath & r.datl;
140
    VAL  <= ival;
141
    BUSY <= ibusy;
142
    ODD  <= iodd;
143
 
144
  end process proc_next;
145
 
146
 
147
end syn;

powered by: WebSVN 2.1.0

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