|
20位元BIN轉BCD的程式5 S. [; T8 X6 L0 K) W: \6 O
LIBRARY IEEE;
0 k" n: t0 K5 ]% d3 `use IEEE.std_logic_1164.all;5 q( m9 _1 F' V. w6 V
/ b5 I5 H, a8 E4 V, q
entity bin2bcd is
8 y) v; P, v4 @- Gport(
. P' u* z2 c# C0 z1 }, { data_in : in std_logic_vector(19 downto 0);
; z- E" Y, e; D- t& C EN : in std_logic;
" I3 a B7 h$ }+ D* g data_out : out std_logic_vector(23 downto 0)1 f; D. d' r# \; a
);
0 {8 A6 V# n k6 O7 a; k8 q/ |end entity;4 Z+ Q2 N" j4 C
- [' P K' o* S& r5 c" G9 |2 b' r) q$ Y! R/ q7 l. u1 M! s
architecture bin2bcd of bin2bcd is
! n7 _$ @7 u) ybegin
) G" s0 r# Y5 `3 K8 r8 ` R/ M1 W
6 ]; k- _, f# Z; Z Y2 }process(data_in, EN)+ o# `7 m; V, C; @
variable data_in_TEMP : std_logic_vector(2 downto 0);
! i* A3 k. F, jbegin! x7 Z# k; T9 u! Q5 ?" [
data_in_TEMP := data_in(19 downto 1);
" u: w/ T% g# j# `' G" @( K1 F data_out '0');0 T# F% C4 u* v9 P
if EN='1' then0 n h: f% V j; S7 p; K$ O
case data_in_TEMP is
8 m6 q2 k7 O, h0 L6 _ when "000" => data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out(23 downto 1) data_out'0');
i. d- k' }/ G6 _ end case;
& J7 B4 F, p- S% O) W
' [+ P2 P% K$ e data_out(0) <= data_in(0);; \9 {6 K: ?! P
end if;" n! b: O; a1 Y- W# j
end process;. t& r4 z! T. J
; y+ C. E$ Z, e3 Xend architecture;
( G4 i5 y' C: j4 b! ?" |2 r8 Q
$ S. ]/ Y; F; C: k2 M$ `8 K6 {
7 ?; v- Q& I- M: WCHECK的時候第一行跟if EN='1' then這行出現錯誤
. s4 K* e8 G! K; H- R# P" A- [7 n會是什麼問題?? |
|