Verilog HDL:PCM解码器设计(Testbench4)

这是一个用Verilog编写的PCM解码器测试平台,用于测试PCM_DECODER模块。测试脚本生成了SOF(帧起始)、2字节数据(如3C和4D)以及EOF(帧结束)信号,模拟PCM数据流。通过改变din信号的值,模拟不同的数据序列,并使用$fsdb进行波形调试。
摘要由CSDN通过智能技术生成

PCM_DECODER_TEST_4.v

/********************************************************************************* 
  *Copyright(C), IC Design
  *FileName: PCM_DECODER_TEST_4.v
  *Author: Yue Shipeng
  *Version: 6.0
  *Date: 2023.01.21 03:00
  *Description: TESTBENCH FOR PCM_DECODER
  *History: Notepad++ version
**********************************************************************************/  

/********************************************************************************* 
PCM DECODER TEST 4
**********************************************************************************/

`timescale 10ns/1ns

module PCM_DECODER_TEST_4;

reg clk;
reg rst;
reg din;
wire [7:0] dout;
wire D_en;
wire F_en;

parameter half_cycle = 10;

PCM_DECODER ut4(
	.clk(clk),
	.rst(rst),
	.din(din),
	.dout(dout),
	.D_en(D_en),
	.F_en(F_en)
);

initial begin
	clk = 0;
	forever begin
		clk = # half_cycle ~ clk;
	end
end

initial begin
	rst = 1;
	# (1 * half_cycle) rst = 0;
	# (2 * half_cycle) rst = 1;
end

initial begin

	// the initial set of din;
	din <= 0;
	
	// the SOF generation;
	repeat (4) @ (posedge clk);
	din <= 1;
	repeat (16) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (160) @ (posedge clk);
	din <= 1;
	
	// the 2 Byte data generation;
	
	// 3C, 0011_1100;
	wave_00();
	wave_11();
	wave_11();
	wave_00();
	
	// 4D, 0100_1101;
	wave_01();
	wave_11();
	wave_00();
	wave_01();

	// the EOF generation;
	repeat (48) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (32) @ (posedge clk);
	din <= 0;
	
	repeat (20) @ (posedge clk);
	$finish;
end

initial begin
	$fsdbDumpfile("./verdiFsdb/PCM_DECODER_TEST_4.fsdb");
	$fsdbDumpvars(0);
end

// the 00 generation;
task wave_00();
	repeat (16) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (128) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (16) @ (posedge clk);
	din <= 1;
endtask

// the 01 generation;
task wave_01();
	repeat (16) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (96) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (48) @ (posedge clk);
	din <= 1;
endtask

// the 10 generation;
task wave_10();
	repeat (48) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (96) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (16) @ (posedge clk);
	din <= 1;
endtask

// the 11 generation;
task wave_11();
	repeat (48) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (64) @ (posedge clk);
	din <= 0;
	repeat (16) @ (posedge clk);
	din <= 1;
	repeat (48) @ (posedge clk);
	din <= 1;
endtask

endmodule

Experiment Result

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值