OpenCores
URL https://opencores.org/ocsvn/iso7816_3_master/iso7816_3_master/trunk

Subversion Repositories iso7816_3_master

[/] [iso7816_3_master/] [trunk/] [test/] [TriWire.v] - Blame information for rev 10

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

Line No. Rev Author Line
1 10 acapola
`timescale 1ns / 1ps
2
`default_nettype none
3
/*****************************************************************
4
* module triwire: bidirectional wire bus model with delay
5
*
6
* This module models the two ends of a bidirectional bus with
7
* transport (not inertial) delays in each direction. The
8
* bus has a width of WIDTH and the delays are as follows:
9
* a->b has a delay of Ta_b (in `timescale units)
10
* b->a has a delay of Tb_a (in `timescale units)
11
* The two delays will typically be the same. This model
12
* overcomes the problem of "echoes" at the receiving end of the
13
* wire by ensuring that data is only transmitted down the wire
14
* when the received data is Z. That means that there may be
15
* collisions resulting in X at the local end, but X's are not
16
* transmitted to the other end, which is a limitation of the
17
* model. Another compromise made in the interest of simulation
18
* speed is that the bus is not treated as individual wires, so
19
* a Z on any single wire may prevent data from being transmitted
20
* on other wires.
21
*
22
* The delays are reals so that they may vary throughout the
23
* course of a simulation. To change the delay, use the Verilog
24
* force command. Here is an example instantiation template:
25
*
26
real Ta_b=1, Tb_a=1;
27
always(Ta_b) force triwire.Ta_b = Ta_b;
28
always(Tb_a) force triwire.Tb_a = Tb_a;
29
triwire #(.WIDTH(WIDTH)) triwire (.a(a),.b(b));
30
 
31
* Kevin Neilson, Xilinx, 2007
32
*****************************************************************/
33
module triwire #(parameter WIDTH=1) (inout wire [WIDTH-1:0] a, b);
34
        real Ta_b=1, Tb_a=1;
35
        reg [WIDTH-1:0] a_dly = 'bz, b_dly = 'bz;
36
        always @(a) a_dly <= #(Ta_b) b_dly==={WIDTH{1'bz}} ? a : 'bz;
37
        always @(b) b_dly <= #(Tb_a) a_dly==={WIDTH{1'bz}} ? b : 'bz;
38
        assign b = a_dly, a = b_dly;
39
endmodule
40
 
41
//delay fixed at build time here
42
//Sebastien Riou
43
module TriWirePullup #(parameter UNIDELAY=1)
44
                                                        (inout wire a, b);
45
        reg a_dly = 'bz, b_dly = 'bz;
46
        always @(a) begin
47
                if(b_dly!==1'b0) begin
48
                        if(a===1'b0)
49
                                a_dly <= #(UNIDELAY) 1'b0;
50
                        else
51
                                a_dly <= #(UNIDELAY) 1'bz;
52
                end
53
        end
54
        always @(b) begin
55
                if(a_dly!==1'b0) begin
56
                        if(b===1'b0)
57
                                b_dly <= #(UNIDELAY) 1'b0;
58
                        else
59
                                b_dly <= #(UNIDELAY) 1'bz;
60
                end
61
        end
62
        assign b = a_dly, a = b_dly;
63
        pullup(a);
64
        pullup(b);
65
endmodule
66
/*module TriWireFixed #(parameter WIDTH=1)
67
                                                        (inout wire [WIDTH-1:0] a, b);
68
        tran (a,b);//not supported by xilinx ISE, even just in simulation :-S
69
        specify
70
                (a*>b)=(1,1);
71
                (b*>a)=(1,1);
72
        endspecify
73
endmodule */

powered by: WebSVN 2.1.0

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