1 |
198 |
zero_gravi |
-- #################################################################################################
|
2 |
|
|
-- # << NEO430 - Processor Top Entity using resolved signal types (std_logic) only >> #
|
3 |
|
|
-- # ********************************************************************************************* #
|
4 |
|
|
-- # BSD 3-Clause License #
|
5 |
|
|
-- # #
|
6 |
|
|
-- # Copyright (c) 2020, Stephan Nolting. All rights reserved. #
|
7 |
|
|
-- # #
|
8 |
|
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
9 |
|
|
-- # permitted provided that the following conditions are met: #
|
10 |
|
|
-- # #
|
11 |
|
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
12 |
|
|
-- # conditions and the following disclaimer. #
|
13 |
|
|
-- # #
|
14 |
|
|
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
15 |
|
|
-- # conditions and the following disclaimer in the documentation and/or other materials #
|
16 |
|
|
-- # provided with the distribution. #
|
17 |
|
|
-- # #
|
18 |
|
|
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
19 |
|
|
-- # endorse or promote products derived from this software without specific prior written #
|
20 |
|
|
-- # permission. #
|
21 |
|
|
-- # #
|
22 |
|
|
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
23 |
|
|
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
24 |
|
|
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
25 |
|
|
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
26 |
|
|
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
27 |
|
|
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
28 |
|
|
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
29 |
|
|
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
30 |
|
|
-- # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
31 |
|
|
-- # ********************************************************************************************* #
|
32 |
|
|
-- # The NEO430 Processor - https://github.com/stnolting/neo430 #
|
33 |
|
|
-- #################################################################################################
|
34 |
|
|
|
35 |
|
|
library ieee;
|
36 |
|
|
use ieee.std_logic_1164.all;
|
37 |
|
|
use ieee.numeric_std.all;
|
38 |
|
|
|
39 |
|
|
library neo430;
|
40 |
|
|
use neo430.neo430_package.all;
|
41 |
|
|
|
42 |
|
|
entity neo430_top_std_logic is
|
43 |
|
|
generic (
|
44 |
|
|
-- general configuration --
|
45 |
|
|
CLOCK_SPEED : natural := 100000000; -- main clock in Hz
|
46 |
|
|
IMEM_SIZE : natural := 4*1024; -- internal IMEM size in bytes, max 48kB (default=4kB)
|
47 |
|
|
DMEM_SIZE : natural := 2*1024; -- internal DMEM size in bytes, max 12kB (default=2kB)
|
48 |
|
|
-- additional configuration --
|
49 |
|
|
USER_CODE : std_logic_vector(15 downto 0) := x"0000"; -- custom user code
|
50 |
|
|
-- module configuration --
|
51 |
|
|
MULDIV_USE : boolean := true; -- implement multiplier/divider unit? (default=true)
|
52 |
|
|
WB32_USE : boolean := true; -- implement WB32 unit? (default=true)
|
53 |
|
|
WDT_USE : boolean := true; -- implement WDT? (default=true)
|
54 |
|
|
GPIO_USE : boolean := true; -- implement GPIO unit? (default=true)
|
55 |
|
|
TIMER_USE : boolean := true; -- implement timer? (default=true)
|
56 |
|
|
UART_USE : boolean := true; -- implement UART? (default=true)
|
57 |
|
|
CRC_USE : boolean := true; -- implement CRC unit? (default=true)
|
58 |
|
|
CFU_USE : boolean := false; -- implement custom functions unit? (default=false)
|
59 |
|
|
PWM_USE : boolean := true; -- implement PWM controller?
|
60 |
|
|
TWI_USE : boolean := true; -- implement two wire serial interface? (default=true)
|
61 |
|
|
SPI_USE : boolean := true; -- implement SPI? (default=true)
|
62 |
|
|
TRNG_USE : boolean := false; -- implement TRNG? (default=false)
|
63 |
|
|
EXIRQ_USE : boolean := true; -- implement EXIRQ? (default=true)
|
64 |
|
|
FREQ_GEN_USE : boolean := true; -- implement FREQ_GEN? (default=true)
|
65 |
|
|
-- boot configuration --
|
66 |
|
|
BOOTLD_USE : boolean := true; -- implement and use bootloader? (default=true)
|
67 |
|
|
IMEM_AS_ROM : boolean := false -- implement IMEM as read-only memory? (default=false)
|
68 |
|
|
);
|
69 |
|
|
port (
|
70 |
|
|
-- global control --
|
71 |
|
|
clk_i : in std_logic; -- global clock, rising edge
|
72 |
|
|
rst_i : in std_logic; -- global reset, async, low-active
|
73 |
|
|
-- gpio --
|
74 |
|
|
gpio_o : out std_logic_vector(15 downto 0); -- parallel output
|
75 |
|
|
gpio_i : in std_logic_vector(15 downto 0); -- parallel input
|
76 |
|
|
-- pwm channels --
|
77 |
|
|
pwm_o : out std_logic_vector(03 downto 0); -- pwm channels
|
78 |
|
|
-- arbitrary frequency generator --
|
79 |
|
|
freq_gen_o : out std_logic_vector(02 downto 0); -- programmable frequency output
|
80 |
|
|
-- serial com --
|
81 |
|
|
uart_txd_o : out std_logic; -- UART send data
|
82 |
|
|
uart_rxd_i : in std_logic; -- UART receive data
|
83 |
|
|
spi_sclk_o : out std_logic; -- serial clock line
|
84 |
|
|
spi_mosi_o : out std_logic; -- serial data line out
|
85 |
|
|
spi_miso_i : in std_logic; -- serial data line in
|
86 |
|
|
spi_cs_o : out std_logic_vector(05 downto 0); -- SPI CS
|
87 |
|
|
twi_sda_io : inout std_logic; -- twi serial data line
|
88 |
|
|
twi_scl_io : inout std_logic; -- twi serial clock line
|
89 |
|
|
-- 32-bit wishbone interface --
|
90 |
|
|
wb_adr_o : out std_logic_vector(31 downto 0); -- address
|
91 |
|
|
wb_dat_i : in std_logic_vector(31 downto 0); -- read data
|
92 |
|
|
wb_dat_o : out std_logic_vector(31 downto 0); -- write data
|
93 |
|
|
wb_we_o : out std_logic; -- read/write
|
94 |
|
|
wb_sel_o : out std_logic_vector(03 downto 0); -- byte enable
|
95 |
|
|
wb_stb_o : out std_logic; -- strobe
|
96 |
|
|
wb_cyc_o : out std_logic; -- valid cycle
|
97 |
|
|
wb_ack_i : in std_logic; -- transfer acknowledge
|
98 |
|
|
-- external interrupts --
|
99 |
|
|
ext_irq_i : in std_logic_vector(07 downto 0); -- external interrupt request lines
|
100 |
|
|
ext_ack_o : out std_logic_vector(07 downto 0) -- external interrupt request acknowledges
|
101 |
|
|
);
|
102 |
|
|
end neo430_top_std_logic;
|
103 |
|
|
|
104 |
|
|
architecture neo430_top_std_logic_rtl of neo430_top_std_logic is
|
105 |
|
|
|
106 |
|
|
-- other signals for conversion --
|
107 |
|
|
constant usrcode_c : std_ulogic_vector(15 downto 0) := std_ulogic_vector(USER_CODE);
|
108 |
|
|
signal clk_i_int : std_ulogic;
|
109 |
|
|
signal rst_i_int : std_ulogic;
|
110 |
|
|
signal gpio_o_int : std_ulogic_vector(15 downto 0);
|
111 |
|
|
signal gpio_i_int : std_ulogic_vector(15 downto 0);
|
112 |
|
|
signal pwm_o_int : std_ulogic_vector(03 downto 0);
|
113 |
|
|
signal uart_txd_o_int : std_ulogic;
|
114 |
|
|
signal uart_rxd_i_int : std_ulogic;
|
115 |
|
|
signal spi_sclk_o_int : std_ulogic;
|
116 |
|
|
signal spi_mosi_o_int : std_ulogic;
|
117 |
|
|
signal spi_miso_i_int : std_ulogic;
|
118 |
|
|
signal spi_cs_o_int : std_ulogic_vector(05 downto 0);
|
119 |
|
|
signal irq_i_int : std_ulogic_vector(07 downto 0);
|
120 |
|
|
signal irq_ack_o_int : std_ulogic_vector(07 downto 0);
|
121 |
|
|
signal wb_adr_o_int : std_ulogic_vector(31 downto 0);
|
122 |
|
|
signal wb_dat_i_int : std_ulogic_vector(31 downto 0);
|
123 |
|
|
signal wb_dat_o_int : std_ulogic_vector(31 downto 0);
|
124 |
|
|
signal wb_we_o_int : std_ulogic;
|
125 |
|
|
signal wb_sel_o_int : std_ulogic_vector(03 downto 0);
|
126 |
|
|
signal wb_stb_o_int : std_ulogic;
|
127 |
|
|
signal wb_cyc_o_int : std_ulogic;
|
128 |
|
|
signal wb_ack_i_int : std_ulogic;
|
129 |
|
|
signal freq_gen_o_int : std_ulogic_vector(02 downto 0);
|
130 |
|
|
|
131 |
|
|
begin
|
132 |
|
|
|
133 |
|
|
-- CPU ----------------------------------------------------------------------
|
134 |
|
|
-- -----------------------------------------------------------------------------
|
135 |
|
|
neo430_top_inst: neo430_top
|
136 |
|
|
generic map (
|
137 |
|
|
-- general configuration --
|
138 |
|
|
CLOCK_SPEED => CLOCK_SPEED, -- main clock in Hz
|
139 |
|
|
IMEM_SIZE => IMEM_SIZE, -- internal IMEM size in bytes, max 48kB (default=4kB)
|
140 |
|
|
DMEM_SIZE => DMEM_SIZE, -- internal DMEM size in bytes, max 12kB (default=2kB)
|
141 |
|
|
-- additional configuration --
|
142 |
|
|
USER_CODE => usrcode_c, -- custom user code
|
143 |
|
|
-- module configuration --
|
144 |
|
|
MULDIV_USE => MULDIV_USE, -- implement multiplier/divider unit? (default=true)
|
145 |
|
|
WB32_USE => WB32_USE, -- implement WB32 unit? (default=true)
|
146 |
|
|
WDT_USE => WDT_USE, -- implement WDT? (default=true)
|
147 |
|
|
GPIO_USE => GPIO_USE, -- implement GPIO unit? (default=true)
|
148 |
|
|
TIMER_USE => TIMER_USE, -- implement timer? (default=true)
|
149 |
|
|
UART_USE => UART_USE, -- implement UART? (default=true)
|
150 |
|
|
CRC_USE => CRC_USE, -- implement CRC unit? (default=true)
|
151 |
|
|
CFU_USE => CFU_USE, -- implement CF unit? (default=false)
|
152 |
|
|
PWM_USE => PWM_USE, -- implement PWM controller? (default=true)
|
153 |
|
|
TWI_USE => TWI_USE, -- implement two wire serial interface? (default=true)
|
154 |
|
|
SPI_USE => SPI_USE, -- implement SPI? (default=true)
|
155 |
|
|
TRNG_USE => TRNG_USE, -- implement TRNG? (default=false)
|
156 |
|
|
EXIRQ_USE => EXIRQ_USE, -- implement EXIRQ? (default=true)
|
157 |
|
|
FREQ_GEN_USE => FREQ_GEN_USE, -- implement FREQ_GEN? (default=true)
|
158 |
|
|
-- boot configuration --
|
159 |
|
|
BOOTLD_USE => BOOTLD_USE, -- implement and use bootloader? (default=true)
|
160 |
|
|
IMEM_AS_ROM => IMEM_AS_ROM -- implement IMEM as read-only memory? (default=false)
|
161 |
|
|
)
|
162 |
|
|
port map (
|
163 |
|
|
-- global control --
|
164 |
|
|
clk_i => clk_i_int, -- global clock, rising edge
|
165 |
|
|
rst_i => rst_i_int, -- global reset, async, low-active
|
166 |
|
|
-- parallel io --
|
167 |
|
|
gpio_o => gpio_o_int, -- parallel output
|
168 |
|
|
gpio_i => gpio_i_int, -- parallel input
|
169 |
|
|
-- pwm channels --
|
170 |
|
|
pwm_o => pwm_o_int, -- pwm channels
|
171 |
|
|
-- arbitrary frequency generator --
|
172 |
|
|
freq_gen_o => freq_gen_o_int, -- programmable frequency output
|
173 |
|
|
-- serial com --
|
174 |
|
|
uart_txd_o => uart_txd_o_int, -- UART send data
|
175 |
|
|
uart_rxd_i => uart_rxd_i_int, -- UART receive data
|
176 |
|
|
spi_sclk_o => spi_sclk_o_int, -- serial clock line
|
177 |
|
|
spi_mosi_o => spi_mosi_o_int, -- serial data line out
|
178 |
|
|
spi_miso_i => spi_miso_i_int, -- serial data line in
|
179 |
|
|
spi_cs_o => spi_cs_o_int, -- SPI CS 0..7
|
180 |
|
|
twi_sda_io => twi_sda_io, -- twi serial data line
|
181 |
|
|
twi_scl_io => twi_scl_io, -- twi serial clock line
|
182 |
|
|
-- 32-bit wishbone interface --
|
183 |
|
|
wb_adr_o => wb_adr_o_int, -- address
|
184 |
|
|
wb_dat_i => wb_dat_i_int, -- read data
|
185 |
|
|
wb_dat_o => wb_dat_o_int, -- write data
|
186 |
|
|
wb_we_o => wb_we_o_int, -- read/write
|
187 |
|
|
wb_sel_o => wb_sel_o_int, -- byte enable
|
188 |
|
|
wb_stb_o => wb_stb_o_int, -- strobe
|
189 |
|
|
wb_cyc_o => wb_cyc_o_int, -- valid cycle
|
190 |
|
|
wb_ack_i => wb_ack_i_int, -- transfer acknowledge
|
191 |
|
|
-- interrupts --
|
192 |
|
|
ext_irq_i => irq_i_int, -- external interrupt request line
|
193 |
|
|
ext_ack_o => irq_ack_o_int -- external interrupt request acknowledge
|
194 |
|
|
);
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
-- Type Conversion ----------------------------------------------------------
|
198 |
|
|
-- -----------------------------------------------------------------------------
|
199 |
|
|
clk_i_int <= std_ulogic(clk_i);
|
200 |
|
|
rst_i_int <= std_ulogic(rst_i);
|
201 |
|
|
gpio_i_int <= std_ulogic_vector(gpio_i);
|
202 |
|
|
uart_rxd_i_int <= std_ulogic(uart_rxd_i);
|
203 |
|
|
spi_miso_i_int <= std_ulogic(spi_miso_i);
|
204 |
|
|
wb_dat_i_int <= std_ulogic_vector(wb_dat_i);
|
205 |
|
|
wb_ack_i_int <= std_ulogic(wb_ack_i);
|
206 |
|
|
irq_i_int <= std_ulogic_vector(ext_irq_i);
|
207 |
|
|
|
208 |
|
|
gpio_o <= std_logic_vector(gpio_o_int);
|
209 |
|
|
pwm_o <= std_logic_vector(pwm_o_int);
|
210 |
|
|
uart_txd_o <= std_logic(uart_txd_o_int);
|
211 |
|
|
spi_sclk_o <= std_logic(spi_sclk_o_int);
|
212 |
|
|
spi_mosi_o <= std_logic(spi_mosi_o_int);
|
213 |
|
|
spi_cs_o <= std_logic_vector(spi_cs_o_int);
|
214 |
|
|
wb_adr_o <= std_logic_vector(wb_adr_o_int);
|
215 |
|
|
wb_dat_o <= std_logic_vector(wb_dat_o_int);
|
216 |
|
|
wb_we_o <= std_logic(wb_we_o_int);
|
217 |
|
|
wb_sel_o <= std_logic_vector(wb_sel_o_int);
|
218 |
|
|
wb_stb_o <= std_logic(wb_stb_o_int);
|
219 |
|
|
wb_cyc_o <= std_logic(wb_cyc_o_int);
|
220 |
|
|
ext_ack_o <= std_logic_vector(irq_ack_o_int);
|
221 |
|
|
freq_gen_o <= std_logic_vector(freq_gen_o_int);
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
end neo430_top_std_logic_rtl;
|