|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
在网上寻找数字地与模拟地的英文材料;" z) t8 E5 t( u. v, V4 I
无意间浏览到一个国外的的CPLD/FPGA论坛,点击进入3 m5 x1 u( |( c8 D/ y/ U, M
发现了有人求51的IP CORE,在回帖里面看到这个,所以下载了。* W# L2 N1 X5 @, c
/ P1 g5 r ~7 i6 E* H8 _$ E
( k0 Y' l9 @/ w; G& Z@: mc8051@oregano.at# F/ t( Z7 U: V8 C5 i) A& W" n; R
W: http://oregano.at/ip/8051.htm# l' ?! j! } W4 h1 q0 ^# u4 v8 r
5 P" I0 b9 e) A5 S. `% ^- ~, P! F************************************************************9 `, X t( t- _" f4 d% h+ i" q
This is version 1.4 of the MC8051 IP core.8 _. l- r7 {. U, g" B' e
November 2004: Oregano Systems - Design & Consulting GesmbH+ H" b- V6 O9 A1 o' z- ?& J6 o
============================================================
$ X& z3 O3 [. ZChanges:) e$ W8 j9 s# d6 A8 _1 X% S0 D& V
- corrected behaviour of RETI instruction handling
" a* L) F7 [$ t- added synchronization for interrupt signals
7 X' o) }% o/ q* ^4 f' ]& z- corrected timer problems
+ |# E: {0 y# b+ Q1 f: _( s, a
8 F7 p) s" T1 R$ _# {- o. L************************************************************
3 ~8 n! x8 I* L% XThis is version 1.3 of the MC8051 IP core.
% x6 J, q k( r/ p W; lSeptember 2002: Oregano Systems - Design & Consulting GesmbH
2 C3 Q4 u; g& A; b) M/ G============================================================
/ K( w; O: j, H$ B" u# TChange history:
4 Y6 t6 A7 J; U- Improved tb_mc8051_siu_sim.vhd to verify duplex operation.
5 H' ?3 d1 [7 S- g0 ?# A+ R: A) K- Corrected problem with duplex operation in file 7 j7 |7 ]- ~2 K6 U
mc8051_siu_rtl.vhd
5 r5 q1 V1 L- M* n
- |3 ~ @* U. L* ]: V6 D% w************************************************************* ^6 M1 o0 ^7 A6 T! o9 t
This is version 1.2. of the MC8051 IP core.% s# H3 E, @" |7 M# C
June 2002 - Oregano Systems - Design & Consulting GesmbH
7 o8 J# } \" R' z* P8 _3 s* t7 U============================================================2 ^, ~5 M( ^+ ]4 G
Change history:
& A# o9 M: q! e) W% K( ?( a- Eliminated the scr subdirectory form the distribution.
6 f1 w% x, ^& _8 _. ~# j: y( `- Improved documentation.
9 g* C: N2 c6 w" C/ y) y# g- Corrected several bugs in the source code (see the& q4 u7 v. G' s
website for more details).
2 i4 u! J6 M) F8 |7 H7 O- Improved the testbench with respect to the I/O port4 W- F$ P; i4 K. D' m2 \' {
behavior.3 ?8 n; ]7 }* E3 Z- z
- Enriched the msim directory with the assembler source' v& l/ F; D! k5 [
code of an example program.1 x# n Q2 v$ S7 L) d# i
- Provided the source code of a Intel hex to binary
! {: [' L# y% f& g textfile converter to ease simulation of the user's
& v& O- ~: R1 T7 y( G assambler programs.
+ a6 F8 }- V$ [- I" [9 W
$ g- a! Q! Y4 f3 H4 I+ b************************************************************2 _ g3 W' J+ ^" @
This is version 1.1. of the MC8051 IP core.
: P% o) ^9 j# k6 L+ uJan 31st 2002 - Oregano Systems - Design & Consulting GesmbH; s4 X% \% q \8 O. e3 @* C
t) d% q* k) M7 E/ ?: n8 s( h
$ `0 O8 }+ j: b, h
4 O9 B. B3 ~* B4 Y) [& X+ @) N下面是里面的部分VHDL. A8 Z& V# f; w- [2 ]2 J( c- Q) T
3 m1 J4 |' S o v" I
" \% P$ [% x( m( w7 j0 k
1 q! G& [1 m6 k; Y: N6 K7 ?7 U8 Vlibrary IEEE;
; B" r, p ?. U4 Euse IEEE.std_logic_1164.all;
' U- l6 ?( M5 H& n1 i5 F: xuse IEEE.std_logic_arith.all;( g* c& D) c7 ~) L5 _% I
library work;
. R* ]& \' _! B9 W5 e9 Juse work.mc8051_p.all;+ x/ n3 Z2 B7 g2 b8 r
( A6 L% d/ E4 V# M2 n O-----------------------------ENTITY DECLARATION--------------------------------
2 B0 O' [8 C+ i! I0 k6 qentity addsub_core is
; ?$ Q! {- N4 Y4 @8 n$ m " g, L2 ]; E5 B2 N" ?
generic (DWIDTH : integer := 16); -- Data width of the ALU
" ?- z: N/ _0 A4 Y port (opa_i : in std_logic_vector(DWIDTH-1 downto 0);4 q$ b" {8 [- R& r% W V$ [
opb_i : in std_logic_vector(DWIDTH-1 downto 0);) l7 K8 g. v/ _! h+ g$ a
addsub_i : in std_logic;
, |% ^- A4 m. o# I' m3 l cy_i : in std_logic;# v5 t( b5 n; A
cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);
- n/ z" W7 S+ q! S6 ]. r ov_o : out std_logic;
7 `! G2 F' S+ C8 x, Q rslt_o : out std_logic_vector(DWIDTH-1 downto 0));- T) m) z& N7 s$ w9 \
G$ w# B3 J, {6 wend addsub_core;4 b# k& K/ j/ O! `" o
0 A! Q; t* e% P% T U6 L' J
$ f4 `' M. ]& ` U5 X
! u0 Y6 t) S" L2 ^% Y7 \6 Ventity mc8051_alu is5 M8 L: q* a* G; l& q
generic (DWIDTH : integer := 8); -- Data width of the ALU
) A2 g; |8 |" O; ~! I2 K port (rom_data_i : in std_logic_vector(DWIDTH-1 downto 0);
" t3 T; M& t" Z: Y ram_data_i : in std_logic_vector(DWIDTH-1 downto 0);
( L% _/ }" D3 N$ H* U+ U3 L acc_i : in std_logic_vector(DWIDTH-1 downto 0);+ k! a. b0 T( U
cmd_i : in std_logic_vector(5 downto 0);
/ Q- w L" h3 ~9 Z- ]; T7 p cy_i : in std_logic_vector((DWIDTH-1)/4 downto 0);) Z ^( }3 D# @" [
ov_i : in std_logic;4 g2 L( K4 y3 b3 T. {* g; U
$ f, n- f, H; H( d new_cy_o : out std_logic_vector((DWIDTH-1)/4 downto 0);' X( ^, t# g7 Z+ V9 b
new_ov_o : out std_logic;
: H* l6 }/ \: {7 p9 b result_a_o : out std_logic_vector(DWIDTH-1 downto 0);
" p) ~2 q# x5 v2 C7 j+ F( q" g3 C result_b_o : out std_logic_vector(DWIDTH-1 downto 0));
5 I) @- q! {( k) B- E, I& w* `
# `* h9 O+ {# O: m. }* L# ]" cend mc8051_alu;" ?! D" `5 X7 ?! _8 z+ A! B
--Inputs:# D, |. b% Q, k6 ]; e1 T
-- rom_data_i...... data input from ROM
+ b9 P; p7 X9 C; u- W0 j4 P# U-- ram_data_i...... data input from RAM# P, h* {% h& I8 D8 d
-- acc_i........... the contents of the accumulator register9 i! `+ ?# @9 J3 N& F: B; W
-- cmd_i........... command from the control unit
' e. |5 f. h: w$ |-- cy_i............ CY-Flags of the SFR1 Q% H3 _; U, I4 V
-- ov_i............ OV-Flag of the SFR
7 y/ ?' s3 R) [% h--Outputs:
% i' y* M( K% K" b D9 t-- new_cy_o........ new CY-Flags for SFR
- J; L$ [8 k6 s9 G y5 a-- new_ov_o........ new OV-Flag for SFR
, u- q" C( Q1 u: f/ o2 {/ B-- result_a_o...... result
- i* [3 e8 y7 {6 I-- result_b_o...... result
& P2 R, A& Y8 p+ ?4 w/ K$ Q$ J: v; N& O, a" A& `
5 f- ?* \0 ~ ?/ V4 C, W1 v
7 O' d/ N- B4 e6 l! n v
4 L2 p! U3 P6 j+ o) narchitecture struc of mc8051_alu is$ M" f5 v9 H' T, C" ^' k
signal s_alu_result : std_logic_vector(DWIDTH-1 downto 0);
! |$ c- q+ @5 G/ k signal s_alu_new_cy : std_logic_vector((DWIDTH-1)/4 downto 0);. J( }7 A$ u" F
signal s_alu_op_a : std_logic_vector(DWIDTH-1 downto 0);" T3 j- F% A7 w: @* Q
signal s_alu_op_b : std_logic_vector(DWIDTH-1 downto 0);
! X+ X* p- L) y% i' L. d signal s_alu_cmd : std_logic_vector(3 downto 0);
! C) L& L6 z% A$ l signal s_dvdnd : std_logic_vector(DWIDTH-1 downto 0);( s; a& Y- P. L
signal s_dvsor : std_logic_vector(DWIDTH-1 downto 0);
1 Z- ]5 g0 |& m' _2 K A5 a signal s_qutnt : std_logic_vector(DWIDTH-1 downto 0);! C- r) k/ B9 j+ e
signal s_rmndr : std_logic_vector(DWIDTH-1 downto 0);% v5 a4 }6 _1 \1 E2 N1 C( R
signal s_mltplcnd : std_logic_vector(DWIDTH-1 downto 0);
6 ]+ v! l2 e* Y" j W- p signal s_mltplctr : std_logic_vector(DWIDTH-1 downto 0);
: [4 @3 D6 N' Z Z signal s_product : std_logic_vector((DWIDTH*2)-1 downto 0);
; C4 D9 V G( P, X; ~2 Q signal s_dcml_data : std_logic_vector(DWIDTH-1 downto 0);2 v V5 h& q6 ^
signal s_dcml_rslt : std_logic_vector(DWIDTH-1 downto 0);! y+ t1 M$ U! s6 U7 ~0 ?. T
signal s_dcml_cy : std_logic;
' ]# H4 V! \6 g5 n6 d signal s_addsub_rslt : std_logic_vector(DWIDTH-1 downto 0);
0 ^4 c c( l8 d. d( ?! G signal s_addsub_newcy : std_logic_vector((DWIDTH-1)/4 downto 0); ^9 H; S( }( W3 U2 t
signal s_addsub_ov : std_logic;
9 Q: q- ^& \) ~" L; A signal s_addsub_cy : std_logic;
6 T1 }; ~( o3 l, X3 H1 V signal s_addsub : std_logic;. G, O' Z8 t( y* }+ V& j) o* s: X3 q
signal s_addsub_opa : std_logic_vector(DWIDTH-1 downto 0);
0 N# p2 P) _/ ~6 Z8 @1 J( G; j. } signal s_addsub_opb : std_logic_vector(DWIDTH-1 downto 0);
2 @: H0 }8 \" t6 tbegin -- architecture structural
) Z0 N9 ~7 P6 c2 M n3 k i_alumux : alumux6 k4 C0 w( v N; W L! U0 d; Q
generic map (6 ^0 A# Z$ Y9 M) c3 a
DWIDTH => DWIDTH)
( M& {3 H/ j! ]# ^ port map (
7 n6 Q) G2 k4 G# | -- Primary I/Os of the ALU unit.* `! \8 N& ^; C* F+ k
rom_data_i => rom_data_i,7 W) k! i7 ~+ q' { n
ram_data_i => ram_data_i,' G/ P( O: z2 h; [5 R# y
acc_i => acc_i,
8 y1 y E0 [( w$ ]9 `. ~ cmd_i => cmd_i,
1 x0 U" ] Z6 V i- G cy_i => cy_i,
& K$ E3 d5 x5 i& I, g ov_i => ov_i,5 S" P! R% \6 t! J8 w
cy_o => new_cy_o,# p* P/ ~& s) S' @% x9 \* T
ov_o => new_ov_o,
% J: @3 f4 A- M I result_a_o => result_a_o,7 Z. n2 b- V$ ]; h6 m8 S) l
result_b_o => result_b_o,
. @% l, X9 y( C( v -- I/Os connecting the submodules.* `6 j3 o; o; y) `
result_i => s_alu_result,
5 F6 {1 {' u+ h2 W6 H/ M& _ new_cy_i => s_alu_new_cy,) a& t0 R7 w% v D
addsub_rslt_i => s_addsub_rslt,8 R; m: m5 \0 Y& T! V$ ^- x) k) c
addsub_cy_i => s_addsub_newcy,
' y& f, X+ k" q; d# v7 E3 F$ K addsub_ov_i => s_addsub_ov,
6 K! p; s* I$ `( d op_a_o => s_alu_op_a,
7 k6 i3 c! y) L g3 f% _* x, _ op_b_o => s_alu_op_b,/ X. {- \$ s6 R8 W
alu_cmd_o => s_alu_cmd,
( Q" E' o5 I1 ^ opa_o => s_addsub_opa,
* d$ T" ^: \( K) n v2 b+ D+ @ opb_o => s_addsub_opb,, {: j, {5 I$ K: C
addsub_o => s_addsub,( F: E; p' s8 h" B3 [/ W
addsub_cy_o => s_addsub_cy,5 A6 T( B( p2 | y" h" l. H% w
dvdnd_o => s_dvdnd,
( {: ?1 s9 g U dvsor_o => s_dvsor,% j% T2 K2 T2 w0 U' u
qutnt_i => s_qutnt,4 J" \. \! L% n8 O+ K
rmndr_i => s_rmndr,: ~5 b, P) x5 O! e
mltplcnd_o => s_mltplcnd,/ T i6 f0 [3 {
mltplctr_o => s_mltplctr,7 q4 R5 F8 h0 G6 t6 E! d
product_i => s_product,
0 Q9 L6 K; P5 D! H' q; M+ Y dcml_data_o => s_dcml_data,
2 j {4 Z! r5 U, ^1 i, f2 L dcml_data_i => s_dcml_rslt,
; D% a5 i) ^/ w& x) F dcml_cy_i => s_dcml_cy);$ O$ T+ A: i, f
i_alucore : alucore8 r1 O# n f% Y7 X2 f0 P2 y) \$ G
generic map (
* Z/ c' b" H- z- a# _ DWIDTH => DWIDTH)( Y6 Z( G- t" s4 u- _
port map (0 v# J; o0 p$ r+ }( d L0 ]7 K- k
op_a_i => s_alu_op_a,
9 b9 t! n# r( S6 H. y6 V, \: A% f op_b_i => s_alu_op_b,
& y( l9 v+ F) y4 t* _! d% v! J2 h0 P alu_cmd_i => s_alu_cmd,. a" U0 J2 z/ g7 @+ p
cy_i => cy_i,1 D: \* s7 R; J
cy_o => s_alu_new_cy,6 X8 T* }* M% i }$ y4 T: o
result_o => s_alu_result);
# h* j1 u$ Q3 q: a i_addsub_core : addsub_core
& f( ^' Q8 N" ]) ~/ ?, j generic map (DWIDTH => DWIDTH)
, X V1 B- C7 n5 R+ u9 C port map (opa_i => s_addsub_opa,) s6 d! p X2 O- W( V* r" t* b9 b
opb_i => s_addsub_opb,+ a% n7 E7 }; P6 O [9 [% s9 _' f
addsub_i => s_addsub,! C% C2 @3 l7 u, g# o9 b9 l( ]
cy_i => s_addsub_cy,
- j! n. I8 ~: [* @- O% a( p y cy_o => s_addsub_newcy,
i$ J( a; z: {7 {3 j) k8 I ov_o => s_addsub_ov,
* C c; ~% X% }4 S5 o4 c rslt_o => s_addsub_rslt);3 |/ U* ~, d. p. b* u; ~
gen_multiplier1 : if C_IMPL_MUL = 1 generate. P- I% y5 N+ G {& U4 L0 G
i_comb_mltplr : comb_mltplr
* V4 F$ k; B1 p; n; \- F/ d generic map (
$ H2 @! C- {8 n0 a DWIDTH => DWIDTH)
/ E9 t. p; ~9 o' \, K port map (8 y- }& Z9 m+ v4 S$ E
mltplcnd_i => s_mltplcnd,
+ T# R' X8 n# J o; u& Y mltplctr_i => s_mltplctr,
6 X+ Y* C7 k3 {: J& Z product_o => s_product);
9 Q! a, m3 i2 B, z0 i end generate gen_multiplier1;+ g, H2 G6 D) D5 }
gen_multiplier0 : if C_IMPL_MUL /= 1 generate: L7 Q1 U+ H$ }# I; v! K! V: g8 v
s_product <= (others => '0');
" Y! ?3 H6 o5 Q4 m" b end generate gen_multiplier0;
5 L4 M; ]* d- Q$ W1 Q gen_divider1 : if C_IMPL_DIV = 1 generate/ }* x; H% S! g2 v9 u
i_comb_divider : comb_divider7 v& g' V; g; \) ?5 X- m& h# q
generic map (
& A4 G# P8 i# v* T. V DWIDTH => DWIDTH)
6 M; _, D- t! U port map (
% F" m$ E" G4 X7 q: r- W A8 O dvdnd_i => s_dvdnd,
- q" O! h' s) S2 N3 V dvsor_i => s_dvsor,
3 Z% t# G( M$ E2 n: l qutnt_o => s_qutnt,
' X/ L2 U4 W3 y3 L6 @ rmndr_o => s_rmndr);2 ~$ L3 A; W, B8 x+ f
end generate gen_divider1;
# ?1 X3 P r, e. T) Z gen_divider0 : if C_IMPL_DIV /= 1 generate
4 r/ j" w) Z# D( t s_qutnt <= (others => '0');7 a* S) w k. R
s_rmndr <= (others => '0');7 a* W$ ]% {; O. |. I
end generate gen_divider0;, ?. O3 f2 h7 ~3 E2 m
gen_dcml_adj1 : if C_IMPL_DA = 1 generate3 X. ?4 P& r; Q' z' ^& y$ a" u7 y9 m2 }
i_dcml_adjust : dcml_adjust
' G! F3 e) R& M9 G1 l generic map (. Y% f6 n9 c( k! D
DWIDTH => DWIDTH)" Y. Y5 `" j* ^$ Z5 U* O! Q# c4 ^* q
port map (' a( |7 p, t7 K( x! z+ D
data_i => s_dcml_data,4 u) s' l! g! I$ ~) k
cy_i => cy_i,' L$ T6 G+ E4 M5 P, I6 \# E
data_o => s_dcml_rslt,: B3 c9 N0 q* ^3 Q) S5 ]2 M
cy_o => s_dcml_cy);) W' @3 h) z+ K; h6 F
end generate gen_dcml_adj1;
2 l4 d. E) z& E6 ?, I, {, U gen_dcml_adj0 : if C_IMPL_DA /= 1 generate- T0 X' }" F1 v8 U: v- ~3 p
s_dcml_rslt <= (others => '0');
4 Q, i; |7 d$ q6 y/ s s_dcml_cy <= '0';
3 B$ M% W( m$ G0 v& S' Z end generate gen_dcml_adj0;
: H3 J8 X4 E3 p$ b( J( m8 c( ~end struc; |
|