为什么quartus仿真不出波形啊啊啊啊球球大佬帮忙看一下呗
<p> RTL视图</p><p></p>
<p> </p>
<p>顶层模块</p>
<p> </p>
<p> </p>
<p><strong>dds正弦波信号发生模块</strong></p>
<p>module dds_noip(<br />
input wire sclk,<br />
input wire rst_n,<br />
input wire FW,<br />
output wire o_wave,<br />
output reg out<br />
);</p>
<p>parameter FRQ_W=32'd85899346; //相当于M<br />
parameter FRQ_ADD=32'd85899346/2;//相当于递增量<br />
reg phase_sum;<br />
wire addr;<br />
reg frq_word;<br />
reg div_cnt;<br />
reg div_flag;</p>
<p><br />
always @(posedge sclk or negedge rst_n)<br />
if(rst_n == 1'b0)<br />
phase_sum <= 1'd0;<br />
else <br />
phase_sum <= phase_sum + FRQ_W/FW;<br />
<br />
assign addr = phase_sum;</p>
<p><br />
<br />
always @(posedge sclk or negedge rst_n)<br />
if(rst_n == 1'b0)<br />
out <= 0;<br />
else if(o_wave>128)<br />
out <= 1;<br />
else <br />
out <= 0;</p>
<p>rom_512x8 rom_512x8_inst(<br />
.address(addr),<br />
.clock(sclk),<br />
.rst(rst_n),<br />
.q(o_wave)<br />
);<br />
<br />
endmodule</p>
<p> </p>
<p><strong>rom模块</strong></p>
<p> </p>
<p>module rom_512x8 (<br />
address,<br />
clock,<br />
rst,<br />
q<br />
);<br />
input address;<br />
input clock;<br />
input rst;<br />
output reg q;<br />
<br />
parameter SINE_FILE = "sine.txt"; </p>
<p>reg sine_rom ; </p>
<p>initial<br />
begin<br />
$readmemh(SINE_FILE, sine_rom); <br />
end</p>
<p>always@(posedge clock,negedge rst)<br />
begin</p>
<p>if(!rst)<br />
begin<br />
q<=8'b0;<br />
end</p>
<p>else <br />
begin<br />
q<=sine_rom;<br />
end</p>
<p><br />
end</p>
<p>endmodule</p>
<p> </p>
<p><strong>uart串口接收模块</strong></p>
<p>module uart_rx(<br />
clk,<br />
res,<br />
RX,<br />
data_out,<br />
en_data_out<br />
);<br />
<br />
input clk;<br />
input res;<br />
input RX;<br />
output data_out;//接收字节输出<br />
output en_data_out;//输出使能<br />
<br />
reg state;//主状态机<br />
reg con;//用于计算比特宽度;<br />
//系统时钟频率24兆赫兹(24,000,000),支持4800波特率<br />
//计数24000000/4800=5000(0001 0011 1000 1000),13位<br />
//1.5倍宽度,5000*1.5=7500,算8000(0001 1111 0100 0000),13位<br />
reg con_bits;//用于计算比特数,计转了多少圈<br />
<br />
reg RX_delay;//RX延时<br />
reg en_data_out;<br />
<br />
reg data_out;<br />
<br />
always@(posedge clk or negedge res)<br />
<br />
if(~res)begin<br />
state<=0;con<=0;con_bits<=0;RX_delay<=0;<br />
data_out<=0;en_data_out<=0;<br />
end<br />
else begin<br />
<br />
RX_delay<=RX;//有时钟就在动,不需要条件<br />
<br />
<br />
case(state)<br />
0://等空闲,10个bit以上连续的1<br />
begin<br />
if(con==5000-1)begin<br />
con<=0;//计数转了一圈<br />
end<br />
else begin<br />
con<=con+1;<br />
end<br />
if(con==0)begin<br />
if(RX)begin<br />
con_bits<=con_bits+1;<br />
end<br />
else begin<br />
con_bits<=0;<br />
end<br />
end<br />
<br />
if(con_bits==12)begin<br />
state<=1;<br />
end<br />
end<br />
<br />
1://等起始位;<br />
begin<br />
en_data_out<=0;<br />
if(~RX&RX_delay)begin<br />
state<=2;<br />
end<br />
end<br />
2://收最低位b0;<br />
begin<br />
//要等1.5Tbit,5000*1.5=7500<br />
if(con==7500-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=3;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
3://收最低位b1;<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=4;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
4://收最低位b2<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=5;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
5://收最低位b3<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=6;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
6://收最低位b4<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=7;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
7://收最低位b5<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=8;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
8://收最低位b6<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=9;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
9://收最低位b7<br />
begin<br />
//要等1Tbit,5000*1=5000<br />
if(con==5000-1)begin<br />
con<=0;<br />
data_out<=RX;<br />
state<=10;<br />
end<br />
else begin<br />
con<=con+1; <br />
end<br />
end<br />
10://产生使能脉冲<br />
begin<br />
en_data_out<=1;<br />
state<=1;<br />
end<br />
<br />
default://其他未定义状态<br />
begin<br />
state<=0;<br />
con<=0;<br />
con_bits<=0;<br />
en_data_out<=0;<br />
<br />
end<br />
<br />
<br />
endcase<br />
<br />
end<br />
<br />
endmodule<br />
</p>
<p>rom的初始化文件也都放在和db、modelsim同级目录下面了,还是不是到什么问题,是模块连接的问题吗</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
页:
[1]