|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在网上寻找数字地与模拟地的英文材料;3 ]- I( W8 m! s3 M( l7 o1 c
无意间浏览到一个国外的的CPLD/FPGA论坛,点击进入
9 p8 o4 u, x- r T- e发现了有人求51的IP CORE,在回帖里面看到这个,所以下载了。( j9 f- E* C* R, o- t+ G
# t6 v1 z& p0 s) Q& I9 L) ~8 k$ l
6 f* f8 J& n5 d# V+ O
@: mc8051@oregano.at
2 |4 Z' N& ~! B4 G( {; A7 CW: http://oregano.at/ip/8051.htm
& M4 M( G% A9 E8 x& ` L& |) C/ I8 h$ A0 u" T
************************************************************3 X2 l6 k" J8 N& [1 I( E0 D
This is version 1.4 of the MC8051 IP core.! _* W/ _9 P& s% P/ g3 C
November 2004: Oregano Systems - Design & Consulting GesmbH$ B# @, o$ a! p4 u; E4 r
============================================================, s; ]4 G, ^6 `
Changes:
0 ]# m) H8 O# V9 U- corrected behaviour of RETI instruction handling7 | o$ ^4 }, f4 J$ D' \0 G; l `" t
- added synchronization for interrupt signals
2 V- o. C* j( M0 q+ L. e& C- corrected timer problems5 q5 J2 }2 n$ }6 ?# \! Z" d
, E' I7 A& S& e
************************************************************
3 N" X" K$ R" @9 L+ N; F& eThis is version 1.3 of the MC8051 IP core.! v# Y3 v$ l' Q3 u1 T5 h7 P, _
September 2002: Oregano Systems - Design & Consulting GesmbH
+ C) C7 P. o- @7 W* L, a============================================================" \. b5 q' n$ H! ~0 E: E. ^
Change history:
' ^* ^" X( M5 I! R$ o8 Y! m* T- Improved tb_mc8051_siu_sim.vhd to verify duplex operation.% U1 J, Z$ G9 O+ }! o6 n& d
- Corrected problem with duplex operation in file 4 u4 ^% s2 s% g3 l+ P( R8 \
mc8051_siu_rtl.vhd) N! f# |, o9 d! O) s
( f$ K" [/ b! n1 N+ N4 H$ E************************************************************2 `- s+ l5 P$ {$ Y
This is version 1.2. of the MC8051 IP core./ Q& u: z% S# K9 V, ?2 Y9 h
June 2002 - Oregano Systems - Design & Consulting GesmbH
$ S* A+ Z6 D3 A" g( l============================================================
2 k5 n# o9 V Y/ YChange history:3 z" c, I/ ]8 k+ J0 Z9 J) H
- Eliminated the scr subdirectory form the distribution.
r n) Z0 b1 K; i- Improved documentation.
+ Z, b4 Q1 O) ]$ P1 p5 O- Corrected several bugs in the source code (see the
, g* A, J; u/ G" Y B website for more details).
2 B3 _9 T7 l9 Q/ g- Improved the testbench with respect to the I/O port
* A1 W5 s5 T8 m$ d( | behavior.# e1 N/ G4 K- X& O! g" ^& F0 x
- Enriched the msim directory with the assembler source
' o$ ^6 j1 N, I1 z code of an example program.
/ ]9 |1 E1 N) _0 j( K, A- Provided the source code of a Intel hex to binary
8 p: B* Y6 O* x: k textfile converter to ease simulation of the user's
+ l& t, l/ G% A) Y assambler programs.8 |5 v+ D& t2 E# G9 E
! ~6 Q8 k+ L' O1 X6 v6 Z& p$ G************************************************************
2 J. q/ p, a6 |0 p2 ?This is version 1.1. of the MC8051 IP core.
( M/ J. N+ I4 r# b+ i, c: wJan 31st 2002 - Oregano Systems - Design & Consulting GesmbH
8 C' C- g. ~0 N8 W( H/ q
4 _" S6 z( ^5 F' s) z9 w- t5 I( L1 L+ b9 U2 d. K( S
* S6 d' q5 }% O7 I* F% f' ~3 t8 m$ G下面是里面的部分VHDL5 x8 g4 h- W1 q, F
/ e, d3 a$ d7 d
2 O: y1 A" O+ O2 ]
) e4 y+ ]* S* A/ }6 V. i3 u
library IEEE; u7 ?+ t7 f4 J3 p
use IEEE.std_logic_1164.all;
( l/ f# P9 h; u4 S w2 Duse IEEE.std_logic_arith.all;
- ^2 I# f/ z* w- S9 Llibrary work;
: w& u. C3 S/ t4 y6 e$ juse work.mc8051_p.all;
. j/ e1 |! C1 H: o: n' w
- U9 `/ a( J: M4 x- K-----------------------------ENTITY DECLARATION--------------------------------
9 c6 \+ |+ s4 }, |& k; Eentity addsub_core is6 b3 p9 z3 I! [2 z: n
+ t$ Q0 \5 n- S- E
generic (DWIDTH : integer := 16); -- Data width of the ALU5 ?% |% o. S2 A
port (opa_i : in std_logic_vector(DWIDTH-1 downto 0);3 F2 _" B; ]" U! Z1 {& l, K
opb_i : in std_logic_vector(DWIDTH-1 downto 0);9 S( j8 R6 [2 S/ Y: m) d0 U+ D8 J) w
addsub_i : in std_logic;) C8 V" l2 x4 C: o$ M3 k
cy_i : in std_logic;% |2 c& g* K* q6 ^
cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
( j: z0 [2 p4 v9 ~& L ov_o : out std_logic;
s) v& T* \- n6 K6 E, u1 ?5 Z& J- [! C rslt_o : out std_logic_vector(DWIDTH-1 downto 0));8 Y% J- ? z; ]' s+ A# ?
) q; }- J- _- q8 ~
end addsub_core;4 | j/ a" h9 B: `
' P6 n3 h) X( l) |2 U# W& q
% o! z9 e, H8 f$ w. b8 {% z0 r0 v: R9 |& Z, f( B
entity mc8051_alu is
- t3 B7 e7 x/ P+ k7 {! N# r generic (DWIDTH : integer := 8); -- Data width of the ALU" F% U9 O) \: L9 ~% p8 t, C& p6 A
port (rom_data_i : in std_logic_vector(DWIDTH-1 downto 0);5 I8 J a5 Z) Z: T; o
ram_data_i : in std_logic_vector(DWIDTH-1 downto 0);- G8 y* s1 c: M8 U8 K+ O9 O
acc_i : in std_logic_vector(DWIDTH-1 downto 0);
5 w) ~8 M$ @6 x* g0 Q$ a' v cmd_i : in std_logic_vector(5 downto 0); I7 N3 _$ k2 \+ h
cy_i : in std_logic_vector((DWIDTH-1)/4 downto 0);' C$ h$ h( o8 [$ Z% ]6 }
ov_i : in std_logic;, z. V' ^# r' R4 d/ Y; z
P( Q% ?: w) t1 t1 s5 T
new_cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);# r9 G# X6 L$ |3 k: u
new_ov_o : out std_logic;2 x" W) X# ~2 h! q9 r% Y
result_a_o : out std_logic_vector(DWIDTH-1 downto 0);
% w0 {# M, n0 H! y4 A& j result_b_o : out std_logic_vector(DWIDTH-1 downto 0));
; T& ~* h H# r1 _7 \
~0 K5 I2 {% fend mc8051_alu;% B. j) x7 W+ U% R. C
--Inputs:/ f' i* k1 @' l# V
-- rom_data_i...... data input from ROM
/ B0 ~- O( b1 d+ `-- ram_data_i...... data input from RAM, j/ q& b0 [% N2 g$ s2 S
-- acc_i........... the contents of the accumulator register
9 X. f1 s/ k5 O k+ O. ]/ O& g3 t: Y-- cmd_i........... command from the control unit; u( B3 j$ m4 t. x
-- cy_i............ CY-Flags of the SFR8 |% G) e4 I$ `
-- ov_i............ OV-Flag of the SFR
$ ^% V! w' Q* e4 z3 a--Outputs:
' p* t: r E0 k; ?8 @. {1 U4 `3 O-- new_cy_o........ new CY-Flags for SFR9 G$ U& L8 z, H: g `2 D. K
-- new_ov_o........ new OV-Flag for SFR6 e* t. x7 k3 ]3 p
-- result_a_o...... result
. D0 q2 O" }- A" I! a- _-- result_b_o...... result
7 }8 h/ K! W9 q0 {8 b' ~. F8 y7 n: g6 j' J# s1 j
% P! c3 C# p+ X6 h9 u0 A3 o
/ J0 d% W2 i: {, S
5 A7 k* c6 a+ Q- p0 g Qarchitecture struc of mc8051_alu is+ X+ K8 S I% m+ D7 \9 Z- k, T$ M
signal s_alu_result : std_logic_vector(DWIDTH-1 downto 0);
/ I; {7 t+ H+ X* n signal s_alu_new_cy : std_logic_vector((DWIDTH-1)/4 downto 0);
8 X8 D/ M0 e5 n$ v B M signal s_alu_op_a : std_logic_vector(DWIDTH-1 downto 0);
2 G" i+ w8 h7 k signal s_alu_op_b : std_logic_vector(DWIDTH-1 downto 0);
( k" _% B O' P+ e% A' [. R5 X signal s_alu_cmd : std_logic_vector(3 downto 0);
a6 g8 }: X$ T. N& }( s8 ? signal s_dvdnd : std_logic_vector(DWIDTH-1 downto 0);
/ ]6 f# F B: t1 D2 R: x' ~7 M8 v signal s_dvsor : std_logic_vector(DWIDTH-1 downto 0);* z. ]" q, f& v. H n$ ^, n
signal s_qutnt : std_logic_vector(DWIDTH-1 downto 0);7 L! }2 F$ ~% b% ~4 H
signal s_rmndr : std_logic_vector(DWIDTH-1 downto 0);. }0 u! E( j2 k' f y0 T
signal s_mltplcnd : std_logic_vector(DWIDTH-1 downto 0);8 O; ~9 e' Y, M8 Z$ D7 g
signal s_mltplctr : std_logic_vector(DWIDTH-1 downto 0);) ?' ^/ x4 B! Z
signal s_product : std_logic_vector((DWIDTH*2)-1 downto 0); t- r) V" U6 S D* G4 |9 D
signal s_dcml_data : std_logic_vector(DWIDTH-1 downto 0);- _( {4 x9 p2 n- T, z# z
signal s_dcml_rslt : std_logic_vector(DWIDTH-1 downto 0);' o$ ~: A1 b1 [" c }* Z+ N H/ D
signal s_dcml_cy : std_logic;
6 r6 M: F" e; q! T: E; @3 A signal s_addsub_rslt : std_logic_vector(DWIDTH-1 downto 0);
/ q) E% O# R3 Z) `. b; s$ J, ~ ^ signal s_addsub_newcy : std_logic_vector((DWIDTH-1)/4 downto 0);
, F1 {8 W( D* ?6 @0 a signal s_addsub_ov : std_logic;
& c$ r- Z+ p* Q" K" \ signal s_addsub_cy : std_logic;5 g2 D- ^2 I/ f! h2 c
signal s_addsub : std_logic;
4 l7 c5 ^+ ^' R, N& ^+ s# {, E signal s_addsub_opa : std_logic_vector(DWIDTH-1 downto 0); N0 b- }- v+ C4 H$ s
signal s_addsub_opb : std_logic_vector(DWIDTH-1 downto 0);
, y1 ^/ g% Q& h: Y* Qbegin -- architecture structural
# S/ S: v- n% H. U2 j" n i_alumux : alumux
$ n4 ~8 D! Y, o6 P generic map (
# D: l e, p6 \ DWIDTH => DWIDTH)0 s' x9 j9 }2 M+ u, I# V' w
port map (9 i, O5 B! b( z/ ?+ ^% ^
-- Primary I/Os of the ALU unit.
0 u! O" Q6 Z9 a# X$ } rom_data_i => rom_data_i,
/ e% [1 e8 G# M8 m ram_data_i => ram_data_i,9 }1 C5 V2 C5 e, }9 E& E
acc_i => acc_i,; h$ _% S) g* m2 O
cmd_i => cmd_i,
$ U& f( d; B" X" m% H- `3 p cy_i => cy_i,( Z/ D7 I. q: R/ N( h& F" v
ov_i => ov_i,
( o2 h4 G; u7 f; H cy_o => new_cy_o,
7 `. ?* u, @0 ^4 x; W9 a: i) r ov_o => new_ov_o,. @. r, N9 q% U
result_a_o => result_a_o,
( y0 V8 i5 W. L9 x1 ^ result_b_o => result_b_o,
0 f* o7 P0 D4 c! _# g -- I/Os connecting the submodules.
! V, E; f8 x5 S! ^7 h0 y( ? result_i => s_alu_result,
: F1 ]$ a* x2 \0 G1 y9 e0 c new_cy_i => s_alu_new_cy,) @1 I1 E' q( h! E$ C3 e1 y
addsub_rslt_i => s_addsub_rslt,, {) K3 i X" ]0 J5 s( H
addsub_cy_i => s_addsub_newcy,
, T' |; O4 J1 n- v" n: `3 Z2 T addsub_ov_i => s_addsub_ov,( z/ |' j8 w4 a, b0 L
op_a_o => s_alu_op_a,6 u' ?( z% E, e! a( S7 J
op_b_o => s_alu_op_b,
4 z g0 _4 y9 H4 b8 B/ | alu_cmd_o => s_alu_cmd,
2 K& Z+ i0 n& Q$ K5 I! _2 w, g opa_o => s_addsub_opa,, E, G$ J0 k& j8 z0 }9 P
opb_o => s_addsub_opb,5 w$ G" U# d8 d7 n
addsub_o => s_addsub,! d# c& f, U$ H2 k4 H; k, l S( C
addsub_cy_o => s_addsub_cy,
$ }+ ?) b2 |$ k+ c$ `2 \0 M dvdnd_o => s_dvdnd,9 J2 b4 `& h+ g3 D7 Q/ I
dvsor_o => s_dvsor,: _: o1 j' o- ~8 { {- E; t4 Z9 j
qutnt_i => s_qutnt,
4 ^2 R+ m, P, l rmndr_i => s_rmndr,
& I, T' d8 H. K0 ~ mltplcnd_o => s_mltplcnd,
4 Z" C4 C4 ?/ @& Y mltplctr_o => s_mltplctr,
* ?9 `! ~& _. i% r Z product_i => s_product,$ T, [# |$ E& u3 P3 V
dcml_data_o => s_dcml_data,
# T, r8 Q: s# @6 h6 _5 N dcml_data_i => s_dcml_rslt,! ^; h/ A; E8 z# u
dcml_cy_i => s_dcml_cy);
/ e2 z1 {/ y$ n ?0 _& o i_alucore : alucore
+ T/ q" T. \% |5 O generic map ( `5 q# W0 b. W0 ^) a: x5 e% Y2 S' D: m
DWIDTH => DWIDTH)
+ s+ E7 `* j3 r" n9 B port map (
7 ^3 j$ b& z. d9 H op_a_i => s_alu_op_a,
- @1 y E8 L+ c' C: y- K2 x, D op_b_i => s_alu_op_b,& p- a, R" D2 H
alu_cmd_i => s_alu_cmd,0 t( @/ Y, J4 S3 y; `' Z+ {
cy_i => cy_i,) s1 u! c/ r( v: q- E# I
cy_o => s_alu_new_cy,
; N5 N, \. w" I2 z+ ]4 `0 H+ D; E result_o => s_alu_result);" Y2 ]/ z$ X# ?6 |, |* }4 j @
i_addsub_core : addsub_core1 ]1 Z4 Y; ~: r+ M P3 z/ J
generic map (DWIDTH => DWIDTH)) {! K& h( y8 f, w% ]
port map (opa_i => s_addsub_opa,
5 ?3 j7 H6 ]( p# R5 g opb_i => s_addsub_opb,
6 H, H$ ?3 S- a7 ]& m) H+ N9 U addsub_i => s_addsub,; X! b( R* M0 T$ U; ~% d% v
cy_i => s_addsub_cy,
' g$ ~3 S; z; T/ i2 v7 u6 X cy_o => s_addsub_newcy,. i& J, l/ h+ x2 w
ov_o => s_addsub_ov,% ~; Z3 j$ k- a/ g0 U j
rslt_o => s_addsub_rslt);% e2 u- p0 H0 J2 q; ?+ M/ g* S( X" ~
gen_multiplier1 : if C_IMPL_MUL = 1 generate
. G& q5 }. ~6 n/ I8 v3 A i_comb_mltplr : comb_mltplr
( |+ U8 V6 W6 |" O2 B* }+ d generic map (4 W4 g% [3 K" C
DWIDTH => DWIDTH)
/ E- m: x- @5 T port map (
8 t0 ?( I t8 } mltplcnd_i => s_mltplcnd,
, ]# l Q" \5 G3 [ mltplctr_i => s_mltplctr,* p1 r, a& d9 T8 N" E4 p2 ?
product_o => s_product);6 B' P% k$ K& T* d% M% m2 ?
end generate gen_multiplier1;* n8 J7 v! j: r' c$ R
gen_multiplier0 : if C_IMPL_MUL /= 1 generate0 s* Y. n7 G% m; v
s_product <= (others => '0');9 {0 O+ Z% H9 i' t: z1 n
end generate gen_multiplier0;; u, G5 K/ M9 x
gen_divider1 : if C_IMPL_DIV = 1 generate u' u& [% e( D0 k" v: _9 R% j: D0 T
i_comb_divider : comb_divider' s. C$ k2 A9 Z
generic map (
/ j& a7 W C0 r- K6 H DWIDTH => DWIDTH)3 A5 P& B7 O$ T& ]
port map (
2 r" h5 n. L( I7 ^8 ? dvdnd_i => s_dvdnd,# p% @ g6 L) L' {7 @1 ~
dvsor_i => s_dvsor,3 i3 j9 ]. V+ N4 e" {, V! v
qutnt_o => s_qutnt,
( x3 _4 C- O1 ?6 c3 G rmndr_o => s_rmndr);! a/ N& o5 o! e6 I5 l8 k4 ~
end generate gen_divider1;8 X* p3 x! g, S
gen_divider0 : if C_IMPL_DIV /= 1 generate
9 d* R% f9 r: {" ]( W8 f+ b P s_qutnt <= (others => '0');# g1 L/ t- k- p9 p7 x+ q0 e5 w6 j, p
s_rmndr <= (others => '0');
8 J5 @0 C* c5 P h/ b0 k7 S end generate gen_divider0;
# x& U1 ?* g% G, [( V) ^. g gen_dcml_adj1 : if C_IMPL_DA = 1 generate
% e$ _7 |# z2 n2 l9 m9 o i_dcml_adjust : dcml_adjust3 y) o, L6 Y) C3 h# ?
generic map () b5 A- p+ J' @0 O( ~5 p$ V
DWIDTH => DWIDTH)
Q$ p+ [( e5 [$ r9 V port map (
8 Z t% S5 J' s9 Z# N6 }7 P data_i => s_dcml_data,
, l# k& H# w" u9 J# r$ @ cy_i => cy_i,4 a+ z$ K4 z* }5 T' y- D, b
data_o => s_dcml_rslt,% C i' ]" ~* n* p: J
cy_o => s_dcml_cy);5 ^ J/ N/ e7 |$ n
end generate gen_dcml_adj1;
0 C& s9 V4 T% v9 G4 C gen_dcml_adj0 : if C_IMPL_DA /= 1 generate
- E% k/ \- D9 C9 `- O s_dcml_rslt <= (others => '0');) ~+ i& c+ x* ]+ I
s_dcml_cy <= '0';
; h1 s5 o) F* c end generate gen_dcml_adj0;" n4 @1 V" j9 }2 M; U
end struc; |
|