|
20位元BIN轉BCD的程式; n7 K [" \* {8 x/ \3 O7 m
LIBRARY IEEE;
1 U5 b: i3 V" N p7 ]use IEEE.std_logic_1164.all;" |4 a/ h$ b0 n; m% B7 Z) V
8 t/ N1 J# p/ q8 s& |9 m- c0 I1 a! I
entity bin2bcd is
8 R$ r P7 [& }1 A& Q+ j* hport(/ x0 P9 x6 i" k7 R) |( r; v
data_in : in std_logic_vector(19 downto 0);
& H8 T3 V7 C7 q7 t$ k EN : in std_logic;
; ^, [, y) }2 l2 V7 l3 C, o data_out : out std_logic_vector(23 downto 0)
5 C$ t& i/ G3 H3 P+ z);
4 ~! l4 `5 `8 }% cend entity;
% u/ h. a- T+ f* M4 A( E
H: {, ^5 v3 K/ p3 T& c" z" q1 H6 H/ I8 E9 \6 o
architecture bin2bcd of bin2bcd is
4 Z0 |2 s+ l3 x( ]0 t1 ^3 X, [3 i nbegin5 W8 `# ^8 ~0 K
' @# _" |, S6 w
process(data_in, EN); V6 a' z y- ]% V' e2 z# u
variable data_in_TEMP : std_logic_vector(2 downto 0);
/ g, U* G T& A: dbegin0 g1 J! H1 J4 P( Q$ W+ M) O9 J
data_in_TEMP := data_in(19 downto 1);
y8 T9 Y. |1 s5 R' | data_out '0');
' w+ u y/ E; P$ X$ n0 v if EN='1' then* |2 w5 a' R+ L2 {, `: U* l, _6 ?$ t
case data_in_TEMP is
8 `2 a2 ?9 p. R4 {0 n 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');
; u; I' D" u) Z3 X) v v7 R, x' X end case;
! c% U* c. K# i! F3 n: C4 m* P
, H/ c$ Z1 z. k data_out(0) <= data_in(0);( C; C) v+ C/ x7 V4 b/ n) e" `) @
end if;% c, b) L3 C- F0 ]& y5 ~. t
end process;# s& @7 @% k7 m" w* v
1 I/ f; o k2 [! Z
end architecture; b# D# m6 U) v2 }3 ]. ^* R
- ^9 k e$ W& A; L) J
# v) m' h. T6 B) [" hCHECK的時候第一行跟if EN='1' then這行出現錯誤
9 `2 D# l0 a6 ]4 d( i會是什麼問題?? |
|