|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在网上寻找数字地与模拟地的英文材料;
5 w; ]) b' }; r# @% @7 U+ p无意间浏览到一个国外的的CPLD/FPGA论坛,点击进入$ t% Z5 L3 C/ m: N. P( E
发现了有人求51的IP CORE,在回帖里面看到这个,所以下载了。
" @- e. C) ~7 f6 z- m
( n2 K" j8 L" K) [$ q* f- h# V5 ?& ?6 Z5 u
@: mc8051@oregano.at
9 J, ?5 Q# [6 J& q0 { KW: http://oregano.at/ip/8051.htm
+ V' ]& U0 K* ^! F
9 }2 u( P# Q1 V. i( @7 _************************************************************* s, x5 }" p+ G
This is version 1.4 of the MC8051 IP core.1 l5 M4 r! W( [& ]
November 2004: Oregano Systems - Design & Consulting GesmbH
- b& Q% R' J+ f* B0 m- s============================================================* I. G5 {9 `5 p# U) e
Changes:9 [5 t4 G z% W( Z$ K
- corrected behaviour of RETI instruction handling
) @4 O( d9 f+ N- b% P- added synchronization for interrupt signals
4 C$ f1 {% [$ s: \2 I" U4 `- corrected timer problems" L% c8 U9 L* R, t, P* R
& {0 Q- p; k2 h$ x7 T+ [) M
************************************************************
) Z8 Y. c; y7 D6 ~9 VThis is version 1.3 of the MC8051 IP core.
5 r0 p; {# l; kSeptember 2002: Oregano Systems - Design & Consulting GesmbH
4 q6 c1 @" K# h1 S, f, A. `- N============================================================. p' \0 z0 h/ b s$ b
Change history:" \' M7 `- ?% t
- Improved tb_mc8051_siu_sim.vhd to verify duplex operation.$ }3 t- Z+ ~" P# } Q
- Corrected problem with duplex operation in file
; v( p& H' C# N2 A" W9 L& U mc8051_siu_rtl.vhd
$ Z) o8 N4 X9 r: v% k1 {- Q- X
0 O! Q0 \5 `4 r' b* X************************************************************% l. G# i/ Z, x$ c
This is version 1.2. of the MC8051 IP core.
1 ~# i8 a+ _4 X* ~& W# C, q0 z' UJune 2002 - Oregano Systems - Design & Consulting GesmbH
, w2 L( J+ a8 L============================================================
) {! n, u: _8 r( f. P. B* T ?% lChange history:
1 l- J( R- q- O& Z( W: c& y- Eliminated the scr subdirectory form the distribution.2 Q0 k. F6 I$ R* Q) S# ]" {4 B* w
- Improved documentation.' D5 `5 a& i+ q, Z* x
- Corrected several bugs in the source code (see the* I0 d' N! I9 A8 o3 W. R0 q* N1 N
website for more details).( ^8 N: h; X4 F9 r! |4 Y. a' s7 y% f
- Improved the testbench with respect to the I/O port
% _: D& s# _. h* L behavior.
) L3 `+ I0 X" j$ O/ R7 A8 T- Enriched the msim directory with the assembler source8 A. ?! T/ T6 N
code of an example program.2 `- P1 w5 Q: \ ~& m* O6 y+ a! m
- Provided the source code of a Intel hex to binary
V1 j2 a& \6 x% N+ ?: D* E textfile converter to ease simulation of the user's0 I* Z: q2 y; n# h5 O- { p" S/ Q
assambler programs.6 d) ?- i0 t: l l1 x
5 s7 P8 i# I2 W- ^( B7 H* B" I
************************************************************. Y9 L c& s6 t8 [7 t
This is version 1.1. of the MC8051 IP core.- ]( z2 ^4 R( ]- N7 a
Jan 31st 2002 - Oregano Systems - Design & Consulting GesmbH2 c4 a& S! J3 [, K
% B% c0 L( \/ P% i* n( {7 z8 E
& V6 Z; |8 |5 r5 D) G
( ~6 E# E( a4 n+ B
下面是里面的部分VHDL
& A- C6 m, K6 } A: d
- |2 b. P- f" B1 ^/ W
$ J2 H8 z$ h2 F. o) h$ k
U Z# ^# e1 Q/ j! }! _" clibrary IEEE; * W$ W3 @9 j9 X3 W) p4 O
use IEEE.std_logic_1164.all; & n1 V" \% i% F8 y% t$ A# m! F+ M
use IEEE.std_logic_arith.all; y1 Y; u: U4 k
library work;3 t% D" b; `0 Q9 V
use work.mc8051_p.all;
' {6 a6 Y" h+ L, e' h8 U
- V- w8 t/ W5 V0 r. ~' K" o-----------------------------ENTITY DECLARATION--------------------------------
) {( u) a) r6 xentity addsub_core is. T0 e3 C. [6 d" @% j7 i( }; `% D
' K& C( {. f$ Z3 J* I
generic (DWIDTH : integer := 16); -- Data width of the ALU
+ F" I! m# G( X6 f Q6 @; w port (opa_i : in std_logic_vector(DWIDTH-1 downto 0);
$ u4 B( X+ c6 o/ G0 [& [ opb_i : in std_logic_vector(DWIDTH-1 downto 0);
+ r8 C6 |5 u; J$ o) @ F, e$ k- M. ] addsub_i : in std_logic;6 s; @" u9 d4 P% g& o
cy_i : in std_logic;8 H" |5 z+ y# R
cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
; n1 t t7 X& p' y b ov_o : out std_logic;* j% [; ]- E9 J, R
rslt_o : out std_logic_vector(DWIDTH-1 downto 0));" A7 i+ j8 m3 }# K8 f
& S* F: y0 P5 Zend addsub_core;* D) I' k% E) }/ {
* E2 W3 ^" w, E, A
+ W5 W( `* o9 @0 k$ S" l7 F1 B6 S
% [6 R( p+ X: ^6 V7 ]" uentity mc8051_alu is
p K' @9 U! t5 W generic (DWIDTH : integer := 8); -- Data width of the ALU; I9 p/ q5 p5 L
port (rom_data_i : in std_logic_vector(DWIDTH-1 downto 0);5 {9 `) c& [3 e7 V0 |
ram_data_i : in std_logic_vector(DWIDTH-1 downto 0);, W& X1 G6 W: |4 l8 B
acc_i : in std_logic_vector(DWIDTH-1 downto 0);4 U G. Y G# z: \& J2 a
cmd_i : in std_logic_vector(5 downto 0);
) l+ K( o# O. D+ Q, v8 `4 Q6 U+ j8 H cy_i : in std_logic_vector((DWIDTH-1)/4 downto 0);
+ x/ V* D: D. m% O1 z2 T: @ ov_i : in std_logic;
- }$ e/ z% R8 K& b & E# F; l9 X2 V
new_cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);" S/ }4 ]/ Q& L
new_ov_o : out std_logic;
7 I2 J2 v! @+ O/ h# g result_a_o : out std_logic_vector(DWIDTH-1 downto 0);1 o7 u. s/ s) J- O) C6 _) t! K: r
result_b_o : out std_logic_vector(DWIDTH-1 downto 0));
2 Y$ S8 A. s5 w; E* [ [
( I" q% L& t/ A% Eend mc8051_alu;! h' }9 x: M! Y% @6 |
--Inputs:
) e1 o/ E5 h p" y; v- f-- rom_data_i...... data input from ROM
2 K& Y/ o0 i* b9 \( A9 |# m-- ram_data_i...... data input from RAM
! d- Q6 R! S8 g9 I-- acc_i........... the contents of the accumulator register# u6 Q0 i1 y* e `
-- cmd_i........... command from the control unit% Y& n* j. @) W3 Y& [$ X
-- cy_i............ CY-Flags of the SFR) f0 R2 s% o2 _3 ?' M
-- ov_i............ OV-Flag of the SFR# f0 i- x& `3 {7 K
--Outputs:- | l0 U3 M9 h6 f4 K) {
-- new_cy_o........ new CY-Flags for SFR- [) N6 Y# K; \# e' ]
-- new_ov_o........ new OV-Flag for SFR" h& T) O- W( p4 R/ }
-- result_a_o...... result9 f9 A# q3 [8 {6 ~) p
-- result_b_o...... result
( J$ h% b1 o$ n# |* a! P$ {
3 A/ w% O- Q, H Y9 q4 A( | b7 H' d g: R& E( W
, E7 v5 r( X$ ~" F
4 Y" z4 V% {1 N0 \
architecture struc of mc8051_alu is/ q4 a2 d% K" X: w: B
signal s_alu_result : std_logic_vector(DWIDTH-1 downto 0);$ C. b" v8 I4 X, i& |
signal s_alu_new_cy : std_logic_vector((DWIDTH-1)/4 downto 0);3 B1 q9 F) j" \$ g% v: k$ a% H
signal s_alu_op_a : std_logic_vector(DWIDTH-1 downto 0);* ~6 ^, f8 ?* p# K( _ o
signal s_alu_op_b : std_logic_vector(DWIDTH-1 downto 0);# p; b6 n1 W, s" x6 Z! S
signal s_alu_cmd : std_logic_vector(3 downto 0);
8 A$ G2 ]; z) i- B. c. y0 ` signal s_dvdnd : std_logic_vector(DWIDTH-1 downto 0);
, n9 t6 D5 K% ?% d! t1 y4 a signal s_dvsor : std_logic_vector(DWIDTH-1 downto 0);( t, K- ^' |5 M
signal s_qutnt : std_logic_vector(DWIDTH-1 downto 0);' v: Q- G, C% s8 V6 u: U
signal s_rmndr : std_logic_vector(DWIDTH-1 downto 0);; J E- y- H( o( P* J; ]* E, T' q
signal s_mltplcnd : std_logic_vector(DWIDTH-1 downto 0);! m& g6 o5 N4 o( n. Q/ K
signal s_mltplctr : std_logic_vector(DWIDTH-1 downto 0);* z+ J2 s3 L3 I+ u- A+ L! j8 ~3 I
signal s_product : std_logic_vector((DWIDTH*2)-1 downto 0);) B9 I) u9 O" g7 ~8 V& F
signal s_dcml_data : std_logic_vector(DWIDTH-1 downto 0);
% J7 N! j1 c5 r; [& m: c) T signal s_dcml_rslt : std_logic_vector(DWIDTH-1 downto 0);4 R, M1 |% o+ n9 F: K
signal s_dcml_cy : std_logic;
. L0 j( t3 a3 ?9 T5 l signal s_addsub_rslt : std_logic_vector(DWIDTH-1 downto 0);
% B o$ S! o) f& Y signal s_addsub_newcy : std_logic_vector((DWIDTH-1)/4 downto 0);
- F5 X# A' C4 Z$ m) y, Y signal s_addsub_ov : std_logic;, X7 C% c3 ^4 y
signal s_addsub_cy : std_logic;) F3 y% x0 y% j2 l7 P6 A! e1 c8 w
signal s_addsub : std_logic;* f. T' i8 {& A
signal s_addsub_opa : std_logic_vector(DWIDTH-1 downto 0);# ~2 p, o, D8 d/ ~( t9 t
signal s_addsub_opb : std_logic_vector(DWIDTH-1 downto 0);
8 q5 s r4 ?2 C" Y- x& [( @/ p+ tbegin -- architecture structural
1 V- z: Y* u9 n8 Q' z i_alumux : alumux o% c0 s% R1 {8 L4 w3 R, L
generic map (6 V4 y1 t- T4 T4 c# T
DWIDTH => DWIDTH)4 ^% g' z! A& } Y% p9 X7 E$ o
port map (/ v& Z- P4 B, I" x5 x, J. q7 r
-- Primary I/Os of the ALU unit.
1 _) W9 k j- D5 i) O" e rom_data_i => rom_data_i,
; A$ M' {# ^. t: | ram_data_i => ram_data_i,
1 a- O2 ^% [4 M9 Z acc_i => acc_i,
! f, B# [* l+ E cmd_i => cmd_i,! y8 p% L6 Y; y
cy_i => cy_i,1 O) ^3 F# I) O: ~) ^( {! t
ov_i => ov_i,
- h# R! ~% [: f! [4 }3 K- x$ R cy_o => new_cy_o,, R* g! U7 G& ]- R: M) N; H) c1 r1 |
ov_o => new_ov_o,# Y2 l4 y0 a6 S. [) n; ^# J
result_a_o => result_a_o,
" A7 | o5 l" Q1 I1 ]) b result_b_o => result_b_o,
6 v- j4 `# [7 ` -- I/Os connecting the submodules.9 Y( s1 y2 w1 q9 ?% q, V- u# i2 ^6 S, ]
result_i => s_alu_result,4 T( m" _! h; L! h" r/ {8 r* L
new_cy_i => s_alu_new_cy,6 r2 m0 U a# o
addsub_rslt_i => s_addsub_rslt,
f" _6 u, N3 ]8 X addsub_cy_i => s_addsub_newcy,! ~3 [, B, {5 A. s' U8 |+ g7 m
addsub_ov_i => s_addsub_ov,
. G5 _+ ?/ R5 g op_a_o => s_alu_op_a,
5 p! t" ]" @& |9 } op_b_o => s_alu_op_b,
3 v" L6 J, _+ e7 s, h* `! C alu_cmd_o => s_alu_cmd,
! A2 |5 q* p, h- t r1 E* }1 Q. e opa_o => s_addsub_opa," l0 k' J6 N0 S+ d
opb_o => s_addsub_opb,( {7 L# `! z2 D* O* n" t6 R
addsub_o => s_addsub,6 |- e% m7 t# w
addsub_cy_o => s_addsub_cy,/ ]& z# n5 R B: j/ L2 O1 d' r
dvdnd_o => s_dvdnd,
. |2 I9 a( a7 O( K, |" T dvsor_o => s_dvsor,$ D) Z7 d4 f- J% p& C6 m7 h5 W% u
qutnt_i => s_qutnt,
* A7 d4 L1 j* I6 D: O# t; y rmndr_i => s_rmndr,
9 u5 ]9 d4 G/ ]% ^7 k5 t mltplcnd_o => s_mltplcnd,
* L7 F I. l, V& v mltplctr_o => s_mltplctr,7 [% A/ t) ]. b }
product_i => s_product,
% ^# g5 m4 V+ U* w dcml_data_o => s_dcml_data,. q4 D$ c9 }% a ^/ U& R: F% v
dcml_data_i => s_dcml_rslt,. Y0 L/ V/ [" b) G3 y
dcml_cy_i => s_dcml_cy);3 |. T4 \( L; X/ _% O f( X% V
i_alucore : alucore
w, B$ |5 y& x, l: o' } generic map (
4 G% C( ]; W0 f; r DWIDTH => DWIDTH). P. `' x/ C, W6 v: l
port map (
% U8 e$ S- v3 p7 b% K: t op_a_i => s_alu_op_a,; o, g0 N( y: I& o8 o' t
op_b_i => s_alu_op_b,
: ~; b5 w) z; L alu_cmd_i => s_alu_cmd,
3 H+ t: Y& a/ U# _7 r cy_i => cy_i,$ ~1 n8 z3 C9 r3 T) @7 m
cy_o => s_alu_new_cy,
0 W" Z# n2 M8 h8 y& f result_o => s_alu_result);% n2 r* b/ q' Y
i_addsub_core : addsub_core3 b: ~3 o* B _8 e5 u
generic map (DWIDTH => DWIDTH)
5 P) t- v \( V0 D: r port map (opa_i => s_addsub_opa,7 J2 z. b1 Z( O% k2 g( L4 h, o. J$ e
opb_i => s_addsub_opb,
. o+ w0 n/ ?0 N addsub_i => s_addsub,9 e! }7 G1 J$ e0 y6 L3 v
cy_i => s_addsub_cy,+ |) T- S: |2 W1 B1 a. h- J7 A \
cy_o => s_addsub_newcy,4 i) F' ?% q) `) Y5 T
ov_o => s_addsub_ov,( j, a* G. x+ x4 S. P0 d! ~
rslt_o => s_addsub_rslt);
4 ~8 O' \/ |* |% Y gen_multiplier1 : if C_IMPL_MUL = 1 generate
7 }4 D0 V# F ] i_comb_mltplr : comb_mltplr/ B* W$ j7 ?9 t8 f, c
generic map (% h: u0 B& p7 {) `
DWIDTH => DWIDTH)" l# f8 j+ ], o
port map (
0 F' E7 n; f$ y mltplcnd_i => s_mltplcnd,' T6 ^2 t" l9 q+ n" M, d# B
mltplctr_i => s_mltplctr,8 p2 E: Z( q. U# H# a3 R% ]( x
product_o => s_product);
9 O, D. G; o% u0 E end generate gen_multiplier1;
" c% Y: ?2 R5 p( P4 ? gen_multiplier0 : if C_IMPL_MUL /= 1 generate
8 y: X7 v0 I% T! ^ s_product <= (others => '0');% D1 V& e; ?7 l3 O1 \
end generate gen_multiplier0;, E6 @/ s& Z; Q
gen_divider1 : if C_IMPL_DIV = 1 generate/ Y1 a+ p$ |$ r$ j) R: ^4 t
i_comb_divider : comb_divider1 K9 ]7 M6 p# X# I7 l5 ~( {# {
generic map (
( E, x, ~5 R- j% G8 j DWIDTH => DWIDTH)7 l0 b; S6 E: y; {4 `* s h
port map (, L% O. f) {( C. s/ e* T$ w; L
dvdnd_i => s_dvdnd,% h' d5 a0 x1 U2 E5 v
dvsor_i => s_dvsor,
3 J1 q4 g9 G, h& k/ K2 \, W9 E qutnt_o => s_qutnt,
! h3 } l" {5 v( N7 z: x# p rmndr_o => s_rmndr);7 l& m7 b- x+ ]6 U
end generate gen_divider1;
9 l$ G. L, j( K6 ^ gen_divider0 : if C_IMPL_DIV /= 1 generate/ z% Y! X& c, X2 [* C5 { d F
s_qutnt <= (others => '0');; O1 J- k* k+ ?8 v; S
s_rmndr <= (others => '0');" A0 D1 n }' t/ b0 S
end generate gen_divider0;+ @ z! h" D7 j' ^1 x
gen_dcml_adj1 : if C_IMPL_DA = 1 generate
; p- ?# H2 v/ s5 W F1 J$ F i_dcml_adjust : dcml_adjust) v! w; q7 R0 @6 i( u
generic map (# ]/ P/ g" e8 \6 _2 S
DWIDTH => DWIDTH)
' ~1 a& B2 p4 C+ a port map (2 [; R7 x6 b, H
data_i => s_dcml_data,
' ^; |2 m7 K( h% ^* R n h. c cy_i => cy_i,. i, J3 m/ p2 j: Y9 }) ~& y/ s
data_o => s_dcml_rslt,1 ^/ J4 j% O% l8 W. T) P! Y
cy_o => s_dcml_cy);
1 z( y. N# p) C% ^- ?0 D- _ end generate gen_dcml_adj1;- U6 t) X; C. X$ f
gen_dcml_adj0 : if C_IMPL_DA /= 1 generate
2 T K& w2 y* |2 n5 P0 J" f s_dcml_rslt <= (others => '0');
; z B* ?1 i. n) S% Z; J s_dcml_cy <= '0';
9 M+ r$ s& P4 Y7 W7 @* b end generate gen_dcml_adj0;8 ]* S, o5 q, w9 z
end struc; |
|