|
20位元BIN轉BCD的程式% `5 {9 G1 R$ a1 S( y' o5 M
LIBRARY IEEE;
. v" g% \) X4 muse IEEE.std_logic_1164.all;
) v& z7 L# M/ Y
5 R/ M' a% ?: f, b3 M/ h$ k+ @entity bin2bcd is
* { _7 b" l- P) kport(' N2 H4 |" m4 ~4 A" V
data_in : in std_logic_vector(19 downto 0);
; ~6 `6 V1 n# N, d5 I: s EN : in std_logic;$ `1 U# x7 `0 c4 V0 ^" B& ~
data_out : out std_logic_vector(23 downto 0)
z( k+ j' {. }$ `);
# o3 R( Q5 l0 W" u4 X) Xend entity;
0 Y9 r* |0 J- ~' w% c8 Y/ A/ E/ e% h# S% |& {, H- i/ y
( z; O- F0 {9 f. J! G) m# e
architecture bin2bcd of bin2bcd is: ?) \+ O8 N8 ]' s5 U
begin2 S1 L A5 b5 F" S' @
8 ~' V; Y; R0 x2 e9 _% i
process(data_in, EN)
2 O# D# y+ A! N) t }& i9 Ivariable data_in_TEMP : std_logic_vector(2 downto 0);* ^+ z% ^) a; ]
begin
( t/ B3 a2 y0 ]2 M! u. I data_in_TEMP := data_in(19 downto 1);
8 l! y, g) G: }4 e2 p- U4 H, } data_out '0');& Z' {: n% N6 P6 G
if EN='1' then! |# a4 H2 N4 s# V' S; S7 B
case data_in_TEMP is
: J3 w0 V/ v% O' ^- v1 o' B& p+ \ 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');
. m# u' L; x8 K6 j2 g end case;" M8 c. K) _ O0 i
0 `% j$ X. W Y8 F3 T
data_out(0) <= data_in(0);- ^+ B5 B" j$ q8 I
end if;# t- n& v/ k- y7 i
end process;
& \: G2 p) G0 a& W4 Z4 h# m- N5 J N2 O v& j
end architecture;7 K y& ]4 x* |
) M0 d$ K8 e7 s& Y, V2 P
3 }/ w s0 z: \/ y# C3 TCHECK的時候第一行跟if EN='1' then這行出現錯誤9 C3 [0 ^' R( M9 N! s ?# W6 I' _
會是什麼問題?? |
|