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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [vector_tx.vhd] - Blame information for rev 269

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

Line No. Rev Author Line
1 240 jshamlet
-- Copyright (c)2020 Jeremy Seth Henry
2
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
--
24
-- VHDL Entity: vector_tx
25
-- Description: Reads  the pushbuttons and switches on the DE1-SOC board and
26
--               sends a vector command and argument to a vector_rx receiver
27
--               which executes them in lieu of a parallel controller.
28
--
29
-- Revision History
30
-- Author          Date     Change
31
------------------ -------- ---------------------------------------------------
32
-- Seth Henry      05/06/20 Added version block
33
 
34
library ieee;
35
  use ieee.std_logic_1164.all;
36
  use ieee.std_logic_unsigned.all;
37
  use ieee.std_logic_arith.all;
38
  use ieee.std_logic_misc.all;
39
 
40
entity vector_tx is
41
generic(
42
  Button_Level               : std_logic;
43
  Bit_Rate                   : real;
44
  Enable_Parity              : boolean;
45
  Parity_Odd_Even_n          : std_logic;
46
  Sys_Freq                   : real;
47
  Reset_Level                : std_logic
48
);
49
port(
50
  Clock                      : in  std_logic;
51
  Reset                      : in  std_logic;
52
  --
53
  Switches                   : in  std_logic_vector(9 downto 0);
54
  Pushbutton                 : in  std_logic;
55
  --
56
  Tx_Out                     : out std_logic
57
);
58
end entity;
59
 
60
architecture behave of vector_tx is
61
 
62
  signal uSec_Tick           : std_logic;
63
  signal mSec_Tick           : std_logic;
64
 
65
  signal Button_Pressed      : std_logic := '0';
66
  signal Button_CoS          : std_logic := '0';
67
 
68 268 jshamlet
  type VEC_ARG_TYPE is array(0 to 31) of std_logic_vector(15 downto 0);
69 240 jshamlet
  constant VEC_ARGS          : VEC_ARG_TYPE := (
70
                               x"0000",
71 268 jshamlet
                               x"0001",
72
                               x"0002",
73
                               x"0003",
74
                               x"0004",
75
                               x"0005",
76
                               x"0006",
77
                               x"0007",
78
                               x"0008",
79
                               x"0009",
80
                               x"000A",
81
                               x"000B",
82
                               x"000C",
83
                               x"000D",
84
                               x"000E",
85
                               x"000F",
86
 
87
                               x"0800",
88
                               x"0866",
89
                               x"0975",
90
                               x"00AE",
91
                               x"DEAD",
92
                               x"BEEF",
93
                               x"CAFE",
94
                               x"BABE",
95
                               x"DECA",
96
                               x"A5A5",
97
                               x"C3C3",
98
                               x"0123",
99
                               x"4567",
100
                               x"89AB",
101
                               x"CDEF",
102 240 jshamlet
                               x"FFFF"
103
                             );
104
 
105 268 jshamlet
  alias Vector_Arg_Sel       is Switches(9 downto 5);
106
  alias Vector_Cmd_Sel       is Switches(4 downto 0);
107 240 jshamlet
 
108
  signal Vector_Cmd          : std_logic_vector(7 downto 0);
109
 
110
  signal Vector_Arg          : std_logic_vector(15 downto 0);
111
  alias Vector_Arg_LB        is Vector_Arg(7 downto 0);
112
  alias Vector_Arg_UB        is Vector_Arg(15 downto 8);
113
 
114
  type VECTOR_TX_STATES is (IDLE, SEND_CMD, WAIT_CMD, SEND_ARG_LB, WAIT_ARG_LB, SEND_ARG_UB, WAIT_ARG_UB );
115
  signal Vector_State        : VECTOR_TX_STATES := IDLE;
116
 
117
  constant BAUD_RATE_DIV     : integer := integer(Sys_Freq / Bit_Rate);
118
 
119
  signal Tx_Data             : std_logic_vector(7 downto 0) := x"00";
120
  signal Tx_Valid            : std_logic := '0';
