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

Subversion Repositories modular_oscilloscope

[/] [modular_oscilloscope/] [trunk/] [hdl/] [ctrl/] [channel_selector.vhd] - Blame information for rev 48

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

Line No. Rev Author Line
1 32 budinero
-------------------------------------------------------------------------------------------------100
2
--| Modular Oscilloscope
3
--| UNSL - Argentine
4
--|
5 38 budinero
--| File: ctrl_channel_selector.vhd
6 48 budinero
--| Version: 0.31
7 32 budinero
--| Tested in: Actel A3PE1500
8
--|   Board: RVI Prototype Board + LP Data Conversion Daughter Board
9
--|-------------------------------------------------------------------------------------------------
10
--| Description:
11
--|   CONTROL - Channel Selector
12
--|   This controls the comunication with the daq module. 
13
--|   
14
--|-------------------------------------------------------------------------------------------------
15
--| File history:
16
--|   0.1   | jul-2009 | First testing
17
--|   0.2   | jul-2009 | Added generic number of channel
18 38 budinero
--|   0.3   | jul-2009 | Added signal indicating when it's selecting the first channel
19 48 budinero
--|   0.31  | aug-2009 | Generic width in channel_number
20 32 budinero
----------------------------------------------------------------------------------------------------
21 33 budinero
--| Copyright © 2009, Facundo Aguilera.
22 32 budinero
--|
23
--| This VHDL design file is an open design; you can redistribute it and/or
24
--| modify it and/or implement it after contacting the author.
25
----------------------------------------------------------------------------------------------------
26
 
27
 
28
--==================================================================================================
29
-- TODO
30 38 budinero
-- · Speed up...
31 48 budinero
-- OK Generic width in channel_number_O
32 32 budinero
--==================================================================================================
33
 
34
 
35
library ieee;
36
use ieee.std_logic_1164.all;
37
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
38
use IEEE.NUMERIC_STD.ALL;
39
use ieee.math_real.all;
40
 
41
 
42
----------------------------------------------------------------------------------------------------
43
----------------------------------------------------------------------------------------------------
44 38 budinero
entity ctrl_channel_selector is
45 32 budinero
  generic(
46 38 budinero
    CHANNEL_WIDTH: integer := 4 -- number of channels 2**CHANNEL_WIDTH, max. 4
47 32 budinero
  );
48
  port(
49 38 budinero
    channels_I:         in  std_logic_vector(integer(2**real(CHANNEL_WIDTH))-1 downto 0);
50 48 budinero
    channel_number_O:   out std_logic_vector(CHANNEL_WIDTH-1 downto 0);
51 38 budinero
    first_channel_O:    out std_logic;
52 32 budinero
    clk_I:              in  std_logic;
53
    enable_I:           in  std_logic;
54
    reset_I:            in  std_logic
55
  );
56 48 budinero
end entity ctrl_channel_selector;
57 32 budinero
 
58
 
59
----------------------------------------------------------------------------------------------------
60
----------------------------------------------------------------------------------------------------
61 38 budinero
architecture ARCH01 of ctrl_channel_selector is
62
  constant N_CHANNELS: integer := integer(2**real(CHANNEL_WIDTH));
63
  -- signal channel:               unsigned(CHANNEL_WIDTH-1 downto 0);
64
  -- signal next_channel:          unsigned(CHANNEL_WIDTH-1 downto 0);
65
  -- signal next_is_first_channel: std_logic;
66
  signal channel:               unsigned(CHANNEL_WIDTH-1 downto 0);
67
  signal next_channel:          unsigned(CHANNEL_WIDTH downto 0);
68
  signal next_is_first_channel: std_logic;
69
  signal rotated: unsigned(N_CHANNELS-1 downto 0);
70
  signal plus: unsigned(CHANNEL_WIDTH downto 0);
71 32 budinero
begin
72
 
73
  --------------------------------------------------------------------------------------------------
