w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ibd_m9312.vhd
Go to the documentation of this file.
1-- $Id: ibd_m9312.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ibd_m9312 - syn
7-- Description: ibus dev: M9312
8--
9-- Dependencies: memlib/ram_1swsr_wfirst_gen
10-- Test bench: -
11-- Target Devices: generic
12-- Tool versions: ise 14.7; viv 2017.2; ghdl 0.35
13--
14-- Revision History:
15-- Date Rev Version Comment
16-- 2019-04-28 1142 1.0 Initial version
17------------------------------------------------------------------------------
18
19
20library ieee;
21use ieee.std_logic_1164.all;
22use ieee.numeric_std.all;
23
24use work.slvtypes.all;
25use work.memlib.all;
26use work.iblib.all;
27
28-- ----------------------------------------------------------------------------
29entity ibd_m9312 is -- ibus dev: M9312
30 -- fixed address: 165***,173***
31 port (
32 CLK : in slbit; -- clock
33 RESET : in slbit; -- system reset
34 IB_MREQ : in ib_mreq_type; -- ibus request
35 IB_SRES : out ib_sres_type -- ibus response
36 );
37end ibd_m9312;
38
39architecture syn of ibd_m9312 is
40 -- 1 111 110 000 000 000
41 -- 5 432 109 876 543 210
42 -- Note: LO-ROM addr is 165xxx: 1 110 101 xxx xxx xx0
43 -- HI-ROM addr is 173xxx: 1 111 011 xxx xxx xx0
44 -- --> addr(12) is 0 for LO and 1 for HI
45 constant ibaddr_m9312_lo : slv16 := slv(to_unsigned(8#165000#,16));
46 constant ibaddr_m9312_hi : slv16 := slv(to_unsigned(8#173000#,16));
47
48 constant csr_ibf_locwe : integer := 7;
49 constant csr_ibf_enahi : integer := 1;
50 constant csr_ibf_enalo : integer := 0;
51
52 type regs_type is record -- state registers
53 ibselcsr : slbit; -- ibus select csr: LO-ROM(0)
54 ibselmem : slbit; -- ibus select mem: LO-ROM or HI-ROM
55 locwe : slbit; -- write enable for loc access
56 enahi : slbit; -- HI-ROM loc visible
57 enalo : slbit; -- LO-ROM loc visible
58 end record regs_type;
59
60 constant regs_init : regs_type := (
61 '0','0', -- ibselcsr,ibselmem
62 '0', -- locwe
63 '0','0' -- enahi,enalo
64 );
65
68
69 signal BRAM_WE : slbit := '0';
70 signal BRAM_DO : slv16 := (others=>'0');
71 signal BRAM_ADDR : slv9 := (others=>'0');
72
73begin
74
76 generic map (
77 AWIDTH => 9,
78 DWIDTH => 16)
79 port map (
80 CLK => CLK,
81 EN => '1',
82 WE => BRAM_WE,
83 ADDR => BRAM_ADDR,
84 DI => IB_MREQ.din,
85 DO => BRAM_DO
86 );
87
88 BRAM_ADDR <= IB_MREQ.addr(12) & IB_MREQ.addr(8 downto 1);
89
90 proc_regs: process (CLK)
91 begin
92 if rising_edge(CLK) then
93 if RESET = '1' then
95 else
96 R_REGS <= N_REGS;
97 end if;
98 end if;
99 end process proc_regs;
100
101 proc_next : process (R_REGS, IB_MREQ, BRAM_DO)
102 variable r : regs_type := regs_init;
103 variable n : regs_type := regs_init;
104 variable idout : slv16 := (others=>'0');
105 variable ibreq : slbit := '0';
106 variable iback : slbit := '0';
107 variable imemwe : slbit := '0';
108 begin
109
110 r := R_REGS;
111 n := R_REGS;
112
113 idout := (others=>'0');
114 ibreq := IB_MREQ.re or IB_MREQ.we;
115 iback := '0';
116 imemwe := '0';
117
118 -- ibus address decoder
119 n.ibselcsr := '0';
120 n.ibselmem := '0';
121 if IB_MREQ.aval='1' then
122 if IB_MREQ.addr(12 downto 1)=ibaddr_m9312_lo(12 downto 1) then
123 n.ibselcsr := '1';
124 end if;
125 if IB_MREQ.addr(12 downto 9)=ibaddr_m9312_lo(12 downto 9) or
126 IB_MREQ.addr(12 downto 9)=ibaddr_m9312_hi(12 downto 9) then
127 n.ibselmem := '1';
128 end if;
129 end if;
130
131 -- ibus transactions
132 if IB_MREQ.racc = '1' then -- rem side --------------------------
133 if r.ibselcsr = '1' then -- csr access
134 idout(csr_ibf_locwe) := r.locwe;
135 idout(csr_ibf_enahi) := r.enahi;
136 idout(csr_ibf_enalo) := r.enalo;
137 if IB_MREQ.we = '1' then
138 n.locwe := IB_MREQ.din(csr_ibf_locwe);
139 n.enahi := IB_MREQ.din(csr_ibf_enahi);
140 n.enalo := IB_MREQ.din(csr_ibf_enalo);
141 end if;
142 iback := ibreq;
143 end if;
144
145 else -- loc side --------------------------
146 if r.ibselmem = '1' then -- mem access
147 idout := BRAM_DO;
148 if IB_MREQ.re = '1' then -- read request
149 if IB_MREQ.addr(12) = '0' then -- LO-ROM
150 iback := r.enalo; -- ack if enabled
151 else -- HI-ROM
152 iback := r.enahi; -- ack if enabled
153 end if;
154 elsif IB_MREQ.we = '1' then -- write request
155 iback := r.locwe;
156 imemwe := r.locwe;
157 end if;
158 end if;
159 end if; -- IB_MREQ.racc
160
161 N_REGS <= n;
162
163 BRAM_WE <= imemwe;
164
165 IB_SRES.dout <= idout;
166 IB_SRES.ack <= iback;
167 IB_SRES.busy <= '0';
168
169 end process proc_next;
170
171
172end syn;
regs_type :=( '0', '0', '0', '0', '0') regs_init
Definition: ibd_m9312.vhd:60
regs_type := regs_init N_REGS
Definition: ibd_m9312.vhd:67
slbit := '0' BRAM_WE
Definition: ibd_m9312.vhd:69
slv16 := slv( to_unsigned( 8#173000#, 16) ) ibaddr_m9312_hi
Definition: ibd_m9312.vhd:46
slv16 :=( others => '0') BRAM_DO
Definition: ibd_m9312.vhd:70
regs_type := regs_init R_REGS
Definition: ibd_m9312.vhd:66
integer := 1 csr_ibf_enahi
Definition: ibd_m9312.vhd:49
slv16 := slv( to_unsigned( 8#165000#, 16) ) ibaddr_m9312_lo
Definition: ibd_m9312.vhd:45
slv9 :=( others => '0') BRAM_ADDR
Definition: ibd_m9312.vhd:71
integer := 7 csr_ibf_locwe
Definition: ibd_m9312.vhd:48
integer := 0 csr_ibf_enalo
Definition: ibd_m9312.vhd:50
in RESET slbit
Definition: ibd_m9312.vhd:33
in CLK slbit
Definition: ibd_m9312.vhd:32
in IB_MREQ ib_mreq_type
Definition: ibd_m9312.vhd:34
out IB_SRES ib_sres_type
Definition: ibd_m9312.vhd:36
Definition: iblib.vhd:33
in ADDR slv( AWIDTH- 1 downto 0)
out DO slv( DWIDTH- 1 downto 0)
in DI slv( DWIDTH- 1 downto 0)
std_logic_vector( 8 downto 0) slv9
Definition: slvtypes.vhd:41
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31