Académique Documents
Professionnel Documents
Culture Documents
Bc 2: Vo File/New/Project
Create new file: To file mi. Add Existing file: Thm file c sn (v
d: bn vit file verilog sn v u , bn ch cn copy file
vo th mc m bn to project, bn vo y thm file vo)
y ti h to file mi
File name: Tn file Add file as type: Chn loi file cn to Folder: C
Top Level Nhn OK. Trong ca s WorkSpace xut hin file cn to
vi trng thi ? (ngha l cha c tng hp, kim tra).
Bng gi tr ca encoder_16_4:
if (enable) begin
case (encoder_in)
16'h0002 : binary_out = 4'd1;
16'h0004 : binary_out = 4'd2;
16'h0008 : binary_out = 4'd3;
16'h0010 : binary_out = 4'd4;
16'h0020 : binary_out = 4'd5;
16'h0040 : binary_out = 4'd6;
16'h0080 : binary_out = 4'd7;
16'h0100 : binary_out = 4'd8;
16'h0200 : binary_out = 4'd9;
16'h0400 : binary_out = 4'd10;
16'h0800 : binary_out = 4'd11;
16'h1000 : binary_out = 4'd12;
16'h2000 : binary_out = 4'd13;
16'h4000 : binary_out = 4'd14;
16'h8000 : binary_out = 4'd15;
endcase
end
end
endmodule
m phng kim tra ta thc hin nh sau:
Bc 1: To testbench
Nhp chut phi vo vng trng ca ca s Workspace. Chn Add to
project/New file
encoder_in = 16'h0020;
#200
encoder_in = 16'h0040;
#200
encoder_in = 16'h0080;
#200
encoder_in = 16'h0100;
#200
encoder_in = 16'h0200;
#200
encoder_in = 16'h0400;
#200
encoder_in = 16'h0800;
#200
encoder_in = 16'h1000;
#200
encoder_in = 16'h2000;
#200
encoder_in = 16'h4000;
#200
encoder_in = 16'h8000;
#200
encoder_in = 16'h1010;
end
endmodule
Bc 2: Compile file testbench (nh compile file RTL code)
Bc 3: Chy m phng
Trong ca s Workspace chn th Library, chn mc work ta s thy
hai file c compile nh sau
Bc 5: Bt ca s tn hiu Signals
vo View/Signals
Ca s Wave
Bc 7: Xem kt qu
Ta thy kt qu m phng ng thit k