1 |
4 |
khatib |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : PCI Parity core
|
3 |
|
|
-- Project : PCI target Core
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : pci_parity.VHD
|
6 |
|
|
-- Author : Jamil Khatib <khatib@ieee.org>
|
7 |
|
|
-- Organization: OpenCores Project
|
8 |
|
|
-- Created : 2000/04/1
|
9 |
|
|
-- Last update : 2000/04/1
|
10 |
|
|
-- Platform :
|
11 |
|
|
-- Simulators : Modelsim 5.3XE / Windows98
|
12 |
|
|
-- Synthesizers: webfitter - Leonardo / WindowsNT
|
13 |
|
|
-- Target : XC9572XL-5-VQ64 - EPF10K100EQC208 Flex10K
|
14 |
|
|
-- Dependency :
|
15 |
|
|
-------------------------------------------------------------------------------
|
16 |
|
|
-- Description: PCI Parity Core
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
-- Copyright (c) 2000 Jamil Khatib
|
19 |
|
|
--
|
20 |
|
|
-- This VHDL design file is an open design; you can redistribute it and/or
|
21 |
|
|
-- modify it and/or implement it under the terms of the Openip General Public
|
22 |
|
|
-- License as it is going to be published by the OpenIPCore Organization and
|
23 |
|
|
-- any coming versions of this license.
|
24 |
|
|
-- You can check the draft license at
|
25 |
|
|
-- http://www.openip.org/oc/license.html
|
26 |
|
|
--
|
27 |
|
|
-------------------------------------------------------------------------------
|
28 |
|
|
-- Revisions :
|
29 |
|
|
-- Revision Number : 1
|
30 |
|
|
-- Version : 1.0
|
31 |
|
|
-- Date : 1st Apr 2000
|
32 |
|
|
-- Modifier : Jamil Khatib (khatib@ieee.org)
|
33 |
|
|
-- Desccription : Created
|
34 |
|
|
--
|
35 |
|
|
-- Known bugs : Extending the PAR signals to wait states
|
36 |
|
|
-- : SERR is generated upon local side request only
|
37 |
|
|
-- : PERR must remain active two clockcycles after the ERR
|
38 |
|
|
-------------------------------------------------------------------------------
|
39 |
|
|
library ieee;
|
40 |
|
|
use ieee.std_logic_1164.all;
|
41 |
|
|
|
42 |
|
|
entity parity is
|
43 |
|
|
|
44 |
|
|
port (
|
45 |
|
|
-- PCI Interface
|
46 |
|
|
CLK : in std_logic; -- PCI clock
|
47 |
|
|
AD : in std_logic_vector(31 downto 0); -- PCI AD signal
|
48 |
|
|
CBE : in std_logic_vector(3 downto 0); -- C/BE PCI bus signals
|
49 |
|
|
PAR : inout std_logic; -- PAR signal
|
50 |
|
|
SERR_n : inout std_logic; -- SERR# signal
|
51 |
|
|
PERR_n : out std_logic; -- PERR# signal
|
52 |
|
|
-- PERR# signal is output only for target
|
53 |
|
|
-- Local Interface
|
54 |
|
|
ParOperation : in std_logic; -- Parity Operation
|
55 |
|
|
-- Drive PAR or check it
|
56 |
|
|
Par_oe : in std_logic; -- PAR Output Enable
|
57 |
|
|
Locserr_n : in std_logic; -- Local System Error
|
58 |
|
|
LocErrRep_n : out std_logic); -- Local Error Report
|
59 |
|
|
-- used to report parity errors for local interface
|
60 |
|
|
-- and to the configuration register
|
61 |
|
|
|
62 |
|
|
end parity;
|
63 |
|
|
|
64 |
|
|
library ieee;
|
65 |
|
|
use ieee.std_logic_1164.all;
|
66 |
|
|
-------------------------------------------------------------------------------
|
67 |
|
|
architecture behavior of parity is
|
68 |
|
|
|
69 |
|
|
begin -- behavior
|
70 |
|
|
|
71 |
|
|
-------------------------------------------------------------------------------
|
72 |
|
|
-- purpose: Parity Generation
|
73 |
|
|
-- type : sequential
|
74 |
|
|
-- inputs : CLK
|
75 |
|
|
-- outputs: PAR, LocErrRep
|
76 |
|
|
Paritygen : process (CLK)
|
77 |
|
|
|
78 |
|
|
variable tmp_par : std_logic; -- temporary parity vriable
|
79 |
|
|
variable par_q : std_logic; -- Next Par signal
|
80 |
|
|
variable perr_q : std_logic; -- Next PERR signal
|
81 |
|
|
|
82 |
|
|
begin -- process Paritygen
|
83 |
|
|
|
84 |
|
|
if CLK'event and CLK = '1' then -- rising clock edge
|
85 |
|
|
if Par_oe = '1' then
|
86 |
|
|
|
87 |
|
|
-------------------------------------------------------------------------------
|
88 |
|
|
-- PAR signal states:
|
89 |
|
|
-- Idel: when no operation on the current target or master
|
90 |
|
|
-- PAR = 'Z' , PERR = 'Z'
|
91 |
|
|
-- Master Read:
|
92 |
|
|
-- Address phase:
|
93 |
|
|
-- Master Drives PAR
|
94 |
|
|
-- Target Drives PERR
|
95 |
|
|
-- Data phase:
|
96 |
|
|
-- Target Drives PAR
|
97 |
|
|
-- Master Drives PERR
|
98 |
|
|
-- Master write:
|
99 |
|
|
-- Address and data phase
|
100 |
|
|
-- Master Drives PAR
|
101 |
|
|
-- Master Drives PERR
|
102 |
|
|
-------------------------------------------------------------------------------
|
103 |
|
|
-- ParOperation = 1 Calculate and drive PAR Port
|
104 |
|
|
-- ParOperation = 0 Calculate and report Parity Errors
|
105 |
|
|
-------------------------------------------------------------------------------
|
106 |
|
|
if ParOperation = '1' then -- Drive PAR signal
|
107 |
|
|
|
108 |
|
|
PAR <= par_q;
|
109 |
|
|
LocErrRep_n <= perr_q;
|
110 |
|
|
PERR_n <= 'Z';
|
111 |
|
|
|
112 |
|
|
else
|
113 |
|
|
|
114 |
|
|
PERR_n <= perr_q;
|
115 |
|
|
PAR <= 'Z';
|
116 |
|
|
|
117 |
|
|
end if;
|
118 |
|
|
|
119 |
|
|
-- No of 1's in AD, CBE & PAR must be even
|
120 |
|
|
tmp_par := CBE(3) xor CBE(2) xor CBE(1) xor CBE(0);
|
121 |
|
|
|
122 |
|
|
for i in AD'range loop
|
123 |
|
|
|
124 |
|
|
tmp_par := tmp_par xor AD(i);
|
125 |
|
|
|
126 |
|
|
end loop; -- i
|
127 |
|
|
|
128 |
|
|
par_q := tmp_par;
|
129 |
|
|
|
130 |
|
|
perr_q := tmp_par xor PAR_q;
|
131 |
|
|
|
132 |
|
|
else
|
133 |
|
|
|
134 |
|
|
PAR <= 'Z';
|
135 |
|
|
PERR_n <= 'Z';
|
136 |
|
|
|
137 |
|
|
end if;
|
138 |
|
|
end if;
|
139 |
|
|
end process Paritygen;
|
140 |
|
|
-------------------------------------------------------------------------------
|
141 |
|
|
|
142 |
|
|
SERR_n <= Locserr_n;
|
143 |
|
|
-------------------------------------------------------------------------------
|
144 |
|
|
end behavior;
|