|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在网上寻找数字地与模拟地的英文材料;
4 L; M& b& l5 A; p% K& X无意间浏览到一个国外的的cpld/FPGA论坛,点击进入! k* G v; }* U$ a) Y- y$ t- I& H
发现了有人求51的IP CORE,在回帖里面看到这个,所以下载了。
9 [2 M; {: A. n; O5 |7 F6 ?! o( J. K! p
% i- O+ y( O4 }) U/ g
% t" m0 ]6 F' j$ u: E1 j h r@: mc8051@oregano.at# ^- S1 g3 p9 x( K5 s1 R/ [
W: http://oregano.at/ip/8051.htm2 @. g8 E" P/ N0 U0 d+ {# ?1 @$ i
4 X; V8 g: J% Z% L7 U/ }************************************************************: ^# T X* r: X
This is version 1.4 of the MC8051 IP core.
. l _6 j- [3 v) sNovember 2004: Oregano Systems - Design & Consulting GesmbH& h2 ?1 k) ~# w; h
============================================================
# J0 r5 A( F+ x9 A$ a6 WChanges:
8 T! u+ \! Z& K+ N! z1 b- corrected behaviour of RETI instruction handling6 X4 C$ d8 m6 \3 {* d) `8 M4 D
- added synchronization for interrupt signals$ }7 B/ w6 T6 } b: c- n6 b [* w
- corrected timer problems
- ~8 t+ ?6 B, c, {, @2 F
) o& U% ^ X8 J% ^- {" d- R************************************************************6 @6 j: k4 l5 \
This is version 1.3 of the MC8051 IP core.
. T" Q2 t: g: B$ l* oSeptember 2002: Oregano Systems - Design & Consulting GesmbH' \/ Y8 Z% \& H( |; y% v0 S
============================================================
" Y5 @! O" T j1 N1 l9 m0 p+ bChange history:6 G0 i$ a3 w% r @ x5 b- D
- Improved tb_mc8051_siu_sim.vhd to verify duplex operation." z, D, ?1 j6 @
- Corrected problem with duplex operation in file - A) R: E) u/ T) x5 g
mc8051_siu_rtl.vhd3 N, d/ ~+ l- ^' \0 |$ h: J6 x
. X1 ?2 V) j- m7 }& E************************************************************
" I) I A. R$ v/ [2 m& x2 _9 GThis is version 1.2. of the MC8051 IP core.1 U' }- }# h. g; p* m
June 2002 - Oregano Systems - Design & Consulting GesmbH A- e: L, t" s+ ~" h- Q& D
============================================================
5 T' K- |! h+ |' p+ A# c) a9 l- \- `; QChange history:' f4 y M" H) a* O% n
- Eliminated the scr subdirectory form the distribution.
& ^( |) ~) y O7 f4 {/ ]4 B4 ~0 W- Improved documentation.
7 d5 ^9 n+ A1 G# H3 z# i! n- Corrected several bugs in the source code (see the1 f' E- |. n7 Y; y% D8 @/ p( s
website for more details).
+ @" k: ?3 M9 ]- Improved the testbench with respect to the I/O port
4 \9 \2 l! @' G# F% y2 n behavior.
+ {: y4 k7 b* S( U. ]- Enriched the msim directory with the assembler source! d) w* p) s6 R, o- H2 V* X& @
code of an example program.
. W$ T8 F9 D$ h- Provided the source code of a Intel hex to binary
1 ]8 ]1 C( D9 |- s E textfile converter to ease simulation of the user's
- ]8 X: D* f) _5 v2 v) P assambler programs.
* N9 e; b+ p) _8 h
2 g# z3 {' r# u. f, N+ |/ ~************************************************************
. S5 R; c0 B j ~1 k1 S2 X& ZThis is version 1.1. of the MC8051 IP core.
/ O3 `1 h0 N0 [& h% u `3 L1 dJan 31st 2002 - Oregano Systems - Design & Consulting GesmbH& ]: ]/ L" b3 _, P$ E7 b1 z
8 P: t1 s$ u9 X- |
1 H+ y4 O9 e6 f' }* t( j7 A( |
. t2 @% Z2 m/ u) L
下面是里面的部分VHDL
2 y! A1 U; r6 n' M; N8 k& {, s, ]& h5 \4 m2 ~( h9 b
! k5 A. q8 k, c. y. X9 A$ N8 A6 V+ n
library IEEE;
F% K# ]) z( {" O# g/ Luse IEEE.std_logic_1164.all;
6 @' W9 c7 t* e0 d6 P/ Q4 Euse IEEE.std_logic_arith.all;8 h. s) O d, f7 o
library work;
. e& t/ k3 G5 p' @, Guse work.mc8051_p.all;& W2 D+ L7 u* D1 E" {
+ ^: W% a2 N6 F4 }- ^) B2 Z-----------------------------ENTITY DECLARATION--------------------------------+ K3 p5 ~, K$ z# ]
entity addsub_core is8 L6 ]9 x. ~4 i- L, m3 v
3 k- y8 e. T3 j. J; f9 \ generic (DWIDTH : integer := 16); -- Data width of the ALU
: ~: T9 v1 {, e/ |- R& j3 D- a port (opa_i : in std_logic_vector(DWIDTH-1 downto 0);1 ?0 S6 F" U" \
opb_i : in std_logic_vector(DWIDTH-1 downto 0);' V* M4 w2 ?7 M5 z
addsub_i : in std_logic;
# B0 ?. ], Z% n# V cy_i : in std_logic;
' a8 i! t1 w) g6 W w! F, Z+ G cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);7 F: r# D7 D2 B* x9 L
ov_o : out std_logic;
7 E0 f, e+ e- g* M+ c6 X rslt_o : out std_logic_vector(DWIDTH-1 downto 0));
& u& `/ I5 a! y. j, J/ i2 s# i
1 C" V' w+ x9 l" v& q; aend addsub_core;
# S2 r' R C' e m
$ h9 t% j( A6 K2 L/ c. Y3 S, R# j6 x! D* J, B' L/ C) V
- ~# P5 }5 s) I2 S$ j
entity mc8051_alu is- Z$ z( ~! {/ }2 T
generic (DWIDTH : integer := 8); -- Data width of the ALU
+ ~4 s; D6 W8 R0 d port (rom_data_i : in std_logic_vector(DWIDTH-1 downto 0);( f: F( ~' Y* t; [" d
ram_data_i : in std_logic_vector(DWIDTH-1 downto 0);
( n* g1 w$ V! \0 j, c acc_i : in std_logic_vector(DWIDTH-1 downto 0);
3 ~7 M! g8 G4 Z3 N# O cmd_i : in std_logic_vector(5 downto 0);& ?* ~2 R5 z# O2 ~& i3 s. k
cy_i : in std_logic_vector((DWIDTH-1)/4 downto 0); x7 _8 b# M" }0 J! n3 ?7 O* g
ov_i : in std_logic;" V% h! O7 j3 n/ w0 S! I
1 r4 s$ k3 w- {, \ new_cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
2 q' k [" x, e& b. w$ Q3 v new_ov_o : out std_logic;
" }6 \% [4 c1 ^& O/ I) k result_a_o : out std_logic_vector(DWIDTH-1 downto 0);1 D" _5 w3 m8 h- m5 L( f1 r
result_b_o : out std_logic_vector(DWIDTH-1 downto 0));4 p7 H, G" j1 E# a/ R @
& p0 ~6 a7 U7 Y% S% k
end mc8051_alu;
* Q" v( O0 T7 W--Inputs:
) s2 k+ J; _9 d* p-- rom_data_i...... data input from ROM# S( o/ H2 U: H! k) E+ n" i3 K
-- ram_data_i...... data input from RAM- U# R2 Q" U" `4 g
-- acc_i........... the contents of the accumulator register
8 u; y$ |1 l, p" |! F-- cmd_i........... command from the control unit7 S+ J: d- l9 n1 u- m1 A- f4 o
-- cy_i............ CY-Flags of the SFR
* R. Q. m2 f: P# P- t-- ov_i............ OV-Flag of the SFR6 n U, i6 w4 \
--Outputs:
; V, M. _, m2 W# `% X-- new_cy_o........ new CY-Flags for SFR. ?- ?& B m+ O$ x T, C4 A
-- new_ov_o........ new OV-Flag for SFR
3 F# \1 L$ j/ }. ^, t# c3 l-- result_a_o...... result- v9 H X+ w0 C: y/ b4 p, P
-- result_b_o...... result
2 P A' l/ j* L" t4 c) }. H, O+ b# w0 e
$ H# Y9 w: E( R) H9 e T0 p
9 |6 b6 r7 f$ C3 J) O+ v3 v
3 e% Y. v( }' M
architecture struc of mc8051_alu is* ^; i. ~( O( }1 a- q# y, o
signal s_alu_result : std_logic_vector(DWIDTH-1 downto 0);/ A! y2 h0 X) z% N5 w1 C0 z, g
signal s_alu_new_cy : std_logic_vector((DWIDTH-1)/4 downto 0);6 h, w4 Y, f+ m, R( ]
signal s_alu_op_a : std_logic_vector(DWIDTH-1 downto 0);* E" @( B* L2 r% p* k r
signal s_alu_op_b : std_logic_vector(DWIDTH-1 downto 0);
; q# {0 T; Y, [8 }$ b signal s_alu_cmd : std_logic_vector(3 downto 0);) g- A( f3 @. V& R9 W
signal s_dvdnd : std_logic_vector(DWIDTH-1 downto 0);1 @ L4 z5 w, Q# N* q
signal s_dvsor : std_logic_vector(DWIDTH-1 downto 0);
, f0 b& q7 r. r. a signal s_qutnt : std_logic_vector(DWIDTH-1 downto 0);
& e* y$ h% g/ _% h2 q v: | signal s_rmndr : std_logic_vector(DWIDTH-1 downto 0);
4 k w$ I( c; }; c9 s signal s_mltplcnd : std_logic_vector(DWIDTH-1 downto 0);
: |4 v/ Z- ]8 {& L6 A signal s_mltplctr : std_logic_vector(DWIDTH-1 downto 0);
u' \! k& `% a6 J9 q8 ^ signal s_product : std_logic_vector((DWIDTH*2)-1 downto 0);
. b4 } P7 m$ Z8 K6 E signal s_dcml_data : std_logic_vector(DWIDTH-1 downto 0);
& k; ^ r/ D# |$ z' [ signal s_dcml_rslt : std_logic_vector(DWIDTH-1 downto 0);2 r+ s2 z1 @4 `' _
signal s_dcml_cy : std_logic;
% N4 M4 n% r) X; D7 S' p3 o signal s_addsub_rslt : std_logic_vector(DWIDTH-1 downto 0);8 |; @! d% n4 a2 j. n
signal s_addsub_newcy : std_logic_vector((DWIDTH-1)/4 downto 0);! A) [- L y9 t+ N( R
signal s_addsub_ov : std_logic;# s8 B& ]. h7 z; V4 Q7 @# i
signal s_addsub_cy : std_logic;
$ p3 ?& w( u, Q4 c6 J# f signal s_addsub : std_logic;
- J' i3 @7 j+ s; B* H signal s_addsub_opa : std_logic_vector(DWIDTH-1 downto 0);$ a; z/ ?/ M& S$ s
signal s_addsub_opb : std_logic_vector(DWIDTH-1 downto 0);( t' i2 Z; R& B0 W* {* f
begin -- architecture structural
, Y8 [- a& @) _' Z9 k3 h7 z: Z i_alumux : alumux
2 T Y' [, V5 T; B4 S generic map (+ I4 z. l" L% F. @; a& N s
DWIDTH => DWIDTH)
; B7 B R- Q+ p port map (
6 T; b- F: }/ Q3 B" l8 V. } -- Primary I/Os of the ALU unit.4 ^+ Z$ J# a" f% r" b( v
rom_data_i => rom_data_i,
( r; O# Z2 o+ F$ j4 ] ram_data_i => ram_data_i,$ H/ o1 J: N& u3 Q: a- V$ T! Q
acc_i => acc_i,+ X7 S, f1 z5 n$ ?" {
cmd_i => cmd_i,# k/ y3 Z# t5 W' `4 G
cy_i => cy_i,
2 J8 h1 V$ L# }' D" L ov_i => ov_i," A8 ]8 [! T- h6 u' }( o$ a1 B
cy_o => new_cy_o,5 x3 O, A |$ L5 W" `; G0 I
ov_o => new_ov_o, ?; z) @, F* ]" l6 O: h* F, Q, T
result_a_o => result_a_o," J# D& |5 R8 D, Q- b
result_b_o => result_b_o,
1 Z5 |9 ^; U; S- j: O -- I/Os connecting the submodules.0 \3 l! E/ [# c- i3 }) `: \
result_i => s_alu_result,* U0 N! N3 N+ y
new_cy_i => s_alu_new_cy," n0 H, A* C4 K/ w
addsub_rslt_i => s_addsub_rslt,
, Q: Y) h; {/ o/ f: `+ R addsub_cy_i => s_addsub_newcy,
) w- Z) B& z! z4 W addsub_ov_i => s_addsub_ov,5 @/ G: f4 J# l& o
op_a_o => s_alu_op_a,
7 Y; }: w9 m5 q" G! N9 r op_b_o => s_alu_op_b,6 e) s7 G9 @- j, l/ o+ ~7 l3 E. }
alu_cmd_o => s_alu_cmd," u. Y$ `! a, ?: B3 `) y
opa_o => s_addsub_opa,! w! a3 q& B7 ^5 W9 w
opb_o => s_addsub_opb,* y! X4 E7 f+ Q U2 w
addsub_o => s_addsub,
% Q4 N8 @& I7 m. V+ h* K+ X addsub_cy_o => s_addsub_cy,
3 Z1 ~" K0 v( }6 |* v dvdnd_o => s_dvdnd,
9 N, y) t& O* O* W dvsor_o => s_dvsor,6 D; A; \+ E4 _- }4 d
qutnt_i => s_qutnt,
7 Z( Q( @+ p! i& l* w3 Y9 P rmndr_i => s_rmndr,
4 v* K/ X* a4 H) n, M: @, X; }' e+ F, d mltplcnd_o => s_mltplcnd,
- h4 k, q! |& G R; O mltplctr_o => s_mltplctr,/ p8 ?( F) A7 c0 }
product_i => s_product,9 u: T P+ d% j# G6 ?. H
dcml_data_o => s_dcml_data,3 z: c2 R7 J* m
dcml_data_i => s_dcml_rslt,& k3 B) C1 M& O( X; B- G
dcml_cy_i => s_dcml_cy);
+ ^- J. i' |- T9 {. L2 t i_alucore : alucore% a+ S6 j& h! G8 |3 ^( [( ~
generic map (
( h2 f; ^2 z i. }' k2 } DWIDTH => DWIDTH). _7 L' `' g9 k$ v* z
port map (
9 V# _% w0 ] N6 j- [$ n4 o) D op_a_i => s_alu_op_a,
8 `+ [' I K' @; N* [# Y/ R op_b_i => s_alu_op_b,, D. {/ b( Z# m3 k
alu_cmd_i => s_alu_cmd,
0 s. x1 }: O, ]0 v( I% D Y+ E cy_i => cy_i,5 G/ @# `8 `) ~2 O8 F0 q# b
cy_o => s_alu_new_cy,
5 V8 _* M/ b; M result_o => s_alu_result);
) b9 H% M- d; M+ O i_addsub_core : addsub_core: l, t. X, A1 l
generic map (DWIDTH => DWIDTH)
4 L. h& j2 w1 H6 T port map (opa_i => s_addsub_opa,* _0 \; E# x1 n" x5 D; q
opb_i => s_addsub_opb,2 [2 o+ }6 r2 Y; O3 w1 u
addsub_i => s_addsub,. |8 G4 \- M q) R D
cy_i => s_addsub_cy,+ H6 [- o( q4 @0 ~' J8 F) N, f' ?
cy_o => s_addsub_newcy,
4 U: H* V6 ?+ H: ] ov_o => s_addsub_ov,
+ C6 E. f" y' S! i x* N8 J rslt_o => s_addsub_rslt);
, \+ Q; v! p* Q$ V" \ gen_multiplier1 : if C_IMPL_MUL = 1 generate
- Q5 J% y$ K6 `+ \6 {6 z p( m i_comb_mltplr : comb_mltplr% x) W0 x4 M+ v2 ]! R( a t; B: _- k
generic map (; B$ E# p2 |: y3 d7 u0 L
DWIDTH => DWIDTH)! n% J* k4 ?9 {- `! E
port map (* q) I2 T( E8 }2 i& Y$ p
mltplcnd_i => s_mltplcnd,/ ^) D7 B" Z& _7 |; Y4 }9 z
mltplctr_i => s_mltplctr,
/ t( ~+ M7 e$ S$ o7 ` product_o => s_product);
! H( u/ J% K8 n- G6 ^1 V end generate gen_multiplier1;
- q' I. i: M# Z" F6 @( i3 \4 } gen_multiplier0 : if C_IMPL_MUL /= 1 generate2 y3 N8 i) ^5 t2 n
s_product <= (others => '0');+ A: `* i5 R9 a+ ]9 n' i, k' s
end generate gen_multiplier0;
* g" [6 Q7 R# S1 B0 j' o gen_divider1 : if C_IMPL_DIV = 1 generate
4 l9 |$ l- N' @$ ~+ E2 `/ l$ j i_comb_divider : comb_divider
+ @+ j4 `7 z; `/ F7 f generic map (
' l" |0 }0 O# \2 A DWIDTH => DWIDTH)
% @. C# k. I0 u7 { port map (3 }/ H5 j6 \6 i3 \3 h6 ]0 e
dvdnd_i => s_dvdnd,
+ C; ]9 n2 A' o. c! ] dvsor_i => s_dvsor,
" K* Z" ]1 Q. b% b1 \1 S/ y qutnt_o => s_qutnt,% d/ \$ a% `$ K/ Y" F7 _
rmndr_o => s_rmndr);
, o) W( C# {9 V4 N7 g end generate gen_divider1;
' D1 T/ S, w9 r9 O' r5 c9 q! s2 Q gen_divider0 : if C_IMPL_DIV /= 1 generate q7 y' H' X2 i. B
s_qutnt <= (others => '0');. e% T& O- Z+ }1 k: `2 f2 t
s_rmndr <= (others => '0');7 c p2 Q. ], _5 V8 A8 w B, y
end generate gen_divider0;9 W- [9 k- U+ J* f$ }
gen_dcml_adj1 : if C_IMPL_DA = 1 generate3 g( I+ c: L. S. b( W
i_dcml_adjust : dcml_adjust
. o8 N( ~$ ~. n generic map ( _3 v1 [* m9 k6 a9 _% F' F+ ~
DWIDTH => DWIDTH), T# a6 j3 ^' u! ?
port map (- B+ a7 U7 o u
data_i => s_dcml_data,* h. B. o/ e) z: j8 z2 v8 |
cy_i => cy_i,
7 j2 b" K% w. z' p" { data_o => s_dcml_rslt,+ N0 c1 J, |+ s E1 M
cy_o => s_dcml_cy);
. a% Q4 j- d7 P( y; a end generate gen_dcml_adj1;
) Y5 U' f: I! v1 g" Q4 D, r gen_dcml_adj0 : if C_IMPL_DA /= 1 generate/ j4 I1 a) k. E$ |3 m" H9 c
s_dcml_rslt <= (others => '0');) I# ]/ t- o2 w; n! ~) _
s_dcml_cy <= '0';, X' m8 F! f3 u9 S+ v- J) R
end generate gen_dcml_adj0;
% D3 R5 _% L$ o( l5 Z/ U2 U% Vend struc; |
|