|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在网上寻找数字地与模拟地的英文材料;
! k' T/ y9 _4 A* x3 U f( s# p9 C无意间浏览到一个国外的的CPLD/FPGA论坛,点击进入
( E4 S4 s; u2 d" R4 ~发现了有人求51的IP CORE,在回帖里面看到这个,所以下载了。
! K/ N2 D- i# Z E/ ^. ~4 P+ O" y) Q3 N1 O; r q
3 v% X" @3 l# q- c@: mc8051@oregano.at
0 _. |0 ~' Q: d+ x+ R3 KW: http://oregano.at/ip/8051.htm8 j- K1 J1 y+ t! }: ]7 N) F* Y
1 b, @$ Q# n4 F* ~
************************************************************6 j4 A) Y" y; y" ]# [. G4 k M; s) S% ~
This is version 1.4 of the MC8051 IP core.
1 T6 B7 F; _" V0 Z0 ~- KNovember 2004: Oregano Systems - Design & Consulting GesmbH) n) @4 k) Q. g7 Q1 o e# Q
============================================================
' I- L: f$ ]! ?Changes:
8 A5 Y2 d6 @% N7 Y1 E4 e6 z' |- corrected behaviour of RETI instruction handling* i$ r, {6 e2 {+ I. P/ ?( E2 U& i, Z0 S
- added synchronization for interrupt signals
7 w) z w0 U0 a" b' F3 t) J- K- corrected timer problems; c& Y' d5 j; Q
8 j9 b) ]3 N$ C3 M9 X. j& C************************************************************5 ~7 W4 x9 y" J$ C5 v- b
This is version 1.3 of the MC8051 IP core.
8 G U( i# F3 z* n7 I/ eSeptember 2002: Oregano Systems - Design & Consulting GesmbH7 ?0 p1 N% Z5 I# L
============================================================
0 F& P0 F9 f+ \7 wChange history:
0 M" T1 x! o, `- Improved tb_mc8051_siu_sim.vhd to verify duplex operation.
" ^1 N# C: B7 Y* q- Corrected problem with duplex operation in file . c* g6 y8 A0 r! u5 }! C' ^" \
mc8051_siu_rtl.vhd
- U7 l; d; g/ o* e0 x' n8 ?; V0 v- A$ \
************************************************************; m: h; K; k7 B, |' h
This is version 1.2. of the MC8051 IP core.
. m& R b7 `$ n! U" f# QJune 2002 - Oregano Systems - Design & Consulting GesmbH3 M! G9 d3 g: f( {9 Z6 V' m
============================================================
2 Q2 e$ p+ j) }0 S/ e' aChange history:
4 V5 y6 {- e- v' ]- Eliminated the scr subdirectory form the distribution., a. l( p6 p/ ?1 t* u/ y! U
- Improved documentation.
8 q$ u6 p) b9 F. g- Corrected several bugs in the source code (see the
$ ]5 ]# ~* y. X9 y# G( c& l2 d website for more details).
7 v3 l# S/ m- d- Improved the testbench with respect to the I/O port
+ F# \+ L9 I3 r4 d" a behavior.
/ |3 M5 Q9 Q+ z' C6 W- Enriched the msim directory with the assembler source
: P2 Q8 @0 S( ?0 {2 C code of an example program.( v6 r. | ^ W# d1 l+ M
- Provided the source code of a Intel hex to binary) m- h3 y& {2 @ \- c/ A& s
textfile converter to ease simulation of the user's) Q- s& M% a( M+ c, z7 A
assambler programs.
4 j) B. B: p8 A; h0 H2 t* \0 C$ M; O0 b; ~
************************************************************& M# }( q1 g1 E! a4 n p* M9 Q, f# W
This is version 1.1. of the MC8051 IP core.# x; B8 i8 l: Z' B0 E: f G
Jan 31st 2002 - Oregano Systems - Design & Consulting GesmbH
8 V% y P/ Y4 ]% O4 N/ W4 P4 E O* {" m8 u8 u* z* t G8 e
, B# R' o9 A/ Y! I+ b" m( U# Z0 k/ F
* n' T, u1 [2 z下面是里面的部分VHDL8 K; A Q4 D r0 D
" j& ] n! P6 @, }; g: F% H# @) T2 W2 J& X! o
" Q) M, _2 K9 glibrary IEEE; + x) O& i( Z) h5 `4 s" l
use IEEE.std_logic_1164.all; 9 p& g# a! G" D! o. D n. a, j
use IEEE.std_logic_arith.all;; `& x8 {6 S' [9 O; @9 ?8 V
library work;
5 t5 R7 H9 t% Vuse work.mc8051_p.all;
$ x3 U7 A7 Z4 y# `% q 4 t& P0 L, y& h3 v$ v
-----------------------------ENTITY DECLARATION--------------------------------' g! W" e9 Z' Y9 P3 B
entity addsub_core is
3 {) d# Z% [9 k" u; _/ W 7 m; }6 r, S Z* t8 C( w5 O; ^& d
generic (DWIDTH : integer := 16); -- Data width of the ALU
7 E9 D* V! ?: `+ v8 C4 ?( m port (opa_i : in std_logic_vector(DWIDTH-1 downto 0);
; J3 N3 H( }' V1 i! D opb_i : in std_logic_vector(DWIDTH-1 downto 0);: s2 Z2 U/ R! f1 T
addsub_i : in std_logic;
( u: `$ x! K+ L' S/ G cy_i : in std_logic;& f8 B4 m7 a! p) u
cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
. e0 `# H% y, J ]8 q$ y2 R3 P ov_o : out std_logic;" j) r/ h/ T2 V6 p' R& I
rslt_o : out std_logic_vector(DWIDTH-1 downto 0));# ?9 h! O! B8 o4 e
9 I) i- M q B* h& cend addsub_core;
% Y- z0 {5 A- h/ O* u3 ?
c1 V8 m( w5 H' n! C, s; J! `: U
( U5 T" c" B: H; `2 ~9 `6 C) W- ]; c6 }entity mc8051_alu is
' M0 K6 x, \- |" k5 Q; I generic (DWIDTH : integer := 8); -- Data width of the ALU
$ y% {2 o$ ~* A, N" [6 k port (rom_data_i : in std_logic_vector(DWIDTH-1 downto 0);' M- C6 G+ Q0 o, z: y
ram_data_i : in std_logic_vector(DWIDTH-1 downto 0);
0 y! [$ e8 Y u5 U1 E acc_i : in std_logic_vector(DWIDTH-1 downto 0);, h, g$ }3 g/ i! |- ]
cmd_i : in std_logic_vector(5 downto 0);7 O+ `7 ~# `6 z
cy_i : in std_logic_vector((DWIDTH-1)/4 downto 0);6 e+ Z' Q: ~; m
ov_i : in std_logic;
& Y7 y$ [/ r1 i" X8 l& m2 i4 Z4 h ; B6 Z t, l8 K& \" p F
new_cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
0 [0 c5 b( v2 Q new_ov_o : out std_logic;$ [0 y2 `$ Q$ s& X0 U1 ^
result_a_o : out std_logic_vector(DWIDTH-1 downto 0);; @2 ?$ m" n: A
result_b_o : out std_logic_vector(DWIDTH-1 downto 0));' d$ V7 w N, ?
% {- Q+ C- ^, |" _. qend mc8051_alu;
# D% {* b6 ?2 y% p9 r--Inputs:7 H. t$ h) ~+ B9 r
-- rom_data_i...... data input from ROM
/ c1 C7 b1 y8 Y-- ram_data_i...... data input from RAM( l: G3 p+ J4 U( w
-- acc_i........... the contents of the accumulator register
8 ]0 H4 g6 v8 b' E$ e- [-- cmd_i........... command from the control unit# Y* g$ L# o+ ]% `
-- cy_i............ CY-Flags of the SFR
' u2 M3 T" i) e-- ov_i............ OV-Flag of the SFR
) b# G4 }) t( }# r# P6 i--Outputs:1 o" W# U. p: A6 S
-- new_cy_o........ new CY-Flags for SFR1 ]& n/ K2 ~3 D$ {
-- new_ov_o........ new OV-Flag for SFR
& Q5 X" J7 g4 n& F( r$ ?/ C, B-- result_a_o...... result3 F+ `% W8 S, _7 Q
-- result_b_o...... result
6 h; E+ t- \( p- x! s2 S0 X7 g* }$ L& U0 p. E
# L7 _% ~1 b i6 ?' Y
; j2 d. f6 U' I; m9 p5 |: u1 N" c
: a1 W, `: r7 c6 x" P5 H9 jarchitecture struc of mc8051_alu is# c5 i. U! g% h4 O
signal s_alu_result : std_logic_vector(DWIDTH-1 downto 0);
; R* W' W& X4 {& ^0 h# @; H signal s_alu_new_cy : std_logic_vector((DWIDTH-1)/4 downto 0);
* P; k5 I8 W4 C7 S9 ^( h4 O signal s_alu_op_a : std_logic_vector(DWIDTH-1 downto 0);
. d; `- t7 E, J* p/ Q signal s_alu_op_b : std_logic_vector(DWIDTH-1 downto 0);
% U' r0 _1 Z6 L" X2 u; c signal s_alu_cmd : std_logic_vector(3 downto 0);
1 O0 O4 b P- O8 [! l, v9 ? signal s_dvdnd : std_logic_vector(DWIDTH-1 downto 0);1 u6 Y5 a/ W5 i# T
signal s_dvsor : std_logic_vector(DWIDTH-1 downto 0);- d$ O1 `3 B. ~ O
signal s_qutnt : std_logic_vector(DWIDTH-1 downto 0);, P7 V1 y& [/ r1 \5 L
signal s_rmndr : std_logic_vector(DWIDTH-1 downto 0);
/ H5 D$ h- t( w2 b! X6 O. ~ signal s_mltplcnd : std_logic_vector(DWIDTH-1 downto 0);' N& S" N4 G: s/ d5 M" v1 b
signal s_mltplctr : std_logic_vector(DWIDTH-1 downto 0);
. c& ~% c2 C& P( Q7 U signal s_product : std_logic_vector((DWIDTH*2)-1 downto 0);# |, K; w9 R* F: g# k
signal s_dcml_data : std_logic_vector(DWIDTH-1 downto 0);
$ ~% G; ^" f" R2 k. j% Y; A signal s_dcml_rslt : std_logic_vector(DWIDTH-1 downto 0);
& F# Y: F/ V) i9 b* D: v! u0 [& j signal s_dcml_cy : std_logic;# n$ r. Y) I- C
signal s_addsub_rslt : std_logic_vector(DWIDTH-1 downto 0);
8 d& z8 d( R: J/ P signal s_addsub_newcy : std_logic_vector((DWIDTH-1)/4 downto 0);4 y& m: U' a1 e9 S# z% o: Z
signal s_addsub_ov : std_logic;! P# e6 [* r: r$ x% A8 D
signal s_addsub_cy : std_logic;7 o) ~( f/ o$ \' z- _$ k/ c* l4 b
signal s_addsub : std_logic;) ~1 x( u0 |" I' \
signal s_addsub_opa : std_logic_vector(DWIDTH-1 downto 0);
2 }& K" D! M; U$ D( |* x: Y signal s_addsub_opb : std_logic_vector(DWIDTH-1 downto 0);0 |- p; {, k- ?9 p2 y9 y1 i# w
begin -- architecture structural
) L. F: z: `1 t; J+ V: e i_alumux : alumux2 j1 C k. V, S6 ^4 F# l9 d0 s
generic map (
% T( q% K! j. Z* n. g DWIDTH => DWIDTH)
: v( O3 H2 Y! L8 u port map (6 h6 }- C) F2 b: z S4 v1 w
-- Primary I/Os of the ALU unit.
3 q5 t* O6 t7 q# L# c5 B rom_data_i => rom_data_i,
6 c! J6 U0 E) t4 r' E ram_data_i => ram_data_i,/ }! z( P# C9 C: E8 Q
acc_i => acc_i,
# Q9 Z" n! h8 H& @ cmd_i => cmd_i,; z( T0 w6 g+ C& l& v% q
cy_i => cy_i,& U3 v( f2 N( f- V
ov_i => ov_i,
0 X, {# L. U% @3 V! d! b: L cy_o => new_cy_o,, S" c; [* q, V/ X
ov_o => new_ov_o,7 U- I$ |7 g0 C, y+ O' G5 u9 @
result_a_o => result_a_o,
9 v! {. @% T& ~ result_b_o => result_b_o,3 w( b2 T9 w' g
-- I/Os connecting the submodules.
, u8 A; O: O8 T$ O# E2 v3 Z' l% Y8 g5 V result_i => s_alu_result,
. y2 S) J2 @4 e& @9 E$ C: N new_cy_i => s_alu_new_cy,# m2 q' ?; @: ^/ S0 K1 c+ C: o; y
addsub_rslt_i => s_addsub_rslt,/ b. s& Q6 ]4 m9 `+ o$ J
addsub_cy_i => s_addsub_newcy,+ `# r& c/ H$ |6 W/ O
addsub_ov_i => s_addsub_ov,
Q9 o- n/ c) R" p% N' {( } op_a_o => s_alu_op_a,
8 i) a+ k; v, Q- M5 c op_b_o => s_alu_op_b,
8 e }( T2 P/ u2 f% K D# w; g1 _ alu_cmd_o => s_alu_cmd,
2 C$ \% } n( | K& ~2 x5 e8 l x opa_o => s_addsub_opa,
% _+ U, `- P2 x, J opb_o => s_addsub_opb,
+ D1 ]* |7 [- D' Y addsub_o => s_addsub,4 u _& T- Z( K% f) _
addsub_cy_o => s_addsub_cy,
* g) c/ N: B0 \6 M dvdnd_o => s_dvdnd,* F- [0 ?7 K+ x {/ P) U
dvsor_o => s_dvsor,
# r* \" F5 J$ H# v* r7 ~6 I qutnt_i => s_qutnt,
# f; k, `( Y m2 H* x& y rmndr_i => s_rmndr,0 Z; @+ h+ S( s$ j. R& |
mltplcnd_o => s_mltplcnd,
6 |, v& o6 t: \8 Y. o% Q mltplctr_o => s_mltplctr,
0 u* G+ j$ [! y6 O; u# Q% T product_i => s_product,
z. h4 r1 [; Q8 Z* D3 C* j dcml_data_o => s_dcml_data,
7 z) w# t. W& W% e( V$ ?. Q dcml_data_i => s_dcml_rslt,
; q' }5 L, D0 t7 ]: i" k! F) g/ o dcml_cy_i => s_dcml_cy);* }# I1 G' z* _- U! h: I0 \
i_alucore : alucore
; i; `7 O5 g( u6 x$ ?; I generic map (
- ]* ?- e/ p. d3 N DWIDTH => DWIDTH)
8 t& r/ _' q% j4 v port map (; y( u* G5 `6 W! V
op_a_i => s_alu_op_a,
% C0 D: y- ?* I$ y) p; W7 @/ k op_b_i => s_alu_op_b,
$ D$ h6 |" G) Z alu_cmd_i => s_alu_cmd,$ w: i0 F9 R6 ~' s8 d
cy_i => cy_i,
. g. l3 p* H, Z& z cy_o => s_alu_new_cy,
' X+ |. i+ A; v. `; D9 n result_o => s_alu_result);
+ g" j4 b$ Q2 N' K" G" u [; s i_addsub_core : addsub_core
0 z% s3 r- |. ~) w$ h C% k generic map (DWIDTH => DWIDTH)
" z2 B F1 O# w$ `7 i* _1 x9 } port map (opa_i => s_addsub_opa,% {) o9 a$ H# ? I% y, i! h1 ^
opb_i => s_addsub_opb,
6 y- d% f) w6 c+ [- A+ _ addsub_i => s_addsub,0 O9 I5 g# f! I, k& I1 } o( \
cy_i => s_addsub_cy,
7 p4 \' w1 ~' G% h j- K cy_o => s_addsub_newcy,8 P1 \ O4 v$ Y2 F! @+ Q
ov_o => s_addsub_ov,
- r! s2 i5 y$ r rslt_o => s_addsub_rslt);
' i( @/ p6 l& ?8 ` gen_multiplier1 : if C_IMPL_MUL = 1 generate5 |5 [( ^" v$ U$ ^3 D K5 U, ~ l
i_comb_mltplr : comb_mltplr2 [, e& w; j; s3 H! g: N8 q
generic map (
$ z7 A [! S' E$ E DWIDTH => DWIDTH)
0 o6 h9 `9 b$ ?% w* l) m port map (! X7 w. r/ ^0 C, }4 j0 g" J4 m
mltplcnd_i => s_mltplcnd,( m3 B. b8 _) M1 T5 t( V' _6 k
mltplctr_i => s_mltplctr,/ N- f4 G( q1 Q
product_o => s_product);
- n- e- X7 { Y1 ~& S end generate gen_multiplier1;. a! a0 \/ F, P
gen_multiplier0 : if C_IMPL_MUL /= 1 generate1 m* c( }4 V% g+ a/ @* g
s_product <= (others => '0');2 a) j. H! m6 I3 T; z" p
end generate gen_multiplier0;' E- T {: c0 v5 |& A3 y4 A$ R' _
gen_divider1 : if C_IMPL_DIV = 1 generate( a* h8 h2 w* `$ m. q2 l
i_comb_divider : comb_divider
1 }2 D: \/ p0 n. i generic map (
4 Q' j; r. G7 Q7 p; I6 C5 M DWIDTH => DWIDTH)
7 E" B/ c2 B2 _' ^ _# W port map (
% s( A; {8 [* U dvdnd_i => s_dvdnd,
! n4 D$ m6 m; c, ?* q" Y5 h- x& p0 `# l dvsor_i => s_dvsor,
K5 F& @# r8 u+ w: @$ z qutnt_o => s_qutnt,
F- M U, G' y5 [ rmndr_o => s_rmndr);
% r3 j( p# l9 ^3 c$ J end generate gen_divider1;& u, ]& ]* M" W2 b4 B# t3 t" l( P
gen_divider0 : if C_IMPL_DIV /= 1 generate8 {0 D) R# Y9 N% l5 }6 y
s_qutnt <= (others => '0');/ H6 F" l5 ]9 @, y; P {& S/ w
s_rmndr <= (others => '0'); I9 F/ M$ y- _( o( _! i
end generate gen_divider0;
( U. ~, }# k/ E3 ~' t gen_dcml_adj1 : if C_IMPL_DA = 1 generate
& L4 c7 N9 K" a i_dcml_adjust : dcml_adjust
" W$ P( |1 h0 B/ x# F generic map (; j* b2 E1 Q5 u) M8 _2 K* U1 I8 N
DWIDTH => DWIDTH)
. A h8 u/ t, r! H* \, e port map (0 l, y% f" `9 _" q/ N
data_i => s_dcml_data,
: [1 t0 W: p. S% V9 e0 h9 j cy_i => cy_i,2 r* f5 G; f, U0 y, [7 E/ D
data_o => s_dcml_rslt,
# y$ X2 r( S0 E cy_o => s_dcml_cy);
4 A5 H: ]6 ~: @; }# d end generate gen_dcml_adj1;
1 Q. [/ ?+ P5 a1 _/ k% N) d gen_dcml_adj0 : if C_IMPL_DA /= 1 generate! I& d5 A+ o5 s( c
s_dcml_rslt <= (others => '0');& R' D# Z! K, O4 l( `" Z. Z
s_dcml_cy <= '0';
8 A2 U& \- Z. l, l# ~ end generate gen_dcml_adj0;1 r' g8 I- ~, N- B/ j$ i
end struc; |
|