使用确定性-函数式对象建模(D-FOM)方法对8051微控制器进行分析和VHDL建模






4.49/5 (24投票s)
2004年7月20日
10分钟阅读

113504

367
本文是对我上一篇论文《D-FOM:又一个OOM》的扩展。这是一项案例研究,旨在通过D-FOM方法来分析系统并进行VHDL建模,从而建立信心。本文将使用D-FOM方法来分析、设计和用VHDL建模一个8051微控制器系统。
微控制器系统(MCU)的D-FOM分析 --
-- 一项旨在建立对此方法信心的案例研究
微控制器可以定义为ALU、内存(RAM/ROM)、数据总线和地址总线、I/O端口(串行/并行)以及控制的特定应用原理图组合。事实上,微控制器是将微处理器与I/O端口集成在同一芯片上的组合。
在我题为《D-FOM:又一个OOM》的论文中,我提出了一种面向对象模型(OOM),该模型在设计和此类芯片的VHDL建模方面具有优势。在此,我以D-FOM方法对微控制器系统进行设计和VHDL建模作为案例研究,以建立对此方法的信心。在此之前,让我们回顾一下D-FOM的概念。
D-FOM 的组成部分
- Actor:使用系统的某物。
- Use Case:说明系统如何被使用。
- Unified Actor:系统内部的 Actor。
- Unified Use Case:用于 Unified Actor 的 Use Case。
- Functional Actor:一个 Actor 或 Unified Actor。
- Functional Use Case:一个 Use Case 或 Unified Use Case。
D-FOM 中的步骤
- 分析的第一步
- 查找 Actor
- 查找 Use Case
- 查找 Unified Actor
- 查找 Unified Use Case
- FUCA
- 准备 FUCM
- 迭代 FUCM
- 分析的终点:初学者的粗略指南。
- 当你无法再找到任何模块时。
- 经验也可能导致更早的结束。
- 向前推进设计:实现视图(涉及依赖关系)
- 一次一个树的层次,并向上整合(自底向上)
- Unified Actor->类
- Functional Use Case->方法
- 迭代并获得泛化
- 获取相似类的包
- 序列分析和序列图
- 自底向上策略:叶子(语句)的序列分析->上一级的序列分析(函数)->系统的序列分析(进程)
- 实现
- 为叶子序列图编写代码并创建函数
- 整合函数以获得树上一级
- 整合以获得系统代码
- 根据手头的项目部署分析,采用传统方法(鉴于新技术、网络技术和数据库概念,实际上并不难)。
优点汇总列表
- 依赖类标识可减少混淆。
- 新加入的成员可以快速开始工作,因为他/她只需要研究和理解 FUCM。
- 集中的易出错区域。
- 该方法提供了适用于 OOPL 和 HDL 实现的设计。因此也适用于 HDL。
- 实现了硬件及其模拟器的并行设计。
- 实现了自动化。
- 预计将减少工作量和资源消耗。
局限性汇总列表
- 需要一个合适的 FUCA。FUCM 需要具备系统深厚的知识。
- 过度依赖 FUCM。
- 不被普遍接受,但取决于问题的性质。可能不适用于高度复杂的架构。(复杂性意味着模块之间的相互依赖,这可能导致巨大的集成问题。但传统方法也存在同样的问题,所以这没什么特别之处。)
- 在该项目领域的经验可以带来更好的结果。
MCU 的第一阶段分析
在第一阶段分析中,微控制器系统被划分为四个主要部分
- 解码器
- 控制单元
- 算术逻辑单元
- 内存 - RAM + ROM
目前可能不需要深入研究这些细节。仅凭这些知识,我们就可以继续前进,稍后我们将深入探讨细节,以便为系统模块和系统进行设计。如果我们从系统的功能来看,可以总结如下:
解码器:将输入信号解码为指令位模式。
此解码器并非简单的普通解码器,它接受单行输入并提供选择性的多行输出。相反,它是微控制器系统中一个复杂的单元,拥有关于微控制器指令集的完整信息。该单元接收二进制字输入,并收集关于该字的所有信息,例如,它是否是有效命令,是否是系统指令集中的指令,执行它需要多少数据值?它指示命令是操作一个/两个/三个还是零个操作数,需要读取多少其他(下一个)字节来完成指令,以及执行所需的必要数据信息等。最后,所有这些信息都将发送到控制单元,以便系统采取适当的行动和功能。
控制单元:控制组件之间的信号和数据流
控制单元是任何微处理器或微控制器系统的核心。就像人体中的心脏负责通过神经网传递血液一样,在微控制器中,控制单元负责通过总线在系统中传递控制和数据信号。控制单元的简要功能可总结如下:
控制单元直接接收来自命令生成器的输入命令信号,并将其处理给解码器。解码器将此信号转换为 Op-Code,并将其与上面讨论的其他不同信息一起提供给控制单元。控制单元检查它是一个控制操作还是算术/逻辑操作。算术/逻辑 op-code 被发送到 ALU 进行操作。控制单元向内存单元发送 Rd/Wr 信号。对于 Rd 信号的响应,内存允许控制单元读取所需位置,对于 Wr 信号,某些信息可能被输入其中(内存访问)。它从内存读取数据并将其发送到 ALU 进行操作。控制单元从 ALU 接收结果,然后通过 Wr 信号存储在内存中。它执行系统所有控制和数据传输操作。
因此,控制单元实际上控制着系统中数据和控制信号的流向。
算术逻辑单元:涵盖所有逻辑和数学计算
它负责系统运行所需的所有算术和逻辑运算。
算术运算:ADD, ADDC, SUBB, INC, DEC, MUL, DIV。
逻辑运算:ANL (AND), ORL (OR), XRL (XOR), CLR, CPL, RL, RC, RR, RRC, SWAP。
内存:存储信息供将来使用
内存是存储系统(和用于系统)的控制和数据信息的设备。它是由一组触发器组成的,可以通过一组称为芯片地址总线的选择线进行寻址。功能列表:
- 检查 Rd/Wr 信号
- 对于 Rd 信号,它将数据总线上的信息存储在其地址总线状态指示的位置。
- 对于 Wr 信号,它将与地址总线指定的位置相同的信息(二进制信号)放到其数据总线上。
表 1 显示了 MCU 系统的功能用例分析(FUCM)。图 1 显示了微控制器的功能用例模型,在此之后,图 2 显示了其 D-FOM 类图。这些分析和图表显示了系统的第一阶段分析,即有助于系统设计的第一次迭代。但此分析在此阶段不直接可实施。如前所述,分析阶段是以自顶向下的方式进行的。当我们达到足够高的抽象级别,能够实现我们的设计时,我们就开始自底向上地实现,一次一个级别。第一次迭代分析将有助于使用其组件(解码器、ALU、控制单元和内存)来集成系统。第一次迭代 FUCM 将有助于分析和实现不同组件如何相互交互。不仅如此,系统级别的 FUCA 还能为各个组件的下一级 FUCA 提供想法,正如我们在本例中稍后准备解码器单元的 FUCM 时所看到的那样。
功能 Actor | 类型 | 功能 Use Cases |
---|---|---|
命令生成器 | Actor |
|
控制单元 (CTR) | Unified Actor |
|
内存 | Unified Actor |
|
解码器 | Unified Actor |
|
Reset (RST) | Actor |
|
表 1:MCU 的功能用例分析。
图 1:微控制器系统的 FUCM。
图 2:微控制器系统的 D-FOM 类模型。
所以,这就是我们进行微控制器系统第一阶段分析所需的内容。在接下来的迭代中,我们将使用 D-FOM 详细阐述其子系统和模块,并尝试深入到语句级别,以便我们可以根据需要使用 OOPS 或 VHDL 实现系统,而不会对设计进行重大更改。我们在这里可以看到,正如我在笔记中指出的那样,D-FOM 在系统中以自顶向下的方式高效工作。在这里,我们也从顶层抽象开始,然后向下移动到语句级别。
我将通过 D-FOM 完成一个模块的实现,以描述完整的实现过程。让我们以“解码器”模块为例,用 VHSIC 硬件描述语言 (VHDL) 实现。
解码器接收来自控制单元的输入,这是一个由“0”和“1”组成的 8 位组合。该单元包含系统识别的所有命令的结构信息。一旦控制单元向该单元提供 8 位输入,解码器就会分析输入是否是系统的有效命令。如果不是有效命令,解码器会通知控制单元提供错误代码,或者通知系统不要响应此输入。但如果命令是有效的,解码器就会查找其结构并将其告知控制单元。
此处命令的结构包括以下内容:
- 命令是什么:解码器将输入的操作码告知控制单元。解码器不提供有关命令的实现或操作的信息。它只返回操作码,而不返回其功能。
- 需要多少数据字节:解码器告知控制单元执行命令以及更新系统输出结果需要多少数据字节。这里再次,解码器不提供有关如何计算结果或如何更新系统的信息,仅告知控制单元操作码所需的数据字节数。在 8051 规范中,一个命令可能需要“0”或“1”,最多“2”个数据字节。
图 1 显示了根据其规范的微控制器系统内部解码器的 FUCM,图 2 显示了 MCU 此命令解码器的相应 D-FOM 类分析。
图 1:MCU 系统内部解码器的功能用例模型。
此处可以注意到,上述用例分析几乎是系统级别 FUCA 的一个子集。从系统级别 FUCA;我们仅提取了解码器-FA 及其相关的 FU Cases。最后,我们可以根据分析过程中的迭代情况,添加更多所需的用例或 Actor。在这里,我们有一个单一的功能 Actor,即解码器。我们得到类图,其中只有一个类 Decoder
,因此没有关联。
图 2:MCU 系统内部解码器的 D-FOM 类模型。
现在需要根据序列图分析函数。对于输入,该单元不做任何努力,只是接受输入并且不修改它。为此,我们可能不需要特殊的函数实现。因此,我们可以忽略方法 input()
的函数实现。
现在,我们可以根据需要为每个可实现的方法创建序列图,以描述其算法信号序列。在当前情况下,我们可以使用此分析以 VHDL 格式创建骨架代码,如下所示:
(注意:方括号 [ ] 中的术语由编码团队替换为适当的值)
entity decoder is
port (Input: in UNSIGNED(7 downto 0); rst: in bit;
cmd_opcode:out bit_vector(6 downto 0);
cmd_length: out bit_vector(1 downto 0));
end decoder;
architecture behavioral of decoder is
function opcode_out(I:UNSIGNED) return bit_vector is
variable opcode:bit_vector(6 downto 0);
begin
if Input=[input_bit_ pattern1] then opcode:=[opcode1]; elsif
Input=[input_bit_ pattern2] then opcode:=[opcode2]; elsif
Input=[input_bit_ pattern3] then opcode:=[opcode3]; elsif
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
end if;
return opcode;
end opcode_out;
function bytelength_out (I:UNSIGNED) return bit_vector is
variable length:bit_vector(1 downto 0);
begin
--"00" means single byte command…
--"01" means two byte command…
--"11" means three byte command…
if Input=[input_bit_ pattern1] then length:=[length-code1]; elsif
Input=[input_bit_ pattern2] then length:=[length-code2]; elsif
Input=[input_bit_ pattern3] then length:=[length-code3]; elsif
- - - - - -
- - - - - -
- - - - - -
- - - - - -
- - - - - -
end if;
return length;
end bytelength_out;
procedure reset(opout:out bit_vector(6 downto 0);
oplength:out bit_vector(1 downto 0)) is
begin
opout:="reset_opcode";
oplength:="00";
end reset;
begin --[architecture begins here]
process(input,rst)
variable opcode:bit_vector(6 downto 0);
variable length:bit_vector(1 downto 0);
begin
if rst='1' then
reset(opcode,length);
cmd_opcode<=opcode;
cmd_length<=length;
else
cmd_opcode<=opcode_out(Input);
cmd_length<=bytelength_out(Input);
end if;
end process;
end behavioral;
现在,最终的骨架代码可以由编码团队根据要求进行定制。 我们编写的最终代码如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use WORK.definition.all;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
-- library UNISIM;
-- use UNISIM.VComponents.all;
entity decoder is
port (Input: in UNSIGNED(7 downto 0);
rst: in std_logic;
cmd_opcode:out std_logic_vector(6 downto 0);
cmd_length: out std_logic_vector(1 downto 0));
end decoder;
Architecture behavioral of decoder is
function opcode_out(I:UNSIGNED) return std_logic_vector is
variable opcode:std_logic_vector(6 downto 0);
begin
if I(4 downto 0) = ACALL then opcode:=("0000000"); elsif
I(7 downto 3) = ADD_1 then opcode:= ("0000001"); elsif
I(7 downto 0) = ADD_2 then opcode:= ("0000010"); elsif
I(7 downto 1) = ADD_3 then opcode:= ("0000011"); elsif
I(7 downto 0) = ADD_4 then opcode:= ("0000100"); elsif
I(7 downto 3) = ADDC_1 then opcode:= ("0000101"); elsif
I(7 downto 0) = ADDC_2 then opcode:= ("0000110"); elsif
I(7 downto 1) = ADDC_3 then opcode:= ("0000111"); elsif
I(7 downto 0) = ADDC_4 then opcode:= ("0001000"); elsif
I(4 downto 0) = AJMP then opcode:= ("0001001"); elsif
I(7 downto 3) = ANL_1 then opcode:= ("0001010"); elsif
I(7 downto 0) = ANL_2 then opcode:= ("0001011"); elsif
I(7 downto 1) = ANL_3 then opcode:= ("0001100"); elsif
I(7 downto 0) = ANL_4 then opcode:= ("0001101"); elsif
I(7 downto 0) = ANL_5 then opcode:= ("0001110"); elsif
I(7 downto 0) = ANL_6 then opcode:= ("0001111"); elsif
I(7 downto 0) = ANL_7 then opcode:= ("0010000"); elsif
I(7 downto 0) = ANL_8 then opcode:= ("0010001"); elsif
I(7 downto 0) = CJNE_1 then opcode:= ("0010010"); elsif
I(7 downto 0) = CJNE_2 then opcode:= ("0010011"); elsif
I(7 downto 3) = CJNE_3 then opcode:= ("0010100"); elsif
I(7 downto 1) = CJNE_4 then opcode:= ("0010101"); elsif
I(7 downto 0) = CLR_1 then opcode:= ("0010110"); elsif
I(7 downto 0) = CLR_2 then opcode:= ("0010111"); elsif
I(7 downto 0) = CLR_3 then opcode:= ("0011000"); elsif
I(7 downto 0) = CPL_1 then opcode:= ("0011001"); elsif
I(7 downto 0) = CPL_2 then opcode:= ("0011010"); elsif
I(7 downto 0) = CPL_3 then opcode:= ("0011011"); elsif
I(7 downto 0) = DA then opcode:= ("0011100"); elsif
I(7 downto 0) = DEC_1 then opcode:= ("0011101"); elsif
I(7 downto 3) = DEC_2 then opcode:= ("0011110"); elsif
I(7 downto 0) = DEC_3 then opcode:= ("0011111"); elsif
I(7 downto 1) = DEC_4 then opcode:= ("0100000"); elsif
I(7 downto 0) = DIV then opcode:= ("0100001"); elsif
I(7 downto 3) = DJNZ_1 then opcode:= ("0100010"); elsif
I(7 downto 0) = DJNZ_2 then opcode:= ("0100011"); elsif
I(7 downto 0) = INC_1 then opcode:= ("0100100"); elsif
I(7 downto 3) = INC_2 then opcode:= ("0100101"); elsif
I(7 downto 0) = INC_3 then opcode:= ("0100110"); elsif
I(7 downto 1) = INC_4 then opcode:= ("0100111"); elsif
I(7 downto 0) = INC_5 then opcode:= ("0101000"); elsif
I(7 downto 0) = JB then opcode:= ("0101001"); elsif
I(7 downto 0) = JBC then opcode:= ("0101010"); elsif
I(7 downto 0) = JC then opcode:= ("0101011"); elsif
I(7 downto 0) = JMP then opcode:= ("0101100"); elsif
I(7 downto 0) = JNB then opcode:= ("0101101"); elsif
I(7 downto 0) = JNC then opcode:= ("0101110"); elsif
I(7 downto 0) = JNZ then opcode:= ("0101111"); elsif
I(7 downto 0) = JZ then opcode:= ("0110000"); elsif
I(7 downto 0) = LCALL then opcode:= ("0110001"); elsif
I(7 downto 0) = LJMP then opcode:= ("0110010"); elsif
I(7 downto 3) = MOV_1 then opcode:= ("0110011"); elsif
I(7 downto 0) = MOV_2 then opcode:= ("0110100"); elsif
I(7 downto 1) = MOV_3 then opcode:= ("0110101"); elsif
I(7 downto 0) = MOV_4 then opcode:= ("0110110"); elsif
I(7 downto 3) = MOV_5 then opcode:= ("0110111"); elsif
I(7 downto 3) = MOV_6 then opcode:= ("0111000"); elsif
I(7 downto 3) = MOV_7 then opcode:= ("0111001"); elsif
I(7 downto 0) = MOV_8 then opcode:= ("0111010"); elsif
I(7 downto 3) = MOV_9 then opcode:= ("0111011"); elsif
I(7 downto 0) = MOV_10 then opcode:= ("0111100"); elsif
I(7 downto 1) = MOV_11 then opcode:= ("0111101"); elsif
I(7 downto 0) = MOV_12 then opcode:= ("0111110"); elsif
I(7 downto 1) = MOV_13 then opcode:= ("0111111"); elsif
I(7 downto 1) = MOV_14 then opcode:= ("1000000"); elsif
I(7 downto 1) = MOV_15 then opcode:= ("1000001"); elsif
I(7 downto 0) = MOV_16 then opcode:= ("1000010"); elsif
I(7 downto 0) = MOV_17 then opcode:= ("1000011"); elsif
I(7 downto 0) = MOV_18 then opcode:= ("1000100"); elsif
I(7 downto 0) = MOVC_1 then opcode:= ("1000101"); elsif
I(7 downto 0) = MOVC_2 then opcode:= ("1000110"); elsif
I(7 downto 1) = MOVX_1 then opcode:= ("1000111"); elsif
I(7 downto 0) = MOVX_2 then opcode:= ("1001000"); elsif
I(7 downto 1) = MOVX_3 then opcode:= ("1001001"); elsif
I(7 downto 0) = MOVX_4 then opcode:= ("1001010"); elsif
I(7 downto 0) = MUL then opcode:= ("1001011"); elsif
I(7 downto 0) = NOP then opcode:= ("1001100"); elsif
I(7 downto 3) = ORL_1 then opcode:= ("1001101"); elsif
I(7 downto 0) = ORL_2 then opcode:= ("1001110"); elsif
I(7 downto 1) = ORL_3 then opcode:= ("1001111"); elsif
I(7 downto 0) = ORL_4 then opcode:= ("1010000"); elsif
I(7 downto 0) = ORL_5 then opcode:= ("1010001"); elsif
I(7 downto 0) = ORL_6 then opcode:= ("1010010"); elsif
I(7 downto 0) = ORL_7 then opcode:= ("1010011"); elsif
I(7 downto 0) = ORL_8 then opcode:= ("1010100"); elsif
I(7 downto 0) = POP then opcode:= ("1010101"); elsif
I(7 downto 0) = PUSH then opcode:= ("1010110"); elsif
I(7 downto 0) = RET then opcode:= ("1010111"); elsif
I(7 downto 0) = RETI then opcode:= ("1011000"); elsif
I(7 downto 0) = RL then opcode:= ("1011001"); elsif
I(7 downto 0) = RLC then opcode:= ("1011010"); elsif
I(7 downto 0) = RR then opcode:= ("1011011"); elsif
I(7 downto 0) = RRC then opcode:= ("1011100"); elsif
I(7 downto 0) = SETB_1 then opcode:= ("1011101"); elsif
I(7 downto 0) = SETB_2 then opcode:= ("1011110"); elsif
I(7 downto 0) = SJMP then opcode:= ("1011111"); elsif
I(7 downto 3) = SUBB_1 then opcode:= ("1100000"); elsif
I(7 downto 0) = SUBB_2 then opcode:= ("1100001"); elsif
I(7 downto 1) = SUBB_3 then opcode:= ("1100010"); elsif
I(7 downto 0) = SUBB_4 then opcode:= ("1100011"); elsif
I(7 downto 0) = SWAP then opcode:= ("1100100"); elsif
I(7 downto 3) = XCH_1 then opcode:= ("1100101"); elsif
I(7 downto 0) = XCH_2 then opcode:= ("1100110"); elsif
I(7 downto 1) = XCH_3 then opcode:= ("1100111"); elsif
I(7 downto 1) = XCHD then opcode:= ("1101000"); elsif
I(7 downto 3) = XRL_1 then opcode:= ("1101001"); elsif
I(7 downto 0) = XRL_2 then opcode:= ("1101010"); elsif
I(7 downto 1) = XRL_3 then opcode:= ("1101011"); elsif
I(7 downto 0) = XRL_4 then opcode:= ("1101100"); elsif
I(7 downto 0) = XRL_5 then opcode:= ("1101101"); elsif
I(7 downto 0) = XRL_6 then opcode:= ("1101110"); else
opcode:= ("1101111");
end if;
return opcode;
end opcode_out;
function bytelength_out (I:UNSIGNED) return std_logic_vector is
variable length:std_logic_vector(1 downto 0);
begin
-- "00" means single byte command… No more bytes need to be read.
-- "01" means two byte command… One more byte needs to be read.
-- "11" means three byte command… Two more bytes need to be read.
if I(4 downto 0) = ACALL then length:=("01"); elsif
I(7 downto 3) = ADD_1 then length:=("00"); elsif
I(7 downto 0) = ADD_2 then length:=("01"); elsif
I(7 downto 1) = ADD_3 then length:=("00"); elsif
I(7 downto 0) = ADD_4 then length:=("01"); elsif
I(7 downto 3) = ADDC_1 then length:=("00"); elsif
I(7 downto 0) = ADDC_2 then length:=("01"); elsif
I(7 downto 1) = ADDC_3 then length:=("00"); elsif
I(7 downto 0) = ADDC_4 then length:=("01"); elsif
I(4 downto 0) = AJMP then length:=("01"); elsif
I(7 downto 3) = ANL_1 then length:=("00"); elsif
I(7 downto 0) = ANL_2 then length:=("01"); elsif
I(7 downto 1) = ANL_3 then length:=("00"); elsif
I(7 downto 0) = ANL_4 then length:=("01"); elsif
I(7 downto 0) = ANL_5 then length:=("01"); elsif
I(7 downto 0) = ANL_6 then length:=("11"); elsif
I(7 downto 0) = ANL_7 then length:=("01"); elsif
I(7 downto 0) = ANL_8 then length:=("01"); elsif
I(7 downto 0) = CJNE_1 then length:=("11"); elsif
I(7 downto 0) = CJNE_2 then length:=("11"); elsif
I(7 downto 3) = CJNE_3 then length:=("11"); elsif
I(7 downto 1) = CJNE_4 then length:=("11"); elsif
I(7 downto 0) = CLR_1 then length:=("00"); elsif
I(7 downto 0) = CLR_2 then length:=("00"); elsif
I(7 downto 0) = CLR_3 then length:=("01"); elsif
I(7 downto 0) = CPL_1 then length:=("00"); elsif
I(7 downto 0) = CPL_2 then length:=("00"); elsif
I(7 downto 0) = CPL_3 then length:=("01"); elsif
I(7 downto 0) = DA then length:=("00"); elsif
I(7 downto 0) = DEC_1 then length:=("00"); elsif
I(7 downto 3) = DEC_2 then length:=("00"); elsif
I(7 downto 0) = DEC_3 then length:=("01"); elsif
I(7 downto 1) = DEC_4 then length:=("00"); elsif
I(7 downto 0) = DIV then length:=("00"); elsif
I(7 downto 3) = DJNZ_1 then length:=("01"); elsif
I(7 downto 0) = DJNZ_2 then length:=("11"); elsif
I(7 downto 0) = INC_1 then length:=("00"); elsif
I(7 downto 3) = INC_2 then length:=("00"); elsif
I(7 downto 0) = INC_3 then length:=("01"); elsif
I(7 downto 1) = INC_4 then length:=("00"); elsif
I(7 downto 0) = INC_5 then length:=("00"); elsif
I(7 downto 0) = JB then length:=("11"); elsif
I(7 downto 0) = JBC then length:=("11"); elsif
I(7 downto 0) = JC then length:=("01"); elsif
I(7 downto 0) = JMP then length:=("00"); elsif
I(7 downto 0) = JNB then length:=("11"); elsif
I(7 downto 0) = JNC then length:=("01"); elsif
I(7 downto 0) = JNZ then length:=("01"); elsif
I(7 downto 0) = JZ then length:=("01"); elsif
I(7 downto 0) = LCALL then length:=("11"); elsif
I(7 downto 0) = LJMP then length:=("11"); elsif
I(7 downto 3) = MOV_1 then length:=("00"); elsif
I(7 downto 0) = MOV_2 then length:=("01"); elsif
I(7 downto 1) = MOV_3 then length:=("00"); elsif
I(7 downto 0) = MOV_4 then length:=("01"); elsif
I(7 downto 3) = MOV_5 then length:=("00"); elsif
I(7 downto 3) = MOV_6 then length:=("01"); elsif
I(7 downto 3) = MOV_7 then length:=("01"); elsif
I(7 downto 0) = MOV_8 then length:=("01"); elsif
I(7 downto 3) = MOV_9 then length:=("01"); elsif
I(7 downto 0) = MOV_10 then length:=("11"); elsif
I(7 downto 1) = MOV_11 then length:=("01"); elsif
I(7 downto 0) = MOV_12 then length:=("11"); elsif
I(7 downto 1) = MOV_13 then length:=("00"); elsif
I(7 downto 1) = MOV_14 then length:=("01"); elsif
I(7 downto 1) = MOV_15 then length:=("01"); elsif
I(7 downto 0) = MOV_16 then length:=("01"); elsif
I(7 downto 0) = MOV_17 then length:=("01"); elsif
I(7 downto 0) = MOV_18 then length:=("11"); elsif
I(7 downto 0) = MOVC_1 then length:=("00"); elsif
I(7 downto 0) = MOVC_2 then length:=("00"); elsif
I(7 downto 1) = MOVX_1 then length:=("00"); elsif
I(7 downto 0) = MOVX_2 then length:=("00"); elsif
I(7 downto 1) = MOVX_3 then length:=("00"); elsif
I(7 downto 0) = MOVX_4 then length:=("00"); elsif
I(7 downto 0) = MUL then length:=("00"); elsif
I(7 downto 0) = NOP then length:=("00"); elsif
I(7 downto 3) = ORL_1 then length:=("00"); elsif
I(7 downto 0) = ORL_2 then length:=("01"); elsif
I(7 downto 1) = ORL_3 then length:=("00"); elsif
I(7 downto 0) = ORL_4 then length:=("01"); elsif
I(7 downto 0) = ORL_5 then length:=("01"); elsif
I(7 downto 0) = ORL_6 then length:=("11"); elsif
I(7 downto 0) = ORL_7 then length:=("01"); elsif
I(7 downto 0) = ORL_8 then length:=("01"); elsif
I(7 downto 0) = POP then length:=("01"); elsif
I(7 downto 0) = PUSH then length:=("01"); elsif
I(7 downto 0) = RET then length:=("00"); elsif
I(7 downto 0) = RETI then length:=("00"); elsif
I(7 downto 0) = RL then length:=("00"); elsif
I(7 downto 0) = RLC then length:=("00"); elsif
I(7 downto 0) = RR then length:=("00"); elsif
I(7 downto 0) = RRC then length:=("00"); elsif
I(7 downto 0) = SETB_1 then length:=("00"); elsif
I(7 downto 0) = SETB_2 then length:=("01"); elsif
I(7 downto 0) = SJMP then length:=("01"); elsif
I(7 downto 3) = SUBB_1 then length:=("00"); elsif
I(7 downto 0) = SUBB_2 then length:=("01"); elsif
I(7 downto 1) = SUBB_3 then length:=("00"); elsif
I(7 downto 0) = SUBB_4 then length:=("01"); elsif
I(7 downto 0) = SWAP then length:=("00"); elsif
I(7 downto 3) = XCH_1 then length:=("00"); elsif
I(7 downto 0) = XCH_2 then length:=("01"); elsif
I(7 downto 1) = XCH_3 then length:=("00"); elsif
I(7 downto 1) = XCHD then length:=("00"); elsif
I(7 downto 3) = XRL_1 then length:=("00"); elsif
I(7 downto 0) = XRL_2 then length:=("01"); elsif
I(7 downto 1) = XRL_3 then length:=("00"); elsif
I(7 downto 0) = XRL_4 then length:=("01"); elsif
I(7 downto 0) = XRL_5 then length:=("01"); elsif
I(7 downto 0) = XRL_6 then length:=("11"); else
length:=("00");
end if;
return length;
end bytelength_out;
Procedure reset(opout:out std_logic_vector(6 downto 0);
oplength:out std_logic_vector(1 downto 0)) is
begin
opout:="1101111";
oplength:="00";
end reset;
--Architecture begins here
begin
process(input,rst)
variable opcode:std_logic_vector(6 downto 0);
variable length:std_logic_vector(1 downto 0);
begin
if rst='1' then
reset(opcode,length);
cmd_opcode(6 downto 0)<=opcode;
cmd_length<=length;
else
cmd_opcode(6 downto 0)<=opcode_out(Input);
cmd_length<=bytelength_out(Input);
end if;
end process;
end behavioral;
后续工作
在后续工作中,我将实现微控制器系统的其他组件,即包括内部 RAM 和 ROM 的内存,以及 ALU,最后将演示系统的集成 VHDL 模型。
参考
- Terry Quatrani, Visual Modeling with Rational Rose 2000 and UML, Addison Wesley。
- James Rumbaugh, Object Oriented Analysis and Design, Prentice Hall, 2002。
- Martin Fowler, What’s a Model for?
- Martin Fowler, Who needs an Architect? IEEE Software July/August 2003。
- Michael A. Ogush, Derek Coleman, Dorothea Beringer, A Template for Documenting Software and Firmware Architectures (Version 1.3, 15-Mar-00)。
- Rational Software, Unified Modeling Language, version 1.1, 1998。