AHDL 中的表如何工作?
我在 AHDL 中有一个控制单元 (UC) 的实现,我应该模拟它并查看它是否按照相应的 ASM 图中的定义工作。 我用MAX+plus II来模拟它,它并没有按照我的预期工作,但我不能真正说出问题所在,因为我不熟悉AHDL,更不用说表部分。
这是我的控制单元:
SUBDESIGN EXP1_UC ( CLKUC: INPUT; RES: INPUT; N1,N2,M1,M2: INPUT;
CLR1, CLR2, CLR3, EN1, EN2, EN3, SEL: OUTPUT; ) VARIABLE UC: MACHINE OF BITS (CLR1, CLR2, CLR3, EN1, EN2, EN3, SEL) WITH STATES ( s0 = B"1110000", s1= B"0001000", s2= B"0000100", s3= B"0000000", s4= B"0000010", s5= B"0000001", s6= B"0000011" ); BEGIN UC.CLK = CLKUC; UC.RESET = RES; TABLE UC, N1,N2,M1,M2 => UC; s0, 0, 0, X, X => s0; s0, 1, X, X, X => s1; s0, X, 1, X, X => s2; s1, X, X, X, X => s3; s2, X, X, X, X => s3; s3, 0, 0, 0, 0 => s3; s3, 1, X, X, X => s1; s3, X, 1, X, X => s2; s3, X, X, 1, X => s4; s3, X, X, X, 1 => s5; s4, X, X, X, X => s3; s5, X, X, X, X => s6; s6, X, X, X, X => s3; END TABLE; END;
模拟中有两种情况我不明白:
1)当当前状态为S3并且输入为M1 = 1和M2 = 1时,下一个状态是S6。我不明白,因为在我看来,不先经过S5就没有办法去S6。
2) 当当前状态为S0且输入为N1 = 1且N2 = 1时,在仿真中将下一个状态定义为“12”。嗯,没有这样的状态...
任何人都可以帮助我吗? 谢谢。
更新:
1)我必须使用 ADHL 和 MAX+plus II,尽管它不是最好的工具组合,因为这是大学的文书工作,而且我没有编写代码(就像我说的,我只是应该模拟它,我无法改变它)。
I have an implementation of a Control Unit (UC) in AHDL, and I'm supposed to simulate it and see if it works as defined in the correspondent ASM diagram.
I used MAX+plus II to simulate it, and it doesn't work as I expected, but I can't really say what's wrong because I am not familiar with AHDL, let alone the TABLE part.
Here is my Control Unit:
SUBDESIGN EXP1_UC ( CLKUC: INPUT; RES: INPUT; N1,N2,M1,M2: INPUT;
CLR1, CLR2, CLR3, EN1, EN2, EN3, SEL: OUTPUT; ) VARIABLE UC: MACHINE OF BITS (CLR1, CLR2, CLR3, EN1, EN2, EN3, SEL) WITH STATES ( s0 = B"1110000", s1= B"0001000", s2= B"0000100", s3= B"0000000", s4= B"0000010", s5= B"0000001", s6= B"0000011" ); BEGIN UC.CLK = CLKUC; UC.RESET = RES; TABLE UC, N1,N2,M1,M2 => UC; s0, 0, 0, X, X => s0; s0, 1, X, X, X => s1; s0, X, 1, X, X => s2; s1, X, X, X, X => s3; s2, X, X, X, X => s3; s3, 0, 0, 0, 0 => s3; s3, 1, X, X, X => s1; s3, X, 1, X, X => s2; s3, X, X, 1, X => s4; s3, X, X, X, 1 => s5; s4, X, X, X, X => s3; s5, X, X, X, X => s6; s6, X, X, X, X => s3; END TABLE; END;
There are 2 situations in the simulation which I don't understand:
1) When the current state is S3 and the inputs are M1 = 1 and M2 = 1, the next state is S6. I don't get that, because the way I see it, there is no way to go to S6 without passing through S5 first.
2) When the current state is S0 and the inputs are N1 = 1 and N2 = 1, the next state is defined in the simulation as "12". Well, there is no such state...
Can anyone help me?
Thanks.
UPDATE:
1) I have to use ADHL and MAX+plus II even though it's hardly the best combination of tools, because this is a paperwork for college, and I didn't write the code (like I said, I am just supposed to simulate it, I can't change it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一:你真的必须使用 AHDL 吗? - 多年来它一直没有成为 Altera-land 的适当支持的一部分。 MAX Plus II 是一个非常古老的软件 - 我的建议是掌握 Quartus 并学习 VHDL(或者 Verilog,如果你必须的话)。抱歉,如果这听起来很刺耳!
但是您的问题实际上听起来像是一个传统的逻辑问题......您的状态机的输入是否正确同步?如果没有,您可能会得到各种奇怪的效果,因为它们在接近时钟边沿时发生变化,然后信号到达时钟一侧的状态机部分和时钟“另一侧”的其他部分(即直到下一个周期才看到)。这会让事情变得非常混乱!另外,请确保您的复位信号也与 clk 信号同步。
快速破解 - 将两个触发器串联在每个输入上。然后阅读同步异步输入......
First: do you really have to use AHDL? - it hasn't been a properly supported part of Altera-land for years. And MAX Plus II is a very old bit of software - get a hold of Quartus and learn VHDL (or Verilog if you must ;) would be my suggestion. Sorry if that sounds harsh!
But what your problem really sounds like is a traditional logic problem... are the inputs to your state machine properly synchronised? If not, you can get all sorts of weird effects as they change close to a clock edge and then the signals get to part of the state machine on one side of the clock and to other parts on the "other side" of the clock (ie not seen until next cycle). This will confuse things dreadfully! Also, make sure your reset signal is also synchronised to the clk signal.
Quick hack - stick two flip flops in a chain on each of the inputs. Then read up on synchronising asynchronous inputs...