74
  -- Output
75 48 budinero
  channel_number_O <= std_logic_vector(channel);
76 32 budinero
  --channel_number_O <=  std_logic_vector(channel);
77
  --------------------------------------------------------------------------------------------------
78 38 budinero
  -- Combinational selection of next channel
79 32 budinero
 
80 38 budinero
  -- P_comb: process(channel,channels_I) 
81
    -- variable j :    integer range 0 to N_CHANNELS-1;
82
    -- variable index: integer range 0 to N_CHANNELS-1;
83
  -- begin
84 32 budinero
 
85 38 budinero
      -- for j in 0 to N_CHANNELS-1 loop
86 32 budinero
 
87 38 budinero
        -- if (j + to_integer(channel) + 1) > (N_CHANNELS - 1) then
88
          -- index := j + to_integer(channel) + 1 - N_CHANNELS;
89
          -- next_is_first_channel <= '1';
90
        -- else
91
          -- index := j + to_integer(channel) + 1;
92
          -- next_is_first_channel <= '0';
93
        -- end if;
94 32 budinero
 
95 38 budinero
        -- if channels_I(index) = '1' then           
96
          -- next_channel <= to_unsigned(index, CHANNEL_WIDTH);
97
          -- exit;
98
        -- else
99
          -- next_channel <= channel;
100
        -- end if;
101
      -- end loop;
102
  -- end process; 
103
 
104
    --100.0 MHz     67.1 MHz  (N_CHANNELS = 16)
105
    -- 271 of 38400 (1%)     
106 32 budinero
 
107
 
108
 
109
 
110 38 budinero
    rotated <= unsigned(channels_I) ror (to_integer(channel));
111
    next_channel <= ('0' & channel) + plus;
112
    --next_channel <= channel + plus;
113
    next_is_first_channel <= next_channel (CHANNEL_WIDTH);
114
    P_coder: process(rotated)
115
      variable i: integer range 1 to N_CHANNELS-1;
116
    begin
117
      for i in 1 to N_CHANNELS-1 loop
118
        if rotated(i) = '1' then
119
          plus <=  to_unsigned(i, CHANNEL_WIDTH+1);
120
          exit;
121
        else
122
          plus <=  (CHANNEL_WIDTH =>'1') & (CHANNEL_WIDTH - 1 downto 0 => '0');
123
        end if;
124
      end loop;
125
    end process;
126 32 budinero
 
127 38 budinero
  --100.0 MHz     70.6 MHz   (N_CHANNELS = 16)
128
  -- 137 of 38400 (0%)
129 32 budinero
 
130
  --------------------------------------------------------------------------------------------------
131 38 budinero
  -- Clocked selection of actual channel
132 32 budinero
 
133 38 budinero
  -- P_clock: process(enable_I, reset_I, next_channel, clk_I) 
134
  -- begin
135
    -- if clk_I'event and clk_I = '1' then
136
      -- if reset_I = '1' then
137
        -- channel <= (others => '0');
138
        -- first_channel_O <= '1';
139
      -- elsif enable_I = '1' then
140
        -- channel <= next_channel;
141
        -- first_channel_O <= next_is_first_channel;
142
      -- end if;
143
    -- end if;
144
  -- end process; 
145
 
146
    P_clock: process(enable_I, reset_I, next_channel, clk_I)
147 32 budinero
  begin
148
    if clk_I'event and clk_I = '1' then
149
      if reset_I = '1' then
150
        channel <= (others => '0');
151 38 budinero
        first_channel_O <= '1';
152 32 budinero
      elsif enable_I = '1' then
153 38 budinero
        channel <= next_channel(CHANNEL_WIDTH-1 downto 0);
154
        first_channel_O <= next_is_first_channel;
155 32 budinero
      end if;
156
    end if;
157
  end process;
158
 
159
 
160
end architecture;

powered by: WebSVN 2.1.0

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