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 240

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
  type VEC_ARG_TYPE is array(0 to 15) of std_logic_vector(15 downto 0);
69
  constant VEC_ARGS          : VEC_ARG_TYPE := (
70
                               x"0000",
71
                               x"1111",
72
                               x"2222",
73
                               x"3333",
74
                               x"4444",
75
                               x"5555",
76
                               x"6666",
77
                               x"7777",
78
                               x"8888",
79
                               x"9999",
80
                               x"AAAA",
81
                               x"BBBB",
82
                               x"CCCC",
83
                               x"DDDD",
84
                               x"EEEE",
85
                               x"FFFF"
86
                             );
87
 
88
  alias Vector_Arg_Sel       is Switches(9 downto 6);
89
  alias Vector_Cmd_Sel       is Switches(5 downto 0);
90
 
91
  signal Vector_Cmd          : std_logic_vector(7 downto 0);
92
 
93
  signal Vector_Arg          : std_logic_vector(15 downto 0);
94
  alias Vector_Arg_LB        is Vector_Arg(7 downto 0);
95
  alias Vector_Arg_UB        is Vector_Arg(15 downto 8);
96
 
97
  type VECTOR_TX_STATES is (IDLE, SEND_CMD, WAIT_CMD, SEND_ARG_LB, WAIT_ARG_LB, SEND_ARG_UB, WAIT_ARG_UB );
98
  signal Vector_State        : VECTOR_TX_STATES := IDLE;
99
 
100
  constant BAUD_RATE_DIV     : integer := integer(Sys_Freq / Bit_Rate);
101
 
102
  signal Tx_Data             : std_logic_vector(7 downto 0) := x"00";
103
  signal Tx_Valid            : std_logic := '0';
104
  signal Tx_Done             : std_logic := '0';
105
 
106
begin
107
 
108
  U_USEC : entity work.sys_tick
109
  generic map(
110
    Reset_Level              => Reset_Level,
111
    Sys_Freq                 => Sys_Freq
112
  )
113
  port map(
114
    Clock                    => Clock,
115
    Reset                    => Reset,
116
    uSec_Tick                => uSec_Tick,
117
    mSec_Tick                => mSec_Tick
118
  );
119
 
120
  U_BTN : entity work.button_db
121
  generic map(
122
    Button_Level             => Button_Level,
123
    Reset_Level              => Reset_Level
124
  )
125
  port map(
126
    Clock                    => Clock,
127
    Reset                    => Reset,
128
    mSec_Tick                => mSec_Tick,
129
    --
130
    Button_In                => Pushbutton,
131
    --
132
    Button_Pressed           => Button_Pressed,
133
    Button_CoS               => Button_CoS
134
  );
135
 
136
  Input_reg_proc: process( Clock, Reset )
137
  begin
138
    if( Reset = Reset_Level )then
139
      Vector_Cmd             <= x"00";
140
      Vector_Arg             <= x"0000";
141
    elsif( rising_edge(Clock) )then
142
      Vector_Cmd             <= "00" & Vector_Cmd_Sel;
143
      Vector_Arg             <= VEC_ARGS(conv_integer(Vector_Arg_Sel));
144
    end if;
145
  end process;
146
 
147
  TX_FSM_proc: process( Clock, Reset )
148
  begin
149
    if( Reset = Reset_Level )then
150
      Vector_State           <= IDLE;
151
      Tx_Data                <= x"00";
152
      Tx_Valid               <= '0';
153
    elsif( rising_edge(Clock) )then
154
      Tx_Data                <= x"00";
155
      Tx_Valid               <= '0';
156
      case( Vector_State )is
157
        when IDLE =>
158
          if( Button_CoS = '1' and Button_Pressed = '1' )then
159
            Vector_State     <= SEND_CMD;
160
          end if;
161
 
162
        when SEND_CMD =>
163
          Tx_Data            <= Vector_Cmd;
164
          Tx_Valid           <= '1';
165
          Vector_State       <= WAIT_CMD;
166
 
167
        when WAIT_CMD =>
168
          if( Tx_Done = '1' )then
169
            Vector_State     <= SEND_ARG_LB;
170
          end if;
171
 
172
        when SEND_ARG_LB =>
173
          Tx_Data            <= Vector_Arg_LB;
174
          Tx_Valid           <= '1';
175
          Vector_State       <= WAIT_ARG_LB;
176
 
177
        when WAIT_ARG_LB =>
178
          if( Tx_Done = '1' )then
179
            Vector_State     <= SEND_ARG_UB;
180
          end if;
181
 
182
        when SEND_ARG_UB =>
183
          Tx_Data            <= Vector_Arg_UB;
184
          Tx_Valid           <= '1';
185
          Vector_State       <= WAIT_ARG_UB;
186
 
187
        when WAIT_ARG_UB =>
188
          if( Tx_Done = '1' )then
189
            Vector_State     <= IDLE;
190
          end if;
191
 
192
      end case;
193
    end if;
194
  end process;
195
 
196
  U_TX : entity work.async_ser_tx
197
  generic map(
198
    Reset_Level              => Reset_Level,
199
    Enable_Parity            => Enable_Parity,
200
    Parity_Odd_Even_n        => Parity_Odd_Even_n,
201
    Clock_Divider            => BAUD_RATE_DIV
202
  )
203
  port map(
204
    Clock                    => Clock,
205
    Reset                    => Reset,
206
    --
207
    Tx_Data                  => Tx_Data,
208
    Tx_Valid                 => Tx_Valid,
209
    --
210
    Tx_Out                   => Tx_Out,
211
    Tx_Done                  => Tx_Done
212
  );
213
 
214
end architecture;

powered by: WebSVN 2.1.0

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