4 package body badger2
is
5 end package body badger2
;
7 -- Incorporates Errata 5.4
10 use ieee.std_logic_1164.
all;
11 use ieee.numeric_std.
all;
13 entity accumulator
is port (
14 a
: in std_logic_vector(3 downto 0);
15 clk
, reset
: in std_logic;
16 accum
: out std_logic_vector(3 downto 0)
20 architecture simple
of accumulator
is
22 signal accumL
: unsigned
(3 downto 0);
26 accumulate
: process (clk
, reset
) begin
29 elsif (clk
'event and clk
= '1') then
30 accumL
<= accumL
+ to_unsigned
(a
);
34 accum
<= std_logic_vector(accumL
);
38 use IEEE.std_logic_1164.
all;
39 use IEEE.std_logic_unsigned.
all;
41 entity adder
is port (
42 a
,b
: in std_logic_vector (15 downto 0);
43 sum
: out std_logic_vector (15 downto 0)
47 architecture dataflow
of adder
is
55 use IEEE.std_logic_1164.
all;
58 generic(n
: integer := 8);
59 port (a
: in std_logic_vector(n
- 1 downto 0);
60 b
: in std_logic_vector(n
- 1 downto 0);
62 sum
: out std_logic_vector(n
- 1 downto 0);
63 cout
: out std_logic);
67 architecture loopDemo
of pAdderAttr
is
72 variable carry
: std_logic_vector(sum
'length downto 0);
73 variable localSum
: std_logic_vector(sum
'high downto 0);
79 for i
in sum
'reverse_range loop
80 localSum
(i
) := (a
(i
) xor b
(i
)) xor carry
(i
);
81 carry
(i
+ 1) := (a
(i
) and b
(i
)) or (carry
(i
) and (a
(i
) or b
(i
)));
85 cout
<= carry
(carry
'high - 1);
91 use ieee.std_logic_1164.
all;
92 use ieee.numeric_std.
all;
94 entity adder
is port (
95 a
,b
: in unsigned
(3 downto 0);
96 sum
: out unsigned
(3 downto 0)
100 architecture simple
of adder
is
108 use IEEE.std_logic_1164.
all;
112 use IEEE.std_logic_1164.
all;
114 entity AND2
is port (
121 architecture rtl
of AND2
is
125 y
<= '1' when i1
= '1' and i2
= '1' else '0';
129 use IEEE.std_logic_1164.
all;
131 entity asyncLoad
is port (
132 loadVal
, d
: in std_logic_vector(3 downto 0);
133 clk
, load
: in std_logic;
134 q
: out std_logic_vector(3 downto 0)
138 architecture rtl
of asyncLoad
is
142 process (clk
, load
, loadVal
) begin
145 elsif (clk
'event and clk
= '1' ) then
152 use IEEE.std_logic_1164.
all;
153 use IEEE.std_logic_unsigned.
all;
155 entity BidirBuf
is port (
157 input
: in std_logic_vector;
158 output
: out std_logic_vector
162 architecture behavioral
of BidirBuf
is
166 bidirBuf
: process (OE
, input
) begin
170 output
<= (others => 'Z');
176 use IEEE.std_logic_1164.
all;
178 entity BidirCnt
is port (
180 CntEnable
: in std_logic;
184 Cnt
: inout std_logic_vector(3 downto 0)
188 architecture behavioral
of BidirCnt
is
190 component LoadCnt
port (
193 LdData
: in std_logic_vector(3 downto 0);
196 CntVal
: out std_logic_vector(3 downto 0)
200 component BidirBuf
port (
202 input
: in std_logic_vector;
203 output
: inout std_logic_vector
207 signal CntVal
: std_logic_vector(3 downto 0);
208 signal LoadVal
: std_logic_vector(3 downto 0);
212 u1
: loadcnt
port map (CntEn
=> CntEnable
,
220 u2
: bidirbuf
port map (OE
=> oe
,
229 use IEEE.std_logic_1164.
all;
231 entity BIDIR
is port (
234 op_fb
: out std_logic;
239 architecture rtl
of BIDIR
is
243 op
<= ip
when oe
= '1' else 'Z';
249 use IEEE.std_logic_1164.
all;
251 use work.primitive.
all;
253 entity bidirbuffer
is port (
255 enable
: in std_logic;
256 feedback
: out std_logic;
257 output
: inout std_logic
261 architecture structural
of bidirbuffer
is
265 u1
: bidir
port map (ip
=> input
,
273 use IEEE.std_logic_1164.
all;
275 entity clkGen
is port (
279 ClkDiv6
,ClkDiv8
: out std_logic
283 architecture behav
of clkGen
is
285 subtype numClks
is std_logic_vector(1 to 4);
286 subtype numPatterns
is integer range 0 to 11;
288 type clkTableType
is array (numpatterns
'low to numPatterns
'high) of numClks
;
290 constant clkTable
: clkTableType
:= clkTableType
'(
309 signal index: numPatterns;
313 lookupTable: process (clk, reset) begin
316 elsif (clk'event and clk = '1') then
317 if index = numPatterns'high then
318 index <= numPatterns'low;
325 (ClkDiv2,ClkDiv4,ClkDiv6,ClkDiv8) <= clkTable(index);
329 use ieee.std_logic_1164.all;
330 use ieee.numeric_std.all;
332 entity counter is port (
334 enable: in std_logic;
336 count: buffer unsigned(3 downto 0)
340 architecture simple of counter is
344 increment: process (clk, reset) begin
347 elsif(clk'event and clk = '1') then
358 use IEEE.std_logic_1164.all;
360 use work.scaleable.all;
362 entity count8 is port (
365 count: out std_logic_vector(7 downto 0)
369 architecture structural of count8 is
373 u1: scaleUpCnt port map (clk => clk,
379 -- Incorporates Errata 5.4
382 use ieee.std_logic_1164.all;
383 use ieee.numeric_std.all;
385 entity counter is port (
388 count: out std_logic_vector(0 to 9)
392 architecture simple of counter is
394 signal countL: unsigned(0 to 9);
398 increment: process (clk, reset) begin
400 countL <= to_unsigned(3,10);
401 elsif(clk'event and clk = '1') then
402 countL <= countL + 1;
406 count <= std_logic_vector(countL);
409 -- Incorporates Errata 5.4
412 use ieee.std_logic_1164.all;
413 use ieee.numeric_std.all;
415 entity counter is port (
418 count: out std_logic_vector(9 downto 0)
422 architecture simple of counter is
424 signal countL: unsigned(9 downto 0);
428 increment: process (clk, reset) begin
430 countL <= to_unsigned(0,10);
431 elsif(clk'event and clk = '1') then
432 countL <= countL + 1;
436 count <= std_logic_vector(countL);
439 -- Incorporates Errata 5.4
442 use ieee.std_logic_1164.all;
443 use ieee.numeric_std.all;
445 entity counter is port (
449 enable: in std_logic;
450 data: in std_logic_vector(3 downto 0);
451 count: out std_logic_vector(3 downto 0)
455 architecture simple of counter is
457 signal countL: unsigned(3 downto 0);
461 increment: process (clk, reset) begin
462 if (reset = '1') then
464 elsif(clk'event and clk = '1') then
466 countL <= to_unsigned(data);
467 elsif (enable = '1') then
468 countL <= countL + 1;
473 count <= std_logic_vector(countL);
476 -- Incorporates Errata 5.4
479 use ieee.std_logic_1164.all;
480 use ieee.numeric_std.all;
482 entity counter is port (
486 data: in std_logic_vector(3 downto 0);
487 count: out std_logic_vector(3 downto 0)
491 architecture simple of counter is
493 signal countL: unsigned(3 downto 0);
497 increment: process (clk, reset) begin
498 if (reset = '1') then
500 elsif(clk'event and clk = '1') then
502 countL <= to_unsigned(data);
504 countL <= countL + 1;
509 count <= std_logic_vector(countL);
513 use IEEE.std_logic_1164.all;
514 use IEEE.numeric_std.all;
516 entity Cnt4Term is port (
518 Cnt: out std_logic_vector(3 downto 0);
519 TermCnt: out std_logic
523 architecture behavioral of Cnt4Term is
525 signal CntL: unsigned(3 downto 0);
529 increment: process begin
530 wait until clk = '1';
534 Cnt <= to_stdlogicvector(CntL);
536 TermCnt <= '1' when CntL = "1111" else '0';
541 use IEEE.std_logic_1164.all;
543 entity Counter is port (
545 Count: out std_logic_vector(3 downto 0)
549 architecture structural of Counter is
551 component Cnt4Term port (
553 Cnt: out std_logic_vector(3 downto 0);
554 TermCnt: out std_logic);
559 u1: Cnt4Term port map (clk => clock,
565 -- Incorporates Errata 5.4
568 use ieee.std_logic_1164.all;
569 use ieee.numeric_std.all;
571 entity counter is port (
574 count: out std_logic_vector(3 downto 0)
578 architecture simple of counter is
580 signal countL: unsigned(3 downto 0);
584 increment: process (clk) begin
585 if(clk'event and clk = '1') then
586 if (reset = '1') then
589 countL <= countL + 1;
594 count <= std_logic_vector(countL);
598 use IEEE.std_logic_1164.all;
599 use IEEE.numeric_std.all;
601 entity convertArith is port (
602 truncate: out unsigned(3 downto 0);
603 extend: out unsigned(15 downto 0);
604 direction: out unsigned(0 to 7)
608 architecture simple of convertArith is
610 constant Const: unsigned(7 downto 0) := "00111010";
614 truncate <= resize(Const, truncate'length);
615 extend <= resize(Const, extend'length);
616 direction <= resize(Const, direction'length);
620 use IEEE.std_logic_1164.all;
621 use IEEE.numeric_std.all;
623 entity FEWGATES is port (
624 a,b,c,d: in std_logic;
629 architecture concurrent of FEWGATES is
631 constant THREE: std_logic_vector(1 downto 0) := "11";
635 y <= '1' when (a & b = THREE) or (c & d /= THREE) else '0';
638 -- incorporates Errata 12.1
641 use IEEE.std_logic_1164.all;
642 use IEEE.numeric_std.all;
644 entity typeConvert is port (
645 a: out unsigned(7 downto 0)
649 architecture simple of typeConvert is
651 constant Const: natural := 43;
655 a <= To_unsigned(Const,8);
658 -- Incorporates Errata 5.4
661 use ieee.std_logic_1164.all;
662 use ieee.numeric_std.all;
664 entity counter is port (
666 count: out std_logic_vector(3 downto 0)
670 architecture simple of counter is
672 signal countL: unsigned(3 downto 0);
676 increment: process (clk) begin
677 if (clk'event and clk = '1') then
678 countL <= countL + 1;
682 count <= std_logic_vector(countL);
685 -- Incorporates Errata 5.4
688 use ieee.std_logic_1164.all;
689 use ieee.numeric_std.all;
691 entity counter is port (
694 count: out std_logic_vector(0 to 3)
698 architecture simple of counter is
700 signal countL: unsigned(0 to 3);
704 increment: process (clk, reset) begin
707 elsif(clk'event and clk = '1') then
708 countL <= countL + 1;
712 count <= std_logic_vector(countL);
716 use ieee.std_logic_1164.all;
717 use ieee.numeric_std.all;
719 entity counter is port (
722 count: out std_logic_vector(3 downto 0)
726 architecture simple of counter is
728 signal countL: unsigned(3 downto 0);
732 increment: process (clk, reset) begin
733 if (reset = '1') then
735 elsif(clk'event and clk = '1') then
736 countL <= countL + "001";
740 count <= std_logic_vector(countL);
743 -- Incorporates Errata 5.4
746 use ieee.std_logic_1164.all;
747 use ieee.numeric_std.all;
749 entity counter is port (
752 count: out std_logic_vector(3 downto 0)
756 architecture simple of counter is
758 signal countL: unsigned(3 downto 0);
762 increment: process (clk, reset) begin
765 elsif(clk'event and clk = '1') then
766 countL <= countL + 1;
770 count <= std_logic_vector(countL);
773 -- Incorporates Errata 5.4
776 use ieee.std_logic_1164.all;
777 use ieee.numeric_std.all;
779 entity counter is port (
782 count: out std_logic_vector(3 downto 0)
786 architecture simple of counter is
788 signal countL: unsigned(3 downto 0);
792 increment: process (clk, reset) begin
793 if (reset = '1') then
795 elsif(clk'event and clk = '1') then
796 countL <= countL + "0001";
800 count <= std_logic_vector(countL);
804 use IEEE.std_logic_1164.all;
806 use work.decProcs.all;
808 entity decoder is port (
809 decIn: in std_logic_vector(1 downto 0);
810 decOut: out std_logic_vector(3 downto 0)
814 architecture simple of decoder is
818 DEC2x4(decIn,decOut);
823 use ieee.std_logic_1164.all;
825 entity isa_dec is port
827 dev_adr: in std_logic_vector(19 downto 0);
829 decOut_n: out std_logic_vector(5 downto 0)
835 architecture synthesis of isa_dec is
837 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
838 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
840 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
841 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
842 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
843 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
844 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
846 alias sio_dec_n: std_logic is decOut_n(5);
847 alias rst_ctrl_rd_n: std_logic is decOut_n(4);
848 alias atc_stat_rd_n: std_logic is decOut_n(3);
849 alias mgmt_stat_rd_n: std_logic is decOut_n(2);
850 alias io_int_stat_rd_n: std_logic is decOut_n(1);
851 alias int_ctrl_rd_n: std_logic is decOut_n(0);
853 alias upper: std_logic_vector(2 downto 0) is dev_adr(19 downto 17);
854 alias CtrlBits: std_logic_vector(16 downto 0) is dev_adr(16 downto 0);
858 decoder: process (upper, CtrlBits)
860 -- Set defaults for outputs - for synthesis reasons.
863 int_ctrl_rd_n <= '1';
864 io_int_stat_rd_n <= '1';
865 rst_ctrl_rd_n <= '1';
866 atc_stat_rd_n <= '1';
867 mgmt_stat_rd_n <= '1';
879 int_ctrl_rd_n <= '0';
882 io_int_stat_rd_n <= '0';
885 rst_ctrl_rd_n <= '0';
888 atc_stat_rd_n <= '0';
890 when MgmtStatusReg =>
891 mgmt_stat_rd_n <= '0';
907 use ieee.std_logic_1164.all;
909 entity isa_dec is port
911 dev_adr: in std_logic_vector(19 downto 0);
913 sio_dec_n: out std_logic;
914 rst_ctrl_rd_n: out std_logic;
915 atc_stat_rd_n: out std_logic;
916 mgmt_stat_rd_n: out std_logic;
917 io_int_stat_rd_n: out std_logic;
918 int_ctrl_rd_n: out std_logic
923 architecture synthesis of isa_dec is
925 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
926 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
928 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
929 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
930 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
931 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
932 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
936 decoder: process (dev_adr)
938 -- Set defaults for outputs
941 int_ctrl_rd_n <= '1';
942 io_int_stat_rd_n <= '1';
943 rst_ctrl_rd_n <= '1';
944 atc_stat_rd_n <= '1';
945 mgmt_stat_rd_n <= '1';
947 case dev_adr(19 downto 17) is
954 case dev_adr(16 downto 0) is
957 int_ctrl_rd_n <= '0';
960 io_int_stat_rd_n <= '0';
963 rst_ctrl_rd_n <= '0';
966 atc_stat_rd_n <= '0';
968 when MgmtStatusReg =>
969 mgmt_stat_rd_n <= '0';
985 use ieee.std_logic_1164.all;
987 entity isa_dec is port
989 dev_adr: in std_logic_vector(19 downto 0);
991 sio_dec_n: out std_logic;
992 rst_ctrl_rd_n: out std_logic;
993 atc_stat_rd_n: out std_logic;
994 mgmt_stat_rd_n: out std_logic;
995 io_int_stat_rd_n:out std_logic;
996 int_ctrl_rd_n: out std_logic
1001 architecture synthesis of isa_dec is
1003 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
1004 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
1006 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
1007 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
1008 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
1009 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
1010 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
1013 sio_dec_n <= '0' when dev_adr (19 downto 17) = SuperIORange else '1';
1015 int_ctrl_rd_n <= '0' when (dev_adr (19 downto 17) = CtrlRegRange)
1016 and (dev_adr(16 downto 0) = IntCtrlReg) else '1';
1018 io_int_stat_rd_n <= '0' when (dev_adr (19 downto 17) = CtrlRegRange)
1019 and (dev_adr(16 downto 0) = IoIntStatReg) else '1';
1021 rst_ctrl_rd_n <= '0' when (dev_adr (19 downto 17) = CtrlRegRange)
1022 and (dev_adr(16 downto 0) = RstCtrlReg) else '1';
1024 atc_stat_rd_n <= '0' when (dev_adr (19 downto 17) = CtrlRegRange)
1025 and (dev_adr(16 downto 0) = AtcStatusReg) else '1';
1027 mgmt_stat_rd_n <= '0' when (dev_adr (19 downto 17) = CtrlRegRange)
1028 and (dev_adr(16 downto 0) = MgmtStatusReg) else '1';
1033 use ieee.std_logic_1164.all;
1035 entity isa_dec is port
1037 dev_adr: in std_logic_vector(19 downto 0);
1038 cs0_n: in std_logic;
1040 sio_dec_n: out std_logic;
1041 rst_ctrl_rd_n: out std_logic;
1042 atc_stat_rd_n: out std_logic;
1043 mgmt_stat_rd_n: out std_logic;
1044 io_int_stat_rd_n: out std_logic;
1045 int_ctrl_rd_n: out std_logic
1050 architecture synthesis of isa_dec is
1052 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
1053 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
1055 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
1056 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
1057 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
1058 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
1059 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
1063 decoder: process (dev_adr, cs0_n)
1065 -- Set defaults for outputs - for synthesis reasons.
1068 int_ctrl_rd_n <= '1';
1069 io_int_stat_rd_n <= '1';
1070 rst_ctrl_rd_n <= '1';
1071 atc_stat_rd_n <= '1';
1072 mgmt_stat_rd_n <= '1';
1074 if (cs0_n = '0') then
1075 case dev_adr(19 downto 17) is
1077 when SuperIoRange =>
1080 when CtrlRegRange =>
1082 case dev_adr(16 downto 0) is
1085 int_ctrl_rd_n <= '0';
1087 when IoIntStatReg =>
1088 io_int_stat_rd_n <= '0';
1091 rst_ctrl_rd_n <= '0';
1093 when AtcStatusReg =>
1094 atc_stat_rd_n <= '0';
1096 when MgmtStatusReg =>
1097 mgmt_stat_rd_n <= '0';
1112 end process decoder;
1116 use ieee.std_logic_1164.all;
1118 entity isa_dec is port
1120 dev_adr: in std_logic_vector(19 downto 0);
1121 cs0_n: in std_logic;
1123 sio_dec_n: out std_logic;
1124 rst_ctrl_rd_n: out std_logic;
1125 atc_stat_rd_n: out std_logic;
1126 mgmt_stat_rd_n: out std_logic;
1127 io_int_stat_rd_n: out std_logic;
1128 int_ctrl_rd_n: out std_logic
1133 architecture synthesis of isa_dec is
1135 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
1136 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
1138 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
1139 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
1140 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
1141 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
1142 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
1144 signal Lsio_dec_n: std_logic;
1145 signal Lrst_ctrl_rd_n: std_logic;
1146 signal Latc_stat_rd_n: std_logic;
1147 signal Lmgmt_stat_rd_n: std_logic;
1148 signal Lio_int_stat_rd_n: std_logic;
1149 signal Lint_ctrl_rd_n: std_logic;
1153 decoder: process (dev_adr)
1155 -- Set defaults for outputs - for synthesis reasons.
1158 Lint_ctrl_rd_n <= '1';
1159 Lio_int_stat_rd_n <= '1';
1160 Lrst_ctrl_rd_n <= '1';
1161 Latc_stat_rd_n <= '1';
1162 Lmgmt_stat_rd_n <= '1';
1164 case dev_adr(19 downto 17) is
1166 when SuperIoRange =>
1169 when CtrlRegRange =>
1171 case dev_adr(16 downto 0) is
1174 Lint_ctrl_rd_n <= '0';
1176 when IoIntStatReg =>
1177 Lio_int_stat_rd_n <= '0';
1180 Lrst_ctrl_rd_n <= '0';
1182 when AtcStatusReg =>
1183 Latc_stat_rd_n <= '0';
1185 when MgmtStatusReg =>
1186 Lmgmt_stat_rd_n <= '0';
1198 end process decoder;
1200 qualify: process (cs0_n) begin
1203 int_ctrl_rd_n <= '1';
1204 io_int_stat_rd_n <= '1';
1205 rst_ctrl_rd_n <= '1';
1206 atc_stat_rd_n <= '1';
1207 mgmt_stat_rd_n <= '1';
1209 if (cs0_n = '0') then
1210 sio_dec_n <= Lsio_dec_n;
1211 int_ctrl_rd_n <= Lint_ctrl_rd_n;
1212 io_int_stat_rd_n <= Lio_int_stat_rd_n;
1213 rst_ctrl_rd_n <= Lrst_ctrl_rd_n;
1214 atc_stat_rd_n <= Latc_stat_rd_n;
1215 mgmt_stat_rd_n <= Lmgmt_stat_rd_n;
1219 end process qualify;
1223 use ieee.std_logic_1164.all;
1225 entity isa_dec is port
1227 dev_adr: in std_logic_vector(19 downto 0);
1229 sio_dec_n: out std_logic;
1230 rst_ctrl_rd_n: out std_logic;
1231 atc_stat_rd_n: out std_logic;
1232 mgmt_stat_rd_n: out std_logic;
1233 io_int_stat_rd_n: out std_logic;
1234 int_ctrl_rd_n: out std_logic
1239 architecture synthesis of isa_dec is
1241 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
1242 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
1244 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
1245 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
1246 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
1247 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
1248 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
1252 decoder: process ( dev_adr)
1254 -- Set defaults for outputs - for synthesis reasons.
1257 int_ctrl_rd_n <= '1';
1258 io_int_stat_rd_n <= '1';
1259 rst_ctrl_rd_n <= '1';
1260 atc_stat_rd_n <= '1';
1261 mgmt_stat_rd_n <= '1';
1263 if dev_adr(19 downto 17) = SuperIOrange then
1267 elsif dev_adr(19 downto 17) = CtrlRegrange then
1269 if dev_adr(16 downto 0) = IntCtrlReg then
1271 int_ctrl_rd_n <= '0';
1273 elsif dev_adr(16 downto 0)= IoIntStatReg then
1275 io_int_stat_rd_n <= '0';
1277 elsif dev_adr(16 downto 0) = RstCtrlReg then
1279 rst_ctrl_rd_n <= '0';
1281 elsif dev_adr(16 downto 0) = AtcStatusReg then
1283 atc_stat_rd_n <= '0';
1285 elsif dev_adr(16 downto 0) = MgmtStatusReg then
1287 mgmt_stat_rd_n <= '0';
1301 end process decoder;
1305 use IEEE.std_logic_1164.all;
1309 procedure DEC2x4 (inputs : in std_logic_vector(1 downto 0);
1310 decode: out std_logic_vector(3 downto 0)
1314 package body decProcs is
1316 procedure DEC2x4 (inputs : in std_logic_vector(1 downto 0);
1317 decode: out std_logic_vector(3 downto 0)
1336 use ieee.std_logic_1164.all;
1338 entity isa_dec is port
1340 dev_adr: in std_logic_vector(19 downto 0);
1342 sio_dec_n: out std_logic;
1343 rst_ctrl_rd_n: out std_logic;
1344 atc_stat_rd_n: out std_logic;
1345 mgmt_stat_rd_n: out std_logic;
1346 io_int_stat_rd_n:out std_logic;
1347 int_ctrl_rd_n: out std_logic
1352 architecture synthesis of isa_dec is
1354 constant CtrlRegRange: std_logic_vector(2 downto 0) := "100";
1355 constant SuperIoRange: std_logic_vector(2 downto 0) := "010";
1357 constant IntCtrlReg: std_logic_vector(16 downto 0) := "00000000000000000";
1358 constant IoIntStatReg: std_logic_vector(16 downto 0) := "00000000000000001";
1359 constant RstCtrlReg: std_logic_vector(16 downto 0) := "00000000000000010";
1360 constant AtcStatusReg: std_logic_vector(16 downto 0) := "00000000000000011";
1361 constant MgmtStatusReg:std_logic_vector(16 downto 0) := "00000000000000100";
1364 with dev_adr(19 downto 17) select
1365 sio_dec_n <= '0' when SuperIORange,
1368 with dev_adr(19 downto 0) select
1369 int_ctrl_rd_n <= '0' when CtrlRegRange & IntCtrlReg,
1372 with dev_adr(19 downto 0) select
1373 io_int_stat_rd_n <= '0' when CtrlRegRange & IoIntStatReg,
1376 with dev_adr(19 downto 0) select
1377 rst_ctrl_rd_n <= '0' when CtrlRegRange & RstCtrlReg,
1380 with dev_adr(19 downto 0) select
1381 atc_stat_rd_n <= '0' when CtrlRegRange & AtcStatusReg,
1384 with dev_adr(19 downto 0) select
1385 mgmt_stat_rd_n <= '0' when CtrlRegRange & MgmtStatusReg,
1390 -- Incorporates Errata 5.1 and 5.4
1393 use ieee.std_logic_1164.all;
1394 use ieee.numeric_std.all;
1396 entity progPulse is port (
1397 clk, reset: in std_logic;
1398 loadLength,loadDelay: in std_logic;
1399 data: in std_logic_vector(7 downto 0);
1400 pulse: out std_logic
1404 architecture rtl of progPulse is
1406 signal delayCnt, pulseCnt: unsigned(7 downto 0);
1407 signal delayCntVal, pulseCntVal: unsigned(7 downto 0);
1408 signal startPulse, endPulse: std_logic;
1412 delayReg: process (clk, reset) begin
1414 delayCntVal <= "11111111";
1415 elsif clk'event and clk = '1' then
1416 if loadDelay = '1' then
1417 delayCntVal <= unsigned(data);
1422 lengthReg: process (clk, reset) begin
1424 pulseCntVal <= "11111111";
1425 elsif clk'event and clk = '1' then
1426 if loadLength = '1' then -- changed loadLength to loadDelay (Errata 5.1)
1427 pulseCntVal <= unsigned(data);
1432 pulseDelay: process (clk, reset) begin
1433 if (reset = '1') then
1434 delayCnt <= "11111111";
1435 elsif(clk'event and clk = '1') then
1436 if (loadDelay = '1' or loadLength = '1' or endPulse = '1') then -- changed startPulse to endPulse (Errata 5.1)
1437 delayCnt <= delayCntVal;
1438 elsif endPulse = '1' then
1439 delayCnt <= delayCnt - 1;
1444 startPulse <= '1' when delayCnt = "00000000" else '0';
1446 pulseLength: process (clk, reset) begin
1447 if (reset = '1') then
1448 pulseCnt <= "11111111";
1449 elsif (clk'event and clk = '1') then
1450 if (loadLength = '1') then
1451 pulseCnt <= pulseCntVal;
1452 elsif (startPulse = '1' and endPulse = '1') then
1453 pulseCnt <= pulseCntVal;
1454 elsif (endPulse = '1') then
1455 pulseCnt <= pulseCnt;
1457 pulseCnt <= pulseCnt - 1;
1462 endPulse <= '1' when pulseCnt = "00000000" else '0';
1464 pulseOutput: process (clk, reset) begin
1465 if (reset = '1') then
1467 elsif (clk'event and clk = '1') then
1468 if (startPulse = '1') then
1470 elsif (endPulse = '1') then
1479 use IEEE.std_logic_1164.all;
1481 entity DFF is port (
1484 arst : in std_logic;
1489 architecture rtl of DFF is
1496 elsif clk'event and clk = '1' then
1503 use IEEE.std_logic_1164.all;
1505 entity DFF is port (
1508 a,b,c : in std_logic;
1513 architecture rtl of DFF is
1517 process (clk, a,b,c) begin
1518 if ((a = '1' and b = '1') or c = '1') then
1520 elsif clk'event and clk = '1' then
1527 use IEEE.std_logic_1164.all;
1529 entity DFF is port (
1532 a,b,c : in std_logic;
1537 architecture rtl of DFF is
1539 signal localRst: std_logic;
1543 localRst <= '1' when (( a = '1' and b = '1') or c = '1') else '0';
1545 process (clk, localRst) begin
1546 if localRst = '1' then
1548 elsif clk'event and clk = '1' then
1555 use IEEE.std_logic_1164.all;
1557 entity DFF is port (
1565 architecture rtl of DFF is
1569 process (clk, arst) begin
1572 elsif clk'event and clk = '1' then
1579 use IEEE.std_logic_1164.all;
1581 entity DFF is port (
1584 aset : in std_logic;
1589 architecture rtl of DFF is
1593 process (clk, aset) begin
1596 elsif clk'event and clk = '1' then
1603 use IEEE.std_logic_1164.all;
1605 entity DFF is port (
1606 d1, d2: in std_logic;
1608 arst : in std_logic;
1609 q1, q2: out std_logic
1613 architecture rtl of DFF is
1617 process (clk, arst) begin
1621 elsif clk'event and clk = '1' then
1629 use IEEE.std_logic_1164.all;
1631 entity DFF is port (
1639 architecture rtl of DFF is
1644 if clk'event and clk = '1' then
1654 use IEEE.std_logic_1164.all;
1656 entity DFFE is port (
1664 architecture rtl of DFFE is
1669 wait until clk = '1';
1677 use IEEE.std_logic_1164.all;
1679 entity DFF is port (
1682 envector: in std_logic_vector(7 downto 0);
1687 architecture rtl of DFF is
1692 if clk'event and clk = '1' then
1693 if envector = "10010111" then
1701 use IEEE.std_logic_1164.all;
1703 entity DFF is port (
1711 architecture rtl of DFF is
1716 if clk'event and clk = '1' then
1726 use IEEE.std_logic_1164.all;
1728 entity DFFE_SR is port (
1738 architecture rtl of DFFE_SR is
1742 process (clk, rst, prst) begin
1743 if (prst = '1') then
1745 elsif (rst = '1') then
1747 elsif (clk'event and clk = '1') then
1758 use IEEE.std_logic_1164.all;
1760 entity flipFlop is port (
1761 clock, input: in std_logic;
1762 ffOut: out std_logic
1766 architecture simple of flipFlop is
1768 procedure dff (signal clk: in std_logic;
1769 signal d: in std_logic;
1770 signal q: out std_logic
1773 if clk'event and clk = '1' then
1780 dff(clock, input, ffOut);
1785 use IEEE.std_logic_1164.all;
1787 entity DFF is port (
1795 architecture rtl of DFF is
1800 wait until rising_edge(clk);
1808 use IEEE.std_logic_1164.all;
1810 entity DFF is port (
1811 d1, d2: in std_logic;
1813 srst : in std_logic;
1814 q1, q2: out std_logic
1818 architecture rtl of DFF is
1823 if clk'event and clk = '1' then
1837 use IEEE.std_logic_1164.all;
1839 entity DFFE_SR is port (
1849 architecture rtl of DFFE_SR is
1853 process (clk, rst, prst) begin
1856 elsif (prst = '1') then
1858 elsif (clk'event and clk = '1') then
1869 use IEEE.std_logic_1164.all;
1871 entity DFF is port (
1874 srst : in std_logic;
1879 architecture rtl of DFF is
1884 wait until clk = '1';
1894 use IEEE.std_logic_1164.all;
1896 entity struct_dffe_sr is port (
1900 rst,prst: in std_logic;
1905 use work.primitive.all;
1907 architecture instance of struct_dffe_sr is
1911 ff: dffe_sr port map (
1922 use IEEE.std_logic_1164.all;
1924 entity DFF is port (
1927 srst : in std_logic;
1932 architecture rtl of DFF is
1937 if clk'event and clk = '1' then
1948 use IEEE.std_logic_1164.all;
1950 entity struct_dffe is port (
1958 use work.primitive.all;
1960 architecture instance of struct_dffe is
1973 use IEEE.std_logic_1164.all;
1975 use work.primitive.all;
1978 generic (size: integer := 8);
1980 data: in std_logic_vector(size - 1 downto 0);
1981 clock: in std_logic;
1982 ff_enable: in std_logic;
1983 op_enable: in std_logic;
1984 qout: out std_logic_vector(size - 1 downto 0)
1988 architecture parameterize of dffTri is
1990 type tribufType is record
1996 type tribufArrayType is array (integer range <>) of tribufType;
1998 signal tri: tribufArrayType(size - 1 downto 0);
2002 g0: for i in 0 to size - 1 generate
2003 u1: DFFE port map (data(i), tri(i).ip, ff_enable, clock);
2006 g1: for i in 0 to size - 1 generate
2007 u2: TRIBUF port map (tri(i).ip, tri(i).oe, tri(i).op);
2008 tri(i).oe <= op_enable;
2009 qout(i) <= tri(i).op;
2014 use IEEE.std_logic_1164.all;
2016 entity DFF is port (
2024 architecture rtl of DFF is
2029 wait until clk = '1';
2037 use IEEE.std_logic_1164.all;
2039 entity TRIBUF is port (
2042 op: out std_logic bus
2046 architecture sequential of TRIBUF is
2050 enable: process (ip,oe) begin
2060 use IEEE.std_logic_1164.all;
2062 entity DLATCHH is port (
2069 architecture rtl of DLATCHH is
2071 signal qLocal: std_logic;
2075 qLocal <= d when en = '1' else qLocal;
2081 use IEEE.std_logic_1164.all;
2083 entity DLATCHH is port (
2090 architecture rtl of DLATCHH is
2094 process (en, d) begin
2102 use IEEE.std_logic_1164.all;
2104 entity struct_dlatch is port (
2111 use work.primitive.all;
2113 architecture instance of struct_dlatch is
2117 latch: dlatchh port map (
2124 -- Incorporates Errata 5.4
2127 use ieee.std_logic_1164.all;
2128 use ieee.numeric_std.all;
2130 entity downCounter is port (
2132 reset: in std_logic;
2133 count: out std_logic_vector(3 downto 0)
2137 architecture simple of downCounter is
2139 signal countL: unsigned(3 downto 0);
2140 signal termCnt: std_logic;
2144 decrement: process (clk, reset) begin
2145 if (reset = '1') then
2146 countL <= "1011"; -- Reset to 11
2148 elsif(clk'event and clk = '1') then
2149 if (termCnt = '1') then
2150 countL <= "1011"; -- Count rolls over to 11
2152 countL <= countL - 1;
2155 if (countL = "0001") then -- Terminal count decoded 1 cycle earlier
2163 count <= std_logic_vector(countL);
2167 use ieee.std_logic_1164.all;
2168 use ieee.std_logic_unsigned.all;
2170 entity compareDC is port (
2171 addressBus: in std_logic_vector(31 downto 0);
2172 addressHit: out std_logic
2176 architecture wontWork of compareDC is
2180 compare: process(addressBus) begin
2181 if (addressBus = "011110101011--------------------") then
2186 end process compare;
2190 use ieee.std_logic_1164.all;
2192 port (invec: in std_logic_vector(7 downto 0);
2193 enc_out: out std_logic_vector(2 downto 0)
2197 architecture rtl of encoder is
2201 encode: process (invec) begin
2235 use ieee.std_logic_1164.all;
2238 port (invec:in std_logic_vector(7 downto 0);
2239 enc_out:out std_logic_vector(2 downto 0)
2243 architecture rtl of encoder is
2247 if invec(7) = '1' then
2250 elsif invec(6) = '1' then
2253 elsif invec(5) = '1' then
2256 elsif invec(4) = '1' then
2259 elsif invec(3) = '1' then
2262 elsif invec(2) = '1' then
2265 elsif invec(1) = '1' then
2268 elsif invec(0) = '1' then
2278 use ieee.std_logic_1164.all;
2280 port (invec: in std_logic_vector(7 downto 0);
2281 enc_out: out std_logic_vector(2 downto 0)
2285 architecture rtl of encoder is
2288 enc_out <= "111" when invec(7) = '1' else
2289 "110" when invec(6) = '1' else
2290 "101" when invec(5) = '1' else
2291 "100" when invec(4) = '1' else
2292 "011" when invec(3) = '1' else
2293 "010" when invec(2) = '1' else
2294 "001" when invec(1) = '1' else
2295 "000" when invec(0) = '1' else
2299 -- includes Errata 5.2
2301 use ieee.std_logic_1164.all;
2302 use ieee.numeric_std.all; -- errata 5.2
2304 entity compare is port (
2305 ina: in std_logic_vector (3 downto 0);
2306 inb: in std_logic_vector (2 downto 0);
2307 equal: out std_logic
2311 architecture simple of compare is
2315 equalProc: process (ina, inb) begin
2316 if (ina = inb ) then
2325 use IEEE.std_logic_1164.all;
2327 entity LogicFcn is port (
2335 architecture behavioral of LogicFcn is
2339 fcn: process (A,B,C) begin
2341 if (A = '0' and B = '0') then
2353 use IEEE.std_logic_1164.all;
2355 entity LogicFcn is port (
2363 architecture dataflow of LogicFcn is
2367 Y <= '1' when (A = '0' AND B = '0') OR
2373 use IEEE.std_logic_1164.all;
2374 use work.primitive.all;
2376 entity LogicFcn is port (
2384 architecture structural of LogicFcn is
2386 signal notA, notB, andSignal: std_logic;
2390 i1: inverter port map (i => A,
2393 i2: inverter port map (i => B,
2396 a1: and2 port map (i1 => notA,
2400 o1: or2 port map (i1 => andSignal,
2406 use IEEE.std_logic_1164.all;
2408 entity SimDFF is port (
2409 D, Clk: in std_logic;
2414 architecture SimModel of SimDFF is
2416 constant tCQ: time := 8 ns;
2417 constant tS: time := 4 ns;
2418 constant tH: time := 3 ns;
2422 reg: process (Clk, D) begin
2424 -- Assign output tCQ after rising clock edge
2425 if (Clk'event and Clk = '1') then
2430 if (Clk'event and Clk = '1') then
2431 assert (D'last_event >= tS)
2432 report "Setup time violation"
2437 if (D'event and Clk'stable and Clk = '1') then
2438 assert (D'last_event - Clk'last_event > tH)
2439 report "Hold Time Violation"
2447 use IEEE.std_logic_1164.all;
2449 entity DFF is port (
2456 architecture rtl of DFF is
2461 wait until clk = '1';
2467 use IEEE.std_logic_1164.all;
2469 entity DFF is port (
2476 architecture rtl of DFF is
2481 wait until clk = '1';
2488 configuration SimpleGatesCfg of FEWGATES is
2493 use entity work.and2(rtl);
2497 use entity work.inverter(rtl);
2501 use entity work.or2(rtl);
2507 configuration SimpleGatesCfg of FEWGATES is
2512 use entity work.and2(rtl);
2516 use entity work.and2(rtl);
2520 use entity work.inverter(rtl);
2524 use entity work.or2(rtl);
2531 use IEEE.std_logic_1164.all;
2533 entity FEWGATES is port (
2534 a,b,c,d: in std_logic;
2543 architecture structural of FEWGATES is
2545 component AND2 port (
2552 component OR2 port (
2559 component INVERTER port (
2565 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2569 u1: and2 port map (i1 => a ,
2574 u2: and2 port map (i1 => c,
2579 u3: inverter port map (i => c_and_d,
2582 u4: or2 port map (i1 => a_and_b,
2588 use IEEE.std_logic_1164.all;
2590 entity FEWGATES is port (
2591 a,b,c,d: in std_logic;
2600 architecture structural of FEWGATES is
2602 component AND2 port (
2609 component OR2 port (
2616 component INVERTER port (
2622 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2624 -- Configution specifications
2626 for all: and2 use entity work.and2(rtl);
2627 for u3: inverter use entity work.inverter(rtl);
2628 for u4: or2 use entity work.or2(rtl);
2632 u1: and2 port map (i1 => a, i2 => b,
2636 u2: and2 port map (i1 => c, i2 => d,
2640 u3: inverter port map (i => c_and_d,
2643 u4: or2 port map (i1 => a_and_b, i2 => not_c_and_d,
2648 use IEEE.std_logic_1164.all;
2650 entity FEWGATES is port (
2651 a,b,c,d: in std_logic;
2656 use work.GatesPkg.all;
2658 architecture structural of FEWGATES is
2660 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2664 u1: and2 port map (i1 => a ,
2669 u2: and2 port map (i1 => c,
2674 u3: inverter port map (i => c_and_d,
2677 u4: or2 port map (i1 => a_and_b,
2683 use IEEE.std_logic_1164.all;
2686 entity FEWGATES is port (
2687 a,b,c,d: in std_logic;
2692 architecture concurrent of FEWGATES is
2694 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2698 a_and_b <= '1' when a = '1' and b = '1' else '0';
2699 c_and_d <= '1' when c = '1' and d = '1' else '0';
2701 not_c_and_d <= not c_and_d;
2703 y <= '1' when a_and_b = '1' or not_c_and_d = '1' else '0';
2707 use IEEE.std_logic_1164.all;
2711 component AND2 port (
2718 component OR2 port (
2725 component INVERTER port (
2733 use IEEE.std_logic_1164.all;
2735 use work.primitive.all;
2737 entity FEWGATES is port (
2738 a,b,c,d: in std_logic;
2743 architecture structural of FEWGATES is
2745 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2749 u1: and2 port map (i1 => a ,
2754 u2: and2 port map (i1 =>c,
2759 u3: inverter port map (a => c_and_d,
2762 u4: or2 port map (i1 => a_and_b,
2769 use IEEE.std_logic_1164.all;
2771 entity AND2 is port (
2778 architecture rtl of AND2 is
2782 y <= '1' when i1 = '1' and i2 = '1' else '0';
2787 use IEEE.std_logic_1164.all;
2789 entity OR2 is port (
2796 architecture rtl of OR2 is
2800 y <= '1' when i1 = '1' or i2 = '1' else '0';
2805 use IEEE.std_logic_1164.all;
2807 entity INVERTER is port (
2813 architecture rtl of INVERTER is
2822 use IEEE.std_logic_1164.all;
2824 entity FEWGATES is port (
2825 a,b,c,d: in std_logic;
2830 architecture structural of FEWGATES is
2832 component AND2 port (
2839 component OR2 port (
2846 component INVERTER port (
2852 signal a_and_b, c_and_d, not_c_and_d: std_logic;
2856 u1: and2 port map (i1 => a ,
2861 u2: and2 port map (i1 => c,
2866 u3: inverter port map (i => c_and_d,
2869 u4: or2 port map (i1 => a_and_b,
2875 use IEEE.std_logic_1164.all;
2877 use work.simPrimitives.all;
2879 entity simHierarchy is port (
2880 A, B, Clk: in std_logic;
2885 architecture hierarchical of simHierarchy is
2887 signal ADly, BDly, OrGateDly, ClkDly: std_logic;
2888 signal OrGate, FlopOut: std_logic;
2892 ADly <= transport A after 2 ns;
2893 BDly <= transport B after 2 ns;
2894 OrGateDly <= transport OrGate after 1.5 ns;
2895 ClkDly <= transport Clk after 1 ns;
2897 u1: OR2 generic map (tPD => 10 ns)
2898 port map ( I1 => ADly,
2903 u2: simDFF generic map ( tS => 4 ns,
2907 port map ( D => OrGateDly,
2912 Y <= transport FlopOut after 2 ns;
2916 use IEEE.std_logic_1164.all;
2919 use IEEE.std_logic_1164.all;
2921 entity INVERTER is port (
2927 architecture rtl of INVERTER is
2934 --------------------------------------------------------------------------------
2935 --| File name : $RCSfile: io1164.vhd $
2936 --| Library : SUPPORT
2937 --| Revision : $Revision: 1.1 $
2938 --| Author(s) : Vantage Analysis Systems, Inc; Des Young
2939 --| Integration : Des Young
2940 --| Creation : Nov 1995
2941 --| Status : $State: Exp $
2943 --| Purpose : IO routines for std_logic_1164.
2944 --| Assumptions : Numbers use radixed character set with no prefix.
2945 --| Limitations : Does not read VHDL pound-radixed numbers.
2946 --| Known Errors: none
2949 --| This is a modified library. The source is basically that donated by
2950 --| Vantage to libutil. Des Young removed std_ulogic_vector support (to
2951 --| conform to synthesizable libraries), and added read_oct/hex to integer.
2953 --| =======================================================================
2954 --| Copyright (c) 1992-1994 Vantage Analysis Systems, Inc., all rights
2955 --| reserved. This package is provided by Vantage Analysis Systems.
2956 --| The package may not be sold without the express written consent of
2957 --| Vantage Analysis Systems, Inc.
2959 --| The VHDL for this package may be copied and/or distributed as long as
2960 --| this copyright notice is retained in the source and any modifications
2961 --| are clearly marked in the History: list.
2963 --| Title : IO1164 package VHDL source
2964 --| Package Name: somelib.IO1164
2965 --| File Name : io1164.vhdl
2967 --| Purpose : * Overloads procedures READ and WRITE for STD_LOGIC types
2968 --| in manner consistent with TEXTIO package.
2969 --| * Provides procedures to read and write logic values as
2970 --| binary, octal, or hexadecimal values ('X' as appropriate
).
2971 --| These should be particularly useful for models
2972 --| to read in stimulus as 0/1/x or octal or hex.
2975 --| History : 1. Donated to libutil by Dave Bernstein 15 Jun 94
2976 --| 2. Removed all std_ulogic_vector support, Des Young, 14 Nov 95
2977 --| (This is because that type is not supported for synthesis).
2978 --| 3. Added read_oct/hex to integer, Des Young, 20 Nov 95
2980 --| =======================================================================
2981 --| Extra routines by Des Young, des@alantec.com. 1995. GNU copyright.
2982 --| =======================================================================
2984 --------------------------------------------------------------------------------
2989 --$ !VANTAGE_METACOMMENTS_ON
2992 -- import std_logic package
2993 use ieee.std_logic_1164.
all;
2995 -- import textio package
2999 -- the READ and WRITE procedures act similarly to the procedures in the
3000 -- STD.TEXTIO package. for each type, there are two read procedures and
3001 -- one write procedure for converting between character and internal
3002 -- representations of values. each value is represented as the string of
3003 -- characters that you would use in VHDL code. (remember that apostrophes
3004 -- and quotation marks are not used.) input is case-insensitive. output
3005 -- is in upper case. see the following LRM sections for more information:
3007 -- 2.3 - Subprogram Overloading
3008 -- 3.3 - Access Types (STD.TEXTIO.LINE is an access type)
3009 -- 7.3.6 - Allocators (allocators create access values)
3010 -- 14.3 - Package TEXTIO
3013 -- Note that the procedures for std_ulogic will match calls with the value
3014 -- parameter of type std_logic.
3017 -- declare READ procedures to overload like in TEXTIO
3019 procedure read
(l
: inout line
; value
: out std_ulogic
; good
: out boolean);
3020 procedure read
(l
: inout line
; value
: out std_ulogic
);
3021 procedure read
(l
: inout line
; value
: out std_logic_vector ; good
: out boolean);
3022 procedure read
(l
: inout line
; value
: out std_logic_vector );
3025 -- declare WRITE procedures to overload like in TEXTIO
3027 procedure write
(l
: inout line
;
3028 value
: in std_ulogic
;
3029 justified
: in side
:= right
;
3030 field
: in width
:= 0 );
3031 procedure write
(l
: inout line
;
3032 value
: in std_logic_vector ;
3033 justified
: in side
:= right
;
3034 field
: in width
:= 0 );
3037 -- declare procedures to convert between logic values and octal
3038 -- or hexadecimal ('X' where appropriate).
3041 -- octal / std_logic_vector
3042 procedure read_oct
(l
: inout line
;
3043 value
: out std_logic_vector ;
3044 good
: out boolean );
3045 procedure read_oct
(l
: inout line
;
3046 value
: out std_logic_vector );
3047 procedure write_oct
(l
: inout line
;
3048 value
: in std_logic_vector ;
3049 justified
: in side
:= right
;
3050 field
: in width
:= 0 );
3052 -- hexadecimal / std_logic_vector
3053 procedure read_hex
(l
: inout line
;
3054 value
: out std_logic_vector ;
3055 good
: out boolean );
3056 procedure read_hex
(l
: inout line
;
3057 value
: out std_logic_vector );
3058 procedure write_hex
(l
: inout line
;
3059 value
: in std_logic_vector ;
3060 justified
: in side
:= right
;
3061 field
: in width
:= 0 );
3063 -- read a number into an integer
3064 procedure read_oct
(l
: inout line
;
3065 value
: out integer;
3066 good
: out boolean);
3067 procedure read_oct
(l
: inout line
;
3068 value
: out integer);
3069 procedure read_hex
(l
: inout line
;
3070 value
: out integer;
3071 good
: out boolean);
3072 procedure read_hex
(l
: inout line
;
3073 value
: out integer);
3077 --------------------------------------------------------------------------------
3078 --| Copyright (c) 1992-1994 Vantage Analysis Systems, Inc., all rights reserved
3079 --| This package is provided by Vantage Analysis Systems.
3080 --| The package may not be sold without the express written consent of
3081 --| Vantage Analysis Systems, Inc.
3083 --| The VHDL for this package may be copied and/or distributed as long as
3084 --| this copyright notice is retained in the source and any modifications
3085 --| are clearly marked in the History: list.
3087 --| Title : IO1164 package body VHDL source
3088 --| Package Name: VANTAGE_LOGIC.IO1164
3089 --| File Name : io1164.vhdl
3091 --| Purpose : source for IO1164 package body
3093 --| Notes : see package declaration
3094 --| History : see package declaration
3095 --------------------------------------------------------------------------------
3097 package body io1164
is
3100 --$ !VANTAGE_METACOMMENTS_ON
3103 -- define lowercase conversion of characters for canonical comparison
3104 type char2char_t
is array (character'low to character'high) of character;
3105 constant lowcase
: char2char_t
:= (
3106 nul
, soh
, stx
, etx
, eot
, enq
, ack
, bel
,
3107 bs
, ht
, lf
, vt
, ff
, cr
, so
, si
,
3108 dle
, dc1
, dc2
, dc3
, dc4
, nak
, syn
, etb
,
3109 can
, em
, sub
, esc
, fsp
, gsp
, rsp
, usp
,
3111 ' ', '!', '"', '#', '$', '%', '&', ''',
3112 '(', ')', '*', '+', ',', '-', '.
', '/',
3113 '0', '1', '2', '3', '4', '5', '6', '7',
3114 '8', '9', ':', ';', '<', '=', '>', '?
',
3116 '@
', 'a
', 'b
', 'c
', 'd
', 'e
', 'f
', 'g
',
3117 'h
', 'i
', 'j
', 'k
', 'l
', 'm
', 'n
', 'o
',
3118 'p
', 'q
', 'r
', 's
', 't
', 'u
', 'v
', 'w
',
3119 'x
', 'y
', 'z
', '[', '\', ']', '^', '_',
3121 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
3122 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
3123 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
3124 'x', 'y', 'z', '{', '|', '}', '~', del
);
3126 -- define conversions between various types
3128 -- logic -> character
3129 type f_logic_to_character_t
is
3130 array (std_ulogic
'low to std_ulogic
'high) of character;
3131 constant f_logic_to_character
: f_logic_to_character_t
:=
3144 -- character, integer, logic
3146 constant x_charcode
: integer := -1;
3147 constant maxoct_charcode
: integer := 7;
3148 constant maxhex_charcode
: integer := 15;
3149 constant bad_charcode
: integer := integer'left;
3152 array ( character'low to character'high ) of integer;
3153 constant octdigit2int
: digit2int_t
:= (
3154 '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
3155 '5' => 5, '6' => 6, '7' => 7,
3156 'X' |
'x' => x_charcode
, others => bad_charcode
);
3157 constant hexdigit2int
: digit2int_t
:= (
3158 '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
3159 '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9,
3160 'A' |
'a' => 10, 'B' |
'b' => 11, 'C' |
'c' => 12,
3161 'D' |
'd' => 13, 'E' |
'e' => 14, 'F' |
'f' => 15,
3162 'X' |
'x' => x_charcode
, others => bad_charcode
);
3164 constant oct_bits_per_digit
: integer := 3;
3165 constant hex_bits_per_digit
: integer := 4;
3167 type int2octdigit_t
is
3168 array ( 0 to maxoct_charcode
) of character;
3169 constant int2octdigit
: int2octdigit_t
:=
3170 ( 0 => '0', 1 => '1', 2 => '2', 3 => '3',
3171 4 => '4', 5 => '5', 6 => '6', 7 => '7' );
3173 type int2hexdigit_t
is
3174 array ( 0 to maxhex_charcode
) of character;
3175 constant int2hexdigit
: int2hexdigit_t
:=
3176 ( 0 => '0', 1 => '1', 2 => '2', 3 => '3',
3177 4 => '4', 5 => '5', 6 => '6', 7 => '7',
3178 8 => '8', 9 => '9', 10 => 'A', 11 => 'B',
3179 12 => 'C', 13 => 'D', 14 => 'E', 15 => 'F' );
3181 type oct_logic_vector_t
is
3182 array(1 to oct_bits_per_digit
) of std_ulogic
;
3183 type octint2logic_t
is
3184 array (x_charcode
to maxoct_charcode
) of oct_logic_vector_t
;
3185 constant octint2logic
: octint2logic_t
:= (
3197 type hex_logic_vector_t
is
3198 array(1 to hex_bits_per_digit
) of std_ulogic
;
3199 type hexint2logic_t
is
3200 array (x_charcode
to maxhex_charcode
) of hex_logic_vector_t
;
3201 constant hexint2logic
: hexint2logic_t
:= (
3202 ( 'X', 'X', 'X', 'X' ),
3203 ( '0', '0', '0', '0' ),
3204 ( '0', '0', '0', '1' ),
3205 ( '0', '0', '1', '0' ),
3206 ( '0', '0', '1', '1' ),
3207 ( '0', '1', '0', '0' ),
3208 ( '0', '1', '0', '1' ),
3209 ( '0', '1', '1', '0' ),
3210 ( '0', '1', '1', '1' ),
3211 ( '1', '0', '0', '0' ),
3212 ( '1', '0', '0', '1' ),
3213 ( '1', '0', '1', '0' ),
3214 ( '1', '0', '1', '1' ),
3215 ( '1', '1', '0', '0' ),
3216 ( '1', '1', '0', '1' ),
3217 ( '1', '1', '1', '0' ),
3218 ( '1', '1', '1', '1' )
3221 ----------------------------------------------------------------------------
3222 -- READ procedure bodies
3224 -- The strategy for duplicating TEXTIO's overloading of procedures
3225 -- with and without GOOD parameters is to put all the logic in the
3226 -- version with the GOOD parameter and to have the version without
3227 -- GOOD approximate a runtime error by use of an assertion.
3229 ----------------------------------------------------------------------------
3233 -- note: compatible with std_logic
3236 procedure read
( l
: inout line
; value
: out std_ulogic
; good
: out boolean ) is
3238 variable c
: character; -- char read while looping
3239 variable m
: line
; -- safe copy of L
3240 variable success
: boolean := false
; -- readable version of GOOD
3241 variable done
: boolean := false
; -- flag to say done reading chars
3248 -- if there are characters in the line
3249 -- save a copy of the line
3250 -- get the next character
3256 -- free passed in line
3257 -- assign copy back to line
3261 -- only operate on lines that contain characters
3262 if ( ( l
/= null ) and ( l.
all'length /= 0 ) ) then
3264 -- save a copy of string in case read fails
3265 m
:= new string'( l.all );
3267 -- grab the next character
3268 read( l, c, success );
3274 -- an issue here is whether lower-case values should be accepted or not
3277 -- determine the value
3279 when 'U
' | 'u
' => value := 'U
';
3280 when 'X
' | 'x
' => value := 'X
';
3281 when '0' => value := '0';
3282 when '1' => value := '1';
3283 when 'Z
' | 'z
' => value := 'Z
';
3284 when 'W
' | 'w
' => value := 'W
';
3285 when 'L
' | 'l
' => value := 'L
';
3286 when 'H
' | 'h
' => value := 'H
';
3287 when '-' => value := '-';
3288 when others => success := false;
3293 -- free working storage
3301 end if; -- non null access, non empty string
3303 -- set output parameter
3308 procedure read( l: inout line; value: out std_ulogic ) is
3309 variable success: boolean; -- internal good flag
3311 read( l, value, success ); -- use safe version
3313 report "IO1164.READ: Unable to read STD_ULOGIC value."
3319 -- note: NOT compatible with std_ulogic_vector
3322 procedure read(l : inout line ;
3323 value: out std_logic_vector;
3324 good : out boolean ) is
3326 variable m : line ; -- saved copy of L
3327 variable success : boolean := true; -- readable GOOD
3328 variable logic_value : std_logic ; -- value for one array element
3329 variable c : character ; -- read a character
3336 -- this procedure strips off leading whitespace, and then calls the
3337 -- READ procedure for each single logic value element in the output
3341 -- only operate on lines that contain characters
3342 if ( ( l /= null ) and ( l.all'length /= 0 ) ) then
3344 -- save a copy of string in case read fails
3345 m := new string'( l.
all );
3347 -- loop for each element in output array
3348 for i
in value
'range loop
3350 -- prohibit internal blanks
3351 if i
/= value
'left then
3352 if l.
all'length = 0 then
3356 c
:= l.
all(l.
all'left);
3357 if c
= ' ' or c
= ht
then
3363 -- read the next logic value
3364 read
( l
, logic_value
, success
);
3366 -- stuff the value in if ok, else bail out
3368 value
( i
) := logic_value
;
3373 end loop; -- each element in output array
3375 -- free working storage
3383 elsif ( value
'length /= 0 ) then
3384 -- string is empty but the return array has 1+ elements
3388 -- set output parameter
3393 procedure read
(l
: inout line
; value
: out std_logic_vector ) is
3394 variable success
: boolean;
3396 read
( l
, value
, success
);
3398 report "IO1164.READ
: Unable
to read T_WLOGIC_VECTOR value."
3402 ----------------------------------------------------------------------------
3403 -- WRITE procedure bodies
3404 ----------------------------------------------------------------------------
3408 -- note: compatible with std_logic
3411 procedure write
(l
: inout line
;
3412 value
: in std_ulogic
;
3413 justified
: in side
:= right
;
3414 field
: in width
:= 0 ) is
3420 -- just write out the string associated with the enumerated
3425 when 'U' => write
( l
, character'('U'), justified
, field
);
3426 when 'X' => write
( l
, character'('X'), justified
, field
);
3427 when '0' => write
( l
, character'('0'), justified
, field
);
3428 when '1' => write
( l
, character'('1'), justified
, field
);
3429 when 'Z' => write
( l
, character'('Z'), justified
, field
);
3430 when 'W' => write
( l
, character'('W'), justified
, field
);
3431 when 'L' => write
( l
, character'('L'), justified
, field
);
3432 when 'H' => write
( l
, character'('H'), justified
, field
);
3433 when '-' => write
( l
, character'('-'), justified, field );
3439 -- note: NOT compatible with std_ulogic_vector
3442 procedure write(l : inout line ;
3443 value : in std_logic_vector ;
3444 justified: in side := right;
3445 field : in width := 0 ) is
3447 variable m: line; -- build up intermediate string
3454 -- for each value in array
3455 -- add string representing value to intermediate string
3456 -- write intermediate string to line parameter
3457 -- free intermediate string
3460 -- for each value in array
3461 for i in value'range loop
3463 -- add string representing value to intermediate string
3464 write( m, value( i ) );
3468 -- write intermediate string to line parameter
3469 write( l, m.all, justified, field );
3471 -- free intermediate string
3477 --------------------------------------------------------------------------------
3479 ----------------------------------------------------------------------------
3480 -- procedure bodies for octal and hexadecimal read and write
3481 ----------------------------------------------------------------------------
3484 -- std_logic_vector/octal
3485 -- note: NOT compatible with std_ulogic_vector
3488 procedure read_oct(l : inout line ;
3489 value : out std_logic_vector;
3490 good : out boolean ) is
3492 variable m : line ; -- safe L
3493 variable success : boolean := true; -- readable GOOD
3494 variable logic_value : std_logic ; -- elem value
3495 variable c : character ; -- char read
3496 variable charcode : integer ; -- char->int
3497 variable oct_logic_vector: oct_logic_vector_t ; -- for 1 digit
3498 variable bitpos : integer ; -- in state vec.
3504 -- skip over leading blanks, then read a digit
3505 -- and do a conversion into a logic value
3506 -- for each element in array
3509 -- make sure logic array is right size to read this base
3510 success := ( ( value'length rem oct_bits_per_digit ) = 0 );
3513 -- only operate on non-empty strings
3514 if ( ( l /= null ) and ( l.all'length /= 0 ) ) then
3516 -- save old copy of string in case read fails
3517 m := new string'( l.
all );
3519 -- pick off leading white space and get first significant char
3521 while success
and ( l.
all'length > 0 ) and ( ( c
= ' ' ) or ( c
= ht
) ) loop
3522 read
( l
, c
, success
);
3525 -- turn character into integer
3526 charcode
:= octdigit2int
( c
);
3528 -- not doing any bits yet
3531 -- check for bad first character
3532 if charcode
= bad_charcode
then
3535 -- loop through each value in array
3536 oct_logic_vector
:= octint2logic
( charcode
);
3537 for i
in value
'range loop
3539 -- doing the next bit
3540 bitpos
:= bitpos
+ 1;
3542 -- stick the value in
3543 value
( i
) := oct_logic_vector
( bitpos
);
3545 -- read the next character if we're not at array end
3546 if ( bitpos
= oct_bits_per_digit
) and ( i
/= value
'right ) then
3547 read
( l
, c
, success
);
3551 -- turn character into integer
3552 charcode
:= octdigit2int
( c
);
3553 -- check for bad char
3554 if charcode
= bad_charcode
then
3558 -- reset bit position
3560 -- turn character code into state array
3561 oct_logic_vector
:= octint2logic
( charcode
);
3564 end loop; -- each index in return array
3566 end if; -- if bad first character
3568 -- clean up working storage
3576 -- no characters to read for return array that isn't null slice
3577 elsif ( value
'length /= 0 ) then
3579 end if; -- non null access, non empty string
3583 -- set out parameter of success
3589 procedure read_oct
(l
: inout line
;
3590 value
: out std_logic_vector) is
3591 variable success
: boolean; -- internal good flag
3593 read_oct
( l
, value
, success
); -- use safe version
3595 report "IO1164.READ_OCT
: Unable
to read T_LOGIC_VECTOR value."
3599 procedure write_oct
(l
: inout line
;
3600 value
: in std_logic_vector ;
3601 justified
: in side
:= right
;
3602 field
: in width
:= 0 ) is
3604 variable m
: line
; -- safe copy of L
3605 variable goodlength
: boolean ; -- array is ok len for this base
3606 variable isx
: boolean ; -- an X in this digit
3607 variable integer_value
: integer ; -- accumulate integer value
3608 variable c
: character; -- character read
3609 variable charpos
: integer ; -- index string being contructed
3610 variable bitpos
: integer ; -- bit index inside digit
3617 -- make sure this array can be written in this base
3618 -- create a string to place intermediate results
3619 -- initialize counters and flags to beginning of string
3620 -- for each item in array
3621 -- note unknown, else accumulate logic into integer
3622 -- if at this digit's last bit
3623 -- stuff digit just computed into intermediate result
3624 -- reset flags and counters except for charpos
3625 -- write intermediate result into line
3626 -- free work storage
3629 -- make sure this array can be written in this base
3630 goodlength
:= ( ( value
'length rem oct_bits_per_digit
) = 0 );
3632 report "IO1164.WRITE_OCT
: VALUE
'Length is not a multiple
of 3."
3636 -- create a string to place intermediate results
3637 m
:= new string(1 to ( value
'length / oct_bits_per_digit
) );
3639 -- initialize counters and flags to beginning of string
3645 -- for each item in array
3646 for i
in value
'range loop
3648 -- note unknown, else accumulate logic into integer
3651 integer_value
:= integer_value
* 2;
3653 integer_value
:= ( integer_value
* 2 ) + 1;
3658 -- see if we've done this digit's last bit
3659 bitpos
:= bitpos
+ 1;
3660 if bitpos
= oct_bits_per_digit
then
3662 -- stuff the digit just computed into the intermediate result
3663 charpos
:= charpos
+ 1;
3665 m.
all(charpos
) := 'X';
3667 m.
all(charpos
) := int2octdigit
( integer_value
);
3670 -- reset flags and counters except for location in string being constructed
3679 -- write intermediate result into line
3680 write
( l
, m.
all, justified
, field
);
3682 -- free work storage
3690 -- std_logic_vector/hexadecimal
3691 -- note: NOT compatible with std_ulogic_vector
3694 procedure read_hex
(l
: inout line
;
3695 value
: out std_logic_vector;
3696 good
: out boolean ) is
3698 variable m
: line
; -- safe L
3699 variable success
: boolean := true
; -- readable GOOD
3700 variable logic_value
: std_logic ; -- elem value
3701 variable c
: character ; -- char read
3702 variable charcode
: integer ; -- char->int
3703 variable hex_logic_vector
: hex_logic_vector_t
; -- for 1 digit
3704 variable bitpos
: integer ; -- in state vec.
3710 -- skip over leading blanks, then read a digit
3711 -- and do a conversion into a logic value
3712 -- for each element in array
3715 -- make sure logic array is right size to read this base
3716 success
:= ( ( value
'length rem hex_bits_per_digit
) = 0 );
3719 -- only operate on non-empty strings
3720 if ( ( l
/= null ) and ( l.
all'length /= 0 ) ) then
3722 -- save old copy of string in case read fails
3723 m
:= new string'( l.all );
3725 -- pick off leading white space and get first significant char
3727 while success and ( l.all'length > 0 ) and ( ( c = ' ' ) or ( c = ht ) ) loop
3728 read( l, c, success );
3731 -- turn character into integer
3732 charcode := hexdigit2int( c );
3734 -- not doing any bits yet
3737 -- check for bad first character
3738 if charcode = bad_charcode then
3741 -- loop through each value in array
3742 hex_logic_vector := hexint2logic( charcode );
3743 for i in value'range loop
3745 -- doing the next bit
3746 bitpos := bitpos + 1;
3748 -- stick the value in
3749 value( i ) := hex_logic_vector( bitpos );
3751 -- read the next character if we're not at array end
3752 if ( bitpos = hex_bits_per_digit ) and ( i /= value'right ) then
3753 read( l, c, success );
3757 -- turn character into integer
3758 charcode := hexdigit2int( c );
3759 -- check for bad char
3760 if charcode = bad_charcode then
3764 -- reset bit position
3766 -- turn character code into state array
3767 hex_logic_vector := hexint2logic( charcode );
3770 end loop; -- each index in return array
3772 end if; -- if bad first character
3774 -- clean up working storage
3782 -- no characters to read for return array that isn't null slice
3783 elsif ( value'length /= 0 ) then
3785 end if; -- non null access, non empty string
3789 -- set out parameter of success
3795 procedure read_hex(l : inout line ;
3796 value : out std_logic_vector) is
3797 variable success: boolean; -- internal good flag
3799 read_hex( l, value, success ); -- use safe version
3801 report "IO1164.READ_HEX: Unable to read T_LOGIC_VECTOR value."
3805 procedure write_hex(l : inout line ;
3806 value : in std_logic_vector ;
3807 justified: in side := right;
3808 field : in width := 0 ) is
3810 variable m : line ; -- safe copy of L
3811 variable goodlength : boolean ; -- array is ok len for this base
3812 variable isx : boolean ; -- an X in this digit
3813 variable integer_value: integer ; -- accumulate integer value
3814 variable c : character; -- character read
3815 variable charpos : integer ; -- index string being contructed
3816 variable bitpos : integer ; -- bit index inside digit
3823 -- make sure this array can be written in this base
3824 -- create a string to place intermediate results
3825 -- initialize counters and flags to beginning of string
3826 -- for each item in array
3827 -- note unknown, else accumulate logic into integer
3828 -- if at this digit's last bit
3829 -- stuff digit just computed into intermediate result
3830 -- reset flags and counters except for charpos
3831 -- write intermediate result into line
3832 -- free work storage
3835 -- make sure this array can be written in this base
3836 goodlength := ( ( value'length rem hex_bits_per_digit ) = 0 );
3838 report "IO1164.WRITE_HEX: VALUE'Length is not a multiple of 4."
3842 -- create a string to place intermediate results
3843 m := new string(1 to ( value'length / hex_bits_per_digit ) );
3845 -- initialize counters and flags to beginning of string
3851 -- for each item in array
3852 for i in value'range loop
3854 -- note unknown, else accumulate logic into integer
3857 integer_value := integer_value * 2;
3859 integer_value := ( integer_value * 2 ) + 1;
3864 -- see if we've done this digit's last bit
3865 bitpos := bitpos + 1;
3866 if bitpos = hex_bits_per_digit then
3868 -- stuff the digit just computed into the intermediate result
3869 charpos := charpos + 1;
3871 m.all(charpos) := 'X
';
3873 m.all(charpos) := int2hexdigit( integer_value );
3876 -- reset flags and counters except for location in string being constructed
3885 -- write intermediate result into line
3886 write( l, m.all, justified, field );
3888 -- free work storage
3895 ------------------------------------------------------------------------------
3897 ------------------------------------
3898 -- Read octal/hex numbers to integer
3899 ------------------------------------
3902 -- Read octal to integer
3905 procedure read_oct(l : inout line;
3906 value : out integer;
3907 good : out boolean) is
3909 variable pos : integer;
3910 variable digit : integer;
3911 variable result : integer := 0;
3912 variable success : boolean := true;
3913 variable c : character;
3914 variable old_l : line := l;
3919 -- skip leading white space, read digit, convert
3923 -- set pos to start of actual number by skipping white space
3926 while ( l.all'length > 0 ) and ( ( c = ' ' ) or ( c = HT ) ) loop
3931 -- check for start of valid number
3932 digit := octdigit2int(l(pos));
3934 if ((digit = bad_charcode) or (digit = x_charcode)) then
3938 -- calculate integer value
3939 for i in pos to l'RIGHT loop
3940 digit := octdigit2int(l(pos));
3941 exit when (digit = bad_charcode) or (digit = x_charcode);
3942 result := (result * 8) + digit;
3948 l := new string'(old_l
(pos
to old_l
'HIGH));
3961 procedure read_oct
(l
: inout line
;
3962 value
: out integer) is
3964 variable success
: boolean; -- internal good flag
3967 read_oct
( l
, value
, success
); -- use safe version
3969 report "IO1164.READ_OCT
: Unable
to read octal
integer value."
3975 -- Read hex to integer
3978 procedure read_hex
(l
: inout line
;
3979 value
: out integer;
3980 good
: out boolean) is
3982 variable pos
: integer;
3983 variable digit
: integer;
3984 variable result
: integer := 0;
3985 variable success
: boolean := true
;
3986 variable c
: character;
3987 variable old_l
: line
:= l
;
3992 -- skip leading white space, read digit, convert
3996 -- set pos to start of actual number by skipping white space
3999 while ( l.
all'length > 0 ) and ( ( c
= ' ' ) or ( c
= HT
) ) loop
4004 -- check for start of valid number
4005 digit
:= hexdigit2int
(l
(pos
));
4007 if ((digit
= bad_charcode
) or (digit
= x_charcode
)) then
4011 -- calculate integer value
4012 for i
in pos
to l
'RIGHT loop
4013 digit
:= hexdigit2int
(l
(pos
));
4014 exit when (digit
= bad_charcode
) or (digit
= x_charcode
);
4015 result
:= (result
* 16) + digit
;
4021 l
:= new string'(old_l(pos to old_l'HIGH));
4034 procedure read_hex(l : inout line;
4035 value : out integer) is
4037 variable success: boolean; -- internal good flag
4040 read_hex( l, value, success ); -- use safe version
4042 report "IO1164.READ_HEX: Unable to read hex integer value."
4048 use IEEE.std_logic_1164.all;
4049 use IEEE.numeric_std.all;
4051 entity asyncLdCnt is port (
4052 loadVal: in std_logic_vector(3 downto 0);
4053 clk, load: in std_logic;
4054 q: out std_logic_vector(3 downto 0)
4058 architecture rtl of asyncLdCnt is
4060 signal qLocal: unsigned(3 downto 0);
4064 process (clk, load, loadVal) begin
4065 if (load = '1') then
4066 qLocal <= to_unsigned(loadVal);
4067 elsif (clk'event and clk = '1' ) then
4068 qLocal <= qLocal + 1;
4072 q <= to_stdlogicvector(qLocal);
4076 use IEEE.std_logic_1164.all;
4077 use IEEE.std_logic_unsigned.all;
4079 entity LoadCnt is port (
4080 CntEn: in std_logic;
4081 LdCnt: in std_logic;
4082 LdData: in std_logic_vector(3 downto 0);
4085 CntVal: out std_logic_vector(3 downto 0)
4089 architecture behavioral of LoadCnt is
4091 signal Cnt: std_logic_vector(3 downto 0);
4095 counter: process (Clk, Rst) begin
4097 Cnt <= (others => '0');
4098 elsif (Clk'event and Clk = '1') then
4099 if (LdCnt = '1') then
4101 elsif (CntEn = '1') then
4113 use IEEE.std_logic_1164.all;
4115 use UTILS.io1164.all;
4121 architecture testbench of loadCntTB is
4123 component loadCnt port (
4124 data: in std_logic_vector (7 downto 0);
4128 q: out std_logic_vector (7 downto 0)
4132 file vectorFile: text is in "vectorfile";
4133 type vectorType is record
4134 data: std_logic_vector(7 downto 0);
4137 q: std_logic_vector(7 downto 0);
4140 signal testVector: vectorType;
4141 signal TestClk: std_logic := '0';
4142 signal Qout: std_logic_vector(7 downto 0);
4144 constant ClkPeriod: time := 100 ns;
4146 for all: loadCnt use entity work.loadcnt(rtl);
4150 -- File reading and stimulus application
4152 variable VectorLine: line;
4153 variable VectorValid: boolean;
4154 variable vRst: std_logic;
4155 variable vLoad: std_logic;
4156 variable vData: std_logic_vector(7 downto 0);
4157 variable vQ: std_logic_vector(7 downto 0);
4160 while not endfile (vectorFile) loop
4161 readline(vectorFile, VectorLine);
4163 read(VectorLine, vRst, good => VectorValid);
4164 next when not VectorValid;
4165 read(VectorLine, vLoad);
4166 read(VectorLine, vData);
4167 read(VectorLine, vQ);
4169 wait for ClkPeriod/4;
4171 testVector.Rst <= vRst;
4172 testVector.Load <= vLoad;
4173 testVector.Data <= vData;
4176 wait for (ClkPeriod/4) * 3;
4181 report "Simulation complete"
4188 -- Free running test clock
4189 TestClk <= not TestClk after ClkPeriod/2;
4191 -- Instance of design being tested
4192 u1: loadCnt port map (Data => testVector.Data,
4193 load => testVector.Load,
4195 rst => testVector.Rst,
4199 -- Process to verify outputs
4200 verify: process (TestClk)
4201 variable ErrorMsg: line;
4203 if (TestClk'event and TestClk = '0') then
4204 if Qout /= testVector.Q then
4205 write(ErrorMsg, string'("Vector failed "
));
4206 write
(ErrorMsg
, now
);
4207 writeline
(output
, ErrorMsg
);
4215 use IEEE.std_logic_1164.
all;
4216 use IEEE.std_logic_unsigned.
all;
4218 entity loadCnt
is port (
4219 data
: in std_logic_vector (7 downto 0);
4223 q
: out std_logic_vector (7 downto 0)
4227 architecture rtl
of loadCnt
is
4229 signal cnt
: std_logic_vector (7 downto 0);
4233 counter
: process (clk
, rst
) begin
4235 cnt
<= (others => '0');
4236 elsif (clk
'event and clk
= '1') then
4237 if (load
= '1') then
4249 use IEEE.std_logic_1164.
all;
4250 use IEEE.std_logic_unsigned.
all;
4252 entity multiplier
is port (
4253 a
,b
: in std_logic_vector (15 downto 0);
4254 product
: out std_logic_vector (31 downto 0)
4258 architecture dataflow
of multiplier
is
4266 use IEEE.std_logic_1164.
all;
4268 entity mux
is port (
4269 A
, B
, Sel
: in std_logic;
4274 architecture simModel
of mux
is
4277 constant tPD_A
: time := 10 ns
;
4278 constant tPD_B
: time := 15 ns
;
4279 constant tPD_Sel
: time := 5 ns
;
4283 DelayMux
: process (A
, B
, Sel
)
4285 variable localY
: std_logic; -- Zero delay place holder for Y
4297 -- Delay calculation
4299 Y
<= localY
after tPD_B
;
4300 elsif (A
'event) then
4301 Y
<= localY
after tPD_A
;
4303 Y
<= localY
after tPD_Sel
;
4311 use IEEE.std_logic_1164.
all;
4312 use IEEE.std_logic_unsigned.
all;
4314 entity ForceShare
is port (
4315 a
,b
,c
,d
,e
,f
: in std_logic_vector (7 downto 0);
4316 result
: out std_logic_vector(7 downto 0)
4320 architecture behaviour
of ForceShare
is
4324 sum
: process (a
,c
,b
,d
,e
,f
)
4327 if (a
+ b
= "
10011010"
) then
4329 elsif (a
+ b
= "
01011001"
) then
4331 elsif (a
+ b
= "
10111011"
) then
4340 use IEEE.std_logic_1164.
all;
4342 entity TRIBUF8
is port (
4343 ip
: in std_logic_vector(7 downto 0);
4345 op
: out std_logic_vector(7 downto 0)
4349 architecture concurrent
of TRIBUF8
is
4353 op
<= ip
when oe
= '1' else (others => 'Z');
4357 use IEEE.std_logic_1164.
all;
4359 entity TRIBUF
is port (
4366 architecture concurrent
of TRIBUF
is
4370 op
<= ip
when oe
= '1' else 'Z';
4374 use IEEE.std_logic_1164.
all;
4376 entity TRIBUF8
is port (
4377 ip
: in std_logic_vector(7 downto 0);
4379 op
: out std_logic_vector(7 downto 0)
4383 architecture sequential
of TRIBUF8
is
4387 enable
: process (ip
,oe
) begin
4391 op
<= (others => 'Z');
4397 use IEEE.std_logic_1164.
all;
4399 entity TRIBUF
is port (
4406 architecture sequential
of TRIBUF
is
4410 enable
: process (ip
,oe
) begin
4420 use IEEE.std_logic_1164.
all;
4422 entity TRIBUF
is port (
4429 architecture sequential
of TRIBUF
is
4433 enable
: process (ip
,oe
) begin
4443 use IEEE.std_logic_1164.
all;
4445 use work.primitive.
all;
4447 entity tribuffer
is port (
4448 input
: in std_logic;
4449 enable
: in std_logic;
4450 output
: out std_logic
4454 architecture structural
of tribuffer
is
4458 u1
: tribuf
port map (ip
=> input
,
4465 use ieee.std_logic_1164.
all;
4467 use work.primitive.
all;
4469 entity oddParityGen
is
4470 generic ( width
: integer := 8 );
4471 port (ad
: in std_logic_vector (width
- 1 downto 0);
4472 oddParity
: out std_logic ) ;
4475 architecture scaleable
of oddParityGen
is
4477 signal genXor
: std_logic_vector(ad
'range);
4483 parTree
: for i
in 1 to ad
'high generate
4484 x1
: xor2
port map (i1
=> genXor
(i
- 1),
4490 oddParity
<= genXor
(ad
'high) ;
4494 use ieee.std_logic_1164.
all;
4496 entity oddParityLoop
is
4497 generic ( width
: integer := 8 );
4498 port (ad
: in std_logic_vector (width
- 1 downto 0);
4499 oddParity
: out std_logic ) ;
4502 architecture scaleable
of oddParityLoop
is
4506 variable loopXor
: std_logic;
4510 for i
in 0 to width
-1 loop
4511 loopXor
:= loopXor
xor ad
( i
) ;
4514 oddParity
<= loopXor
;
4520 use IEEE.std_logic_1164.
all;
4523 use IEEE.std_logic_1164.
all;
4525 entity OR2
is port (
4532 architecture rtl
of OR2
is
4536 y
<= '1' when i1
= '1' or i2
= '1' else '0';
4540 USE IEEE.std_logic_1164.
all;
4543 entity OR2
is port (
4544 I1
, I2
: in std_logic;
4549 architecture simple
of OR2
is
4553 Y
<= I1
OR I2
after 10 ns
;
4557 USE IEEE.std_logic_1164.
all;
4559 package simPrimitives
is
4562 generic (tPD
: time := 1 ns
);
4564 port (I1
, I2
: in std_logic;
4573 USE IEEE.std_logic_1164.
all;
4576 generic (tPD
: time := 1 ns
);
4578 port (I1
, I2
: in std_logic;
4583 architecture simple
of OR2
is
4587 Y
<= I1
OR I2
after tPD
;
4591 use ieee.std_logic_1164.
all;
4592 use ieee.numeric_std.
all;
4594 entity adder
is port (
4595 a
,b
: in std_logic_vector(3 downto 0);
4596 sum
: out std_logic_vector(3 downto 0);
4597 overflow
: out std_logic
4601 architecture concat
of adder
is
4603 signal localSum
: std_logic_vector(4 downto 0);
4607 localSum
<= std_logic_vector(unsigned
('0' & a) + unsigned('0' & b
));
4609 sum
<= localSum
(3 downto 0);
4610 overflow
<= localSum
(4);
4614 use IEEE.std_logic_1164.
all;
4616 use work.primitive.
all;
4619 generic (size
: integer := 8);
4621 data
: in std_logic_vector(size
- 1 downto 0);
4622 clock
: in std_logic;
4623 reset
: in std_logic;
4624 ff_enable
: in std_logic;
4625 op_enable
: in std_logic;
4626 qout
: out std_logic_vector(size
- 1 downto 0)
4630 architecture parameterize
of paramDFF
is
4632 signal reg
: std_logic_vector(size
- 1 downto 0);
4636 u1
: pDFFE
generic map (n
=> size
)
4637 port map (d
=> data
,
4643 u2
: pTRIBUF
generic map (n
=> size
)
4644 port map (ip
=> reg
,
4651 use ieee.std_logic_1164.
all;
4653 use work.primitive.
all;
4655 entity oddParityGen
is
4656 generic ( width
: integer := 32 );
4657 port (ad
: in std_logic_vector (width
- 1 downto 0);
4658 oddParity
: out std_logic ) ;
4661 architecture scaleable
of oddParityGen
is
4663 signal genXor
: std_logic_vector(ad
'range);
4665 signal one
: std_logic := '1';
4669 parTree
: for i
in ad
'range generate
4670 g0
: if i
= 0 generate
4671 x0
: xor2
port map (i1
=> one
,
4677 g1
: if i
> 0 and i
<= ad
'high generate
4678 x1
: xor2
port map (i1
=> genXor
(i
- 1),
4686 oddParity
<= genXor
(ad
'high) ;
4690 use ieee.std_logic_1164.
all;
4692 use work.primitive.
all;
4694 entity oddParityGen
is
4695 generic ( width
: integer := 32 ); -- (2 <= width <= 32) and a power of 2
4696 port (ad
: in std_logic_vector (width
- 1 downto 0);
4697 oddParity
: out std_logic ) ;
4700 architecture scaleable
of oddParityGen
is
4702 signal stage0
: std_logic_vector(31 downto 0);
4703 signal stage1
: std_logic_vector(15 downto 0);
4704 signal stage2
: std_logic_vector(7 downto 0);
4705 signal stage3
: std_logic_vector(3 downto 0);
4706 signal stage4
: std_logic_vector(1 downto 0);
4710 g4
: for i
in stage4
'range generate
4711 g41
: if (ad
'length > 2) generate
4712 x4
: xor2
port map (stage3
(i
), stage3
(i
+ stage4
'length), stage4
(i
));
4716 g3
: for i
in stage3
'range generate
4717 g31
: if (ad
'length > 4) generate
4718 x3
: xor2
port map (stage2
(i
), stage2
(i
+ stage3
'length), stage3
(i
));
4722 g2
: for i
in stage2
'range generate
4723 g21
: if (ad
'length > 8) generate
4724 x2
: xor2
port map (stage1
(i
), stage1
(i
+ stage2
'length), stage2
(i
));
4728 g1
: for i
in stage1
'range generate
4729 g11
: if (ad
'length > 16) generate
4730 x1
: xor2
port map (stage0
(i
), stage0
(i
+ stage1
'length), stage1
(i
));
4735 s1
: for i
in ad
'range generate
4736 s14
: if (ad
'length = 2) generate
4740 s13
: if (ad
'length = 4) generate
4744 s12
: if (ad
'length = 8) generate
4748 s11
: if (ad
'length = 16) generate
4752 s10
: if (ad
'length = 32) generate
4759 genPar
: xor2
port map (stage4
(0), stage4
(1), oddParity
);
4763 use IEEE.std_logic_1164.
all;
4764 use IEEE.numeric_std.
all;
4766 entity powerOfFour
is port(
4768 inputVal
: in unsigned
(3 downto 0);
4769 power
: out unsigned
(15 downto 0)
4773 architecture behavioral
of powerOfFour
is
4775 function Pow
( N
, Exp
: integer ) return integer is
4776 Variable Result
: integer := 1;
4779 for i
in 1 to Exp
loop
4780 Result
:= Result
* N
;
4785 signal inputValInt
: integer range 0 to 15;
4786 signal powerL
: integer range 0 to 65535;
4790 inputValInt
<= to_integer
(inputVal
);
4791 power
<= to_unsigned
(powerL
,16);
4794 wait until Clk
= '1';
4796 powerL
<= Pow
(inputValInt
,4);
4802 component Power
port(
4804 inputVal
: in bit_vector(0 to 3);
4805 power
: out bit_vector(0 to 15) );
4809 use work.bv_math.
all;
4810 use work.int_math.
all;
4811 use work.PowerPkg.
all;
4813 entity Power
is port(
4815 inputVal
: in bit_vector(0 to 3);
4816 power
: out bit_vector(0 to 15) );
4822 architecture funky
of Power
is
4824 function Pow
( N
, Exp
: integer ) return integer is
4825 Variable Result
: integer := 1;
4826 Variable i
: integer := 0;
4828 while( i
< Exp
) loop
4829 Result
:= Result
* N
;
4836 function RollVal
( CntlVal
: integer ) return integer is
4838 return( Pow
( 2, CntlVal
) + 2 );
4845 wait until Clk
= '1';
4847 power
<= i2bv
(Rollval
(bv2I
(inputVal
)),16);
4852 use ieee.std_logic_1164.
all;
4853 use ieee.numeric_std.
all;
4855 entity priority_encoder
is port
4856 (interrupts
: in std_logic_vector(7 downto 0);
4857 priority
: in std_logic_vector(2 downto 0);
4858 result
: out std_logic_vector(2 downto 0)
4860 end priority_encoder
;
4862 architecture behave
of priority_encoder
is
4865 process (interrupts
)
4866 variable selectIn
: integer;
4867 variable LoopCount
: integer;
4871 selectIn
:= to_integer
(to_unsigned
(priority
));
4873 while (LoopCount
<= 7) and (interrupts
(selectIn
) /= '0') loop
4875 if (selectIn
= 0) then
4878 selectIn
:= selectIn
- 1;
4881 LoopCount
:= LoopCount
+ 1;
4885 result
<= std_logic_vector(to_unsigned
(selectIn
,3));
4891 use IEEE.std_logic_1164.
all;
4893 package primitive
is
4894 component DFFE
port (
4902 component DFFE_SR
port (
4912 component DLATCHH
port (
4919 component AND2
port (
4926 component OR2
port (
4933 component INVERTER
port (
4939 component TRIBUF
port (
4946 component BIDIR
port (
4949 op_fb
: out std_logic;
4957 use IEEE.std_logic_1164.
all;
4959 entity DFFE
is port (
4967 architecture rtl
of DFFE
is
4972 wait until clk
= '1';
4981 use IEEE.std_logic_1164.
all;
4983 entity DFFE_SR
is port (
4993 architecture rtl
of DFFE_SR
is
4997 process (clk
, rst
, prst
) begin
5000 elsif (prst
= '1') then
5002 elsif (clk
'event and clk
= '1') then
5012 use IEEE.std_logic_1164.
all;
5014 entity DLATCHH
is port (
5021 architecture rtl
of DLATCHH
is
5035 use IEEE.std_logic_1164.
all;
5037 entity AND2
is port (
5044 architecture rtl
of AND2
is
5048 y
<= '1' when i1
= '1' and i2
= '1' else '0';
5054 use IEEE.std_logic_1164.
all;
5056 entity OR2
is port (
5063 architecture rtl
of OR2
is
5067 y
<= '1' when i1
= '1' or i2
= '1' else '0';
5074 use IEEE.std_logic_1164.
all;
5076 entity INVERTER
is port (
5082 architecture rtl
of INVERTER
is
5092 use IEEE.std_logic_1164.
all;
5094 entity TRIBUF
is port (
5101 architecture rtl
of TRIBUF
is
5105 op
<= ip
when oe
= '1' else 'Z';
5111 use IEEE.std_logic_1164.
all;
5113 entity BIDIR
is port (
5116 op_fb
: out std_logic;
5121 architecture rtl
of BIDIR
is
5125 op
<= ip
when oe
= '1' else 'Z';
5131 use ieee.std_logic_1164.
all;
5132 use ieee.numeric_std.
all;
5134 entity progPulse
is port (
5135 clk
, reset
: in std_logic;
5136 loadLength
,loadDelay
: in std_logic;
5137 data
: in std_logic_vector(7 downto 0);
5138 pulse
: out std_logic
5142 architecture rtl
of progPulse
is
5144 signal downCnt
, downCntData
: unsigned
(7 downto 0);
5145 signal downCntLd
, downCntEn
: std_logic;
5146 signal delayCntVal
, pulseCntVal
: unsigned
(7 downto 0);
5147 signal startPulse
, endPulse
: std_logic;
5149 subtype fsmType
is std_logic_vector(1 downto 0);
5150 constant loadDelayCnt
: fsmType
:= "
00"
;
5151 constant waitDelayEnd
: fsmType
:= "
10"
;
5152 constant loadLengthCnt
: fsmType
:= "
11"
;
5153 constant waitLengthEnd
: fsmType
:= "
01"
;
5155 signal currState
, nextState
: fsmType
;
5159 delayreg
: process (clk
, reset
) begin
5161 delayCntVal
<= "
11111111"
;
5162 elsif clk
'event and clk
= '1' then
5163 if loadDelay
= '1' then
5164 delayCntVal
<= to_unsigned
(data
);
5169 lengthReg
: process (clk
, reset
) begin
5171 pulseCntVal
<= "
11111111"
;
5172 elsif clk
'event and clk
= '1' then
5173 if loadDelay
= '1' then
5174 pulseCntVal
<= to_unsigned
(data
);
5179 nextStProc
: process (currState
, downCnt
, loadDelay
, loadLength
) begin
5181 when loadDelayCnt
=>
5182 nextState
<= waitDelayEnd
;
5184 when waitDelayEnd
=>
5185 if (loadDelay
= '1' or loadLength
= '1') then
5186 nextState
<= loadDelayCnt
;
5187 elsif (downCnt
= 0) then
5188 nextState
<= loadLengthCnt
;
5190 nextState
<= waitDelayEnd
;
5193 when loadLengthCnt
=>
5194 if (loadDelay
= '1' or loadLength
= '1') then
5195 nextState
<= loadDelayCnt
;
5197 nextState
<= waitLengthEnd
;
5200 when waitLengthEnd
=>
5201 if (loadDelay
= '1' or loadLength
= '1') then
5202 nextState
<= loadDelayCnt
;
5203 elsif (downCnt
= 0) then
5204 nextState
<= loadDelayCnt
;
5206 nextState
<= waitDelayEnd
;
5213 end process nextStProc
;
5215 currStProc
: process (clk
, reset
) begin
5216 if (reset
= '1') then
5217 currState
<= loadDelayCnt
;
5218 elsif (clk
'event and clk
= '1') then
5219 currState
<= nextState
;
5221 end process currStProc
;
5223 outConProc
: process (currState
, delayCntVal
, pulseCntVal
) begin
5225 when loadDelayCnt
=>
5228 downCntData
<= delayCntVal
;
5230 when waitDelayEnd
=>
5233 downCntData
<= delayCntVal
;
5235 when loadLengthCnt
=>
5238 downCntData
<= pulseCntVal
;
5240 when waitLengthEnd
=>
5243 downCntData
<= pulseCntVal
;
5248 downCntData
<= pulseCntVal
;
5251 end process outConProc
;
5253 downCntr
: process (clk
,reset
) begin
5254 if (reset
= '1') then
5255 downCnt
<= "
00000000"
;
5256 elsif (clk
'event and clk
= '1') then
5257 if (downCntLd
= '1') then
5258 downCnt
<= downCntData
;
5259 elsif (downCntEn
= '1') then
5260 downCnt
<= downCnt
- 1;
5267 -- Assign pulse output
5268 pulse
<= currState
(0);
5273 use ieee.std_logic_1164.
all;
5275 entity pulseErr
is port
5281 architecture behavior
of pulseErr
is
5283 signal c
: std_logic;
5287 pulse
: process (a
,c
) begin
5295 use ieee.std_logic_1164.
all;
5296 use ieee.numeric_std.
all;
5298 entity progPulse
is port (
5299 clk
, reset
: in std_logic;
5300 loadLength
,loadDelay
: in std_logic;
5301 data
: in std_logic_vector(7 downto 0);
5302 pulse
: out std_logic
5306 architecture rtl
of progPulse
is
5308 signal downCnt
, downCntData
: unsigned
(7 downto 0);
5309 signal downCntLd
, downCntEn
: std_logic;
5310 signal delayCntVal
, pulseCntVal
: unsigned
(7 downto 0);
5311 signal startPulse
, endPulse
: std_logic;
5313 type progPulseFsmType
is (loadDelayCnt
, waitDelayEnd
, loadLengthCnt
, waitLengthEnd
);
5314 signal currState
, nextState
: progPulseFsmType
;
5318 delayreg
: process (clk
, reset
) begin
5320 delayCntVal
<= "
11111111"
;
5321 elsif clk
'event and clk
= '1' then
5322 if loadDelay
= '1' then
5323 delayCntVal
<= to_unsigned
(data
);
5328 lengthReg
: process (clk
, reset
) begin
5330 pulseCntVal
<= "
11111111"
;
5331 elsif clk
'event and clk
= '1' then
5332 if loadDelay
= '1' then
5333 pulseCntVal
<= to_unsigned
(data
);
5338 nextStProc
: process (currState
, downCnt
, loadDelay
, loadLength
) begin
5340 when loadDelayCnt
=>
5341 nextState
<= waitDelayEnd
;
5343 when waitDelayEnd
=>
5344 if (loadDelay
= '1' or loadLength
= '1') then
5345 nextState
<= loadDelayCnt
;
5346 elsif (downCnt
= 0) then
5347 nextState
<= loadLengthCnt
;
5349 nextState
<= waitDelayEnd
;
5352 when loadLengthCnt
=>
5353 if (loadDelay
= '1' or loadLength
= '1') then
5354 nextState
<= loadDelayCnt
;
5356 nextState
<= waitLengthEnd
;
5359 when waitLengthEnd
=>
5360 if (loadDelay
= '1' or loadLength
= '1') then
5361 nextState
<= loadDelayCnt
;
5362 elsif (downCnt
= 0) then
5363 nextState
<= loadDelayCnt
;
5365 nextState
<= waitDelayEnd
;
5372 end process nextStProc
;
5374 currStProc
: process (clk
, reset
) begin
5375 if (reset
= '1') then
5376 currState
<= loadDelayCnt
;
5377 elsif (clk
'event and clk
= '1') then
5378 currState
<= nextState
;
5380 end process currStProc
;
5382 outConProc
: process (currState
, delayCntVal
, pulseCntVal
) begin
5384 when loadDelayCnt
=>
5387 downCntData
<= delayCntVal
;
5390 when waitDelayEnd
=>
5393 downCntData
<= delayCntVal
;
5396 when loadLengthCnt
=>
5399 downCntData
<= pulseCntVal
;
5402 when waitLengthEnd
=>
5405 downCntData
<= pulseCntVal
;
5411 downCntData
<= pulseCntVal
;
5415 end process outConProc
;
5417 downCntr
: process (clk
,reset
) begin
5418 if (reset
= '1') then
5419 downCnt
<= "
00000000"
;
5420 elsif (clk
'event and clk
= '1') then
5421 if (downCntLd
= '1') then
5422 downCnt
<= downCntData
;
5423 elsif (downCntEn
= '1') then
5424 downCnt
<= downCnt
- 1;
5434 use ieee.std_logic_1164.
all;
5435 use ieee.numeric_std.
all;
5437 entity progPulseFsm
is port (
5438 downCnt
: in std_logic_vector(7 downto 0);
5439 delayCntVal
: in std_logic_vector(7 downto 0);
5440 lengthCntVal
: in std_logic_vector(7 downto 0);
5441 loadLength
: in std_logic;
5442 loadDelay
: in std_logic;
5444 reset
: in std_logic;
5446 downCntEn
: out std_logic;
5447 downCntLd
: out std_logic;
5448 downCntData
: out std_logic_vector(7 downto 0);
5450 pulse
: out std_logic
5454 architecture fsm
of progPulseFsm
is
5456 type progPulseFsmType
is (loadDelayCnt
, waitDelayEnd
, loadLengthCnt
, waitLengthEnd
);
5457 type stateVec
is array (3 downto 0) of std_logic;
5458 type stateBits
is array (progPulseFsmType
) of stateVec
;
5460 signal loadVal
: std_logic;
5462 constant stateTable
: stateBits
:= (
5463 loadDelayCnt
=> "
0010"
,
5464 waitDelayEnd
=> "
0100"
,
5465 loadLengthCnt
=> "
0011"
,
5466 waitLengthEnd
=> "
1101"
);
5473 signal currState
, nextState
: progPulseFsmType
;
5477 nextStProc
: process (currState
, downCnt
, loadDelay
, loadLength
) begin
5479 when loadDelayCnt
=>
5480 nextState
<= waitDelayEnd
;
5482 when waitDelayEnd
=>
5483 if (loadDelay
= '1' or loadLength
= '1') then
5484 nextState
<= loadDelayCnt
;
5485 elsif (to_unsigned
(downCnt
) = 0) then
5486 nextState
<= loadLengthCnt
;
5488 nextState
<= waitDelayEnd
;
5491 when loadLengthCnt
=>
5492 if (loadDelay
= '1' or loadLength
= '1') then
5493 nextState
<= loadDelayCnt
;
5495 nextState
<= waitLengthEnd
;
5498 when waitLengthEnd
=>
5499 if (loadDelay
= '1' or loadLength
= '1') then
5500 nextState
<= loadDelayCnt
;
5501 elsif (to_unsigned
(downCnt
) = 0) then
5502 nextState
<= loadDelayCnt
;
5504 nextState
<= waitDelayEnd
;
5512 end process nextStProc
;
5514 currStProc
: process (clk
, reset
) begin
5515 if (reset
= '1') then
5516 currState
<= loadDelayCnt
;
5517 elsif (clk
'event and clk
= '1') then
5518 currState
<= nextState
;
5520 end process currStProc
;
5522 pulse
<= stateTable
(currState
)(3);
5523 downCntEn
<= stateTable
(currState
)(2);
5524 downCntLd
<= stateTable
(currState
)(1);
5525 loadVal
<= stateTable
(currState
)(0);
5527 downCntData
<= delayCntVal
when loadVal
= '0' else lengthCntVal
;
5530 -- Incorporates Errata 6.1
5533 use ieee.std_logic_1164.
all;
5534 use ieee.numeric_std.
all;
5536 entity progPulseFsm
is port (
5537 downCnt
: in std_logic_vector(7 downto 0);
5538 delayCntVal
: in std_logic_vector(7 downto 0);
5539 lengthCntVal
: in std_logic_vector(7 downto 0);
5540 loadLength
: in std_logic;
5541 loadDelay
: in std_logic;
5543 reset
: in std_logic;
5545 downCntEn
: out std_logic;
5546 downCntLd
: out std_logic;
5547 downtCntData
: out std_logic_vector(7 downto 0);
5549 pulse
: out std_logic
5553 architecture fsm
of progPulseFsm
is
5555 type progPulseFsmType
is (loadDelayCnt
, waitDelayEnd
, loadLengthCnt
, waitLengthEnd
);
5556 signal currState
, nextState
: progPulseFsmType
;
5557 signal downCntL
: unsigned
(7 downto 0);
5561 downCntL
<= to_unsigned
(downCnt
); -- convert downCnt to unsigned
5563 nextStProc
: process (currState
, downCntL
, loadDelay
, loadLength
) begin
5565 when loadDelayCnt
=>
5566 nextState
<= waitDelayEnd
;
5568 when waitDelayEnd
=>
5569 if (loadDelay
= '1' or loadLength
= '1') then
5570 nextState
<= loadDelayCnt
;
5571 elsif (downCntL
= 0) then
5572 nextState
<= loadLengthCnt
;
5574 nextState
<= waitDelayEnd
;
5577 when loadLengthCnt
=>
5578 if (loadDelay
= '1' or loadLength
= '1') then
5579 nextState
<= loadDelayCnt
;
5581 nextState
<= waitLengthEnd
;
5584 when waitLengthEnd
=>
5585 if (loadDelay
= '1' or loadLength
= '1') then
5586 nextState
<= loadDelayCnt
;
5587 elsif (downCntL
= 0) then
5588 nextState
<= loadDelayCnt
;
5590 nextState
<= waitDelayEnd
;
5598 end process nextStProc
;
5600 currStProc
: process (clk
, reset
) begin
5601 if (reset
= '1') then
5602 currState
<= loadDelayCnt
;
5603 elsif (clk
'event and clk
= '1') then
5604 currState
<= nextState
;
5606 end process currStProc
;
5608 outConProc
: process (currState
, delayCntVal
, lengthCntVal
) begin
5610 when loadDelayCnt
=>
5613 downtCntData
<= delayCntVal
;
5616 when waitDelayEnd
=>
5619 downtCntData
<= delayCntVal
;
5622 when loadLengthCnt
=>
5625 downtCntData
<= lengthCntVal
;
5628 when waitLengthEnd
=>
5631 downtCntData
<= lengthCntVal
;
5637 downtCntData
<= delayCntVal
;
5641 end process outConProc
;
5644 -- Incorporates errata 5.4
5647 use IEEE.std_logic_1164.
all;
5648 use IEEE.numeric_std.
all;
5650 use work.specialFunctions.
all;
5652 entity powerOfFour
is port(
5654 inputVal
: in std_logic_vector(3 downto 0);
5655 power
: out std_logic_vector(15 downto 0)
5659 architecture behavioral
of powerOfFour
is
5664 wait until Clk
= '1';
5666 power
<= std_logic_vector(to_unsigned
(Pow
(to_integer
(unsigned
(inputVal
)),4),16));
5671 -- Incorporate errata 5.4
5674 use IEEE.std_logic_1164.
all;
5675 use IEEE.numeric_std.
all;
5677 entity powerOfFour
is port(
5679 inputVal
: in std_logic_vector(3 downto 0);
5680 power
: out std_logic_vector(15 downto 0)
5684 architecture behavioral
of powerOfFour
is
5686 function Pow
( N
, Exp
: integer ) return integer is
5687 Variable Result
: integer := 1;
5690 for i
in 1 to Exp
loop
5691 Result
:= Result
* N
;
5699 wait until Clk
= '1';
5701 power
<= std_logic_vector(to_unsigned
(Pow
(to_integer
(to_unsigned
(inputVal
)),4),16));
5707 use IEEE.std_logic_1164.
all;
5708 use IEEE.std_logic_arith.
all;
5709 use IEEE.std_logic_unsigned.
all;
5711 entity powerOfFour
is port(
5713 inputVal
: in std_logic_vector(3 downto 0);
5714 power
: out std_logic_vector(15 downto 0)
5718 architecture behavioral
of powerOfFour
is
5720 function Pow
( N
, Exp
: integer ) return integer is
5721 Variable Result
: integer := 1;
5724 for i
in 1 to Exp
loop
5725 Result
:= Result
* N
;
5733 wait until Clk
= '1';
5735 power
<= conv_std_logic_vector
(Pow
(conv_integer
(inputVal
),4),16);
5741 use IEEE.std_logic_1164.
all;
5743 entity regFile
is port (
5744 clk
, rst
: in std_logic;
5745 data
: in std_logic_vector(31 downto 0);
5746 regSel
: in std_logic_vector(1 downto 0);
5747 wrEnable
: in std_logic;
5748 regOut
: out std_logic_vector(31 downto 0)
5752 architecture behavioral
of regFile
is
5754 subtype reg
is std_logic_vector(31 downto 0);
5755 type regArray
is array (integer range <>) of reg
;
5757 signal registerFile
: regArray
(0 to 3);
5761 regProc
: process (clk
, rst
)
5762 variable i
: integer;
5768 while i
<= registerFile
'high loop
5769 registerFile
(i
) <= (others => '0');
5773 elsif clk
'event and clk
= '1' then
5774 if (wrEnable
= '1') then
5777 registerFile
(0) <= data
;
5779 registerFile
(1) <= data
;
5781 registerFile
(2) <= data
;
5783 registerFile
(3) <= data
;
5791 outputs
: process(regSel
, registerFile
) begin
5794 regOut
<= registerFile
(0);
5796 regOut
<= registerFile
(1);
5798 regOut
<= registerFile
(2);
5800 regOut
<= registerFile
(3);
5808 use IEEE.std_logic_1164.
all;
5810 entity DFF
is port (
5811 d1
,d2
: in std_logic;
5812 q1
,q2
: out std_logic;
5818 architecture rtl
of DFF
is
5822 resetLatch
: process (clk
, rst
) begin
5825 elsif clk
'event and clk
= '1' then
5833 use ieee.std_logic_1164.
all;
5835 entity resFcnDemo
is port (
5837 oeA
,oeB
: in std_logic;
5838 result
: out std_logic
5842 architecture multiDriver
of resFcnDemo
is
5846 result
<= a
when oeA
= '1' else 'Z';
5847 result
<= b
when oeB
= '1' else 'Z';
5851 use IEEE.std_logic_1164.
all;
5853 use work.primitive.
all;
5855 entity scaleDFF
is port (
5856 data
: in std_logic_vector(7 downto 0);
5857 clock
: in std_logic;
5858 enable
: in std_logic;
5859 qout
: out std_logic_vector(7 downto 0)
5863 architecture scalable
of scaleDFF
is
5867 u1
: sDFFE
port map (d
=> data
,
5875 use ieee.std_logic_1164.
all;
5876 use ieee.std_logic_unsigned.
all;
5878 entity sevenSegment
is port (
5879 bcdInputs
: in std_logic_vector (3 downto 0);
5881 e_n
, f_n
, g_n
: out std_logic
5885 architecture behavioral
of sevenSegment
is
5887 signal la_n
, lb_n
, lc_n
, ld_n
, le_n
, lf_n
, lg_n
: std_logic;
5888 signal oe
: std_logic;
5892 bcd2sevSeg
: process (bcdInputs
) begin
5894 -- Assign default to "off"
5895 la_n
<= '1'; lb_n
<= '1';
5896 lc_n
<= '1'; ld_n
<= '1';
5897 le_n
<= '1'; lf_n
<= '1';
5901 when "
0000"
=> la_n
<= '0'; lb_n
<= '0';
5902 lc_n
<= '0'; ld_n
<= '0';
5903 le_n
<= '0'; lf_n
<= '0';
5905 when "
0001"
=> lb_n
<= '0'; lc_n
<= '0';
5907 when "
0010"
=> la_n
<= '0'; lb_n
<= '0';
5908 ld_n
<= '0'; le_n
<= '0';
5911 when "
0011"
=> la_n
<= '0'; lb_n
<= '0';
5912 lc_n
<= '0'; ld_n
<= '0';
5915 when "
0100"
=> lb_n
<= '0'; lc_n
<= '0';
5916 lf_n
<= '0'; lg_n
<= '0';
5918 when "
0101"
=> la_n
<= '0'; lc_n
<= '0';
5919 ld_n
<= '0'; lf_n
<= '0';
5922 when "
0110"
=> la_n
<= '0'; lc_n
<= '0';
5923 ld_n
<= '0'; le_n
<= '0';
5924 lf_n
<= '0'; lg_n
<= '0';
5926 when "
0111"
=> la_n
<= '0'; lb_n
<= '0';
5929 when "
1000"
=> la_n
<= '0'; lb_n
<= '0';
5930 lc_n
<= '0'; ld_n
<= '0';
5931 le_n
<= '0'; lf_n
<= '0';
5934 when "
1001"
=> la_n
<= '0'; lb_n
<= '0';
5935 lc_n
<= '0'; ld_n
<= '0';
5936 lf_n
<= '0'; lg_n
<= '0';
5938 -- All other inputs possibilities are "don't care"
5940 when others => la_n
<= 'X'; lb_n
<= 'X';
5941 lc_n
<= 'X'; ld_n
<= 'X';
5942 le_n
<= 'X'; lf_n
<= 'X';
5947 end process bcd2sevSeg
;
5949 -- Disable outputs for all invalid input values
5951 oe
<= '1' when (bcdInputs
< 10) else '0';
5953 a_n
<= la_n
when oe
= '1' else 'Z';
5954 b_n
<= lb_n
when oe
= '1' else 'Z';
5955 c_n
<= lc_n
when oe
= '1' else 'Z';
5956 d_n
<= ld_n
when oe
= '1' else 'Z';
5957 e_n
<= le_n
when oe
= '1' else 'Z';
5958 f_n
<= lf_n
when oe
= '1' else 'Z';
5959 g_n
<= lg_n
when oe
= '1' else 'Z';
5964 use ieee.std_logic_1164.
all;
5968 entity sevenSegmentTB
is
5971 architecture testbench
of sevenSegmentTB
is
5973 component sevenSegment
port (
5974 bcdInputs
: in std_logic_vector (3 downto 0);
5976 e_n
, f_n
, g_n
: out std_logic
5980 type vector
is record
5981 bcdStimulus
: std_logic_vector(3 downto 0);
5982 sevSegOut
: std_logic_vector(6 downto 0);
5985 constant NumVectors
: integer:= 17;
5986 constant PropDelay
: time := 40 ns
;
5987 constant SimLoopDelay
: time := 10 ns
;
5989 type vectorArray
is array (0 to NumVectors
- 1) of vector
;
5990 constant vectorTable
: vectorArray
:= (
5991 (bcdStimulus
=> "
0000"
, sevSegOut
=> "
0000001"
),
5992 (bcdStimulus
=> "
0001"
, sevSegOut
=> "
1001111"
),
5993 (bcdStimulus
=> "
0010"
, sevSegOut
=> "
0010010"
),
5994 (bcdStimulus
=> "
0011"
, sevSegOut
=> "
0000110"
),
5995 (bcdStimulus
=> "
0100"
, sevSegOut
=> "
1001100"
),
5996 (bcdStimulus
=> "
0101"
, sevSegOut
=> "
0100100"
),
5997 (bcdStimulus
=> "
0110"
, sevSegOut
=> "
0100000"
),
5998 (bcdStimulus
=> "
0111"
, sevSegOut
=> "
0001111"
),
5999 (bcdStimulus
=> "
1000"
, sevSegOut
=> "
0000000"
),
6000 (bcdStimulus
=> "
1001"
, sevSegOut
=> "
0000100"
),
6001 (bcdStimulus
=> "
1010"
, sevSegOut
=> "ZZZZZZZ"
),
6002 (bcdStimulus
=> "
1011"
, sevSegOut
=> "ZZZZZZZ"
),
6003 (bcdStimulus
=> "
1100"
, sevSegOut
=> "ZZZZZZZ"
),
6004 (bcdStimulus
=> "
1101"
, sevSegOut
=> "ZZZZZZZ"
),
6005 (bcdStimulus
=> "
1110"
, sevSegOut
=> "ZZZZZZZ"
),
6006 (bcdStimulus
=> "
1111"
, sevSegOut
=> "ZZZZZZZ"
),
6007 (bcdStimulus
=> "
0000"
, sevSegOut
=> "
0110110"
) -- this vector fails
6010 for all : sevenSegment
use entity work.sevenSegment
(behavioral
);
6012 signal StimInputs
: std_logic_vector(3 downto 0);
6013 signal CaptureOutputs
: std_logic_vector(6 downto 0);
6017 u1
: sevenSegment
port map (bcdInputs
=> StimInputs
,
6018 a_n
=> CaptureOutputs
(6),
6019 b_n
=> CaptureOutputs
(5),
6020 c_n
=> CaptureOutputs
(4),
6021 d_n
=> CaptureOutputs
(3),
6022 e_n
=> CaptureOutputs
(2),
6023 f_n
=> CaptureOutputs
(1),
6024 g_n
=> CaptureOutputs
(0));
6027 variable FoundError
: boolean := false
;
6028 variable TempVector
: vector
;
6029 variable ErrorMsgLine
: line
;
6032 for i
in vectorTable
'range loop
6033 TempVector
:= vectorTable
(i
);
6035 StimInputs
<= TempVector.bcdStimulus
;
6039 if CaptureOutputs
/= TempVector.sevSegOut
then
6040 write
(ErrorMsgLine
, string'("Vector failed at "));
6041 write (ErrorMsgLine, now);
6042 writeline (output, ErrorMsgLine);
6046 wait for SimLoopDelay;
6051 report "No errors. All vectors passed."
6060 use ieee.std_logic_1164.all;
6062 entity sevenSegment is port (
6063 bcdInputs: in std_logic_vector (3 downto 0);
6065 e_n, f_n, g_n: out std_logic
6069 architecture behavioral of sevenSegment is
6073 bcd2sevSeg: process (bcdInputs) begin
6075 -- Assign default to "off"
6076 a_n <= '1'; b_n <= '1';
6077 c_n <= '1'; d_n <= '1';
6078 e_n <= '1'; f_n <= '1';
6083 a_n <= '0'; b_n <= '0';
6084 c_n <= '0'; d_n <= '0';
6085 e_n <= '0'; f_n <= '0';
6088 b_n <= '0'; c_n <= '0';
6091 a_n <= '0'; b_n <= '0';
6092 d_n <= '0'; e_n <= '0';
6096 a_n <= '0'; b_n <= '0';
6097 c_n <= '0'; d_n <= '0';
6101 b_n <= '0'; c_n <= '0';
6102 f_n <= '0'; g_n <= '0';
6105 a_n <= '0'; c_n <= '0';
6106 d_n <= '0'; f_n <= '0';
6110 a_n <= '0'; c_n <= '0';
6111 d_n <= '0'; e_n <= '0';
6112 f_n <= '0'; g_n <= '0';
6115 a_n <= '0'; b_n <= '0';
6119 a_n <= '0'; b_n <= '0';
6120 c_n <= '0'; d_n <= '0';
6121 e_n <= '0'; f_n <= '0';
6125 a_n <= '0'; b_n <= '0';
6126 c_n <= '0'; d_n <= '0';
6127 f_n <= '0'; g_n <= '0';
6134 end process bcd2sevSeg;
6138 use IEEE.std_logic_1164.all;
6139 use IEEE.std_logic_unsigned.all;
6141 entity ForceShare is port (
6142 a,b,c,d,e,f: in std_logic_vector (7 downto 0);
6143 result: out std_logic_vector(7 downto 0)
6147 architecture behaviour of ForceShare is
6151 sum: process (a,c,b,d,e,f)
6152 variable tempSum: std_logic_vector(7 downto 0);
6155 tempSum := a + b; -- temporary node for sum
6157 if (tempSum = "10011010") then
6159 elsif (tempSum = "01011001") then
6161 elsif (tempSum = "10111011") then
6170 use IEEE.std_logic_1164.all;
6172 entity shifter is port (
6173 clk, rst: in std_logic;
6174 shiftEn,shiftIn: std_logic;
6175 q: out std_logic_vector (15 downto 0)
6180 architecture behav of shifter is
6182 signal qLocal: std_logic_vector(15 downto 0);
6186 shift: process (clk, rst) begin
6188 qLocal <= (others => '0');
6189 elsif (clk'event and clk = '1') then
6190 if (shiftEn = '1') then
6191 qLocal <= qLocal(14 downto 0) & shiftIn;
6202 use ieee.std_logic_1164.all;
6204 entity lastAssignment is port
6205 (a, b: in std_logic;
6206 selA, selb: in std_logic;
6207 result: out std_logic
6211 architecture behavioral of lastAssignment is
6215 demo: process (a,b,selA,selB) begin
6216 if (selA = '1') then
6222 if (selB = '1') then
6231 use ieee.std_logic_1164.all;
6233 entity signalDemo is port (
6239 architecture basic of signalDemo is
6241 signal c: std_logic;
6245 demo: process (a) begin
6259 use ieee.std_logic_1164.all;
6261 entity signalDemo is port (
6267 architecture basic of signalDemo is
6269 signal c: std_logic;
6273 demo: process (a) begin
6287 USE IEEE.std_logic_1164.all;
6289 package simPrimitives is
6292 generic (tPD: time := 1 ns);
6294 port (I1, I2: in std_logic;
6300 generic(tCQ: time := 1 ns;
6304 port (D, Clk: in std_logic;
6314 USE IEEE.std_logic_1164.all;
6317 generic (tPD: time := 1 ns);
6319 port (I1, I2: in std_logic;
6324 architecture simple of OR2 is
6328 Y <= I1 OR I2 after tPD;
6335 use IEEE.std_logic_1164.all;
6338 generic(tCQ: time := 1 ns;
6342 port (D, Clk: in std_logic;
6347 architecture SimModel of SimDFF is
6351 reg: process (Clk, D) begin
6353 -- Assign output tCQ after rising clock edge
6354 if (Clk'event and Clk = '1') then
6359 if (Clk'event and Clk = '1') then
6360 assert (D'last_event >= tS)
6361 report "Setup time violation"
6366 if (D'event and Clk'stable and Clk = '1') then
6367 assert (D'last_event - Clk'last_event > tH)
6368 report "Hold Time Violation"
6377 use IEEE.std_logic_1164.all;
6379 entity SRFF is port (
6386 architecture rtl of SRFF is
6391 wait until rising_edge(clk);
6392 if s = '0' and r = '1' then
6394 elsif s = '1' and r = '0' then
6401 use IEEE.std_logic_1164.all;
6403 entity SRFF is port (
6410 architecture rtl of SRFF is
6415 wait until clk = '1';
6416 if s = '0' and r = '1' then
6418 elsif s = '1' and r = '0' then
6425 use IEEE.std_logic_1164.all;
6427 package scaleable is
6428 component scaleUpCnt port (
6430 reset: in std_logic;
6431 cnt: in std_logic_vector
6437 use IEEE.std_logic_1164.all;
6439 use work.primitive.all;
6441 entity scaleUpCnt is port (
6443 reset: in std_logic;
6444 cnt: out std_logic_vector
6448 architecture scaleable of scaleUpCnt is
6450 signal one: std_logic := '1';
6451 signal cntL: std_logic_vector(cnt'range);
6452 signal andTerm: std_logic_vector(cnt'range);
6456 -- Special case is the least significant bit
6458 lsb: tff port map (t => one,
6464 andTerm(0) <= cntL(cntL'low);
6467 -- General case for all other bits
6469 genAnd: for i in 1 to cntL'high generate
6470 andTerm(i) <= andTerm(i - 1) and cntL(i);
6473 genTFF: for i in 1 to cntL'high generate
6474 t1: tff port map (t => andTerm(i),
6485 use IEEE.std_logic_1164.all;
6487 entity pci_target is port (
6488 PCI_Frame_n: in std_logic; -- PCI Frame#
6489 PCI_Irdy_n: in std_logic; -- PCI Irdy#
6490 Hit: in std_logic; -- Hit on address decode
6491 D_Done: in std_logic; -- Device decode complete
6492 Term: in std_logic; -- Terminate transaction
6493 Ready: in std_logic; -- Ready to transfer data
6494 Cmd_Write: in std_logic; -- Command is Write
6495 Cmd_Read: in std_logic; -- Command is Read
6496 T_Abort: in std_logic; -- Target error - abort transaction
6497 PCI_Clk: in std_logic; -- PCI Clock
6498 PCI_Reset_n: in std_logic; -- PCI Reset#
6500 PCI_Devsel_n: out std_logic; -- PCI Devsel#
6501 PCI_Trdy_n: out std_logic; -- PCI Trdy#
6502 PCI_Stop_n: out std_logic; -- PCI Stop#
6503 OE_AD: out std_logic; -- PCI AD bus enable
6504 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
6505 OE_Stop_n: out std_logic; -- PCI Stop# enable
6506 OE_Devsel_n: out std_logic -- PCI Devsel# enable
6511 architecture fsm of pci_target is
6513 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
6515 subtype targetFsmType is std_logic_vector(2 downto 0);
6517 constant Idle: targetFsmType := "000";
6518 constant B_Busy: targetFsmType := "101";
6519 constant Backoff: targetFsmType := "010";
6520 constant S_Data: targetFsmType := "011";
6521 constant Turn_Ar: targetFsmType := "110";
6523 signal currState, nextState: targetFsmType;
6527 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
6528 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
6531 if (PCI_Frame_n = '0' and Hit = '0') then
6532 nextState <= B_BUSY;
6538 if (PCI_Frame_n ='1' and D_Done = '1') or
6539 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
6541 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6542 (Term = '0' or (Term = '1' and Ready = '1') ) then
6543 nextState <= S_Data;
6544 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6545 (Term = '1' and Ready = '0') then
6546 nextState <= BACKOFF;
6548 nextState <= B_BUSY;
6552 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
6553 nextState <= BACKOFF;
6554 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
6555 nextState <= TURN_AR;
6557 nextState <= S_DATA;
6562 if PCI_Frame_n = '1' then
6563 nextState <= TURN_AR;
6565 nextState <= BACKOFF;
6569 if (PCI_Frame_n = '0' and Hit = '0') then
6570 nextState <= B_BUSY;
6578 end process nxtStProc;
6581 curStProc: process (PCI_Clk, PCI_Reset_n) begin
6582 if (PCI_Reset_n = '0') then
6584 elsif (PCI_Clk'event and PCI_Clk = '1') then
6585 currState <= nextState;
6587 end process curStProc;
6590 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
6591 Cmd_Read, T_Abort, Term) begin
6594 if (Cmd_Read = '1') then
6600 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
6606 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
6612 if (T_Abort = '0') then
6613 LPCI_Devsel_n <= '0';
6615 LPCI_Devsel_n <= '1';
6623 if (Cmd_Read = '1') then
6635 if (T_Abort = '0') then
6636 LPCI_Devsel_n <= '0';
6638 LPCI_Devsel_n <= '1';
6655 LPCI_Devsel_n <= '1';
6659 end process outConProc;
6661 PCI_Devsel_n <= LPCI_Devsel_n;
6662 PCI_Trdy_n <= LPCI_Trdy_n;
6663 PCI_Stop_n <= LPCI_Stop_n;
6667 use IEEE.std_logic_1164.all;
6669 entity pci_target is port (
6670 PCI_Frame_n: in std_logic; -- PCI Frame#
6671 PCI_Irdy_n: in std_logic; -- PCI Irdy#
6672 Hit: in std_logic; -- Hit on address decode
6673 D_Done: in std_logic; -- Device decode complete
6674 Term: in std_logic; -- Terminate transaction
6675 Ready: in std_logic; -- Ready to transfer data
6676 Cmd_Write: in std_logic; -- Command is Write
6677 Cmd_Read: in std_logic; -- Command is Read
6678 T_Abort: in std_logic; -- Target error - abort transaction
6679 PCI_Clk: in std_logic; -- PCI Clock
6680 PCI_Reset_n: in std_logic; -- PCI Reset#
6682 PCI_Devsel_n: out std_logic; -- PCI Devsel#
6683 PCI_Trdy_n: out std_logic; -- PCI Trdy#
6684 PCI_Stop_n: out std_logic; -- PCI Stop#
6685 OE_AD: out std_logic; -- PCI AD bus enable
6686 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
6687 OE_Stop_n: out std_logic; -- PCI Stop# enable
6688 OE_Devsel_n: out std_logic -- PCI Devsel# enable
6693 architecture fsm of pci_target is
6695 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
6697 subtype targetFsmType is std_logic_vector(2 downto 0);
6699 constant Idle: targetFsmType := "000";
6700 constant B_Busy: targetFsmType := "001";
6701 constant Backoff: targetFsmType := "011";
6702 constant S_Data: targetFsmType := "010";
6703 constant Turn_Ar: targetFsmType := "110";
6705 signal currState, nextState: targetFsmType;
6709 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
6710 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
6713 if (PCI_Frame_n = '0' and Hit = '0') then
6714 nextState <= B_BUSY;
6720 if (PCI_Frame_n ='1' and D_Done = '1') or
6721 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
6723 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6724 (Term = '0' or (Term = '1' and Ready = '1') ) then
6725 nextState <= S_Data;
6726 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6727 (Term = '1' and Ready = '0') then
6728 nextState <= BACKOFF;
6730 nextState <= B_BUSY;
6734 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
6735 nextState <= BACKOFF;
6736 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
6737 nextState <= TURN_AR;
6739 nextState <= S_DATA;
6744 if PCI_Frame_n = '1' then
6745 nextState <= TURN_AR;
6747 nextState <= BACKOFF;
6751 if (PCI_Frame_n = '0' and Hit = '0') then
6752 nextState <= B_BUSY;
6760 end process nxtStProc;
6763 curStProc: process (PCI_Clk, PCI_Reset_n) begin
6764 if (PCI_Reset_n = '0') then
6766 elsif (PCI_Clk'event and PCI_Clk = '1') then
6767 currState <= nextState;
6769 end process curStProc;
6772 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
6773 Cmd_Read, T_Abort, Term) begin
6776 if (Cmd_Read = '1') then
6782 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
6788 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
6794 if (T_Abort = '0') then
6795 LPCI_Devsel_n <= '0';
6797 LPCI_Devsel_n <= '1';
6805 if (Cmd_Read = '1') then
6817 if (T_Abort = '0') then
6818 LPCI_Devsel_n <= '0';
6820 LPCI_Devsel_n <= '1';
6837 LPCI_Devsel_n <= '1';
6841 end process outConProc;
6843 PCI_Devsel_n <= LPCI_Devsel_n;
6844 PCI_Trdy_n <= LPCI_Trdy_n;
6845 PCI_Stop_n <= LPCI_Stop_n;
6849 use IEEE.std_logic_1164.all;
6851 entity pci_target is port (
6852 PCI_Frame_n: in std_logic; -- PCI Frame#
6853 PCI_Irdy_n: in std_logic; -- PCI Irdy#
6854 Hit: in std_logic; -- Hit on address decode
6855 D_Done: in std_logic; -- Device decode complete
6856 Term: in std_logic; -- Terminate transaction
6857 Ready: in std_logic; -- Ready to transfer data
6858 Cmd_Write: in std_logic; -- Command is Write
6859 Cmd_Read: in std_logic; -- Command is Read
6860 T_Abort: in std_logic; -- Target error - abort transaction
6861 PCI_Clk: in std_logic; -- PCI Clock
6862 PCI_Reset_n: in std_logic; -- PCI Reset#
6864 PCI_Devsel_n: out std_logic; -- PCI Devsel#
6865 PCI_Trdy_n: out std_logic; -- PCI Trdy#
6866 PCI_Stop_n: out std_logic; -- PCI Stop#
6867 OE_AD: out std_logic; -- PCI AD bus enable
6868 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
6869 OE_Stop_n: out std_logic; -- PCI Stop# enable
6870 OE_Devsel_n: out std_logic -- PCI Devsel# enable
6875 architecture fsm of pci_target is
6877 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
6879 subtype targetFsmType is std_logic_vector(2 downto 0);
6881 constant Idle: targetFsmType := "000";
6882 constant B_Busy: targetFsmType := "001";
6883 constant Backoff: targetFsmType := "010";
6884 constant S_Data: targetFsmType := "011";
6885 constant Turn_Ar: targetFsmType := "100";
6887 signal currState, nextState: targetFsmType;
6891 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
6892 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
6895 if (PCI_Frame_n = '0' and Hit = '0') then
6896 nextState <= B_BUSY;
6902 if (PCI_Frame_n ='1' and D_Done = '1') or
6903 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
6905 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6906 (Term = '0' or (Term = '1' and Ready = '1') ) then
6907 nextState <= S_Data;
6908 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
6909 (Term = '1' and Ready = '0') then
6910 nextState <= BACKOFF;
6912 nextState <= B_BUSY;
6916 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
6917 nextState <= BACKOFF;
6918 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
6919 nextState <= TURN_AR;
6921 nextState <= S_DATA;
6926 if PCI_Frame_n = '1' then
6927 nextState <= TURN_AR;
6929 nextState <= BACKOFF;
6933 if (PCI_Frame_n = '0' and Hit = '0') then
6934 nextState <= B_BUSY;
6942 end process nxtStProc;
6945 curStProc: process (PCI_Clk, PCI_Reset_n) begin
6946 if (PCI_Reset_n = '0') then
6948 elsif (PCI_Clk'event and PCI_Clk = '1') then
6949 currState <= nextState;
6951 end process curStProc;
6954 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
6955 Cmd_Read, T_Abort, Term) begin
6958 if (Cmd_Read = '1') then
6964 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
6970 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
6976 if (T_Abort = '0') then
6977 LPCI_Devsel_n <= '0';
6979 LPCI_Devsel_n <= '1';
6987 if (Cmd_Read = '1') then
6999 if (T_Abort = '0') then
7000 LPCI_Devsel_n <= '0';
7002 LPCI_Devsel_n <= '1';
7019 LPCI_Devsel_n <= '1';
7023 end process outConProc;
7025 PCI_Devsel_n <= LPCI_Devsel_n;
7026 PCI_Trdy_n <= LPCI_Trdy_n;
7027 PCI_Stop_n <= LPCI_Stop_n;
7031 use IEEE.std_logic_1164.all;
7033 entity pci_target is port (
7034 PCI_Frame_n: in std_logic; -- PCI Frame#
7035 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7036 Hit: in std_logic; -- Hit on address decode
7037 D_Done: in std_logic; -- Device decode complete
7038 Term: in std_logic; -- Terminate transaction
7039 Ready: in std_logic; -- Ready to transfer data
7040 Cmd_Write: in std_logic; -- Command is Write
7041 Cmd_Read: in std_logic; -- Command is Read
7042 T_Abort: in std_logic; -- Target error - abort transaction
7043 PCI_Clk: in std_logic; -- PCI Clock
7044 PCI_Reset_n: in std_logic; -- PCI Reset#
7046 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7047 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7048 PCI_Stop_n: out std_logic; -- PCI Stop#
7049 OE_AD: out std_logic; -- PCI AD bus enable
7050 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7051 OE_Stop_n: out std_logic; -- PCI Stop# enable
7052 OE_Devsel_n: out std_logic -- PCI Devsel# enable
7057 architecture fsm of pci_target is
7059 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
7061 subtype targetFsmType is std_logic_vector(3 downto 0);
7063 constant Idle: targetFsmType := "0000";
7064 constant B_Busy: targetFsmType := "0001";
7065 constant Backoff: targetFsmType := "0011";
7066 constant S_Data: targetFsmType := "1100";
7067 constant Turn_Ar: targetFsmType := "1101";
7069 signal currState, nextState: targetFsmType;
7073 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
7074 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
7077 if (PCI_Frame_n = '0' and Hit = '0') then
7078 nextState <= B_BUSY;
7084 if (PCI_Frame_n ='1' and D_Done = '1') or
7085 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
7087 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7088 (Term = '0' or (Term = '1' and Ready = '1') ) then
7089 nextState <= S_Data;
7090 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7091 (Term = '1' and Ready = '0') then
7092 nextState <= BACKOFF;
7094 nextState <= B_BUSY;
7098 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
7099 nextState <= BACKOFF;
7100 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
7101 nextState <= TURN_AR;
7103 nextState <= S_DATA;
7108 if PCI_Frame_n = '1' then
7109 nextState <= TURN_AR;
7111 nextState <= BACKOFF;
7115 if (PCI_Frame_n = '0' and Hit = '0') then
7116 nextState <= B_BUSY;
7124 end process nxtStProc;
7127 curStProc: process (PCI_Clk, PCI_Reset_n) begin
7128 if (PCI_Reset_n = '0') then
7130 elsif (PCI_Clk'event and PCI_Clk = '1') then
7131 currState <= nextState;
7133 end process curStProc;
7136 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
7137 Cmd_Read, T_Abort, Term) begin
7140 if (Cmd_Read = '1') then
7146 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
7152 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
7158 if (T_Abort = '0') then
7159 LPCI_Devsel_n <= '0';
7161 LPCI_Devsel_n <= '1';
7169 if (Cmd_Read = '1') then
7181 if (T_Abort = '0') then
7182 LPCI_Devsel_n <= '0';
7184 LPCI_Devsel_n <= '1';
7201 LPCI_Devsel_n <= '1';
7205 end process outConProc;
7207 PCI_Devsel_n <= LPCI_Devsel_n;
7208 PCI_Trdy_n <= LPCI_Trdy_n;
7209 PCI_Stop_n <= LPCI_Stop_n;
7213 use IEEE.std_logic_1164.all;
7215 entity pci_target is port (
7216 PCI_Frame_n: in std_logic; -- PCI Frame#
7217 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7218 Hit: in std_logic; -- Hit on address decode
7219 D_Done: in std_logic; -- Device decode complete
7220 Term: in std_logic; -- Terminate transaction
7221 Ready: in std_logic; -- Ready to transfer data
7222 Cmd_Write: in std_logic; -- Command is Write
7223 Cmd_Read: in std_logic; -- Command is Read
7224 T_Abort: in std_logic; -- Target error - abort transaction
7225 PCI_Clk: in std_logic; -- PCI Clock
7226 PCI_Reset_n: in std_logic; -- PCI Reset#
7228 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7229 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7230 PCI_Stop_n: out std_logic; -- PCI Stop#
7231 OE_AD: out std_logic; -- PCI AD bus enable
7232 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7233 OE_Stop_n: out std_logic; -- PCI Stop# enable
7234 OE_Devsel_n: out std_logic -- PCI Devsel# enable
7239 architecture fsm of pci_target is
7241 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
7243 subtype targetFsmType is std_logic_vector(2 downto 0);
7245 constant Idle: targetFsmType := "000";
7246 constant B_Busy: targetFsmType := "101";
7247 constant Backoff: targetFsmType := "010";
7248 constant S_Data: targetFsmType := "011";
7249 constant Turn_Ar: targetFsmType := "110";
7250 constant Dont_Care: targetFsmType := "XXX";
7252 signal currState, nextState: targetFsmType;
7256 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
7257 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
7260 if (PCI_Frame_n = '0' and Hit = '0') then
7261 nextState <= B_BUSY;
7267 if (PCI_Frame_n ='1' and D_Done = '1') or
7268 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
7270 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7271 (Term = '0' or (Term = '1' and Ready = '1') ) then
7272 nextState <= S_Data;
7273 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7274 (Term = '1' and Ready = '0') then
7275 nextState <= BACKOFF;
7277 nextState <= B_BUSY;
7281 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
7282 nextState <= BACKOFF;
7283 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
7284 nextState <= TURN_AR;
7286 nextState <= S_DATA;
7291 if PCI_Frame_n = '1' then
7292 nextState <= TURN_AR;
7294 nextState <= BACKOFF;
7298 if (PCI_Frame_n = '0' and Hit = '0') then
7299 nextState <= B_BUSY;
7305 nextState <= Dont_Care;
7307 end process nxtStProc;
7310 curStProc: process (PCI_Clk, PCI_Reset_n) begin
7311 if (PCI_Reset_n = '0') then
7313 elsif (PCI_Clk'event and PCI_Clk = '1') then
7314 currState <= nextState;
7316 end process curStProc;
7319 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
7320 Cmd_Read, T_Abort, Term) begin
7322 -- Set default output assignments
7329 LPCI_Devsel_n <= '1';
7333 if (Cmd_Read = '1') then
7339 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
7345 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
7351 if (T_Abort = '0') then
7352 LPCI_Devsel_n <= '0';
7354 LPCI_Devsel_n <= '1';
7362 if (Cmd_Read = '1') then
7374 if (T_Abort = '0') then
7375 LPCI_Devsel_n <= '0';
7377 LPCI_Devsel_n <= '1';
7394 LPCI_Devsel_n <= '1';
7398 end process outConProc;
7400 PCI_Devsel_n <= LPCI_Devsel_n;
7401 PCI_Trdy_n <= LPCI_Trdy_n;
7402 PCI_Stop_n <= LPCI_Stop_n;
7406 use IEEE.std_logic_1164.all;
7408 entity pci_target is port (
7409 PCI_Frame_n: in std_logic; -- PCI Frame#
7410 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7411 Hit: in std_logic; -- Hit on address decode
7412 D_Done: in std_logic; -- Device decode complete
7413 Term: in std_logic; -- Terminate transaction
7414 Ready: in std_logic; -- Ready to transfer data
7415 Cmd_Write: in std_logic; -- Command is Write
7416 Cmd_Read: in std_logic; -- Command is Read
7417 T_Abort: in std_logic; -- Target error - abort transaction
7418 PCI_Clk: in std_logic; -- PCI Clock
7419 PCI_Reset_n: in std_logic; -- PCI Reset#
7421 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7422 PCI_Stop_n: out std_logic; -- PCI Stop#
7423 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7424 OE_AD: out std_logic; -- PCI AD bus enable
7425 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7426 OE_Stop_n: out std_logic; -- PCI Stop# enable
7427 OE_Devsel_n: out std_logic -- PCI Devsel# enable
7431 architecture fsm of pci_target is
7433 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
7435 type targetFsmType is (Idle, B_Busy, Backoff, S_Data, Turn_Ar);
7437 signal currState, nextState: targetFsmType;
7441 -- Process to generate next state logic
7443 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
7444 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
7447 if (PCI_Frame_n = '0' and Hit = '0') then
7448 nextState <= B_Busy;
7454 if (PCI_Frame_n ='1' and D_Done = '1') or
7455 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
7457 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7458 (Term = '0' or (Term = '1' and Ready = '1') ) then
7459 nextState <= S_Data;
7460 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7461 (Term = '1' and Ready = '0') then
7462 nextState <= Backoff;
7464 nextState <= B_Busy;
7468 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
7469 nextState <= Backoff;
7470 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
7471 nextState <= Turn_Ar;
7473 nextState <= S_Data;
7478 if PCI_Frame_n = '1' then
7479 nextState <= Turn_Ar;
7481 nextState <= Backoff;
7485 if (PCI_Frame_n = '0' and Hit = '0') then
7486 nextState <= B_Busy;
7496 end process nxtStProc;
7499 -- Process to register the current state
7501 curStProc: process (PCI_Clk, PCI_Reset_n) begin
7502 if (PCI_Reset_n = '0') then
7504 elsif (PCI_Clk'event and PCI_Clk = '1') then
7505 currState <= nextState;
7507 end process curStProc;
7510 -- Process to generate outputs
7512 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
7513 Cmd_Read, T_Abort, Term) begin
7516 if (Cmd_Read = '1') then
7522 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
7528 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
7534 if (T_Abort = '0') then
7535 LPCI_Devsel_n <= '0';
7537 LPCI_Devsel_n <= '1';
7545 if (Cmd_Read = '1') then
7557 if (T_Abort = '0') then
7558 LPCI_Devsel_n <= '0';
7560 LPCI_Devsel_n <= '1';
7577 LPCI_Devsel_n <= '1';
7581 end process outConProc;
7583 -- Assign output ports
7585 PCI_Devsel_n <= LPCI_Devsel_n;
7586 PCI_Trdy_n <= LPCI_Trdy_n;
7587 PCI_Stop_n <= LPCI_Stop_n;
7590 -- Incorporates Errata 10.1 and 10.2
7593 use IEEE.std_logic_1164.all;
7595 entity pci_target is port (
7596 PCI_Frame_n: in std_logic; -- PCI Frame#
7597 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7598 Hit: in std_logic; -- Hit on address decode
7599 D_Done: in std_logic; -- Device decode complete
7600 Term: in std_logic; -- Terminate transaction
7601 Ready: in std_logic; -- Ready to transfer data
7602 Cmd_Write: in std_logic; -- Command is Write
7603 Cmd_Read: in std_logic; -- Command is Read
7604 T_Abort: in std_logic; -- Target error - abort transaction
7605 PCI_Clk: in std_logic; -- PCI Clock
7606 PCI_Reset_n: in std_logic; -- PCI Reset#
7608 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7609 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7610 PCI_Stop_n: out std_logic; -- PCI Stop#
7611 OE_AD: out std_logic; -- PCI AD bus enable
7612 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7613 OE_Stop_n: out std_logic; -- PCI Stop# enable
7614 OE_Devsel_n: out std_logic -- PCI Devsel# enable
7618 architecture fsm of pci_target is
7620 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
7622 subtype targetFsmType is std_logic_vector(4 downto 0);
7624 constant Idle: integer := 0;
7625 constant B_Busy: integer := 1;
7626 constant Backoff: integer := 2;
7627 constant S_Data: integer := 3;
7628 constant Turn_Ar: integer := 4;
7630 signal currState, nextState: targetFsmType;
7634 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
7635 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
7637 nextState <= (others => '0');
7639 if currState(Idle) = '1' then
7640 if (PCI_Frame_n = '0' and Hit = '0') then
7641 nextState(B_Busy) <= '1';
7643 nextState(Idle) <= '1';
7647 if currState(B_Busy) = '1' then
7648 if (PCI_Frame_n ='1' and D_Done = '1') or
7649 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
7650 nextState(Idle) <= '1';
7651 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7652 (Term = '0' or (Term = '1' and Ready = '1') ) then
7653 nextState(S_Data) <= '1';
7654 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7655 (Term = '1' and Ready = '0') then
7656 nextState(Backoff) <= '1';
7658 nextState(B_Busy) <= '1';
7662 if currState(S_Data) = '1' then
7663 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and
7664 (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
7665 nextState(Backoff) <= '1';
7666 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
7667 nextState(Turn_Ar) <= '1';
7669 nextState(S_Data) <= '1';
7674 if currState(Backoff) = '1' then
7675 if PCI_Frame_n = '1' then
7676 nextState(Turn_Ar) <= '1';
7678 nextState(Backoff) <= '1';
7682 if currState(Turn_Ar) = '1' then
7683 if (PCI_Frame_n = '0' and Hit = '0') then
7684 nextState(B_Busy) <= '1';
7686 nextState(Idle) <= '1';
7690 end process nxtStProc;
7693 curStProc: process (PCI_Clk, PCI_Reset_n) begin
7694 if (PCI_Reset_n = '0') then
7695 currState <= (others => '0'); -- per Errata 10.2
7696 currState(Idle) <= '1';
7697 elsif (PCI_Clk'event and PCI_Clk = '1') then
7698 currState <= nextState;
7700 end process curStProc;
7703 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
7704 Cmd_Read, T_Abort, Term) begin
7705 OE_Trdy_n <= '0'; OE_Stop_n <= '0'; OE_Devsel_n <= '0'; -- defaults per errata 10.1
7706 OE_AD <= '0'; LPCI_Trdy_n <= '1'; LPCI_Stop_n <= '1';
7707 LPCI_Devsel_n <= '1';
7709 if (currState(S_Data) = '1') then
7710 if (Cmd_Read = '1') then
7716 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
7722 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
7728 if (T_Abort = '0') then
7729 LPCI_Devsel_n <= '0';
7731 LPCI_Devsel_n <= '1';
7740 if (currState(Backoff) = '1') then
7741 if (Cmd_Read = '1') then
7753 if (T_Abort = '0') then
7754 LPCI_Devsel_n <= '0';
7756 LPCI_Devsel_n <= '1';
7761 if (currState(Turn_Ar) = '1') then
7767 if (currState(Idle) = '1' or currState(B_Busy) = '1') then
7774 LPCI_Devsel_n <= '1';
7777 end process outConProc;
7779 PCI_Devsel_n <= LPCI_Devsel_n;
7780 PCI_Trdy_n <= LPCI_Trdy_n;
7781 PCI_Stop_n <= LPCI_Stop_n;
7785 use IEEE.std_logic_1164.all;
7787 entity pci_target is port (
7788 PCI_Frame_n: in std_logic; -- PCI Frame#
7789 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7790 Hit: in std_logic; -- Hit on address decode
7791 D_Done: in std_logic; -- Device decode complete
7792 Term: in std_logic; -- Terminate transaction
7793 Ready: in std_logic; -- Ready to transfer data
7794 Cmd_Write: in std_logic; -- Command is Write
7795 Cmd_Read: in std_logic; -- Command is Read
7796 T_Abort: in std_logic; -- Target error - abort transaction
7797 PCI_Clk: in std_logic; -- PCI Clock
7798 PCI_Reset_n: in std_logic; -- PCI Reset#
7800 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7801 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7802 PCI_Stop_n: out std_logic; -- PCI Stop#
7803 OE_AD: out std_logic; -- PCI AD bus enable
7804 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7805 OE_Stop_n: out std_logic; -- PCI Stop# enable
7806 OE_Devsel_n: out std_logic -- PCI Devsel# enable
7811 architecture fsm of pci_target is
7813 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
7815 subtype targetFsmType is std_logic_vector(2 downto 0);
7817 constant Idle: targetFsmType := "000";
7818 constant B_Busy: targetFsmType := "001";
7819 constant Backoff: targetFsmType := "011";
7820 constant S_Data: targetFsmType := "110";
7821 constant Turn_Ar: targetFsmType := "100";
7823 signal currState, nextState: targetFsmType;
7827 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
7828 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
7831 if (PCI_Frame_n = '0' and Hit = '0') then
7832 nextState <= B_BUSY;
7838 if (PCI_Frame_n ='1' and D_Done = '1') or
7839 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
7841 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7842 (Term = '0' or (Term = '1' and Ready = '1') ) then
7843 nextState <= S_Data;
7844 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
7845 (Term = '1' and Ready = '0') then
7846 nextState <= BACKOFF;
7848 nextState <= B_BUSY;
7852 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
7853 nextState <= BACKOFF;
7854 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
7855 nextState <= TURN_AR;
7857 nextState <= S_DATA;
7862 if PCI_Frame_n = '1' then
7863 nextState <= TURN_AR;
7865 nextState <= BACKOFF;
7869 if (PCI_Frame_n = '0' and Hit = '0') then
7870 nextState <= B_BUSY;
7878 end process nxtStProc;
7881 curStProc: process (PCI_Clk, PCI_Reset_n) begin
7882 if (PCI_Reset_n = '0') then
7884 elsif (PCI_Clk'event and PCI_Clk = '1') then
7885 currState <= nextState;
7887 end process curStProc;
7890 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
7891 Cmd_Read, T_Abort, Term) begin
7893 -- Set default output assignments
7900 LPCI_Devsel_n <= '1';
7904 if (Cmd_Read = '1') then
7910 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
7916 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
7922 if (T_Abort = '0') then
7923 LPCI_Devsel_n <= '0';
7925 LPCI_Devsel_n <= '1';
7933 if (Cmd_Read = '1') then
7945 if (T_Abort = '0') then
7946 LPCI_Devsel_n <= '0';
7948 LPCI_Devsel_n <= '1';
7965 LPCI_Devsel_n <= '1';
7969 end process outConProc;
7971 PCI_Devsel_n <= LPCI_Devsel_n;
7972 PCI_Trdy_n <= LPCI_Trdy_n;
7973 PCI_Stop_n <= LPCI_Stop_n;
7977 use IEEE.std_logic_1164.all;
7979 entity pci_target is port (
7980 PCI_Frame_n: in std_logic; -- PCI Frame#
7981 PCI_Irdy_n: in std_logic; -- PCI Irdy#
7982 Hit: in std_logic; -- Hit on address decode
7983 D_Done: in std_logic; -- Device decode complete
7984 Term: in std_logic; -- Terminate transaction
7985 Ready: in std_logic; -- Ready to transfer data
7986 Cmd_Write: in std_logic; -- Command is Write
7987 Cmd_Read: in std_logic; -- Command is Read
7988 T_Abort: in std_logic; -- Target error - abort transaction
7989 PCI_Clk: in std_logic; -- PCI Clock
7990 PCI_Reset_n: in std_logic; -- PCI Reset#
7992 PCI_Devsel_n: out std_logic; -- PCI Devsel#
7993 PCI_Trdy_n: out std_logic; -- PCI Trdy#
7994 PCI_Stop_n: out std_logic; -- PCI Stop#
7995 OE_AD: out std_logic; -- PCI AD bus enable
7996 OE_Trdy_n: out std_logic; -- PCI Trdy# enable
7997 OE_Stop_n: out std_logic; -- PCI Stop# enable
7998 OE_Devsel_n: out std_logic -- PCI Devsel# enable
8002 architecture fsm of pci_target is
8004 signal LPCI_Devsel_n, LPCI_Trdy_n, LPCI_Stop_n: std_logic;
8006 subtype targetFsmType is std_logic_vector(2 downto 0);
8008 constant Idle: targetFsmType := "000";
8009 constant B_Busy: targetFsmType := "001";
8010 constant Backoff: targetFsmType := "011";
8011 constant S_Data: targetFsmType := "110";
8012 constant Turn_Ar: targetFsmType := "100";
8014 signal currState, nextState: targetFsmType;
8018 nxtStProc: process (currState, PCI_Frame_n, Hit, D_Done, PCI_Irdy_n, LPCI_Trdy_n,
8019 LPCI_Devsel_n, LPCI_Stop_n, Term, Ready) begin
8022 if (PCI_Frame_n = '0' and Hit = '0') then
8023 nextState <= B_Busy;
8029 if (PCI_Frame_n ='1' and D_Done = '1') or
8030 (PCI_Frame_n = '1' and D_Done = '0' and LPCI_Devsel_n = '0') then
8032 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
8033 (Term = '0' or (Term = '1' and Ready = '1') ) then
8034 nextState <= S_Data;
8035 elsif (PCI_Frame_n = '0' or PCI_Irdy_n = '0') and Hit = '1' and
8036 (Term = '1' and Ready = '0') then
8037 nextState <= Backoff;
8039 nextState <= B_Busy;
8043 if PCI_Frame_n = '0' and LPCI_Stop_n = '0' and
8044 (LPCI_Trdy_n = '1' or PCI_Irdy_n = '0') then
8045 nextState <= Backoff;
8046 elsif PCI_Frame_n = '1' and (LPCI_Trdy_n = '0' or LPCI_Stop_n = '0') then
8047 nextState <= Turn_Ar;
8049 nextState <= S_Data;
8054 if PCI_Frame_n = '1' then
8055 nextState <= Turn_Ar;
8057 nextState <= Backoff;
8061 if (PCI_Frame_n = '0' and Hit = '0') then
8062 nextState <= B_Busy;
8070 end process nxtStProc;
8073 curStProc: process (PCI_Clk, PCI_Reset_n) begin
8074 if (PCI_Reset_n = '0') then
8076 elsif (PCI_Clk'event and PCI_Clk = '1') then
8077 currState <= nextState;
8079 end process curStProc;
8082 outConProc: process (currState, Ready, T_Abort, Cmd_Write,
8083 Cmd_Read, T_Abort, Term) begin
8086 if (Cmd_Read = '1') then
8092 if (Ready = '1' and T_Abort = '0' and (Cmd_Write = '1' or Cmd_Read = '1')) then
8098 if (T_Abort = '1' or Term = '1') and (Cmd_Write = '1' or Cmd_Read = '1') then
8104 if (T_Abort = '0') then
8105 LPCI_Devsel_n <= '0';
8107 LPCI_Devsel_n <= '1';
8115 if (Cmd_Read = '1') then
8127 if (T_Abort = '0') then
8128 LPCI_Devsel_n <= '0';
8130 LPCI_Devsel_n <= '1';
8147 LPCI_Devsel_n <= '1';
8151 end process outConProc;
8153 PCI_Devsel_n <= LPCI_Devsel_n;
8154 PCI_Trdy_n <= LPCI_Trdy_n;
8155 PCI_Stop_n <= LPCI_Stop_n;
8159 use ieee.std_logic_1164.all;
8161 entity test is port (
8168 architecture simple of test is
8172 z <= a when en = '1' else 'z
';