【发布时间】:2012-10-21 14:19:01
【问题描述】:
我是 VHDL 新手,正在做家庭作业。
我有一个使用泛型的非常简单的时钟分频器。 (这是一个计数器/分隔符。)
-- the actual divider will be 2.1e6 or so (25Mhz down to 15hz)
run_divider : clk_divider
--pragma synthesis off
generic map(clkmax => 4) -- simulation
--pragma synthesis on
generic map(clkmax => 50000) -- synthesis
port map( clk_in => mclk,
reset => rst,
clk_out => divider_out );
我在上面的编译指示中部分使用了Equivalent of #ifdef in VHDL for simulation/synthesis separation?。但是,这仅适用于综合,但在模拟中是语法错误。
除了使用外部工具(建议的另一个答案是 M4、C 预处理器)之外,还有没有更好的方法来为合成和模拟分别编写代码?当我在综合和仿真之间切换时,我不想再担心这些常量。
How to convert 24MHz and 12MHz clock to 8MHz clock using VHDL? 的回答告诉我计数器/除法器不是最佳解决方案,但它对我的作业来说足够简单 :-)
我的完整分隔符代码在这里: https://github.com/linuxlizard/vhdl/blob/master/divider.vhdl
谢谢!
【问题讨论】:
标签: vhdl