verilog中的窦 [英] Sinus in verilog

查看:33
本文介绍了verilog中的窦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我需要得到正弦波形.如果我在 2pi 的范围内写了 x 和 y 轴的值

So I need to get sinus waveform. In cases I have wrote values of x and y axis in range of 2pi

如何得到这个范围内的正弦波形?

how to get the waveform of the sinus in this range?

module sinus1(in,clk,res,out);
input clk,res;
input [7:0]in;
output reg [7:0]out;
always @(posedge clk)
if (res)
case (in)
8'b00000000: out<=8'b10000000;
8'b00000001: out<=8'b10000011;
8'b00000010: out<=8'b10000110;
8'b00000011: out<=8'b10001001;
8'b00000100: out<=8'b10001100;
8'b00000101: out<=8'b10001111;
8'b00000110: out<=8'b10010010;
...
...
...
8'b11111111: out<=8'b01111101;
endcase
else out<=8'b00000000;
endmodule

module testbench;
reg clk,res;
reg [7:0]in;
sinus1 sinusoid(in,clk,res,out);
always #5 clk=~clk
initial
begin
clk=0;res=0;
#5 res=1;
#5000 $finish;
end
endmodule

推荐答案

如果您想获取每个输入的值,您应该扫描测试平台中的值,可能是从 0 到 255.艾达游乐场:

If you want get the values for each input, you should sweep the values in your testbench, perhaps from 0 to 255. Here is a link that does this on Eda Playground:

http://www.edaplayground.com/x/2bx

输出:

in=00000000, out = sin(in) = 10000000
in=00000001, out = sin(in) = 10000011
in=00000010, out = sin(in) = 10000110
in=00000011, out = sin(in) = 10001001
in=00000100, out = sin(in) = 10001100
in=00000101, out = sin(in) = 10001111
...

这篇关于verilog中的窦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