w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
sys_tst_sram_n2.vhd
Go to the documentation of this file.
1-- $Id: sys_tst_sram_n2.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2010-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: sys_tst_sram_n2 - syn
7-- Description: test of nexys2 sram and its controller
8--
9-- Dependencies: vlib/xlib/dcm_sfs
10-- vlib/genlib/clkdivce
11-- bplib/bpgen/bp_rs232_2line_iob
12-- bplib/bpgen/sn_humanio
13-- vlib/rlink/rlink_sp1c
14-- tst_sram
15-- bplib/nxcramlib/nx_cram_memctl_as
16--
17-- Test bench: tb/tb_tst_sram_n2
18--
19-- Target Devices: generic
20-- Tool versions: xst 11.4-14.7; ghdl 0.29-0.33
21--
22-- Synthesized (xst):
23-- Date Rev ise Target flop lutl lutm slic t peri
24-- 2014-12-20 614 14.7 131013 xc3s1200e-4 878 1881 96 1428 t 11.7 ns (85M)
25-- 2014-08-13 581 14.7 131013 xc3s1200e-4 721 1515 64 1119 t 10.5 ns (95M)
26-- 2011-12-21 442 13.1 O40d xc3s1200e-4 721 1510 64 1112 p 10.5 ns (95M)
27-- 2010-12-31 352 12.1 M53d xc3s1200e-4 701 1426 36 901 p 10.5 ns (95M)
28-- 2010-11-27 341 12.1 M53d xc3s1200e-4 674 1387 36 867 p 10.5 ns (95M)
29-- 2010-11-06 336 12.1 M53d xc3s1200e-4 665 1388 36 864 p 18.9 ns
30-- 2010-06-03 300 11.4 L68 xc3s1200e-4 667 1378 36 860 p 15.8 ns
31-- 2010-06-03 299 11.4 L68 xc3s1200e-4 659 1371 18 848 p 15.8 ns
32-- 2010-05-24 294 11.4 L68 xc3s1200e-4 663 1358 18 841 p 15.8 ns
33--
34-- Revision History:
35-- Date Rev Version Comment
36-- 2016-07-10 785 1.5.1 SWI(1) now XON
37-- 2016-07-09 784 1.5 tst_sram with AWIDTH and 22bit support
38-- 2016-03-19 748 1.4.2 define rlink SYSID
39-- 2015-04-11 666 1.4.1 rearrange XON handling
40-- 2014-08-28 588 1.4 use new rlink v4 iface and 4 bit STAT
41-- 2014-08-15 583 1.3 rb_mreq addr now 16 bit
42-- 2011-12-23 444 1.2 remove clksys output hack
43-- 2011-12-21 442 1.1.6 use rlink_sp1c
44-- 2011-11-26 433 1.1.5 use nx_cram_memctl_as now
45-- 2011-11-23 432 1.1.4 now numeric_std clean; update O_FLA_CE_N usage
46-- 2011-11-17 426 1.1.3 use dcm_sfs now
47-- 2011-07-08 390 1.1.2 use now sn_humanio
48-- 2011-07-02 387 1.1.1 use bp_rs232_2line_iob now
49-- 2010-12-31 352 1.1 port to rbv3
50-- 2010-11-27 341 1.0.6 now proper clkdivce handling
51-- 2010-11-22 339 1.0.5 use memctl delays from sys_conf constants
52-- 2010-11-13 338 1.0.4 add DCM and O_CLKSYS (for DCM derived system clock)
53-- 2010-11-06 336 1.0.3 rename input pin CLK -> I_CLK50
54-- 2010-10-23 335 1.0.2 rename RRI_LAM->RB_LAM;
55-- 2010-06-03 300 1.0.1 use default FAWIDTH for rri_core_serport
56-- 2010-05-23 294 1.0 Initial version (derived from sys_tst_sram_s3)
57------------------------------------------------------------------------------
58
59library ieee;
60use ieee.std_logic_1164.all;
61use ieee.numeric_std.all;
62
63use work.slvtypes.all;
64use work.xlib.all;
65use work.genlib.all;
66use work.serportlib.all;
67use work.rblib.all;
68use work.rlinklib.all;
69use work.bpgenlib.all;
70use work.s3boardlib.all;
71use work.nxcramlib.all;
72use work.sys_conf.all;
73
74-- ----------------------------------------------------------------------------
75
76entity sys_tst_sram_n2 is -- top level
77 -- implements nexys2_aif
78 port (
79 I_CLK50 : in slbit; -- 50 MHz board clock
80 I_RXD : in slbit; -- receive data (board view)
81 O_TXD : out slbit; -- transmit data (board view)
82 I_SWI : in slv8; -- n2 switches
83 I_BTN : in slv4; -- n2 buttons
84 O_LED : out slv8; -- n2 leds
85 O_ANO_N : out slv4; -- 7 segment disp: anodes (act.low)
86 O_SEG_N : out slv8; -- 7 segment disp: segments (act.low)
87 O_MEM_CE_N : out slbit; -- cram: chip enable (act.low)
88 O_MEM_BE_N : out slv2; -- cram: byte enables (act.low)
89 O_MEM_WE_N : out slbit; -- cram: write enable (act.low)
90 O_MEM_OE_N : out slbit; -- cram: output enable (act.low)
91 O_MEM_ADV_N : out slbit; -- cram: address valid (act.low)
92 O_MEM_CLK : out slbit; -- cram: clock
93 O_MEM_CRE : out slbit; -- cram: command register enable
94 I_MEM_WAIT : in slbit; -- cram: mem wait
95 O_MEM_ADDR : out slv23; -- cram: address lines
96 IO_MEM_DATA : inout slv16; -- cram: data lines
97 O_FLA_CE_N : out slbit -- flash ce.. (act.low)
98 );
100
101architecture syn of sys_tst_sram_n2 is
102
103 signal CLK : slbit := '0';
104
105 signal CE_USEC : slbit := '0';
106 signal CE_MSEC : slbit := '0';
107
108 signal GBL_RESET : slbit := '0';
109
110 signal RXD : slbit := '1';
111 signal TXD : slbit := '0';
112 signal CTS_N : slbit := '0';
113 signal RTS_N : slbit := '0';
114
115 signal SWI : slv8 := (others=>'0');
116 signal BTN : slv4 := (others=>'0');
117 signal LED : slv8 := (others=>'0');
118 signal DSP_DAT : slv16 := (others=>'0');
119 signal DSP_DP : slv4 := (others=>'0');
120
121 signal RB_MREQ : rb_mreq_type := rb_mreq_init;
122 signal RB_SRES : rb_sres_type := rb_sres_init;
123 signal RB_LAM : slv16 := (others=>'0');
124 signal RB_STAT : slv4 := (others=>'0');
125
126 signal SER_MONI : serport_moni_type := serport_moni_init;
127
128 signal RB_SRES_TST : rb_sres_type := rb_sres_init;
129 signal RB_LAM_TST : slbit := '0';
130
131 signal MEM_RESET : slbit := '0';
132 signal MEM_REQ : slbit := '0';
133 signal MEM_WE : slbit := '0';
134 signal MEM_BUSY : slbit := '0';
135 signal MEM_ACK_R : slbit := '0';
136 signal MEM_ACK_W : slbit := '0';
137 signal MEM_ACT_R : slbit := '0';
138 signal MEM_ACT_W : slbit := '0';
139 signal MEM_ADDR : slv22 := (others=>'0');
140 signal MEM_BE : slv4 := (others=>'0');
141 signal MEM_DI : slv32 := (others=>'0');
142 signal MEM_DO : slv32 := (others=>'0');
143
144 constant sysid_proj : slv16 := x"0104"; -- tst_sram
145 constant sysid_board : slv8 := x"02"; -- nexys2
146 constant sysid_vers : slv8 := x"00";
147
148begin
149
150 DCM : dcm_sfs
151 generic map (
152 CLKFX_DIVIDE => sys_conf_clkfx_divide,
153 CLKFX_MULTIPLY => sys_conf_clkfx_multiply,
154 CLKIN_PERIOD => 20.0)
155 port map (
156 CLKIN => I_CLK50,
157 CLKFX => CLK,
158 LOCKED => open
159 );
160
161 CLKDIV : clkdivce
162 generic map (
163 CDUWIDTH => 7, -- good for up to 127 MHz !
164 USECDIV => sys_conf_clksys_mhz,
165 MSECDIV => 1000)
166 port map (
167 CLK => CLK,
168 CE_USEC => CE_USEC,
170 );
171
172 IOB_RS232 : bp_rs232_2line_iob
173 port map (
174 CLK => CLK,
175 RXD => RXD,
176 TXD => TXD,
177 I_RXD => I_RXD,
178 O_TXD => O_TXD
179 );
180
181 HIO : sn_humanio
182 port map (
183 CLK => CLK,
184 RESET => '0',
185 CE_MSEC => CE_MSEC,
186 SWI => SWI,
187 BTN => BTN,
188 LED => LED,
189 DSP_DAT => DSP_DAT,
190 DSP_DP => DSP_DP,
191 I_SWI => I_SWI,
192 I_BTN => I_BTN,
193 O_LED => O_LED,
194 O_ANO_N => O_ANO_N,
196 );
197
198 RLINK : rlink_sp1c
199 generic map (
200 BTOWIDTH => 6, -- 64 cycles access timeout
201 RTAWIDTH => 12,
202 SYSID => sysid_proj & sysid_board & sysid_vers ,
203 IFAWIDTH => 5, -- 32 word input fifo
204 OFAWIDTH => 5, -- 32 word output fifo
205 ENAPIN_RLMON => sbcntl_sbf_rlmon,
206 ENAPIN_RBMON => sbcntl_sbf_rbmon,
207 CDWIDTH => 13,
208 CDINIT => sys_conf_ser2rri_cdinit,
209 RBMON_AWIDTH => 0,
210 RBMON_RBADDR => x"ffe8")
211 port map (
212 CLK => CLK,
213 CE_USEC => CE_USEC,
214 CE_MSEC => CE_MSEC,
215 CE_INT => CE_MSEC,
216 RESET => GBL_RESET,
217 ENAXON => SWI(1),
218 ESCFILL => '0',
219 RXSD => RXD,
220 TXSD => TXD,
221 CTS_N => CTS_N,
222 RTS_N => RTS_N,
223 RB_MREQ => RB_MREQ,
224 RB_SRES => RB_SRES,
225 RB_LAM => RB_LAM,
226 RB_STAT => RB_STAT,
227 RL_MONI => open,
229 );
230
231 TST : entity work.tst_sram
232 generic map (
233 RB_ADDR => slv(to_unsigned(2#0000000000000000#,16)),
234 AWIDTH => 22)
235 port map (
236 CLK => CLK,
237 RESET => GBL_RESET,
238 RB_MREQ => RB_MREQ,
240 RB_STAT => RB_STAT,
242 SWI => SWI,
243 BTN => BTN,
244 LED => LED,
245 DSP_DAT => DSP_DAT,
247 MEM_REQ => MEM_REQ,
248 MEM_WE => MEM_WE,
255 MEM_BE => MEM_BE,
256 MEM_DI => MEM_DI,
257 MEM_DO => MEM_DO
258 );
259
260 CRAMCTL : nx_cram_memctl_as
261 generic map (
262 READ0DELAY => sys_conf_memctl_read0delay, -- was 2 for 50 MHz
263 READ1DELAY => sys_conf_memctl_read1delay, -- was 2 "
264 WRITEDELAY => sys_conf_memctl_writedelay) -- was 3 "
265 port map (
266 CLK => CLK,
267 RESET => MEM_RESET,
268 REQ => MEM_REQ,
269 WE => MEM_WE,
270 BUSY => MEM_BUSY,
271 ACK_R => MEM_ACK_R,
272 ACK_W => MEM_ACK_W,
273 ACT_R => MEM_ACT_R,
274 ACT_W => MEM_ACT_W,
275 ADDR => MEM_ADDR,
276 BE => MEM_BE,
277 DI => MEM_DI,
278 DO => MEM_DO,
289 );
290
291 O_FLA_CE_N <= '1'; -- keep Flash memory disabled
292
293 RB_SRES <= RB_SRES_TST; -- can be sres_or later...
294 RB_LAM(0) <= RB_LAM_TST;
295
296 DSP_DP(3) <= not SER_MONI.txok;
297 DSP_DP(2) <= SER_MONI.txact;
298 DSP_DP(1) <= not SER_MONI.rxok;
299 DSP_DP(0) <= SER_MONI.rxact;
300
301end syn;
302
out CE_MSEC slbit
Definition: clkdivce.vhd:39
USECDIV positive := 50
Definition: clkdivce.vhd:33
CDUWIDTH positive := 6
Definition: clkdivce.vhd:32
out CE_USEC slbit
Definition: clkdivce.vhd:37
MSECDIV positive := 1000
Definition: clkdivce.vhd:34
in CLK slbit
Definition: clkdivce.vhd:36
CLKFX_DIVIDE positive := 1
in CLKIN slbit
CLKFX_MULTIPLY positive := 1
out LOCKED slbit
CLKIN_PERIOD real := 20.0
out CLKFX slbit
READ0DELAY positive := 4
WRITEDELAY positive := 4
inout IO_MEM_DATA slv16
READ1DELAY positive := 2
Definition: rblib.vhd:32
std_logic_vector( 22 downto 0) slv23
Definition: slvtypes.vhd:56
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 31 downto 0) slv32
Definition: slvtypes.vhd:59
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic_vector( 21 downto 0) slv22
Definition: slvtypes.vhd:55
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector( 1 downto 0) slv2
Definition: slvtypes.vhd:34
std_logic_vector slv
Definition: slvtypes.vhd:31
in DSP_DP slv(( 2** DCWIDTH)- 1 downto 0)
Definition: sn_humanio.vhd:63
out O_LED slv( LWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:66
in DSP_DAT slv( 4*( 2** DCWIDTH)- 1 downto 0)
Definition: sn_humanio.vhd:62
out SWI slv( SWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:59
in I_BTN slv( BWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:65
in I_SWI slv( SWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:64
out O_SEG_N slv8
Definition: sn_humanio.vhd:69
out BTN slv( BWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:60
in CLK slbit
Definition: sn_humanio.vhd:56
out O_ANO_N slv(( 2** DCWIDTH)- 1 downto 0)
Definition: sn_humanio.vhd:67
in LED slv( LWIDTH- 1 downto 0)
Definition: sn_humanio.vhd:61
in RESET slbit := '0'
Definition: sn_humanio.vhd:57
in CE_MSEC slbit
Definition: sn_humanio.vhd:58
slv22 :=( others => '0') MEM_ADDR
slv16 :=( others => '0') DSP_DAT
slv8 :=( others => '0') LED
slv4 :=( others => '0') RB_STAT
slv8 :=( others => '0') SWI
slv32 :=( others => '0') MEM_DI
rb_mreq_type := rb_mreq_init RB_MREQ
serport_moni_type := serport_moni_init SER_MONI
slv32 :=( others => '0') MEM_DO
rb_sres_type := rb_sres_init RB_SRES
slv4 :=( others => '0') DSP_DP
slv8 := x"00" sysid_vers
rb_sres_type := rb_sres_init RB_SRES_TST
slv4 :=( others => '0') BTN
slv16 :=( others => '0') RB_LAM
slv4 :=( others => '0') MEM_BE
slv16 := x"0104" sysid_proj
slv8 := x"02" sysid_board
out O_MEM_WE_N slbit
out O_MEM_CE_N slbit
in I_MEM_WAIT slbit
out O_MEM_OE_N slbit
out O_MEM_CLK slbit
out O_MEM_ADV_N slbit
out O_MEM_ADDR slv23
out O_MEM_BE_N slv2
inout IO_MEM_DATA slv16
out O_FLA_CE_N slbit
out O_MEM_CRE slbit
in MEM_BUSY slbit
Definition: tst_sram.vhd:182
out MEM_DI slv32
Definition: tst_sram.vhd:189
AWIDTH natural := 18
Definition: tst_sram.vhd:167
in RESET slbit
Definition: tst_sram.vhd:170
in MEM_ACK_W slbit
Definition: tst_sram.vhd:184
out MEM_RESET slbit
Definition: tst_sram.vhd:179
out RB_LAM slbit
Definition: tst_sram.vhd:174
in BTN slv4
Definition: tst_sram.vhd:176
out MEM_BE slv4
Definition: tst_sram.vhd:188
out RB_STAT slv4
Definition: tst_sram.vhd:173
in MEM_ACT_W slbit
Definition: tst_sram.vhd:186
in CLK slbit
Definition: tst_sram.vhd:169
RB_ADDR slv16 := slv( to_unsigned( 2#0000000000000000#, 16) )
Definition: tst_sram.vhd:166
out MEM_REQ slbit
Definition: tst_sram.vhd:180
in RB_MREQ rb_mreq_type
Definition: tst_sram.vhd:171
out MEM_ADDR slv( AWIDTH- 1 downto 0)
Definition: tst_sram.vhd:187
in MEM_ACT_R slbit
Definition: tst_sram.vhd:185
in MEM_ACK_R slbit
Definition: tst_sram.vhd:183
out RB_SRES rb_sres_type
Definition: tst_sram.vhd:172
in MEM_DO slv32
Definition: tst_sram.vhd:191
out MEM_WE slbit
Definition: tst_sram.vhd:181
out DSP_DAT slv16
Definition: tst_sram.vhd:178
out LED slv8
Definition: tst_sram.vhd:177
in SWI slv8
Definition: tst_sram.vhd:175
Definition: xlib.vhd:35