Line 1... |
Line 1... |
-- $Id: ibd_iist.vhd 314 2010-07-09 17:38:41Z mueller $
|
-- $Id: ibd_iist.vhd 335 2010-10-24 22:24:23Z mueller $
|
--
|
--
|
-- Copyright 2009- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
-- Copyright 2009-2010 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
--
|
--
|
-- This program is free software; you may redistribute and/or modify it under
|
-- This program is free software; you may redistribute and/or modify it under
|
-- the terms of the GNU General Public License as published by the Free
|
-- the terms of the GNU General Public License as published by the Free
|
-- Software Foundation, either version 2, or at your option any later version.
|
-- Software Foundation, either version 2, or at your option any later version.
|
--
|
--
|
Line 16... |
Line 16... |
-- Description: ibus dev(loc): IIST
|
-- Description: ibus dev(loc): IIST
|
--
|
--
|
-- Dependencies: -
|
-- Dependencies: -
|
-- Test bench: -
|
-- Test bench: -
|
-- Target Devices: generic
|
-- Target Devices: generic
|
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2; ghdl 0.18-0.25
|
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2, 12.1; ghdl 0.18-0.29
|
--
|
--
|
-- Synthesized (xst):
|
-- Synthesized (xst):
|
-- Date Rev ise Target flop lutl lutm slic t peri
|
-- Date Rev ise Target flop lutl lutm slic t peri
|
|
-- 2010-10-17 333 12.1 M53 xc3s1000-4 112 510 0 291 s 15.8
|
|
-- 2010-10-17 314 12.1 M53 xc3s1000-4 111 504 0 290 s 15.6
|
-- 2009-06-01 223 10.1.03 K39 xc3s1000-4 111 439 0 256 s 9.8
|
-- 2009-06-01 223 10.1.03 K39 xc3s1000-4 111 439 0 256 s 9.8
|
-- 2009-06-01 221 10.1.03 K39 xc3s1000-4 111 449 0 258 s 13.3
|
-- 2009-06-01 221 10.1.03 K39 xc3s1000-4 111 449 0 258 s 13.3
|
--
|
--
|
-- Revision History:
|
-- Revision History:
|
-- Date Rev Version Comment
|
-- Date Rev Version Comment
|
|
-- 2010-10-17 333 0.8 use ibus V2 interface
|
-- 2009-06-07 224 0.7 send inverted stc_stp; remove pgc_err; honor msk_im
|
-- 2009-06-07 224 0.7 send inverted stc_stp; remove pgc_err; honor msk_im
|
-- also for dcf_dcf and exc_rte; add iist_mreq and
|
-- also for dcf_dcf and exc_rte; add iist_mreq and
|
-- iist_sreq, boot and lock interfaces
|
-- iist_sreq, boot and lock interfaces
|
-- 2009-06-05 223 0.6 level interrupt, parity logic, exc.ui logic
|
-- 2009-06-05 223 0.6 level interrupt, parity logic, exc.ui logic
|
-- st logic modified (partially tested)
|
-- st logic modified (partially tested)
|
Line 140... |
Line 143... |
s_stsnd, -- handle st transmit
|
s_stsnd, -- handle st transmit
|
s_pgsnd -- handle pg transmit
|
s_pgsnd -- handle pg transmit
|
);
|
);
|
|
|
type regs_type is record -- state registers
|
type regs_type is record -- state registers
|
|
ibsel : slbit; -- ibus select
|
acr_ac : slv4; -- acr: ac
|
acr_ac : slv4; -- acr: ac
|
pge_pbe : slv4; -- pge: pg boot ena
|
pge_pbe : slv4; -- pge: pg boot ena
|
pge_pie : slv4; -- pge: pg int ena
|
pge_pie : slv4; -- pge: pg int ena
|
pgc_grj : slbit; -- pgc: go reject
|
pgc_grj : slbit; -- pgc: go reject
|
pgc_pgrmr : slbit; -- pgc: pg req refused
|
pgc_pgrmr : slbit; -- pgc: pg req refused
|
Line 183... |
Line 187... |
req_lock : slbit; -- cpu lock request
|
req_lock : slbit; -- cpu lock request
|
req_boot : slbit; -- cpu boot request
|
req_boot : slbit; -- cpu boot request
|
end record regs_type;
|
end record regs_type;
|
|
|
constant regs_init : regs_type := (
|
constant regs_init : regs_type := (
|
|
'0', -- ibsel
|
"0000", -- acr_ac
|
"0000", -- acr_ac
|
"0000","0000", -- pge_pbe, pge_pie
|
"0000","0000", -- pge_pbe, pge_pie
|
'0', -- pgc_grj
|
'0', -- pgc_grj
|
'0','0', -- pgc_pgrmr, pgc_strmr
|
'0','0', -- pgc_pgrmr, pgc_strmr
|
'0','0', -- pgc_ie, pgc_ptp
|
'0','0', -- pgc_ie, pgc_ptp
|
Line 236... |
Line 241... |
proc_next : process (R_REGS, CE_USEC, IB_MREQ, EI_ACK, EI_ACK,
|
proc_next : process (R_REGS, CE_USEC, IB_MREQ, EI_ACK, EI_ACK,
|
IIST_BUS(0), IIST_BUS(1), IIST_BUS(2), IIST_BUS(3),
|
IIST_BUS(0), IIST_BUS(1), IIST_BUS(2), IIST_BUS(3),
|
IIST_SRES)
|
IIST_SRES)
|
variable r : regs_type := regs_init;
|
variable r : regs_type := regs_init;
|
variable n : regs_type := regs_init;
|
variable n : regs_type := regs_init;
|
variable ibsel : slbit := '0';
|
variable ibhold : slbit := '0';
|
variable ibbusy : slbit := '0';
|
|
variable idout : slv16 := (others=>'0');
|
variable idout : slv16 := (others=>'0');
|
|
variable ibreq : slbit := '0';
|
variable ibrd : slbit := '0';
|
variable ibrd : slbit := '0';
|
variable ibw0 : slbit := '0';
|
variable ibw0 : slbit := '0';
|
variable ibw1 : slbit := '0';
|
variable ibw1 : slbit := '0';
|
variable int_or : slbit := '0';
|
variable int_or : slbit := '0';
|
variable tcnt256_end : slbit := '0';
|
variable tcnt256_end : slbit := '0';
|
Line 256... |
Line 261... |
begin
|
begin
|
|
|
r := R_REGS;
|
r := R_REGS;
|
n := R_REGS;
|
n := R_REGS;
|
|
|
ibsel := '0';
|
ibhold := '0';
|
ibbusy := '0';
|
|
idout := (others=>'0');
|
idout := (others=>'0');
|
ibrd := not IB_MREQ.we;
|
ibreq := IB_MREQ.re or IB_MREQ.we;
|
|
ibrd := IB_MREQ.re;
|
ibw0 := IB_MREQ.we and IB_MREQ.be0;
|
ibw0 := IB_MREQ.we and IB_MREQ.be0;
|
ibw1 := IB_MREQ.we and IB_MREQ.be1;
|
ibw1 := IB_MREQ.we and IB_MREQ.be1;
|
|
|
int_or := r.pgc_grj or r.pgc_pgrmr or r.pgc_strmr;
|
int_or := r.pgc_grj or r.pgc_pgrmr or r.pgc_strmr;
|
for i in r.dcf_dcf'range loop
|
for i in r.dcf_dcf'range loop
|
Line 298... |
Line 303... |
act_ibit := '0';
|
act_ibit := '0';
|
act_bbit := '0';
|
act_bbit := '0';
|
iout := iist_line_init; -- default state of out line
|
iout := iist_line_init; -- default state of out line
|
|
|
-- ibus address decoder
|
-- ibus address decoder
|
if IB_MREQ.req='1' and
|
n.ibsel := '0';
|
|
if IB_MREQ.aval='1' and
|
IB_MREQ.addr(12 downto 2)=ibaddr_iist(12 downto 2) then
|
IB_MREQ.addr(12 downto 2)=ibaddr_iist(12 downto 2) then
|
ibsel := '1';
|
n.ibsel := '1';
|
end if;
|
end if;
|
|
|
-- internal state machine
|
-- internal state machine
|
case r.state is
|
case r.state is
|
when s_idle => -- idle state
|
when s_idle => -- idle state
|
Line 314... |
Line 320... |
elsif r.req_pgsnd = '1' then -- prog. gen. request pending
|
elsif r.req_pgsnd = '1' then -- prog. gen. request pending
|
n.state := s_pgsnd;
|
n.state := s_pgsnd;
|
end if;
|
end if;
|
|
|
when s_clear => -- handle acr clr
|
when s_clear => -- handle acr clr
|
ibbusy := ibsel; -- keep req pending if selected
|
ibhold := r.ibsel; -- keep req pending if selected
|
ibsel := '0'; -- but don't process selection
|
|
-- r.req_clear is set when in this state and cause a reset in prog_regs
|
-- r.req_clear is set when in this state and cause a reset in prog_regs
|
-- --> n.req_clear := '0';
|
-- --> n.req_clear := '0';
|
-- --> n.state := s_idle;
|
-- --> n.state := s_idle;
|
|
|
when s_stsnd => -- handle st transmit
|
when s_stsnd => -- handle st transmit
|
Line 353... |
Line 358... |
iout.stf := r.mtc_mttp; -- force type from mtc_mttp
|
iout.stf := r.mtc_mttp; -- force type from mtc_mttp
|
iout.frm := r.mtc_mfrm; -- force frame from mtc_mfrm
|
iout.frm := r.mtc_mfrm; -- force frame from mtc_mfrm
|
end if;
|
end if;
|
|
|
-- ibus transactions
|
-- ibus transactions
|
if ibsel = '1' then
|
if r.ibsel = '1' and ibhold='0' then
|
|
|
if IB_MREQ.addr(1 downto 1) = "0" then -- ACR -- access control reg -----
|
if IB_MREQ.addr(1 downto 1) = "0" then -- ACR -- access control reg -----
|
|
|
idout(acr_ibf_sid) := SID;
|
idout(acr_ibf_sid) := SID;
|
idout(acr_ibf_ac) := r.acr_ac;
|
idout(acr_ibf_ac) := r.acr_ac;
|
Line 551... |
Line 556... |
null;
|
null;
|
|
|
end case;
|
end case;
|
|
|
if unsigned(r.acr_ac) <= unsigned(ac_exc) then -- if ac 0,..,10
|
if unsigned(r.acr_ac) <= unsigned(ac_exc) then -- if ac 0,..,10
|
if IB_MREQ.dip = '0' then -- if not 1st part of rmw
|
if IB_MREQ.rmw = '0' then -- if not 1st part of rmw
|
n.acr_ac := unsigned(r.acr_ac) + 1; -- autoincrement
|
n.acr_ac := unsigned(r.acr_ac) + 1; -- autoincrement
|
end if;
|
end if;
|
end if;
|
end if;
|
|
|
end if;
|
end if;
|
Line 656... |
Line 661... |
end if;
|
end if;
|
|
|
N_REGS <= n;
|
N_REGS <= n;
|
|
|
IB_SRES.dout <= idout;
|
IB_SRES.dout <= idout;
|
IB_SRES.ack <= ibsel;
|
IB_SRES.ack <= r.ibsel and ibreq;
|
IB_SRES.busy <= ibbusy;
|
IB_SRES.busy <= ibhold and ibreq;
|
|
|
EI_REQ <= r.pgc_ie and int_or;
|
EI_REQ <= r.pgc_ie and int_or;
|
|
|
if r.mtc_dsdrv = '1' then -- if driver disconnected
|
if r.mtc_dsdrv = '1' then -- if driver disconnected
|
iout.dcf := '1'; -- set dcf flag
|
iout.dcf := '1'; -- set dcf flag
|