数据抽取

源码:
module YWJCQ(
input clk,
input rst_n,
input [2:0]sel,
input [7:0]in,

output out_o

);
reg out;
always@(sel)
begin
case(sel)
3’d0: out<=in[0];
3’d1: out<=in[1];
3’d2: out<=in[2];
3’d3: out<=in[3];
3’d4: out<=in[4];
3’d5: out<=in[5];
3’d6: out<=in[6];
3’d7: out<=in[7];
default:;
endcase
end
assign out_o=out;

endmodule

激励:
`timescale 1ns/1ns
module YWJCQ_tb();
reg clk;
reg rst_n;
reg [7:0]in;
reg [2:0] sel;
initial
begin
rst_n=0;

100 rst_n=1;

#1000 $stop;
end

initial
begin
clk=0;
end

initial
begin
in=8’b01000111;
end

initial
begin
sel=3’b000;
#100 sel=3’b001;
#100 sel=3’b010;
#100 sel=3’b011;
#100 sel=3’b100;
#100 sel=3’b101;
#100 sel=3’b110;
#100 sel=3’b111;
end

always #10 clk<=~clk;

YWJCQ YWJCQ_out(
.clk(clk),
.rst_n(rst_n),
.in(in),
.sel(sel),
.out_o()

);

endmodule
数据抽取最主要的是数据的分离与case语句的用法。
case的格式:
always@(ct)
begin
out=xxxx;
case(ct)
x’bxxxx:out=xxxxx;



endcase
end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值