Skip to content

Commit

Permalink
更新decoder2to4:改良
Browse files Browse the repository at this point in the history
  • Loading branch information
V字龍(Vdragon) committed Apr 20, 2012
1 parent 164aeee commit 41a1b53
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 42 deletions.
16 changes: 11 additions & 5 deletions decoder2to4/GNU_toolchain/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#Makefile of 2 to 4 line decoder
#author:Vdragon(pika1021@gmail.com)
#this file is licensed under LGPL 3 or later
build:
iverilog -o Simulation/decoder2to4.executable Source_code/test.tbw

test:
Simulation/decoder2to4.executable
gtkwave Simulation/decoder2to4.vcd
mkdir --parents Simulation
iverilog -o Simulation/decoder2to4_tb.executable Source_code/decoder2to4_tb.v

simulate:
Simulation/decoder2to4_tb.executable

wave:
gtkwave Simulation/decoder2to4_tb.vcd
35 changes: 19 additions & 16 deletions decoder2to4/GNU_toolchain/Source_code/decoder2to4/decoder2to4.v
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
/* 模組名稱: 2 to 4 line decoder
著作權宣告:copyright 2012 林博仁(pika1021@gmail.com)
*/
`timescale 1ns / 1ps
`include "Source_code/decoder1to2/decoder1to2.v"
`ifndef DECODER2TO4_V_INCLUDED
`define DECODER2TO4_V_INCLUDED
`timescale 1ns / 100ps
`include "Source_code/decoder1to2/decoder1to2.v"

module decoder2to4(o0, o1, o2, o3, i1, i0);
input i1, i0;
output o0, o1, o2, o3;
wire a0, a1, b0, b1;
decoder1to2
dec12a(a1, a0, i0),
dec12b(b1, b0, i1);
and
and00(o0, b0, a0),
and01(o1, b0, a1),
and10(o2, b1, a0),
and11(o3, b1, a1);

endmodule
module decoder2to4(o, i);
output [3:0]o;
input [1:0]i;
wire a0, a1, b0, b1;
decoder1to2
dec12a(a1, a0, i[0]),
dec12b(b1, b0, i[1]);
and
and00(o[0], b0, a0),
and01(o[1], b0, a1),
and10(o[2], b1, a0),
and11(o[3], b1, a1);

endmodule
`endif
26 changes: 26 additions & 0 deletions decoder2to4/GNU_toolchain/Source_code/decoder2to4_tb.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//2對4解碼器的testbench
`timescale 1ns / 1ps
`include "Source_code/decoder2to4/decoder2to4.v"
module decoder2to4Test;
reg [1:0] i;
wire [3:0] o;

//D.U.T.實體化
decoder2to4 dec24(o, i);

initial
begin
$dumpfile("Simulation/decoder2to4_tb.vcd");
$dumpvars;
$monitor($time, " i=%2b -> o=%4b", i, o);
i = 2'b00;

#10 i = 2'b01;
#10 i = 2'b10;
#10 i = 2'b11;

#10;
end


endmodule
21 changes: 0 additions & 21 deletions decoder2to4/GNU_toolchain/Source_code/test.tbw

This file was deleted.

0 comments on commit 41a1b53

Please sign in to comment.