OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [alu/] [test_mux_3z.sv] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
//==============================================================
2
// Test ALU op1 MUX which is a bit more complicated
3
//==============================================================
4
`timescale 100 ns/ 100 ns
5
 
6
module test_mux_3z;
7
 
8
// ----------------- INPUT -----------------
9
reg sel_a_sig;
10
reg sel_b_sig;
11
reg sel_zero_sig;
12
reg [3:0] a_sig;
13
reg [3:0] b_sig;
14
 
15
// ----------------- OUTPUT -----------------
16
wire [3:0] Q_sig;           // Output of a mux
17
wire ena_out_sig;           // Write enable to the latch
18
 
19
// ----------------- TEST -------------------
20
`define CHECK(arg) \
21
   assert(Q_sig==arg);
22
 
23
initial begin
24
    sel_a_sig = 0;
25
    sel_b_sig = 0;
26
    sel_zero_sig = 0;
27
    a_sig = 4'hA;
28
    b_sig = 4'h5;
29
    #1  `CHECK(0);
30
 
31
    sel_zero_sig = 0;
32
    sel_a_sig = 0;
33
    sel_b_sig = 0;
34
    #1  `CHECK(0);
35
 
36
    sel_zero_sig = 1;
37
    sel_a_sig = 0;
38
    sel_b_sig = 0;
39
    #1  `CHECK(0);
40
 
41
    sel_zero_sig = 0;
42
    sel_a_sig = 1;
43
    sel_b_sig = 0;
44
    #1  `CHECK(a_sig);
45
 
46
    sel_zero_sig = 0;
47
    sel_a_sig = 0;
48
    sel_b_sig = 1;
49
    #1  `CHECK(b_sig);
50
 
51
    sel_zero_sig = 1;
52
    sel_a_sig = 1;
53
    sel_b_sig = 1;
54
    #1  `CHECK(0);
55
 
56
    #1 $display("End of test");
57
end
58
 
59
//--------------------------------------------------------------
60
// Instantiate a mux
61
//--------------------------------------------------------------
62
alu_mux_3z alu_mux_3z_inst
63
(
64
    .sel_zero(sel_zero_sig) ,   // input  sel_zero_sig
65
    .sel_a(sel_a_sig) ,         // input  sel_a_sig
66
    .b(b_sig) ,                 // input [3:0] b_sig
67
    .sel_b(sel_b_sig) ,         // input  sel_b_sig
68
    .a(a_sig) ,                 // input [3:0] a_sig
69
    .Q(Q_sig) ,                 // output [3:0] Q_sig
70
    .ena(ena_out_sig)           // output  ena_out_sig
71
);
72
 
73
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.