121
  signal Tx_Done             : std_logic := '0';
122
 
123
begin
124
 
125
  U_USEC : entity work.sys_tick
126
  generic map(
127
    Reset_Level              => Reset_Level,
128
    Sys_Freq                 => Sys_Freq
129
  )
130
  port map(
131
    Clock                    => Clock,
132
    Reset                    => Reset,
133
    uSec_Tick                => uSec_Tick,
134
    mSec_Tick                => mSec_Tick
135
  );
136
 
137
  U_BTN : entity work.button_db
138
  generic map(
139
    Button_Level             => Button_Level,
140
    Reset_Level              => Reset_Level
141
  )
142
  port map(
143
    Clock                    => Clock,
144
    Reset                    => Reset,
145
    mSec_Tick                => mSec_Tick,
146
    --
147
    Button_In                => Pushbutton,
148
    --
149
    Button_Pressed           => Button_Pressed,
150
    Button_CoS               => Button_CoS
151
  );
152
 
153
  Input_reg_proc: process( Clock, Reset )
154
  begin
155
    if( Reset = Reset_Level )then
156
      Vector_Cmd             <= x"00";
157
      Vector_Arg             <= x"0000";
158
    elsif( rising_edge(Clock) )then
159 268 jshamlet
      Vector_Cmd             <= "000" & Vector_Cmd_Sel;
160 240 jshamlet
      Vector_Arg             <= VEC_ARGS(conv_integer(Vector_Arg_Sel));
161
    end if;
162
  end process;
163
 
164
  TX_FSM_proc: process( Clock, Reset )
165
  begin
166
    if( Reset = Reset_Level )then
167
      Vector_State           <= IDLE;
168
      Tx_Data                <= x"00";
169
      Tx_Valid               <= '0';
170
    elsif( rising_edge(Clock) )then
171
      Tx_Data                <= x"00";
172
      Tx_Valid               <= '0';
173
      case( Vector_State )is
174
        when IDLE =>
175
          if( Button_CoS = '1' and Button_Pressed = '1' )then
176
            Vector_State     <= SEND_CMD;
177
          end if;
178
 
179
        when SEND_CMD =>
180
          Tx_Data            <= Vector_Cmd;
181
          Tx_Valid           <= '1';
182
          Vector_State       <= WAIT_CMD;
183
 
184
        when WAIT_CMD =>
185
          if( Tx_Done = '1' )then
186
            Vector_State     <= SEND_ARG_LB;
187
          end if;
188
 
189
        when SEND_ARG_LB =>
190
          Tx_Data            <= Vector_Arg_LB;
191
          Tx_Valid           <= '1';
192
          Vector_State       <= WAIT_ARG_LB;
193
 
194
        when WAIT_ARG_LB =>
195
          if( Tx_Done = '1' )then
196
            Vector_State     <= SEND_ARG_UB;
197
          end if;
198
 
199
        when SEND_ARG_UB =>
200
          Tx_Data            <= Vector_Arg_UB;
201
          Tx_Valid           <= '1';
202
          Vector_State       <= WAIT_ARG_UB;
203
 
204
        when WAIT_ARG_UB =>
205
          if( Tx_Done = '1' )then
206
            Vector_State     <= IDLE;
207
          end if;
208
 
209
      end case;
210
    end if;
211
  end process;
212
 
213
  U_TX : entity work.async_ser_tx
214
  generic map(
215
    Reset_Level              => Reset_Level,
216
    Enable_Parity            => Enable_Parity,
217
    Parity_Odd_Even_n        => Parity_Odd_Even_n,
218
    Clock_Divider            => BAUD_RATE_DIV
219
  )
220
  port map(
221
    Clock                    => Clock,
222
    Reset                    => Reset,
223
    --
224
    Tx_Data                  => Tx_Data,
225
    Tx_Valid                 => Tx_Valid,
226
    --
227
    Tx_Out                   => Tx_Out,
228
    Tx_Done                  => Tx_Done
229
  );
230
 
231
end architecture;

powered by: WebSVN 2.1.0

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