w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
migui2bram.vhd
Go to the documentation of this file.
1-- $Id: migui2bram.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2018- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: migui2bram - sim
7-- Description: MIG to BRAM adapter
8--
9-- Dependencies: xlib/s7_cmt_sfs
10-- memlib/ram_1swsr_wfirst_gen
11-- cdclib/cdc_signal_s1_as
12-- Test bench: -
13-- Target Devices: 7-Series
14-- Tool versions: viv 2017.2; ghdl 0.34
15--
16-- Revision History:
17-- Date Rev Version Comment
18-- 2018-12-28 1096 1.0 Initial version
19-- 2018-11-10 1067 0.1 First draft
20--
21------------------------------------------------------------------------------
22
23library ieee;
24use ieee.std_logic_1164.all;
25use ieee.numeric_std.all;
26
27use work.slvtypes.all;
28use work.memlib.all;
29use work.cdclib.all;
30use work.xlib.all;
31
32entity migui2bram is -- MIG to BRAM adapter
33 generic (
34 BAWIDTH : positive := 4; -- byte address width
35 MAWIDTH : positive := 28; -- memory address width
36 RAWIDTH : positive := 19; -- BRAM memory address width
37 RDELAY : positive := 5; -- read response delay
38 CLKMUI_MUL : positive := 6; -- multiplier for MIGUI clock
39 CLKMUI_DIV : positive := 12; -- divider for MIGUI clock
40 CLKMSYS_PERIOD : real := 6.000); -- MIG SYS_CLK period
41 port (
42 SYS_CLK : in slbit; -- system clock
43 SYS_RST : in slbit; -- system reset
44 UI_CLK : out slbit; -- MIGUI clock
45 UI_CLK_SYNC_RST : out slbit; -- MIGUI reset
46 INIT_CALIB_COMPLETE : out slbit; -- MIGUI calibration done
47 APP_RDY : out slbit; -- MIGUI ready for cmd
48 APP_EN : in slbit; -- MIGUI command enable
49 APP_CMD : in slv3; -- MIGUI command
50 APP_ADDR : in slv(MAWIDTH-1 downto 0); -- MIGUI address
51 APP_WDF_RDY : out slbit; -- MIGUI ready for data write
52 APP_WDF_WREN : in slbit; -- MIGUI data write enable
53 APP_WDF_DATA : in slv(8*(2**BAWIDTH)-1 downto 0);-- MIGUI write data
54 APP_WDF_MASK : in slv((2**BAWIDTH)-1 downto 0); -- MIGUI write mask
55 APP_WDF_END : in slbit; -- MIGUI write end
56 APP_RD_DATA_VALID : out slbit; -- MIGUI read valid
57 APP_RD_DATA : out slv(8*(2**BAWIDTH)-1 downto 0);-- MIGUI read data
58 APP_RD_DATA_END : out slbit -- MIGUI read end
59 );
60end migui2bram;
61
62
63architecture syn of migui2bram is
64
65 constant mwidth : positive := 2**BAWIDTH; -- mask width (8 or 16)
66
67 signal CLKFX : slbit := '0';
68 signal CLK : slbit := '0'; -- local copy of UI_CLK
69 signal R_RDVAL : slv(RDELAY downto 0) := (others=>'0');
70
71 signal LOCKED : slbit := '0'; -- raw from mmcm
72 signal LOCKED_UICLK : slbit := '0'; -- sync'ed to UI_CLK
73
74
75begin
76
77 assert BAWIDTH = 3 or BAWIDTH = 4
78 report "assert( BAWIDTH = 3 or 4 )"
79 severity failure;
80
81 GEN_CLKMUI : s7_cmt_sfs -- ui clock ------------
82 generic map (
83 VCO_DIVIDE => 1,
84 VCO_MULTIPLY => CLKMUI_MUL,
85 OUT_DIVIDE => CLKMUI_DIV,
86 CLKIN_PERIOD => CLKMSYS_PERIOD,
87 CLKIN_JITTER => 0.01,
88 STARTUP_WAIT => false,
89 GEN_TYPE => "MMCM")
90 port map (
91 CLKIN => SYS_CLK,
92 CLKFX => CLKFX,
93 LOCKED => LOCKED
94 );
95
96 CLK <= CLKFX; -- !! copy both local CLK and exported
97 UI_CLK <= CLKFX; -- !! UI_CLK to avoid delta cycle diff
98
99 CDC_LOCKED : cdc_signal_s1_as
100 port map (
101 CLKO => CLK,
102 DI => LOCKED,
104 );
105
106 MARRAY: for col in mwidth-1 downto 0 generate
107 signal MEM_WE : slbit := '0';
108 begin
109 MEM_WE <= APP_WDF_WREN and not APP_WDF_MASK(col); -- WE = not MASK !
111 generic map (
113 DWIDTH => 8) -- byte wide
114 port map (
115 CLK => CLK,
116 EN => APP_EN,
117 WE => MEM_WE,
118 ADDR => APP_ADDR(RAWIDTH-1 downto BAWIDTH),
119 DI => APP_WDF_DATA(8*col+7 downto 8*col),
120 DO => APP_RD_DATA(8*col+7 downto 8*col)
121 );
122 end generate MARRAY;
123
126
127 APP_RDY <= '1';
128 APP_WDF_RDY <= '1';
129
130 proc_regs: process (CLK)
131 begin
132
133 if rising_edge(CLK) then
134 if SYS_RST = '1' then
135 R_RDVAL <= (others=>'0');
136 else
137 R_RDVAL(0) <= APP_EN and not APP_WDF_WREN;
138 R_RDVAL(RDELAY downto 1) <= R_RDVAL(RDELAY-1 downto 0);
139 end if;
140 end if;
141
142 end process proc_regs;
143
146
147-- synthesis translate_off
148
149 proc_moni: process (CLK)
150 begin
151 if rising_edge(CLK) then
152 if SYS_RST = '0' then
153 if APP_EN = '1' then
154 assert unsigned(APP_ADDR(MAWIDTH-1 downto RAWIDTH)) = 0
155 report "migui2bram: FAIL: out of memory size access"
156 severity error;
157 else
158 assert APP_WDF_WREN = '0'
159 report "migui2bram: FAIL: APP_WDF_WREN=1 when APP_EN=0"
160 severity error;
161 end if;
163 report "migui2bram: FAIL: APP_WDF_WREN /= APP_WDF_END"
164 severity error;
165 end if;
166 end if;
167 end process proc_moni;
168
169-- synthesis translate_on
170
171end syn;
slbit := '0' MEM_WE
Definition: migui2bram.vhd:107
positive := 2** BAWIDTH mwidth
Definition: migui2bram.vhd:65
slbit := '0' CLKFX
Definition: migui2bram.vhd:67
slbit := '0' CLK
Definition: migui2bram.vhd:68
slbit := '0' LOCKED_UICLK
Definition: migui2bram.vhd:72
slv( RDELAY downto 0) :=( others => '0') R_RDVAL
Definition: migui2bram.vhd:69
slbit := '0' LOCKED
Definition: migui2bram.vhd:71
MAWIDTH positive := 28
Definition: migui2bram.vhd:35
out UI_CLK slbit
Definition: migui2bram.vhd:44
out APP_RDY slbit
Definition: migui2bram.vhd:47
out APP_RD_DATA_VALID slbit
Definition: migui2bram.vhd:56
out APP_RD_DATA_END slbit
Definition: migui2bram.vhd:59
in APP_WDF_MASK slv(( 2** BAWIDTH)- 1 downto 0)
Definition: migui2bram.vhd:54
in SYS_CLK slbit
Definition: migui2bram.vhd:42
CLKMSYS_PERIOD real := 6.000
Definition: migui2bram.vhd:40
CLKMUI_MUL positive := 6
Definition: migui2bram.vhd:38
in APP_WDF_DATA slv( 8*( 2** BAWIDTH)- 1 downto 0)
Definition: migui2bram.vhd:53
in APP_WDF_END slbit
Definition: migui2bram.vhd:55
RDELAY positive := 5
Definition: migui2bram.vhd:37
out INIT_CALIB_COMPLETE slbit
Definition: migui2bram.vhd:46
out APP_RD_DATA slv( 8*( 2** BAWIDTH)- 1 downto 0)
Definition: migui2bram.vhd:57
in SYS_RST slbit
Definition: migui2bram.vhd:43
RAWIDTH positive := 19
Definition: migui2bram.vhd:36
out APP_WDF_RDY slbit
Definition: migui2bram.vhd:51
CLKMUI_DIV positive := 12
Definition: migui2bram.vhd:39
in APP_WDF_WREN slbit
Definition: migui2bram.vhd:52
in APP_EN slbit
Definition: migui2bram.vhd:48
in APP_ADDR slv( MAWIDTH- 1 downto 0)
Definition: migui2bram.vhd:50
in APP_CMD slv3
Definition: migui2bram.vhd:49
BAWIDTH positive := 4
Definition: migui2bram.vhd:34
out UI_CLK_SYNC_RST slbit
Definition: migui2bram.vhd:45
in ADDR slv( AWIDTH- 1 downto 0)
out DO slv( DWIDTH- 1 downto 0)
in DI slv( DWIDTH- 1 downto 0)
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31
Definition: xlib.vhd:35