-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
V字龍(Vdragon)
committed
Apr 20, 2012
1 parent
164aeee
commit 41a1b53
Showing
4 changed files
with
56 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
decoder2to4/GNU_toolchain/Source_code/decoder2to4/decoder2to4.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.