1 |
8 |
ja_rd |
--##############################################################################
|
2 |
|
|
-- light52 MCU demo on Avnet's Spartan-3A Evaluation Kit board.
|
3 |
|
|
--##############################################################################
|
4 |
|
|
--
|
5 |
|
|
-- This is a minimal demo of the light52 core targetting Avnet's Spartan-3A
|
6 |
|
|
-- Evaluation Kit board for Xilinx Spartan-3A FPGAs.
|
7 |
|
|
-- This file is strictly for trial purposes and has not been tested.
|
8 |
|
|
--
|
9 |
|
|
-- This demo has been built from a generic template for designs targetting the
|
10 |
|
|
-- same development board. The entity defines all the inputs and outputs present
|
11 |
|
|
-- in the actual board, whether or not they are used in the design at hand.
|
12 |
|
|
--##############################################################################
|
13 |
|
|
|
14 |
|
|
library ieee;
|
15 |
|
|
use ieee.std_logic_1164.all;
|
16 |
|
|
use ieee.numeric_std.all;
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
-- Define the entity outputs as they are connected in the DE-1 development
|
20 |
|
|
-- board. Many of the outputs will be left unused in this demo.
|
21 |
|
|
entity s3aeval_soc is
|
22 |
|
|
port (
|
23 |
|
|
-- ***** Clocks
|
24 |
|
|
CLK_12MHZ : in std_logic;
|
25 |
|
|
CLK_16MHZ : in std_logic;
|
26 |
|
|
CLK_32KHZ : in std_logic;
|
27 |
|
|
|
28 |
|
|
-- ***** Parallel Flash 4MB
|
29 |
|
|
FLASH_A : out std_logic_vector(21 downto 0);
|
30 |
|
|
FLASH_D : inout std_logic_vector(15 downto 0);
|
31 |
|
|
FLASH_BYTEn : out std_logic;
|
32 |
|
|
FLASH_CEn : out std_logic;
|
33 |
|
|
FLASH_OEn : out std_logic;
|
34 |
|
|
FLASH_RESETn : out std_logic;
|
35 |
|
|
FLASH_RY_BYn : out std_logic;
|
36 |
|
|
FLASH_WEn : out std_logic;
|
37 |
|
|
|
38 |
|
|
-- ***** Serial flash
|
39 |
|
|
FPGA_MOSI : in std_logic;
|
40 |
|
|
FPGA_SPI_SELn : in std_logic;
|
41 |
|
|
SF_HOLDn : in std_logic;
|
42 |
|
|
SF_Wn : in std_logic;
|
43 |
|
|
SPI_CLK : in std_logic;
|
44 |
|
|
--FLASH_D00 : inout std_logic;
|
45 |
|
|
|
46 |
|
|
-- ***** User I/O
|
47 |
|
|
FPGA_RESET : in std_logic;
|
48 |
|
|
FPGA_PUSH_A : in std_logic;
|
49 |
|
|
FPGA_PUSH_B : in std_logic;
|
50 |
|
|
FPGA_PUSH_C : in std_logic;
|
51 |
|
|
LEDS : out std_logic_vector(3 downto 0);
|
52 |
|
|
|
53 |
|
|
-- ***** I2C
|
54 |
|
|
IIC_SCL : in std_logic;
|
55 |
|
|
IIC_SDA : in std_logic;
|
56 |
|
|
|
57 |
|
|
-- ***** PSoC
|
58 |
|
|
PSOC_P0_4 : in std_logic;
|
59 |
|
|
PSOC_P2_1 : in std_logic;
|
60 |
|
|
PSOC_P2_3 : in std_logic;
|
61 |
|
|
PSOC_P2_5 : in std_logic;
|
62 |
|
|
PSOC_P2_7 : in std_logic;
|
63 |
|
|
PSOC_P4_6 : in std_logic;
|
64 |
|
|
PSOC_P5_3 : in std_logic;
|
65 |
|
|
PSOC_P5_4 : in std_logic;
|
66 |
|
|
PSOC_P5_6 : in std_logic;
|
67 |
|
|
PSOC_P5_7 : in std_logic;
|
68 |
|
|
PSOC_P7_0 : in std_logic;
|
69 |
|
|
PSOC_P7_7 : in std_logic;
|
70 |
|
|
|
71 |
|
|
-- ***** RS-232
|
72 |
|
|
uart_rxd : in std_logic;
|
73 |
|
|
uart_txd : out std_logic;
|
74 |
|
|
|
75 |
|
|
-- ***** Digi Headers
|
76 |
|
|
DIGI1 : inout std_logic_vector(3 downto 0);
|
77 |
|
|
DIGI2 : inout std_logic_vector(3 downto 0);
|
78 |
|
|
|
79 |
|
|
-- ***** GPIO
|
80 |
|
|
BANK0_IO : inout std_logic_vector(32 downto 1);
|
81 |
|
|
BANK1_IO : inout std_logic_vector(1 downto 1);
|
82 |
|
|
BANK2_IO : inout std_logic_vector(2 downto 1)
|
83 |
|
|
);
|
84 |
|
|
end s3aeval_soc;
|
85 |
|
|
|
86 |
|
|
architecture minimal of s3aeval_soc is
|
87 |
|
|
|
88 |
|
|
-- light52 MCU signals ---------------------------------------------------------
|
89 |
|
|
signal p0_out : std_logic_vector(7 downto 0);
|
90 |
|
|
signal p1_out : std_logic_vector(7 downto 0);
|
91 |
|
|
signal p2_in : std_logic_vector(7 downto 0);
|
92 |
|
|
signal p3_in : std_logic_vector(7 downto 0);
|
93 |
|
|
signal external_irq : std_logic_vector(7 downto 0);
|
94 |
|
|
signal reset : std_logic;
|
95 |
|
|
signal clk : std_logic;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
begin
|
99 |
|
|
|
100 |
|
|
-- The clock comes from the on-board oscillator. We need no speed so we
|
101 |
|
|
-- won't instantiate a DCM.
|
102 |
|
|
clk <= clk_16MHz;
|
103 |
|
|
|
104 |
|
|
-- SOC instantiation
|
105 |
|
|
mcu: entity work.light52_mcu
|
106 |
|
|
generic map (
|
107 |
|
|
-- Memory size is defined in package obj_code_pkg...
|
108 |
|
|
CODE_ROM_SIZE => work.obj_code_pkg.XCODE_SIZE,
|
109 |
|
|
XDATA_RAM_SIZE => work.obj_code_pkg.XDATA_SIZE,
|
110 |
|
|
-- ...as is the object code initialization constant.
|
111 |
|
|
OBJ_CODE => work.obj_code_pkg.object_code,
|
112 |
|
|
-- Leave BCD opcodes disabled.
|
113 |
|
|
IMPLEMENT_BCD_INSTRUCTIONS => true,
|
114 |
|
|
-- UART baud rate isn't programmable in run time.
|
115 |
|
|
UART_HARDWIRED => true,
|
116 |
|
|
-- We're using the 16MHz clock of the Avnet S3A board.
|
117 |
|
|
CLOCK_RATE => 16e6
|
118 |
|
|
)
|
119 |
|
|
port map (
|
120 |
|
|
clk => clk,
|
121 |
|
|
reset => reset,
|
122 |
|
|
|
123 |
|
|
txd => uart_txd,
|
124 |
|
|
rxd => uart_rxd,
|
125 |
|
|
|
126 |
|
|
external_irq => external_irq,
|
127 |
|
|
|
128 |
|
|
p0_out => p0_out,
|
129 |
|
|
p1_out => p1_out,
|
130 |
|
|
p2_in => p2_in,
|
131 |
|
|
p3_in => p3_in
|
132 |
|
|
);
|
133 |
|
|
|
134 |
|
|
-- The CPU reset input will be wired straight to the PSoC-controlled
|
135 |
|
|
-- capacitive button labelled 'reset'. This is a recipe for faulty resets
|
136 |
|
|
-- but it will do for the first quick tests.
|
137 |
|
|
reset <= FPGA_RESET;
|
138 |
|
|
|
139 |
|
|
p2_in <= "00000" & FPGA_PUSH_C & FPGA_PUSH_B & FPGA_PUSH_A;
|
140 |
|
|
p3_in <= p1_out;
|
141 |
|
|
|
142 |
|
|
LEDS <= p1_out(3 downto 0);
|
143 |
|
|
|
144 |
|
|
-- The parallel flash is not used so leave its interface inactive.
|
145 |
|
|
FLASH_A <= (others => '0');
|
146 |
|
|
FLASH_D <= (others => 'Z');
|
147 |
|
|
FLASH_BYTEn <= '1';
|
148 |
|
|
FLASH_CEn <= '1';
|
149 |
|
|
FLASH_OEn <= '1';
|
150 |
|
|
FLASH_RESETn <= '1';
|
151 |
|
|
FLASH_RY_BYn <= '1';
|
152 |
|
|
FLASH_WEn <= '1';
|
153 |
|
|
|
154 |
|
|
-- FIXME he board has some other peripheral devices which are not accounted
|
155 |
|
|
-- for; there will be plenty of warnings.
|
156 |
|
|
|
157 |
|
|
end minimal;
|