1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我还在学习VHDL,而且我对创建状态机有点困惑。
我正在设计一个状态机,它应该从分别产生分钟和小时的计数器中取出两个输入,然后画出分针和分针的线条。 还有来自RAM的输入,它在我的高级设计(clock.vhd)中实例化。 所以我有四种状态:空闲状态,擦除状态,绘制分钟状态和时针状态。 当显示器处于活动状态时,我将处于空闲状态。 在消隐状态期间,我需要做的第一件事是向内存中的每个位置写入零。 绘制状态分别为分针和时针设置80和50位,然后返回到空闲状态。 我应该使用等式y = mx + b来绘制线条。 我需要一些指示才能继续。 谢谢! fsm.zip 2 KB 以上来自于谷歌翻译 以下为原文 I'm still learning VHDL and I'm a little stuck with creating a state machine. I'm designing a state machine which is supposed to take two inputs from the counters that generate minutes and hours respectively and then draw the lines for minutes hand and then the hour hand. There are also inputs from the RAM which instantiated in my high level design (clock.vhd). So I have four states: Idle state, erase state, draw a minute state , and hour hand state. I'll be in the idle state while the display is active. During the blanking state the first thing I need to do is to write a zero to every location in the memory. The draw states set 80 and 50 bits for the minute hand and hour hand respectively then go back to the idle state. I'm supposed to use the equation y=mx +b to draw the lines. I'll need some directions to proceed. Thanks! fsm.zip 2 KB |
|
相关推荐
3个回答
|
|
如何完成图像输出?
想法是这个状态机将所有内容写入某个内存缓冲区(在块RAM中吗?片外DDR?)然后由VGA控制器读回? 或者状态机是否有效地成为VGA控制器,当它打开像素以将时钟指针放在正确的位置时仔细计时? 我建议暂时建立个别州。 空闲状态很容易; 在发生有趣的事情之前,它什么也没做。 空白状态将需要一个计数器来跟踪它在RAM中的位置。 它将对每个地址进行计数并将其写入零(如果没有帧缓冲,则不需要此步骤)。 显然,两个绘图是最难的。 您熟悉任何高级编程语言吗? Matlab对于这类事情来说是完美的。 首先使用您之前使用的等式,使用您选择的语言绘制算法以绘制适当的线条。 然后梳理如何将其映射到硬件。 请注意,在此阶段您不需要状态机; 只需按一个按钮触发此块。 它可能会导致一帧的混乱显示,但这不是一个问题。 完成所有这些操作后,将它们添加到状态机应该是微不足道的。 以上来自于谷歌翻译 以下为原文 How's the image output done? Is the idea that this state machine writes everything to a memory buffer somewhere (in block RAM? Off-chip DDR?) which then gets read back by a VGA controller? Or is the state machine effectively going to be the VGA controller, carefully timing when it turns on pixels to put the clock hands in the right places? I suggest just building the individual states for now. Idle state is easy; it just does nothing until something interesting happens. The blank state will need a counter to keep track of where it is in the RAM. It'll count up over every address and write it to zero (this step is unnecessary if there's no framebuffer). The two drawing ones are the hardest, obviously. Are you familiar with any higher-level programming languages? Matlab would be perfect for this sort of thing. First get an algorithm going in a language of your choice to draw appropriate lines, using the equation you had earlier. Then sort out how to map it into hardware. Note that at this stage you don't need a state machine; just have this block triggered by a button. It'll probably cause a messed-up display for one frame, but that's not really an issue. Once all of that is done, adding them to a state machine should be trivial. |
|
|
|
是的,这就是我的理解,状态机写入一个记忆,然后得到一个RAM端口连接到VGA。
附上的拉链显示了我到目前为止已经完成了多少工作,但是再一次是状态机代码,我有点被困住了。 不,我不懂任何更高级的编程语言。 谢谢! 以上来自于谷歌翻译 以下为原文 Yes, that's how I understand it, the state machine write to a memeory and then gets one of the RAM port is connected to the VGA. The attached zip shows how much of I've done so far but again it's the state machine code that I am little bit stuck on. No, I don't know any higher level programming languages. Thanks! |
|
|
|
不了解更高级别的语言会使这更棘手。
我可以提供一些建议,但我不是一个VHDL人(我使用Verilog)所以它必须非常有限。 第一步是在图像中画一条线。 现在,只需将其设为水平线 - 这是最简单的。 目的是生成一个模块,从给定的起始点(x,y)沿直线绘制n个像素,然后停止并设置输出。 对此的伪代码将是: 在每个上升的时钟边缘: 如果计数器小于50: 将像素(x +计数器,y)设置为1 增量计数器 除此以外: 设置“完成”输出 结束 结束 尝试暂时实现它,并模拟它。 将它包含在状态机中应该很容易; 你把所有这些都包含在一个状态中,而不是设置一个“完成”输出,它只是在完成时移动到下一个状态 为了使它在角度上绘制,你需要正弦和余弦值。 然后该块变为: 在每个上升的时钟边缘: 如果计数器小于50: 将像素(x +计数器* cos(角度),y +计数器* sin(角度))设置为1 增量计数器 除此以外: 设置“完成”输出 结束 结束 计算正弦和余弦很难,但在这种情况下,你知道最多有六十个值(因为指针只能在六十个位置)。 正弦和余弦具有良好的对称性(例如sin(x)= -sin(x + 180)),这大大减少了实际需要存储的值的数量。 (例如,您可以将30个版本存储为0 ... 180度,然后对于圆圈的另一半,您将这些值的负值存储起来)。 在状态机本身,你应该得到一些看起来像这样的东西: 在每个上升的时钟边缘: 如果state是“wait_for_start”: 如果没有绘制图像: 将状态设置为“清除” 将计数器设置为零(因为我们需要在下一个状态下使用计数器) 结束 否则,如果州是“清除”: 如果counter小于内存大小: 将内存位置(计数器)设置为零 增量计数器 除此以外: 将状态设置为“draw_hours” 将计数器设为零 结束 否则如果state是“draw_hours”: 如果计数器小于50: 将像素(x +计数器* cos(hours_angle),y + counter * sin(hours_angle))设置为1 增量计数器 除此以外: 将状态设置为“小时” 将计数器设为零 结束 否则如果state是“draw_minutes”: 如果计数器小于八十: 将像素(x +计数器* cos(minutes_angle),y + counter * sin(minutes_angle))设置为1 增量计数器 除此以外: 将状态设置为“空闲” 将计数器设为零 结束 else :(这是我们的“空闲”状态。我们不能只回到“wait_for_start”状态,因为如果我们在没有绘制图像时这样做,它会立即进入“清除”状态) 如果正在绘制图像: 将状态设置为“wait_for_start” 结束 结束 结束 这有什么意义吗? 以上来自于谷歌翻译 以下为原文 Not knowing higher level languages will make this more tricky. I can give some advice, but I'm not much of a VHDL person (I use Verilog) so it'll have to be pretty limited. First step is going to be drawing a line in the image. For now, just make it a horizontal line - that's the easiest. The aim is to produce a module that draws n pixels in a straight line, from a given starting point (x,y), and then stops and sets an output. The pseudocode for this would be something along the lines of: at each rising clock edge:if counter is less than fifty:set pixel (x + counter,y) to 1increment counterotherwise:set "done" outputendendTry just implementing that for now, and simulating it. To include it in a state machine should be easy; you include all of that in one state, and rather than setting a "done" output it just moves on to the next state when it finishes To make it draw on angles, you'll need sine and cosine values. Then the block becomes: at each rising clock edge:if counter is less than fifty:set pixel (x + counter * cos(angle),y + counter * sin(angle)) to 1increment counterotherwise:set "done" outputendendCalculating sine and cosine is hard, but in this case you know that there are a maximum of sixty values (because the hands can only be in sixty positions). Sine and cosine have nice symmetry (eg. sin(x) = -sin(x + 180)) which drastically reduces the number of values that actually need to be stored. (eg. you could just store the 30 vlaues for 0 ... 180 degrees, and then for the other half of the circle you take the negative of those values). In the state machine itself, you should end up with something that looks a bit like this: at each rising clock edge:if state is "wait_for_start":if image is not being drawn:set state to "clear"set counter to zero (because we need the counter in the next state)endelse if state is "clear":if counter is less than memory size:set memory location (counter) to zeroincrement counterotherwise:set state to "draw_hours"set counter to zeroendelse if state is "draw_hours":if counter is less than fifty:set pixel (x + counter * cos(hours_angle),y + counter * sin(hours_angle)) to 1increment counterotherwise:set state to "hours"set counter to zeroendelse if state is "draw_minutes":if counter is less than eighty:set pixel (x + counter * cos(minutes_angle),y + counter * sin(minutes_angle)) to 1increment counterotherwise:set state to "idle"set counter to zeroendelse: (this is our "idle" state. We can't just go back to the "wait_for_start" state because if we do that while the image is not being drawn, it'll immediately move on to the "clear" state)if image is being drawn:set state to "wait_for_start"endendendDoes that make some sort of sense? |
|
|
|
只有小组成员才能发言,加入小组>>
2420 浏览 7 评论
2823 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2294 浏览 9 评论
3374 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2461 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
1176浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
587浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
451浏览 1评论
2005浏览 0评论
731浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 20:24 , Processed in 2.080962 second(s), Total 80, Slave 64 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号