0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windowsでiverilog その192

Last updated at Posted at 2025-07-01

概要 

windowsでiverilogやってみた。
sinテーブル、見つけたので、テストベンチ書いてみた。

参考にしたページ

サンプルコード

module sincos_tb;
	reg clock;
	reg [4:0] t = 0;
	reg [7:0] i = 255;
	reg [7:0] q = 64;
	wire signed [8:0] icos;
	wire signed [8:0] qsin;
	sincos sc0(icos, qsin, t, i, q);
	always
		#1 clock = !clock;
	always
		#1 t = t + 1;
	initial
	begin
		$monitor(" %d, %d, %d, %d, %d", t, i, q, icos, qsin);
		clock = 1;
		#33
			i = 254;
		#33
			$finish;
	end
endmodule

実行結果

>vvp a.out
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
 -180 ,  -90
 -212 ,  -71
 -236 ,  -49
 -250 ,  -25
 -255 ,    0
 -250 ,   25
 -236 ,   49
 -212 ,   71
 -180 ,   90
 -142 ,  106
  -98 ,  117
  -50 ,  125
    0 ,  127
   50 ,  125
   98 ,  117
  142 ,  106
  180 ,   90
  212 ,   71
  236 ,   49
  250 ,   25
  255 ,    0
  250 ,  -25
  236 ,  -49
  212 ,  -71
  180 ,  -90
  142 , -106
   98 , -117
   50 , -125
    0 , -127
  -50 , -125
  -98 , -117
 -142 , -106
sincos.v:21: $finish called at 300 (1s)
 -180 ,  -90



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?